Skip to content

Badges · E2E tests

0 modules · 0 exports · 1 repository · 1 e2e test · 3 routes

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

Badges

adds a badge owner sending a notification

Renders//badges/badges/:id/badges/:id/edit

Setup
Arrange
  1. Create badge display name “4v4 Sundaes” manager ids N-ZAP → badge
    const badge = await factories.BadgeFactory.create(
    	{ displayName: BADGE_NAME },
    	{ managerIds: [NZAP_TEST_ID] },
    );
  2. the popover links onwards only once its peek list is full

    Repeat for (let seasonNth = 1; seasonNth < NOTIFICATIONS.PEEK_COUNT; seasonNth++)
    for (let seasonNth = 1; seasonNth < NOTIFICATIONS.PEEK_COUNT; seasonNth++) {
    	await factories.NotificationFactory.create({
    		notification: { type: "SEASON_STARTED", meta: { seasonNth } },
    		users: [{ userId: ADMIN_ID, seen: 1 }],
    	});
    }
    1. Create notification notification type “SEASON_STARTED” meta seasonNth users user Sendou seen 1
      await factories.NotificationFactory.create({
      	notification: { type: "SEASON_STARTED", meta: { seasonNth } },
      	users: [{ userId: ADMIN_ID, seen: 1 }],
      });
NN-ZAP
Badge page
Act
  1. Open the badge page badge.id
    await badgeDetails.goto(badge.id);
  2. Open edit → badgeEdit
    const badgeEdit = await badgeDetails.openEdit();
Badge edit dialog
Act
  1. Add owner “Sendou”
    await badgeEdit.addOwner("Sendou");
  2. Save
    await badgeEdit.save();
Badge page
Assert
  1. owner “Sendou” is visible
    await expect(badgeDetails.owner("Sendou")).toBeVisible();
SSendou
Act
  1. Go to “/”
    await navigate({ page, url: "/" });
Notification popover
Act
  1. Open
    await notifications.open();
  2. Open notification `New badge (${BADGE_NAME})`
    await notifications.openNotification(`New badge (${BADGE_NAME})`);
Assert
  1. the page URL is badgePage(badge.id)
    await expect(page).toHaveURL(badgePage(badge.id));
Act
  1. Open
    await notifications.open();
  2. Open all → allNotifications
    const allNotifications = await notifications.openAll();
Notifications page
Assert
  1. heading is visible
    await expect(allNotifications.locators.heading).toBeVisible();
Source
test("adds a badge owner sending a notification", async ({
	page,
	factories,
}) => {
	const badge = await factories.BadgeFactory.create(
		{ displayName: BADGE_NAME },
		{ managerIds: [NZAP_TEST_ID] },
	);
	// the popover links onwards only once its peek list is full
	for (let seasonNth = 1; seasonNth < NOTIFICATIONS.PEEK_COUNT; seasonNth++) {
		await factories.NotificationFactory.create({
			notification: { type: "SEASON_STARTED", meta: { seasonNth } },
			users: [{ userId: ADMIN_ID, seen: 1 }],
		});
	}

	await impersonate(page, NZAP_TEST_ID);

	const badgeDetails = new BadgePage(page);
	await badgeDetails.goto(badge.id);

	const badgeEdit = await badgeDetails.openEdit();
	await badgeEdit.addOwner("Sendou");
	await badgeEdit.save();

	await expect(badgeDetails.owner("Sendou")).toBeVisible();

	await impersonate(page);
	await navigate({ page, url: "/" });

	const notifications = new NotificationPopover(page);
	await notifications.open();
	await notifications.openNotification(`New badge (${BADGE_NAME})`);

	await expect(page).toHaveURL(badgePage(badge.id));

	await notifications.open();
	const allNotifications = await notifications.openAll();

	await expect(allNotifications.locators.heading).toBeVisible();
})