Skip to content

Friends · E2E tests

0 modules · 0 exports · 1 repository · 6 e2e tests · 1 route

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

Friends

Requests

a sent request shows as pending to both users

Renders/friends

1Sendou sends N-ZAP a friend request

SSendou
Friends page
Act
  1. Open the friends page
    await friends.goto();
  2. Send request “N-ZAP”
    await friends.sendRequest("N-ZAP");
Assert
  1. cancel request button is visible
    await expect(friends.locators.cancelRequestButton).toBeVisible();

2N-ZAP is notified and can accept it

NN-ZAP
Friends page
Act
  1. Open the friends page
    await friends.goto();
Notification popover
Assert
  1. bell dot is visible
    await expect(notifications.locators.bellDot).toBeVisible();
Friends page
Assert
  1. accept button is visible
    await expect(friends.locators.acceptButton).toBeVisible();
Source
test("a sent request shows as pending to both users", async ({ page }) => {
	const friends = new FriendsPage(page);
	const notifications = new NotificationPopover(page);

	await test.step("Sendou sends N-ZAP a friend request", async () => {
		await impersonate(page);
		await friends.goto();
		await friends.sendRequest("N-ZAP");

		await expect(friends.locators.cancelRequestButton).toBeVisible();
	});

	await test.step("N-ZAP is notified and can accept it", async () => {
		await impersonate(page, NZAP_TEST_ID);
		await friends.goto();

		await expect(notifications.locators.bellDot).toBeVisible();
		await expect(friends.locators.acceptButton).toBeVisible();
	});
})

accepting a request marks its notification read without opening the bell

Renders/friends

Setup
Arrange
  1. Request friendship from Sendou to N-ZAP
    await requestFriendship(factories, { from: ADMIN_ID, to: NZAP_TEST_ID });
NN-ZAP
Friends page
Act
  1. Open the friends page
    await friends.goto();
Notification popover
Assert
  1. bell dot is visible
    await expect(notifications.locators.bellDot).toBeVisible();
Friends page
Act
  1. Accept request
    await friends.acceptRequest();
Notification popover
Assert
  1. bell dot is hidden
    await expect(notifications.locators.bellDot).toBeHidden();
Act
  1. Open
    await notifications.open();
Assert
  1. notification “Sendou sent you a friend request” is visible
    await expect(
    	notifications.notification("Sendou sent you a friend request"),
    ).toBeVisible();
Source
test("accepting a request marks its notification read without opening the bell", async ({
	page,
	factories,
}) => {
	await requestFriendship(factories, { from: ADMIN_ID, to: NZAP_TEST_ID });

	await impersonate(page, NZAP_TEST_ID);
	const friends = new FriendsPage(page);
	await friends.goto();
	const notifications = new NotificationPopover(page);
	await expect(notifications.locators.bellDot).toBeVisible();

	await friends.acceptRequest();

	await expect(notifications.locators.bellDot).toBeHidden();
	await notifications.open();
	await expect(
		notifications.notification("Sendou sent you a friend request"),
	).toBeVisible();
})

deleting a friend removes them from the list

Renders/friends

Setup
Arrange
  1. Befriend Sendou
    await befriend(factories, [ADMIN_ID]);
NN-ZAP
Friends page
Act
  1. Open the friends page
    await friends.goto();
  2. Delete friend
    await friends.friend("Sendou").deleteFriend();
Assert
  1. no friends text is visible
    await expect(friends.locators.noFriendsText).toBeVisible();
Source
test("deleting a friend removes them from the list", async ({
	page,
	factories,
}) => {
	await befriend(factories, [ADMIN_ID]);

	await impersonate(page, NZAP_TEST_ID);
	const friends = new FriendsPage(page);
	await friends.goto();
	await friends.friend("Sendou").deleteFriend();

	await expect(friends.locators.noFriendsText).toBeVisible();
})

Weekly schedule

friends who shared a schedule sort above those who didn't

Renders/friends

Setup
Arrange
  1. Friends with schedules → { scheduled, unscheduled, queueing }
    const { scheduled, unscheduled, queueing } =
    	await friendsWithSchedules(factories);
SSendou
Friends page
Act
  1. Open the friends page
    await friends.goto();
