Skip to content

Associations · E2E tests

1 module · 4 exports · 1 repository · 4 e2e tests · 2 routes

  • NN-ZAP
  • SSendou
  • Arrange data setup
  • Act what the user does
  • Assert what is expected

Associations

creates a new association

Renders//associations/associations/new

NN-ZAP
Act
  1. Go to “/”
    await navigate({ page, url: "/" });
Anything adder
Act
  1. Add “association”
    await new AnythingAdder(page).add("association");
New association page
Act
  1. Fill Name with “My Association”
    await newAssociation.form.fill("name", "My Association");
  2. Save
    await newAssociation.save();
Associations page
Assert
  1. 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();
})

deletes an association

Renders/associations/scrims

Setup
Arrange
  1. Create association user Sendou
    await factories.AssociationFactory.create({ userId: ADMIN_ID });
  2. Create association user Sendou
    await factories.AssociationFactory.create({ userId: ADMIN_ID });
SSendou
Scrims page
Act
  1. Open the scrims page
    await scrims.goto();
  2. Open associations → associations
    const associations = await scrims.openAssociations();
Associations page
Assert
  1. delete buttons count is 2
    await expect(associations.locators.deleteButtons).toHaveCount(2);
Act
  1. Delete first
    await associations.deleteFirst();
Assert
  1. 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

Setup
Arrange
  1. Create association user Sendou member user ids N-ZAP
    await factories.AssociationFactory.create(
    	{ userId: ADMIN_ID },
    	{ memberUserIds: [NZAP_TEST_ID] },
    );
SSendou
Associations page
Act
  1. Open the associations page
    await associations.goto();
Assert
  1. leave button is not visible
    await isNotVisible(associations.locators.leaveButton);
Act
  1. Toggle manager “N-ZAP”
    await associations.toggleManager("N-ZAP");
Assert
  1. leave button is visible
    await expect(associations.locators.leaveButton).toBeVisible();
NN-ZAP
Associations page
Act
  1. Open the associations page
    await associations.goto();
Assert
  1. invite link inputs count is 1
    await expect(associations.locators.inviteLinkInputs).toHaveCount(1);
  2. reset link button is visible
    await expect(associations.locators.resetLinkButton).toBeVisible();
  3. delete buttons is not visible
    await isNotVisible(associations.locators.deleteButtons);
SSendou
Associations page
Act
  1. Open the associations page
    await associations.goto();
  2. Leave
    await associations.leave();
NN-ZAP
Associations page
Act
  1. Open the associations page
    await associations.goto();
Assert
  1. 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

Setup
Arrange
  1. Create association user Sendou
    await factories.AssociationFactory.create({ userId: ADMIN_ID });
SSendou
Associations page
Act
  1. Open the associations page
    await associations.goto();
  2. Invite code → inviteCode
    const inviteCode = await associations.inviteCode();
NN-ZAP
Associations page
Act
  1. Go to invite inviteCode
    await associations.gotoInvite(inviteCode);
  2. Join
    await associations.join();
  3. Leave
    await associations.leave();
Assert
  1. 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);
})