Associations
creates a new association
Renders//associations/associations/new
Act
Go to “/”
await navigate({ page, url: "/" });
Anything adder Act
Add “association”
await new AnythingAdder(page).add("association");
New association page Act
Fill Name with “My Association”
await newAssociation.form.fill("name", "My Association");Save
await newAssociation.save();
Associations page Assert
heading “My Association” is visible
await expect(associations.heading("My Association")).toBeVisible();
Source
test("creates a new association", async ({ page }) => {
await impersonate(page, NZAP_TEST_ID);
await navigate({ page, url: "/" });
await new AnythingAdder(page).add("association");
const newAssociation = new NewAssociationPage(page);
await newAssociation.form.fill("name", "My Association");
await newAssociation.save();
const associations = new AssociationsPage(page);
await expect(associations.heading("My Association")).toBeVisible();
})Renders/associations/scrims
Arrange
Create association user Sendou
await factories.AssociationFactory.create({ userId: ADMIN_ID });Create association user Sendou
await factories.AssociationFactory.create({ userId: ADMIN_ID });
Scrims page Act
Open the scrims page
await scrims.goto();
Open associations → associations
const associations = await scrims.openAssociations();
Associations page Assert
delete buttons count is 2
await expect(associations.locators.deleteButtons).toHaveCount(2);
Act
Delete first
await associations.deleteFirst();
Assert
delete buttons count is 1
await expect(associations.locators.deleteButtons).toHaveCount(1);
Source
test("deletes an association", async ({ page, factories }) => {
await factories.AssociationFactory.create({ userId: ADMIN_ID });
await factories.AssociationFactory.create({ userId: ADMIN_ID });
await impersonate(page, ADMIN_ID);
const scrims = new ScrimsPage(page);
await scrims.goto();
const associations = await scrims.openAssociations();
await expect(associations.locators.deleteButtons).toHaveCount(2);
await associations.deleteFirst();
await expect(associations.locators.deleteButtons).toHaveCount(1);
})stars a member, who then takes over when the admin leaves
Renders/associations
Arrange
Create association user Sendou member user ids N-ZAP
await factories.AssociationFactory.create(
{ userId: ADMIN_ID },
{ memberUserIds: [NZAP_TEST_ID] },
);
Associations page Act
Open the associations page
await associations.goto();
Assert
leave button is not visible
await isNotVisible(associations.locators.leaveButton);
Act
Toggle manager “N-ZAP”
await associations.toggleManager("N-ZAP");
Assert
leave button is visible
await expect(associations.locators.leaveButton).toBeVisible();
Associations page Act
Open the associations page
await associations.goto();
Assert
invite link inputs count is 1
await expect(associations.locators.inviteLinkInputs).toHaveCount(1);
reset link button is visible
await expect(associations.locators.resetLinkButton).toBeVisible();
delete buttons is not visible
await isNotVisible(associations.locators.deleteButtons);
Associations page Act
Open the associations page
await associations.goto();
Leave
await associations.leave();
Associations page Act
Open the associations page
await associations.goto();
Assert
delete buttons count is 1
await expect(associations.locators.deleteButtons).toHaveCount(1);
Source
test("stars a member, who then takes over when the admin leaves", async ({
page,
factories,
}) => {
await factories.AssociationFactory.create(
{ userId: ADMIN_ID },
{ memberUserIds: [NZAP_TEST_ID] },
);
await impersonate(page, ADMIN_ID);
const associations = new AssociationsPage(page);
await associations.goto();
await isNotVisible(associations.locators.leaveButton);
await associations.toggleManager("N-ZAP");
await expect(associations.locators.leaveButton).toBeVisible();
await impersonate(page, NZAP_TEST_ID);
await associations.goto();
await expect(associations.locators.inviteLinkInputs).toHaveCount(1);
await expect(associations.locators.resetLinkButton).toBeVisible();
await isNotVisible(associations.locators.deleteButtons);
await impersonate(page, ADMIN_ID);
await associations.goto();
await associations.leave();
await impersonate(page, NZAP_TEST_ID);
await associations.goto();
await expect(associations.locators.deleteButtons).toHaveCount(1);
})joins and leaves an association
Renders/associations
Arrange
Create association user Sendou
await factories.AssociationFactory.create({ userId: ADMIN_ID });
Associations page Act
Open the associations page
await associations.goto();
Invite code → inviteCode
const inviteCode = await associations.inviteCode();
Associations page Act
Go to invite inviteCode
await associations.gotoInvite(inviteCode);
Join
await associations.join();
Leave
await associations.leave();
Assert
leave button is not visible
await isNotVisible(associations.locators.leaveButton);
Source
test("joins and leaves an association", async ({ page, factories }) => {
await factories.AssociationFactory.create({ userId: ADMIN_ID });
await impersonate(page, ADMIN_ID);
const associations = new AssociationsPage(page);
await associations.goto();
const inviteCode = await associations.inviteCode();
await impersonate(page, NZAP_TEST_ID);
await associations.gotoInvite(inviteCode);
await associations.join();
await associations.leave();
await isNotVisible(associations.locators.leaveButton);
})AnythingAdder.adde2e/pages/layout/anything-adder.ts:28
No JSDoc
async add(item: AddableItem) {
await this.locators.menuButton.click();
await this.page.getByTestId(`menu-item-${item}`).click();
}createNewAssociationSchema.nameapp/features/associations/associations-schemas.ts:7
name: textField({
label: "labels.name",
maxLength: 100,
})NewAssociationPage.savee2e/pages/associations/new-association-page.ts:20
No JSDoc
async save() {
await submit(this.page);
}AssociationsPage.headinge2e/pages/associations/associations-page.ts:32
No JSDoc
heading(name: string) {
return this.page.getByRole("heading").filter({ hasText: name });
}AnythingAddere2e/pages/layout/anything-adder.ts:17
NewAssociationPagee2e/pages/associations/new-association-page.ts:7
No JSDoc
AssociationsPagee2e/pages/associations/associations-page.ts:10
No JSDoc
ScrimsPage.gotoe2e/pages/scrims/scrims-page.ts:54
No JSDoc
async goto() {
await navigate({ page: this.page, url: scrimsPage() });
}ScrimsPage.openAssociationse2e/pages/scrims/scrims-page.ts:109
No JSDoc
async openAssociations() {
await this.locators.associationsLink.click();
return new AssociationsPage(this.page);
}AssociationsPage.locators.deleteButtonse2e/pages/associations/associations-page.ts:17
No JSDoc
page.getByTestId("delete-association")AssociationsPage.deleteFirste2e/pages/associations/associations-page.ts:51
No JSDoc
async deleteFirst() {
await this.locators.deleteButtons.first().click();
await modalClickConfirmButton(this.page);
}ScrimsPagee2e/pages/scrims/scrims-page.ts:24
No JSDoc
AssociationsPage.gotoe2e/pages/associations/associations-page.ts:24
No JSDoc
async goto() {
await navigate({ page: this.page, url: associationsPage() });
}AssociationsPage.locators.leaveButtone2e/pages/associations/associations-page.ts:18
No JSDoc
page.getByTestId("leave-team-button")isNotVisiblee2e/helpers/playwright.ts:745
No JSDoc
export function isNotVisible(locator: Locator) {
return expect(locator).toHaveCount(0);
}AssociationsPage.toggleManagere2e/pages/associations/associations-page.ts:57
async toggleManager(username: string) {
await this.page
.getByRole("button", { name: username, exact: false })
.click();
}AssociationsPage.locators.inviteLinkInputse2e/pages/associations/associations-page.ts:19
No JSDoc
page.getByLabel("Share link to add members")AssociationsPage.locators.resetLinkButtone2e/pages/associations/associations-page.ts:20
No JSDoc
page.getByText("Reset link")AssociationsPage.leavee2e/pages/associations/associations-page.ts:63
No JSDoc
async leave() {
await this.locators.leaveButton.click();
await modalClickConfirmButton(this.page);
}AssociationsPage.inviteCodee2e/pages/associations/associations-page.ts:37
async inviteCode() {
const inviteLink = await this.locators.inviteLinkInputs
.first()
.inputValue();
const inviteCode = new URL(inviteLink).searchParams.get("inviteCode");
invariant(inviteCode, `No invite code in the share link: ${inviteLink}`);
return inviteCode;
}AssociationsPage.gotoInvitee2e/pages/associations/associations-page.ts:28
No JSDoc
async gotoInvite(inviteCode: string) {
await navigate({ page: this.page, url: associationsPage(inviteCode) });
}AssociationsPage.joine2e/pages/associations/associations-page.ts:47
No JSDoc
async join() {
await submit(this.page);
}