Assert
  1. friends.row(queueing.id), friends.row(scheduled.id), friends.row(unscheduled.id) top to bottom
    await expectTopToBottom([
    	friends.row(queueing.id),
    	friends.row(scheduled.id),
    	friends.row(unscheduled.id),
    ]);
  2. schedule button unscheduled.id is not visible
    await isNotVisible(friends.scheduleButton(unscheduled.id));
Source
test("friends who shared a schedule sort above those who didn't", async ({
	page,
	factories,
}) => {
	const { scheduled, unscheduled, queueing } =
		await friendsWithSchedules(factories);

	await impersonate(page, ADMIN_ID);
	const friends = new FriendsPage(page);
	await friends.goto();

	await expectTopToBottom([
		friends.row(queueing.id),
		friends.row(scheduled.id),
		friends.row(unscheduled.id),
	]);
	await isNotVisible(friends.scheduleButton(unscheduled.id));
})

a friend's week shows when they are free, not what they are doing

Renders/friends

Setup
Arrange
  1. Friends with schedules → { scheduled }
    const { scheduled } = await friendsWithSchedules(factories);
SSendou
Friends page
Act
  1. Open the friends page
    await friends.goto();
  2. Click schedule button scheduled.id
    await friends.scheduleButton(scheduled.id).click();

1This week shows their free time but not the team event taking part of it

SSendou
Friends page
Assert
  1. schedule ranges count is 1
    await expect(friends.locators.scheduleRanges).toHaveCount(1);
  2. day 2 contains “6:00”
    await expect(friends.day(WEDNESDAY)).toContainText("6:00");
  3. day 2 does not contain “VoD review”
    await expect(friends.day(WEDNESDAY)).not.toContainText("VoD review");

2Next week is empty as they only filled in this week

SSendou
Friends page
Act
  1. Click next week toggle
    await friends.locators.nextWeekToggle.click();
Assert
  1. no schedule text is visible
    await expect(friends.locators.noScheduleText).toBeVisible();
Source
test("a friend's week shows when they are free, not what they are doing", async ({
	page,
	factories,
}) => {
	const { scheduled } = await friendsWithSchedules(factories);

	await impersonate(page, ADMIN_ID);
	await setTimezoneCookie(page);
	const friends = new FriendsPage(page);
	await friends.goto();
	await friends.scheduleButton(scheduled.id).click();

	await test.step("This week shows their free time but not the team event taking part of it", async () => {
		await expect(friends.locators.scheduleRanges).toHaveCount(1);
		await expect(friends.day(WEDNESDAY)).toContainText("6:00");
		await expect(friends.day(WEDNESDAY)).not.toContainText("VoD review");
	});

	await test.step("Next week is empty as they only filled in this week", async () => {
		await friends.locators.nextWeekToggle.click();

		await expect(friends.locators.noScheduleText).toBeVisible();
	});
})

Pinning

pinned friends sort to the top of their section, on the page and in the sidebar

Pins only reorder within a section: a pinned idle friend stays below everyone queueing.

Renders/friends

Setup
Arrange
  1. Create named users “PinQueue”, “PlainQueue”, “PinIdle”, “PlainIdle” → [pinnedQueueing, queueing, pinnedIdle, idle]
    const [pinnedQueueing, queueing, pinnedIdle, idle] =
    	await createNamedUsers(factories, [
    		"PinQueue",
    		"PlainQueue",
    		"PinIdle",
    		"PlainIdle",
    	]);
  2. Befriend idle.id, pinnedIdle.id, queueing.id, pinnedQueueing.id, Sendou
    await befriend(
    	factories,
    	[idle.id, pinnedIdle.id, queueing.id, pinnedQueueing.id],
    	ADMIN_ID,
    );
  3. Create SQ group member user ids queueing.id
    await factories.SQGroupFactory.create({ memberUserIds: [queueing.id] });
  4. Create SQ group member user ids pinnedQueueing.id
    await factories.SQGroupFactory.create({
    	memberUserIds: [pinnedQueueing.id],
    });
SSendou
Friends page
Act
  1. Open the friends page
    await friends.goto();

1Sendou pins an idle and a queueing friend

