Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.TimeoutException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void testRegistrationConsumesInvitation() throws IOException {
registerPage.assertCurrent();
registerPage.register("Invited", "User", INVITEE_EMAIL, "invitee", "password");

assertEquals(1L, organization.members().count());
awaitMemberCount(organization, 1L);
assertTrue(organization.invitations().list().isEmpty());
assertInvitationConsumed(link);
}
Expand All @@ -130,6 +131,15 @@ public void testUsedInvitationRollsBackRegistration() throws IOException {
assertEquals(0L, organization.members().count());
}

// The submit returns before the server has processed the request, so wait for the membership instead of reading it once
private void awaitMemberCount(OrganizationResource organization, long expected) {
try {
driver.waiting().until(d -> organization.members().count() == expected);
} catch (TimeoutException e) {
assertEquals(expected, organization.members().count());
}
}

private void assertInvitationConsumed(String link) {
String tokenString = getInvitationToken(link);
runOnServer.run(session -> {
Expand Down
Loading