SSendou
Friends page
Act
  1. Toggle pin pinnedIdle.id
    await friends.togglePin(pinnedIdle.id);
  2. Toggle pin pinnedQueueing.id
    await friends.togglePin(pinnedQueueing.id);
Assert
  1. pin button pinnedIdle.id has “aria-pressed” = “true”
    await expect(friends.pinButton(pinnedIdle.id)).toHaveAttribute(
    	"aria-pressed",
    	"true",
    );
  2. pin button idle.id has “aria-pressed” = “false”
    await expect(friends.pinButton(idle.id)).toHaveAttribute(
    	"aria-pressed",
    	"false",
    );

2The page lists pinned friends first within each section

SSendou
Assert
  1. friends.row(pinnedQueueing.id), friends.row(queueing.id), friends.row(pinnedIdle.id), friends.row(idle.id) top to bottom
    await expectTopToBottom([
    	friends.row(pinnedQueueing.id),
    	friends.row(queueing.id),
    	friends.row(pinnedIdle.id),
    	friends.row(idle.id),
    ]);

3The sidebar reorders too, without navigating

SSendou
Assert
  1. sideNav.friend("PinQueue").trigger, sideNav.friend("PlainQueue").trigger, sideNav.friend("PinIdle").trigger, sideNav.friend("PlainIdle").trigger top to bottom
    await expectTopToBottom([
    	sideNav.friend("PinQueue").trigger,
    	sideNav.friend("PlainQueue").trigger,
    	sideNav.friend("PinIdle").trigger,
    	sideNav.friend("PlainIdle").trigger,
    ]);

4Unpinning a friend turns their pin off again

SSendou
Friends page
Act
  1. Open the friends page
    await friends.goto();
  2. Toggle pin pinnedIdle.id
    await friends.togglePin(pinnedIdle.id);
Assert
  1. pin button pinnedIdle.id has “aria-pressed” = “false”
    await expect(friends.pinButton(pinnedIdle.id)).toHaveAttribute(
    	"aria-pressed",
    	"false",
    );
Source
test("pinned friends sort to the top of their section, on the page and in the sidebar", async ({
	page,
	factories,
}) => {
	const [pinnedQueueing, queueing, pinnedIdle, idle] =
		await createNamedUsers(factories, [
			"PinQueue",
			"PlainQueue",
			"PinIdle",
			"PlainIdle",
		]);
	await befriend(
		factories,
		[idle.id, pinnedIdle.id, queueing.id, pinnedQueueing.id],
		ADMIN_ID,
	);
	await factories.SQGroupFactory.create({ memberUserIds: [queueing.id] });
	await factories.SQGroupFactory.create({
		memberUserIds: [pinnedQueueing.id],
	});

	await impersonate(page, ADMIN_ID);
	const friends = new FriendsPage(page);
	await friends.goto();

	await test.step("Sendou pins an idle and a queueing friend", async () => {
		await friends.togglePin(pinnedIdle.id);
		await friends.togglePin(pinnedQueueing.id);

		await expect(friends.pinButton(pinnedIdle.id)).toHaveAttribute(
			"aria-pressed",
			"true",
		);
		await expect(friends.pinButton(idle.id)).toHaveAttribute(
			"aria-pressed",
			"false",
		);
	});

	await test.step("The page lists pinned friends first within each section", async () => {
		await expectTopToBottom([
			friends.row(pinnedQueueing.id),
			friends.row(queueing.id),
			friends.row(pinnedIdle.id),
			friends.row(idle.id),
		]);
	});

	await test.step("The sidebar reorders too, without navigating", async () => {
		const sideNav = new SideNav(page);
		await expectTopToBottom([
			sideNav.friend("PinQueue").trigger,
			sideNav.friend("PlainQueue").trigger,
			sideNav.friend("PinIdle").trigger,
			sideNav.friend("PlainIdle").trigger,
		]);
	});

	await test.step("Unpinning a friend turns their pin off again", async () => {
		await friends.goto();
		await friends.togglePin(pinnedIdle.id);

		await expect(friends.pinButton(pinnedIdle.id)).toHaveAttribute(
			"aria-pressed",
			"false",
		);
	});
})