Skip to content

Lobbies · E2E tests

14 modules · 73 exports · 2 repositories · 67 e2e tests · 3 routes

  • SSendou
  • Users a test creates itself are coloured per test
  • Arrange data setup
  • Act what the user does
  • Assert what is expected

Lobbies

Signing up

Only a supporter can make a lobby, others sign up for it. Signing up reserves a spot, check-in opening once 8 have signed up and the start is at most 10 minutes away, with a notification to the signed up and the check-in button appearing on an open page as it does. A lobby made to start now opens check-in as the 8th signs up, who is checked in right away like everyone signing up after them. Checking in shows the room's pool and pass. Past the room size sign-ups go to the waitlist, the first on it taking a spot someone frees and being notified of it. When the lobby starts the waitlisted stay on the waitlist, unless someone with a spot didn't check in: then a waitlisted player checking in plays in their place.

a lobby made to start now waits for 8 sign-ups before check-in

Sendouvisitorlobbies.spec.ts:70
Setup
Arrange
  1. Create user → visitor
    const visitor = await factories.UserFactory.create();
  2. Set friend code user Sendou
    await factories.UserFactory.setFriendCode(ADMIN_ID);
SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
  2. Fill name with “Test 8s”
    await newLobby.form.fill("name", LOBBY_NAME);
  3. Fill description with “Bring your main, no Tacticooler”
    await newLobby.form.fill("description", LOBBY_DESCRIPTION);
  4. Save
    await newLobby.save();
Lobby page
Assert
  1. heading “Test 8s” is visible
    await expect(lobby.heading(LOBBY_NAME)).toBeVisible();
  2. description reads “Bring your main, no Tacticooler”
    await expect(lobby.locators.description).toHaveText(LOBBY_DESCRIPTION);
  3. participants count is 1
    await expect(lobby.locators.participants).toHaveCount(1);
Act
  1. lobbyId = Number(page.url().split("/").at(-1))
    const lobbyId = Number(page.url().split("/").at(-1));
Vvisitor
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobby.goto(lobbyId);
  2. Sign up
    await lobby.signUp();
Assert
  1. participants count is 2
    await expect(lobby.locators.participants).toHaveCount(2);
  2. viewer status contains “notified when check-in opens”
    await expect(lobby.locators.viewerStatus).toContainText(
    	"notified when check-in opens",
    );
  3. start banner contains “2/8 signed up”
    await expect(lobby.locators.startBanner).toContainText("2/8 signed up");
  4. check in button is not visible
    await isNotVisible(lobby.locators.checkInButton);
Source
test("a lobby made to start now waits for 8 sign-ups before check-in", async ({
	page,
	factories,
}) => {
	const visitor = await factories.UserFactory.create();
	await factories.UserFactory.setFriendCode(ADMIN_ID);

	await impersonate(page, ADMIN_ID);
	const newLobby = new NewLobbyPage(page);
	await newLobby.goto();
	await newLobby.form.fill("name", LOBBY_NAME);
	await newLobby.form.fill("description", LOBBY_DESCRIPTION);
	await newLobby.save();

	const lobby = new LobbyPage(page);
	await expect(lobby.heading(LOBBY_NAME)).toBeVisible();
	await expect(lobby.locators.description).toHaveText(LOBBY_DESCRIPTION);
	await expect(lobby.locators.participants).toHaveCount(1);
	const lobbyId = Number(page.url().split("/").at(-1));

	await impersonate(page, visitor.id);
	await lobby.goto(lobbyId);
	await lobby.signUp();

	await expect(lobby.locators.participants).toHaveCount(2);
	await expect(lobby.locators.viewerStatus).toContainText(
		"notified when check-in opens",
	);
	await expect(lobby.locators.startBanner).toContainText("2/8 signed up");
	await isNotVisible(lobby.locators.checkInButton);
})

the 8th to sign up to a started lobby opens check-in for everyone

Setup
Arrange
  1. Create ROOM_SIZE - 1 × user → [host, ...others]
    const [host, ...others] = await factories.UserFactory.createMany(
    	ROOM_SIZE - 1,
    );
  2. Create user → eighth
    const eighth = await factories.UserFactory.create();
  3. Create lobby host user id host.id name “Test 8s” room size 8 starts at dateToDatabaseTimestamp(subMinutes(new Date(), 1)) signed up user ids idsOf(others) → lobby
    const lobby = await factories.LobbyFactory.create(
    	{
    		hostUserId: host.id,
    		name: LOBBY_NAME,
    		roomSize: ROOM_SIZE,
    		startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 1)),
    	},
    	{ signedUpUserIds: idsOf(others) },
    );

1The 8th signing up is checked in right away

Eeighth
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. viewer status contains “checked in”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"checked in",
    );
  2. start banner contains “1/8 checked in”
    await expect(lobbyPage.locators.startBanner).toContainText(
    	"1/8 checked in",
    );

2The others are notified and can check in

Hhost
Act
  1. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification(`Check in to ${LOBBY_NAME}`) is visible
    await expect(
    	notifications.notification(`Check in to ${LOBBY_NAME}`),
    ).toBeVisible();
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. check in button is visible
    await expect(lobbyPage.locators.checkInButton).toBeVisible();
Source
test("the 8th to sign up to a started lobby opens check-in for everyone", async ({
	page,
	factories,
}) => {
	const [host, ...others] = await factories.UserFactory.createMany(
		ROOM_SIZE - 1,
	);
	const eighth = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create(
		{
			hostUserId: host.id,
			name: LOBBY_NAME,
			roomSize: ROOM_SIZE,
			startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 1)),
		},
		{ signedUpUserIds: idsOf(others) },
	);
	const lobbyPage = new LobbyPage(page);

	await test.step("The 8th signing up is checked in right away", async () => {
		await impersonate(page, eighth.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.signUp();

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"checked in",
		);
		await expect(lobbyPage.locators.startBanner).toContainText(
			"1/8 checked in",
		);
	});

	await test.step("The others are notified and can check in", async () => {
		await impersonate(page, host.id);
		const notifications = await openNotifications(page);
		await expect(
			notifications.notification(`Check in to ${LOBBY_NAME}`),
		).toBeVisible();

		await lobbyPage.goto(lobby.id);
		await expect(lobbyPage.locators.checkInButton).toBeVisible();
	});
})

signing up for a later lobby reserves a spot without check-in yet

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → visitor
    const visitor = await factories.UserFactory.create();
  3. Create lobby host user id host.id → lobby
    const lobby = await factories.LobbyFactory.create({
    	hostUserId: host.id,
    });
Vvisitor
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. viewer status contains “notified when check-in opens”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"notified when check-in opens",
    );
  2. start banner contains “2/8 signed up”
    await expect(lobbyPage.locators.startBanner).toContainText(
    	"2/8 signed up",
    );
  3. check in button is not visible
    await isNotVisible(lobbyPage.locators.checkInButton);
Source
test("signing up for a later lobby reserves a spot without check-in yet", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const visitor = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create({
		hostUserId: host.id,
	});

	await impersonate(page, visitor.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.signUp();

	await expect(lobbyPage.locators.viewerStatus).toContainText(
		"notified when check-in opens",
	);
	await expect(lobbyPage.locators.startBanner).toContainText(
		"2/8 signed up",
	);
	await isNotVisible(lobbyPage.locators.checkInButton);
})

the signed up are notified when check-in opens

Setup
Arrange
  1. Full lobby starts at dateToDatabaseTimestamp(addMinutes(new Date(), 5)) → { signedUp }
    const { signedUp } = await fullLobby(factories, {
    	startsAt: dateToDatabaseTimestamp(addMinutes(new Date(), 5)),
    });
SUsigned up
Act
  1. Run routine “Lobbies”
    await runRoutine(page, "Lobbies");
  2. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification(`Check in to ${LOBBY_NAME}`) is visible
    await expect(
    	notifications.notification(`Check in to ${LOBBY_NAME}`),
    ).toBeVisible();
Source
test("the signed up are notified when check-in opens", async ({
	page,
	factories,
}) => {
	const { signedUp } = await fullLobby(factories, {
		startsAt: dateToDatabaseTimestamp(addMinutes(new Date(), 5)),
	});

	await impersonate(page, signedUp.id);
	await runRoutine(page, "Lobbies");

	const notifications = await openNotifications(page);
	await expect(
		notifications.notification(`Check in to ${LOBBY_NAME}`),
	).toBeVisible();
})

a signed-up player checks in once check-in opens

Setup
Arrange
  1. Full lobby starts at dateToDatabaseTimestamp(addMinutes(new Date(), 5)) → { lobby, signedUp }
    const { lobby, signedUp } = await fullLobby(factories, {
    	startsAt: dateToDatabaseTimestamp(addMinutes(new Date(), 5)),
    });
SUsigned up
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Check in
    await lobbyPage.checkIn();
Assert
  1. viewer status contains “You're checked in, the lobby starts soon”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're checked in, the lobby starts soon",
    );
  2. start banner contains “1/8 checked in”
    await expect(lobbyPage.locators.startBanner).toContainText(
    	"1/8 checked in",
    );
Source
test("a signed-up player checks in once check-in opens", async ({
	page,
	factories,
}) => {
	const { lobby, signedUp } = await fullLobby(factories, {
		startsAt: dateToDatabaseTimestamp(addMinutes(new Date(), 5)),
	});

	await impersonate(page, signedUp.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.checkIn();

	await expect(lobbyPage.locators.viewerStatus).toContainText(
		"You're checked in, the lobby starts soon",
	);
	await expect(lobbyPage.locators.startBanner).toContainText(
		"1/8 checked in",
	);
})

check-in opening shows the check-in button on an open page, checking in the room's pool and pass

Setup
Arrange
  1. Full lobby starts at dateToDatabaseTimestamp( addSeconds(addMinutes(new Date(), CHECK_IN_LEAD_MINU… → { lobby, signedUp }
    const { lobby, signedUp } = await fullLobby(factories, {
    	startsAt: dateToDatabaseTimestamp(
    		addSeconds(addMinutes(new Date(), CHECK_IN_LEAD_MINUTES), 10),
    	),
    });

1Before check-in opens there is no check-in button

SUsigned up
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “notified when check-in opens”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"notified when check-in opens",
    );
  2. start banner contains “Check-in opens at”
    await expect(lobbyPage.locators.startBanner).toContainText(
    	"Check-in opens at",
    );
  3. check in button is not visible
    await isNotVisible(lobbyPage.locators.checkInButton);

2The check-in button appears as check-in opens

SUsigned up
Lobby page
Assert
  1. check in button is visible
    await expect(lobbyPage.locators.checkInButton).toBeVisible({
    	timeout: 20_000,
    });

3Checking in shows the room's pool and pass

SUsigned up
Lobby page
Act
  1. Check in
    await lobbyPage.checkIn();
Assert
  1. room pool is visible
    await expect(lobbyPage.locators.roomPool).toBeVisible();
  2. room pass is visible
    await expect(lobbyPage.locators.roomPass).toBeVisible();
Source
test("check-in opening shows the check-in button on an open page, checking in the room's pool and pass", async ({
	page,
	factories,
}) => {
	const { lobby, signedUp } = await fullLobby(factories, {
		startsAt: dateToDatabaseTimestamp(
			addSeconds(addMinutes(new Date(), CHECK_IN_LEAD_MINUTES), 10),
		),
	});
	const lobbyPage = new LobbyPage(page);

	await test.step("Before check-in opens there is no check-in button", async () => {
		await impersonate(page, signedUp.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"notified when check-in opens",
		);
		await expect(lobbyPage.locators.startBanner).toContainText(
			"Check-in opens at",
		);
		await isNotVisible(lobbyPage.locators.checkInButton);
	});

	await test.step("The check-in button appears as check-in opens", async () => {
		await expect(lobbyPage.locators.checkInButton).toBeVisible({
			timeout: 20_000,
		});
	});

	await test.step("Checking in shows the room's pool and pass", async () => {
		await lobbyPage.checkIn();

		await expect(lobbyPage.locators.roomPool).toBeVisible();
		await expect(lobbyPage.locators.roomPass).toBeVisible();
	});
})

past the room size sign-ups go to the waitlist

Setup
Arrange
  1. Full lobby → { lobby }
    const { lobby } = await fullLobby(factories);
  2. Create user → visitor
    const visitor = await factories.UserFactory.create();
Vvisitor
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. viewer status contains “You're #1 on the waitlist”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're #1 on the waitlist",
    );
Source
test("past the room size sign-ups go to the waitlist", async ({
	page,
	factories,
}) => {
	const { lobby } = await fullLobby(factories);
	const visitor = await factories.UserFactory.create();

	await impersonate(page, visitor.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.signUp();

	await expect(lobbyPage.locators.viewerStatus).toContainText(
		"You're #1 on the waitlist",
	);
})

a spot freed before the start goes to the first on the waitlist

signed upwaitlistedlobbies.spec.ts:263
Setup
Arrange
  1. Create user → waitlisted
    const waitlisted = await factories.UserFactory.create();
  2. Full lobby waitlisted user ids waitlisted.id → { lobby, signedUp }
    const { lobby, signedUp } = await fullLobby(factories, {
    	waitlistedUserIds: [waitlisted.id],
    });

1A signed-up player leaves

SUsigned up
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Leave
    await lobbyPage.leave();
Assert
  1. sign up button is visible
    await expect(lobbyPage.locators.signUpButton).toBeVisible();

2The waitlisted player is notified and has their spot

Wwaitlisted
Act
  1. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification(`You got a spot in ${LOBBY_NAME}`) is visible
    await expect(
    	notifications.notification(`You got a spot in ${LOBBY_NAME}`),
    ).toBeVisible();
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “You're signed up”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're signed up",
    );
Source
test("a spot freed before the start goes to the first on the waitlist", async ({
	page,
	factories,
}) => {
	const waitlisted = await factories.UserFactory.create();
	const { lobby, signedUp } = await fullLobby(factories, {
		waitlistedUserIds: [waitlisted.id],
	});
	const lobbyPage = new LobbyPage(page);

	await test.step("A signed-up player leaves", async () => {
		await impersonate(page, signedUp.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.leave();

		await expect(lobbyPage.locators.signUpButton).toBeVisible();
	});

	await test.step("The waitlisted player is notified and has their spot", async () => {
		await impersonate(page, waitlisted.id);
		const notifications = await openNotifications(page);
		await expect(
			notifications.notification(`You got a spot in ${LOBBY_NAME}`),
		).toBeVisible();

		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're signed up",
		);
	});
})

the waitlisted stay on the waitlist when everyone with a spot checks in

last to check inwaitlistedlobbies.spec.ts:296
Setup
Arrange
  1. Starting lobby → { lobby, lastToCheckIn, waitlisted }
    const { lobby, lastToCheckIn, waitlisted } =
    	await startingLobby(factories);

1The last player with a spot checks in, starting the lobby

LTlast to check in
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Check in
    await lobbyPage.checkIn();
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();

2The waitlisted player is first on the waitlist

Wwaitlisted
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “You're #1 on the waitlist”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're #1 on the waitlist",
    );
Source
test("the waitlisted stay on the waitlist when everyone with a spot checks in", async ({
	page,
	factories,
}) => {
	const { lobby, lastToCheckIn, waitlisted } =
		await startingLobby(factories);
	const lobbyPage = new LobbyPage(page);

	await test.step("The last player with a spot checks in, starting the lobby", async () => {
		await impersonate(page, lastToCheckIn.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.checkIn();

		await expect(lobbyPage.tab("action")).toBeVisible();
	});

	await test.step("The waitlisted player is first on the waitlist", async () => {
		await impersonate(page, waitlisted.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're #1 on the waitlist",
		);
	});
})

a waitlisted player plays in place of one who didn't check in

waitlisteddid not check inlobbies.spec.ts:322
Setup
Arrange
  1. Starting lobby → { lobby, lastToCheckIn: didNotCheckIn, waitlisted, }
    const {
    	lobby,
    	lastToCheckIn: didNotCheckIn,
    	waitlisted,
    } = await startingLobby(factories);

1The waitlisted player checks in after the start

Wwaitlisted
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Check in
    await lobbyPage.checkIn();
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();

2The one who didn't check in is no longer in the lobby

DNdid not check in
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. sign up button is visible
    await expect(lobbyPage.locators.signUpButton).toBeVisible();
Source
test("a waitlisted player plays in place of one who didn't check in", async ({
	page,
	factories,
}) => {
	const {
		lobby,
		lastToCheckIn: didNotCheckIn,
		waitlisted,
	} = await startingLobby(factories);
	const lobbyPage = new LobbyPage(page);

	await test.step("The waitlisted player checks in after the start", async () => {
		await impersonate(page, waitlisted.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.checkIn();

		await expect(lobbyPage.tab("action")).toBeVisible();
	});

	await test.step("The one who didn't check in is no longer in the lobby", async () => {
		await impersonate(page, didNotCheckIn.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.signUpButton).toBeVisible();
	});
})

Who can join

Signing up and making a lobby take a friend code, making one is for now only for an admin, and a user in SendouQ or present in another lobby can't check in to a lobby until they leave it.

without a friend code a user can't sign up or make a lobby

without friend codeSendoulobbies.spec.ts:356
Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user friend code null → withoutFriendCode
    const withoutFriendCode = await factories.UserFactory.create({
    	friendCode: null,
    });
  3. Create lobby host user id host.id → lobby
    const lobby = await factories.LobbyFactory.create({
    	hostUserId: host.id,
    });
WFwithout friend code
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. friend code needed text is visible
    await expect(lobbyPage.locators.friendCodeNeededText).toBeVisible();
  2. sign up button is not visible
    await isNotVisible(lobbyPage.locators.signUpButton);
SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
Assert
  1. friend code needed text is visible
    await expect(newLobby.locators.friendCodeNeededText).toBeVisible();
Source
test("without a friend code a user can't sign up or make a lobby", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const withoutFriendCode = await factories.UserFactory.create({
		friendCode: null,
	});
	const lobby = await factories.LobbyFactory.create({
		hostUserId: host.id,
	});

	await impersonate(page, withoutFriendCode.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);

	await expect(lobbyPage.locators.friendCodeNeededText).toBeVisible();
	await isNotVisible(lobbyPage.locators.signUpButton);

	await impersonate(page, ADMIN_ID);
	const newLobby = new NewLobbyPage(page);
	await newLobby.goto();

	await expect(newLobby.locators.friendCodeNeededText).toBeVisible();
})

only a supporter can make a lobby

Setup
Arrange
  1. Create user → user
    const user = await factories.UserFactory.create();
Uuser
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
Assert
  1. no permissions text is visible
    await expect(newLobby.locators.noPermissionsText).toBeVisible();
Source
test("only a supporter can make a lobby", async ({ page, factories }) => {
	const user = await factories.UserFactory.create();

	await impersonate(page, user.id);
	const newLobby = new NewLobbyPage(page);
	await newLobby.goto();

	await expect(newLobby.locators.noPermissionsText).toBeVisible();
})

a user in SendouQ can't check in

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → inSendouQ
    const inSendouQ = await factories.UserFactory.create();
  3. Create SQ group member user ids inSendouQ.id
    await factories.SQGroupFactory.create({ memberUserIds: [inSendouQ.id] });
  4. Create lobby host user id host.id starts at dateToDatabaseTimestamp(addMinutes(new Date(), 5)) check in opened at dateToDatabaseTimestamp(new Date()) signed up user ids inSendouQ.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{
    		hostUserId: host.id,
    		startsAt: dateToDatabaseTimestamp(addMinutes(new Date(), 5)),
    		checkInOpenedAt: dateToDatabaseTimestamp(new Date()),
    	},
    	{ signedUpUserIds: [inSendouQ.id] },
    );
ISin SendouQ
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Check in
    await lobbyPage.checkIn();
Assert
  1. toasts render hidden in e2e runs

    text “Leave SendouQ before checking in to a lobby” is in the page
    await expect(
    	page.getByText("Leave SendouQ before checking in to a lobby"),
    ).toBeAttached();
  2. check in button is visible
    await expect(lobbyPage.locators.checkInButton).toBeVisible();
Source
test("a user in SendouQ can't check in", async ({ page, factories }) => {
	const host = await factories.UserFactory.create();
	const inSendouQ = await factories.UserFactory.create();
	await factories.SQGroupFactory.create({ memberUserIds: [inSendouQ.id] });
	const lobby = await factories.LobbyFactory.create(
		{
			hostUserId: host.id,
			startsAt: dateToDatabaseTimestamp(addMinutes(new Date(), 5)),
			checkInOpenedAt: dateToDatabaseTimestamp(new Date()),
		},
		{ signedUpUserIds: [inSendouQ.id] },
	);

	await impersonate(page, inSendouQ.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.checkIn();

	// toasts render hidden in e2e runs
	await expect(
		page.getByText("Leave SendouQ before checking in to a lobby"),
	).toBeAttached();
	await expect(lobbyPage.locators.checkInButton).toBeVisible();
})

a player checked in to another lobby can't check in

Setup
Arrange
  1. Create 3 × user → [host, otherHost, player]
    const [host, otherHost, player] =
    	await factories.UserFactory.createMany(3);
  2. startsSoon = dateToDatabaseTimestamp(addMinutes(new Date(), 5))
    const startsSoon = dateToDatabaseTimestamp(addMinutes(new Date(), 5));
  3. Create lobby host user id otherHost.id starts at startsSoon signed up user ids player.id checked in user ids player.id
    await factories.LobbyFactory.create(
    	{ hostUserId: otherHost.id, startsAt: startsSoon },
    	{ signedUpUserIds: [player.id], checkedInUserIds: [player.id] },
    );
  4. Create lobby host user id host.id starts at startsSoon check in opened at dateToDatabaseTimestamp(new Date()) signed up user ids player.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{
    		hostUserId: host.id,
    		startsAt: startsSoon,
    		checkInOpenedAt: dateToDatabaseTimestamp(new Date()),
    	},
    	{ signedUpUserIds: [player.id] },
    );
Pplayer
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Check in
    await lobbyPage.checkIn();
Assert
  1. toasts render hidden in e2e runs

    text “Leave the other lobby before checking in to this one” is in the page
    await expect(
    	page.getByText("Leave the other lobby before checking in to this one"),
    ).toBeAttached();
  2. check in button is visible
    await expect(lobbyPage.locators.checkInButton).toBeVisible();
Source
test("a player checked in to another lobby can't check in", async ({
	page,
	factories,
}) => {
	const [host, otherHost, player] =
		await factories.UserFactory.createMany(3);
	const startsSoon = dateToDatabaseTimestamp(addMinutes(new Date(), 5));
	await factories.LobbyFactory.create(
		{ hostUserId: otherHost.id, startsAt: startsSoon },
		{ signedUpUserIds: [player.id], checkedInUserIds: [player.id] },
	);
	const lobby = await factories.LobbyFactory.create(
		{
			hostUserId: host.id,
			startsAt: startsSoon,
			checkInOpenedAt: dateToDatabaseTimestamp(new Date()),
		},
		{ signedUpUserIds: [player.id] },
	);

	await impersonate(page, player.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.checkIn();

	// toasts render hidden in e2e runs
	await expect(
		page.getByText("Leave the other lobby before checking in to this one"),
	).toBeAttached();
	await expect(lobbyPage.locators.checkInButton).toBeVisible();
})

a player in another lobby's room can't join a started lobby

Setup
Arrange
  1. Started lobby → { alphaPlayer }
    const { alphaPlayer } = await startedLobby(page, factories);
  2. Create user → otherHost
    const otherHost = await factories.UserFactory.create();
  3. Create lobby host user id otherHost.id starts at dateToDatabaseTimestamp(subMinutes(new Date(), 1)) checked in user ids otherHost.id → otherLobby
    const otherLobby = await factories.LobbyFactory.create(
    	{
    		hostUserId: otherHost.id,
    		startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 1)),
    	},
    	{ checkedInUserIds: [otherHost.id] },
    );
APalpha player
Lobby page
Act
  1. Open the lobby page otherLobby.id
    await lobbyPage.goto(otherLobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. text “Leave the other lobby before checking in to this one” is in the page
    await expect(
    	page.getByText("Leave the other lobby before checking in to this one"),
    ).toBeAttached();
  2. participants count is 1
    await expect(lobbyPage.locators.participants).toHaveCount(1);
Source
test("a player in another lobby's room can't join a started lobby", async ({
	page,
	factories,
}) => {
	const { alphaPlayer } = await startedLobby(page, factories);
	const otherHost = await factories.UserFactory.create();
	const otherLobby = await factories.LobbyFactory.create(
		{
			hostUserId: otherHost.id,
			startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 1)),
		},
		{ checkedInUserIds: [otherHost.id] },
	);

	await impersonate(page, alphaPlayer.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(otherLobby.id);
	await lobbyPage.signUp();

	await expect(
		page.getByText("Leave the other lobby before checking in to this one"),
	).toBeAttached();
	await expect(lobbyPage.locators.participants).toHaveCount(1);
})

Visibility

A lobby limited to an association is listed only to its members, its card marked as such, and its page is not found for others. Its host can still invite anyone with the lobby's invite link, which only they get, and change who sees it later on. A link-only lobby is listed to no one but its participants: others find it only through the link its host shares, and once signed up they find it without the link too. Everyone who can open it gets the link to share, and their address bar always shows it. Without the link others are told the lobby is invite only.

a lobby limited to an association is hidden from outsiders

memberoutsiderlobbies.spec.ts:485
Setup
Arrange
  1. Create 3 × user → [host, member, outsider]
    const [host, member, outsider] =
    	await factories.UserFactory.createMany(3);
  2. Create association user id host.id name “Inkling Alliance” member user ids member.id → association
    const association = await factories.AssociationFactory.create(
    	{ userId: host.id, name: ASSOCIATION_NAME },
    	{ memberUserIds: [member.id] },
    );
  3. Create lobby host user id host.id name “Test 8s” visibility for association association.id → lobby
    const lobby = await factories.LobbyFactory.create({
    	hostUserId: host.id,
    	name: LOBBY_NAME,
    	visibility: { forAssociation: association.id },
    });

1A member of the association sees it marked as limited

Mmember
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Open tab “upcoming”
    await lobbies.openTab("upcoming");
Assert
  1. limited visibility icon “Test 8s” is visible
    await expect(lobbies.limitedVisibilityIcon(LOBBY_NAME)).toBeVisible();

2An outsider neither sees it listed nor finds its page

Ooutsider
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Open tab “upcoming”
    await lobbies.openTab("upcoming");
Assert
  1. card “Test 8s” count is 0
    await expect(lobbies.card(LOBBY_NAME)).toHaveCount(0);
Lobby page
Act
  1. Open the lobby page lobby.id
    await new LobbyPage(page).goto(lobby.id);
Error page
Assert
  1. not found heading is visible
    await expect(errorPage.locators.notFoundHeading).toBeVisible();
Source
test("a lobby limited to an association is hidden from outsiders", async ({
	page,
	factories,
}) => {
	const [host, member, outsider] =
		await factories.UserFactory.createMany(3);
	const association = await factories.AssociationFactory.create(
		{ userId: host.id, name: ASSOCIATION_NAME },
		{ memberUserIds: [member.id] },
	);
	const lobby = await factories.LobbyFactory.create({
		hostUserId: host.id,
		name: LOBBY_NAME,
		visibility: { forAssociation: association.id },
	});
	const lobbies = new LobbiesPage(page);

	await test.step("A member of the association sees it marked as limited", async () => {
		await impersonate(page, member.id);
		await lobbies.goto();
		await lobbies.openTab("upcoming");

		await expect(lobbies.limitedVisibilityIcon(LOBBY_NAME)).toBeVisible();
	});

	await test.step("An outsider neither sees it listed nor finds its page", async () => {
		await impersonate(page, outsider.id);
		await lobbies.goto();
		await lobbies.openTab("upcoming");

		await expect(lobbies.card(LOBBY_NAME)).toHaveCount(0);

		const errorPage = new ErrorPage(page);
		await new LobbyPage(page).goto(lobby.id);
		await expect(errorPage.locators.notFoundHeading).toBeVisible();
	});
})

the host invites an outsider to a lobby limited to an association and opens it to everyone

hostmemberinviteeoutsiderlobbies.spec.ts:523
Setup
Arrange
  1. Create 4 × user → [host, member, invitee, outsider]
    const [host, member, invitee, outsider] =
    	await factories.UserFactory.createMany(4);
  2. Create association user id host.id name “Inkling Alliance” member user ids member.id → association
    const association = await factories.AssociationFactory.create(
    	{ userId: host.id, name: ASSOCIATION_NAME },
    	{ memberUserIds: [member.id] },
    );
  3. Create lobby host user id host.id name “Test 8s” visibility for association association.id → lobby
    const lobby = await factories.LobbyFactory.create({
    	hostUserId: host.id,
    	name: LOBBY_NAME,
    	visibility: { forAssociation: association.id },
    });
Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Copy share link as host → oldShareLink
    const oldShareLink = await lobbyPage.copyShareLinkAsHost();
  3. Reset share link
    await lobbyPage.resetShareLink();
Assert
  1. toasts render hidden in e2e runs

    share link reset toast is in the page
    await expect(lobbyPage.locators.shareLinkResetToast).toBeAttached();
Act
  1. Copy share link as host → shareLink
    const shareLink = await lobbyPage.copyShareLinkAsHost();
Assert
  1. shareLink is not oldShareLink
    expect(shareLink).not.toBe(oldShareLink);

1A member sees the lobby but gets no link to share

Mmember
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. heading “Test 8s” is visible
    await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
  2. copy share link button is not visible
    await isNotVisible(lobbyPage.locators.copyShareLinkButton);

2Through the link an outsider opens it, the reset one doesn't work

Iinvitee
Lobby page
Act
  1. Go to via share link shareLink
    await lobbyPage.gotoViaShareLink(shareLink);
Assert
  1. heading “Test 8s” is visible
    await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
Act
  1. Go to via share link oldShareLink
    await lobbyPage.gotoViaShareLink(oldShareLink);
Error page
Assert
  1. not found heading is visible
    await expect(errorPage.locators.notFoundHeading).toBeVisible();

3Opened to everyone, an outsider sees it listed

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Change visibility “Public”
    await lobbyPage.changeVisibility("Public");
Ooutsider
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Open tab “upcoming”
    await lobbies.openTab("upcoming");
Assert
  1. card “Test 8s” is visible
    await expect(lobbies.card(LOBBY_NAME)).toBeVisible();
  2. limited visibility icon “Test 8s” is not visible
    await isNotVisible(lobbies.limitedVisibilityIcon(LOBBY_NAME));
Source
test("the host invites an outsider to a lobby limited to an association and opens it to everyone", async ({
	page,
	factories,
}) => {
	const [host, member, invitee, outsider] =
		await factories.UserFactory.createMany(4);
	const association = await factories.AssociationFactory.create(
		{ userId: host.id, name: ASSOCIATION_NAME },
		{ memberUserIds: [member.id] },
	);
	const lobby = await factories.LobbyFactory.create({
		hostUserId: host.id,
		name: LOBBY_NAME,
		visibility: { forAssociation: association.id },
	});
	const lobbyPage = new LobbyPage(page);
	const lobbies = new LobbiesPage(page);

	await impersonate(page, host.id);
	await lobbyPage.goto(lobby.id);
	const oldShareLink = await lobbyPage.copyShareLinkAsHost();
	await lobbyPage.resetShareLink();
	// toasts render hidden in e2e runs
	await expect(lobbyPage.locators.shareLinkResetToast).toBeAttached();
	const shareLink = await lobbyPage.copyShareLinkAsHost();
	expect(shareLink).not.toBe(oldShareLink);

	await test.step("A member sees the lobby but gets no link to share", async () => {
		await impersonate(page, member.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
		await isNotVisible(lobbyPage.locators.copyShareLinkButton);
	});

	await test.step("Through the link an outsider opens it, the reset one doesn't work", async () => {
		await impersonate(page, invitee.id);
		await lobbyPage.gotoViaShareLink(shareLink);
		await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();

		const errorPage = new ErrorPage(page);
		await lobbyPage.gotoViaShareLink(oldShareLink);
		await expect(errorPage.locators.notFoundHeading).toBeVisible();
	});

	await test.step("Opened to everyone, an outsider sees it listed", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.changeVisibility("Public");

		await impersonate(page, outsider.id);
		await lobbies.goto();
		await lobbies.openTab("upcoming");

		await expect(lobbies.card(LOBBY_NAME)).toBeVisible();
		await isNotVisible(lobbies.limitedVisibilityIcon(LOBBY_NAME));
	});
})
Sendououtsidervisitorlobbies.spec.ts:582
Setup
Arrange
  1. Create 2 × user → [visitor, outsider]
    const [visitor, outsider] = await factories.UserFactory.createMany(2);
  2. Set friend code user Sendou
    await factories.UserFactory.setFriendCode(ADMIN_ID);
SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
  2. Fill name with “Test 8s”
    await newLobby.form.fill("name", LOBBY_NAME);
  3. Select visibility “Only with the link”
    await newLobby.selectVisibility("Only with the link");
  4. Save
    await newLobby.save();
Lobby page
Assert
  1. heading “Test 8s” is visible
    await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
Act
  1. lobbyId = Number(new URL(page.url()).pathname.split("/").at(-1))
    const lobbyId = Number(new URL(page.url()).pathname.split("/").at(-1));
  2. Copy share link as host → shareLink
    const shareLink = await lobbyPage.copyShareLinkAsHost();

1The host's address bar shows the link

SSendou
Assert
  1. new URL(page.url()).search is new URL(shareLink).search
    expect(new URL(page.url()).search).toBe(new URL(shareLink).search);
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);
Assert
  1. heading “Test 8s” is visible
    await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
  2. new URL(page.url()).search is new URL(shareLink).search
    expect(new URL(page.url()).search).toBe(new URL(shareLink).search);

2Without the link an outsider neither sees it listed nor its page

Ooutsider
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Open tab “running”
    await lobbies.openTab("running");
Assert
  1. card “Test 8s” count is 0
    await expect(lobbies.card(LOBBY_NAME)).toHaveCount(0);
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);
Assert
  1. invite only heading is visible
    await expect(lobbyPage.locators.inviteOnlyHeading).toBeVisible();
  2. heading “Test 8s” is not visible
    await isNotVisible(lobbyPage.heading(LOBBY_NAME));

3Through the link a visitor opens it and signs up

Vvisitor
Lobby page
Act
  1. Go to via share link shareLink
    await lobbyPage.gotoViaShareLink(shareLink);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. participants count is 2
    await expect(lobbyPage.locators.participants).toHaveCount(2);

4Signed up, the visitor finds it without the link

Vvisitor
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Open tab “running”
    await lobbies.openTab("running");
Assert
  1. card “Test 8s” is visible
    await expect(lobbies.card(LOBBY_NAME)).toBeVisible();
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);
Assert
  1. heading “Test 8s” is visible
    await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
  2. new URL(page.url()).search is new URL(shareLink).search
    expect(new URL(page.url()).search).toBe(new URL(shareLink).search);

5Not being the host, the visitor can share the link too

Vvisitor
Lobby page
Assert
  1. copy share link is shareLink
    expect(await lobbyPage.copyShareLink()).toBe(shareLink);
Source
test("a link-only lobby is found only through its shared link", async ({
	page,
	factories,
}) => {
	const [visitor, outsider] = await factories.UserFactory.createMany(2);
	await factories.UserFactory.setFriendCode(ADMIN_ID);
	const lobbyPage = new LobbyPage(page);
	const lobbies = new LobbiesPage(page);

	await impersonate(page, ADMIN_ID);
	const newLobby = new NewLobbyPage(page);
	await newLobby.goto();
	await newLobby.form.fill("name", LOBBY_NAME);
	await newLobby.selectVisibility("Only with the link");
	await newLobby.save();

	await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
	const lobbyId = Number(new URL(page.url()).pathname.split("/").at(-1));
	const shareLink = await lobbyPage.copyShareLinkAsHost();

	await test.step("The host's address bar shows the link", async () => {
		expect(new URL(page.url()).search).toBe(new URL(shareLink).search);

		await lobbyPage.goto(lobbyId);
		await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
		expect(new URL(page.url()).search).toBe(new URL(shareLink).search);
	});

	await test.step("Without the link an outsider neither sees it listed nor its page", async () => {
		await impersonate(page, outsider.id);
		await lobbies.goto();
		await lobbies.openTab("running");

		await expect(lobbies.card(LOBBY_NAME)).toHaveCount(0);

		await lobbyPage.goto(lobbyId);
		await expect(lobbyPage.locators.inviteOnlyHeading).toBeVisible();
		await isNotVisible(lobbyPage.heading(LOBBY_NAME));
	});

	await test.step("Through the link a visitor opens it and signs up", async () => {
		await impersonate(page, visitor.id);
		await lobbyPage.gotoViaShareLink(shareLink);
		await lobbyPage.signUp();

		await expect(lobbyPage.locators.participants).toHaveCount(2);
	});

	await test.step("Signed up, the visitor finds it without the link", async () => {
		await lobbies.goto();
		await lobbies.openTab("running");

		await expect(lobbies.card(LOBBY_NAME)).toBeVisible();

		await lobbyPage.goto(lobbyId);
		await expect(lobbyPage.heading(LOBBY_NAME)).toBeVisible();
		expect(new URL(page.url()).search).toBe(new URL(shareLink).search);
	});

	await test.step("Not being the host, the visitor can share the link too", async () => {
		expect(await lobbyPage.copyShareLink()).toBe(shareLink);
	});
})

Lobby list

The lobby list splits lobbies into running and upcoming ones, opening on the tab of a lobby the viewer is in. A lobby can be joined and, before the viewer is in its room, left from its card.

running and upcoming lobbies are on their own tabs, opening on the viewer's

Setup
Arrange
  1. Create 3 × user → [runningHost, upcomingHost, viewer]
    const [runningHost, upcomingHost, viewer] =
    	await factories.UserFactory.createMany(3);
  2. Create lobby host user id runningHost.id name “Running 8s” starts at dateToDatabaseTimestamp(subMinutes(new Date(), 30))
    await factories.LobbyFactory.create({
    	hostUserId: runningHost.id,
    	name: "Running 8s",
    	startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 30)),
    });
  3. Create lobby host user id upcomingHost.id name “Upcoming 8s” signed up user ids viewer.id
    await factories.LobbyFactory.create(
    	{ hostUserId: upcomingHost.id, name: "Upcoming 8s" },
    	{ signedUpUserIds: [viewer.id] },
    );
Vviewer
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
Assert
  1. selected tab contains “Upcoming”
    await expect(lobbies.locators.selectedTab).toContainText("Upcoming");
  2. card “Upcoming 8s” is visible
    await expect(lobbies.card("Upcoming 8s")).toBeVisible();
  3. card “Running 8s” count is 0
    await expect(lobbies.card("Running 8s")).toHaveCount(0);
Act
  1. Open tab “running”
    await lobbies.openTab("running");
Assert
  1. card “Running 8s” is visible
    await expect(lobbies.card("Running 8s")).toBeVisible();
Source
test("running and upcoming lobbies are on their own tabs, opening on the viewer's", async ({
	page,
	factories,
}) => {
	const [runningHost, upcomingHost, viewer] =
		await factories.UserFactory.createMany(3);
	await factories.LobbyFactory.create({
		hostUserId: runningHost.id,
		name: "Running 8s",
		startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 30)),
	});
	await factories.LobbyFactory.create(
		{ hostUserId: upcomingHost.id, name: "Upcoming 8s" },
		{ signedUpUserIds: [viewer.id] },
	);

	await impersonate(page, viewer.id);
	const lobbies = new LobbiesPage(page);
	await lobbies.goto();

	await expect(lobbies.locators.selectedTab).toContainText("Upcoming");
	await expect(lobbies.card("Upcoming 8s")).toBeVisible();
	await expect(lobbies.card("Running 8s")).toHaveCount(0);

	await lobbies.openTab("running");

	await expect(lobbies.card("Running 8s")).toBeVisible();
})

joins a lobby from its card

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → visitor
    const visitor = await factories.UserFactory.create();
  3. Create lobby host user id host.id name “Test 8s”
    await factories.LobbyFactory.create({
    	hostUserId: host.id,
    	name: LOBBY_NAME,
    });
Vvisitor
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Join “Test 8s”
    await lobbies.join(LOBBY_NAME);
Assert
  1. card “Test 8s” contains “Signed up”
    await expect(lobbies.card(LOBBY_NAME)).toContainText("Signed up");
Source
test("joins a lobby from its card", async ({ page, factories }) => {
	const host = await factories.UserFactory.create();
	const visitor = await factories.UserFactory.create();
	await factories.LobbyFactory.create({
		hostUserId: host.id,
		name: LOBBY_NAME,
	});

	await impersonate(page, visitor.id);
	const lobbies = new LobbiesPage(page);
	await lobbies.goto();
	await lobbies.join(LOBBY_NAME);

	await expect(lobbies.card(LOBBY_NAME)).toContainText("Signed up");
})

leaves a lobby from its card

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → signedUp
    const signedUp = await factories.UserFactory.create();
  3. Create lobby host user id host.id name “Test 8s” signed up user ids signedUp.id
    await factories.LobbyFactory.create(
    	{ hostUserId: host.id, name: LOBBY_NAME },
    	{ signedUpUserIds: [signedUp.id] },
    );
SUsigned up
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Leave “Test 8s”
    await lobbies.leave(LOBBY_NAME);
Assert
  1. card “Test 8s” does not contain “Signed up”
    await expect(lobbies.card(LOBBY_NAME)).not.toContainText("Signed up");
  2. card “Test 8s” › element “lobby-join-button” is visible
    await expect(
    	lobbies.card(LOBBY_NAME).getByTestId("lobby-join-button"),
    ).toBeVisible();
Source
test("leaves a lobby from its card", async ({ page, factories }) => {
	const host = await factories.UserFactory.create();
	const signedUp = await factories.UserFactory.create();
	await factories.LobbyFactory.create(
		{ hostUserId: host.id, name: LOBBY_NAME },
		{ signedUpUserIds: [signedUp.id] },
	);

	await impersonate(page, signedUp.id);
	const lobbies = new LobbiesPage(page);
	await lobbies.goto();
	await lobbies.leave(LOBBY_NAME);

	await expect(lobbies.card(LOBBY_NAME)).not.toContainText("Signed up");
	await expect(
		lobbies.card(LOBBY_NAME).getByTestId("lobby-join-button"),
	).toBeVisible();
})

Playing sets

The lobby starts once 8 have checked in after its start time, splitting the room into two teams for a set and notifying its players. The banner shows who voted for the map being played with their match profile map pool. One side reports the maps, can undo a report while the set is being played, and the other confirms the result, after which the set shows on the Result tab and counts on the Rankings tab together with the weapons reported, the Rankings then also offering a head-to-head view of the players who have played. The confirming side can instead dispute the result, the reporting side then undoing their report or the host settling it by confirming the result or undoing the report, whichever side they're on.

starting the lobby notifies its players

Setup
Arrange
  1. Started lobby → { host }
    const { host } = await startedLobby(page, factories);
Hhost
Act
  1. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification( `${LOBBY_NAME} started and you're in a room`, ) is visible
    await expect(
    	notifications.notification(
    		`${LOBBY_NAME} started and you're in a room`,
    	),
    ).toBeVisible();
Source
test("starting the lobby notifies its players", async ({
	page,
	factories,
}) => {
	const { host } = await startedLobby(page, factories);

	await impersonate(page, host.id);
	const notifications = await openNotifications(page);
	await expect(
		notifications.notification(
			`${LOBBY_NAME} started and you're in a room`,
		),
	).toBeVisible();
})

the banner shows who voted for the map being played

Setup
Arrange
  1. Started lobby is pooling every map true
    await startedLobby(page, factories, { isPoolingEveryMap: true });
LOLogged out
Lobby page
Assert
  1. map voters badge reads String(ROOM_SIZE)
    await expect(lobbyPage.locators.mapVotersBadge).toHaveText(
    	String(ROOM_SIZE),
    );
Act
  1. Click map voters badge
    await lobbyPage.locators.mapVotersBadge.click();
Assert
  1. map voters header is visible
    await expect(lobbyPage.locators.mapVotersHeader).toBeVisible();
Source
test("the banner shows who voted for the map being played", async ({
	page,
	factories,
}) => {
	await startedLobby(page, factories, { isPoolingEveryMap: true });
	const lobbyPage = new LobbyPage(page);

	await expect(lobbyPage.locators.mapVotersBadge).toHaveText(
		String(ROOM_SIZE),
	);
	await lobbyPage.locators.mapVotersBadge.click();
	await expect(lobbyPage.locators.mapVotersHeader).toBeVisible();
})

a set reported by one side and confirmed by the other counts

alpha playerbravo playerlobbies.spec.ts:759
Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer, bravoPlayer }
    const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );

1The Rankings have no head-to-head view before a set is played

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
Assert
  1. leaderboard rows count is 8
    await expect(lobbyPage.locators.leaderboardRows).toHaveCount(ROOM_SIZE);
  2. head to head view chip count is 0
    await expect(lobbyPage.locators.headToHeadViewChip).toHaveCount(0);

2An Alpha player reports a sweep

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team sweep 2
    await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);

3A Bravo player confirms it

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Confirm set
    await lobbyPage.confirmSet();

4The set shows on the Rankings and Result tabs

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
Assert
  1. leaderboard rows count is 8
    await expect(lobbyPage.locators.leaderboardRows).toHaveCount(ROOM_SIZE);
Act
  1. Click head to head view chip
    await lobbyPage.locators.headToHeadViewChip.click();
Assert
  1. head to head rows count is 8
    await expect(lobbyPage.locators.headToHeadRows).toHaveCount(ROOM_SIZE);
Act
  1. Open tab “result”
    await lobbyPage.openTab("result");
Assert
  1. tab panel contains “2-0”
    await expect(lobbyPage.locators.tabPanel).toContainText("2-0");
Source
test("a set reported by one side and confirmed by the other counts", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const lobbyPage = new LobbyPage(page);

	await test.step("The Rankings have no head-to-head view before a set is played", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id, "leaderboard");
		await expect(lobbyPage.locators.leaderboardRows).toHaveCount(ROOM_SIZE);
		await expect(lobbyPage.locators.headToHeadViewChip).toHaveCount(0);
	});

	await test.step("An Alpha player reports a sweep", async () => {
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);
	});

	await test.step("A Bravo player confirms it", async () => {
		await impersonate(page, bravoPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.confirmSet();
	});

	await test.step("The set shows on the Rankings and Result tabs", async () => {
		await lobbyPage.goto(lobby.id, "leaderboard");
		await expect(lobbyPage.locators.leaderboardRows).toHaveCount(ROOM_SIZE);

		await lobbyPage.locators.headToHeadViewChip.click();
		await expect(lobbyPage.locators.headToHeadRows).toHaveCount(ROOM_SIZE);

		await lobbyPage.openTab("result");
		await expect(lobbyPage.locators.tabPanel).toContainText("2-0");
	});
})

a map report is undone while the set is being played

Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer }
    const { lobby, alphaPlayer } = await startedLobby(page, factories);
APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team win
    await lobbyPage.reportOwnTeamWin();
Assert
  1. tab “result” is visible
    await expect(lobbyPage.tab("result")).toBeVisible();
Act
  1. Undo report
    await lobbyPage.undoReport();
Assert
  1. tab “result” count is 0
    await expect(lobbyPage.tab("result")).toHaveCount(0);
Source
test("a map report is undone while the set is being played", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer } = await startedLobby(page, factories);

	await impersonate(page, alphaPlayer.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id, "action");
	await lobbyPage.reportOwnTeamWin();

	await expect(lobbyPage.tab("result")).toBeVisible();

	await lobbyPage.undoReport();

	await expect(lobbyPage.tab("result")).toHaveCount(0);
})

a reported weapon shows on the Result and Rankings tabs

alpha playerbravo playerlobbies.spec.ts:817
Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer, bravoPlayer }
    const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );

1An Alpha player reports their weapon and a sweep

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report weapon “Splattershot”
    await lobbyPage.reportWeapon(WEAPON_NAME);
  3. Report own team sweep 2
    await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);

2A Bravo player confirms the set

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Confirm set
    await lobbyPage.confirmSet();

3The weapon shows on the Result and Rankings tabs

BPbravo player
Lobby page
Act
  1. Open tab “result”
    await lobbyPage.openTab("result");
Assert
  1. weapon image “Splattershot” is visible
    await expect(lobbyPage.weaponImage(WEAPON_NAME)).toBeVisible();
Act
  1. Open tab “leaderboard”
    await lobbyPage.openTab("leaderboard");
Assert
  1. rankings row alphaPlayer.name › img “Splattershot” is visible
    await expect(
    	lobbyPage
    		.rankingsRow(alphaPlayer.name)
    		.getByRole("img", { name: WEAPON_NAME }),
    ).toBeVisible();
Source
test("a reported weapon shows on the Result and Rankings tabs", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const lobbyPage = new LobbyPage(page);

	await test.step("An Alpha player reports their weapon and a sweep", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportWeapon(WEAPON_NAME);
		await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);
	});

	await test.step("A Bravo player confirms the set", async () => {
		await impersonate(page, bravoPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.confirmSet();
	});

	await test.step("The weapon shows on the Result and Rankings tabs", async () => {
		await lobbyPage.openTab("result");
		await expect(lobbyPage.weaponImage(WEAPON_NAME)).toBeVisible();

		await lobbyPage.openTab("leaderboard");
		await expect(
			lobbyPage
				.rankingsRow(alphaPlayer.name)
				.getByRole("img", { name: WEAPON_NAME }),
		).toBeVisible();
	});
})

a disputed result goes back to reporting when the reporting side undoes it

alpha playerbravo playerlobbies.spec.ts:853
Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer, bravoPlayer }
    const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );

1An Alpha player reports a sweep

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team sweep 2
    await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);

2A Bravo player disputes it

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Dispute result
    await lobbyPage.disputeResult();
Assert
  1. disputed text is visible
    await expect(lobbyPage.locators.disputedText).toBeVisible();

3The Alpha player undoes the deciding report

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Undo report
    await lobbyPage.undoReport();
Assert
  1. report score button is visible
    await expect(lobbyPage.locators.reportScoreButton).toBeVisible();
Source
test("a disputed result goes back to reporting when the reporting side undoes it", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const lobbyPage = new LobbyPage(page);

	await test.step("An Alpha player reports a sweep", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);
	});

	await test.step("A Bravo player disputes it", async () => {
		await impersonate(page, bravoPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.disputeResult();

		await expect(lobbyPage.locators.disputedText).toBeVisible();
	});

	await test.step("The Alpha player undoes the deciding report", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.undoReport();

		await expect(lobbyPage.locators.reportScoreButton).toBeVisible();
	});
})

the host undoes a disputed result the other team reported

Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayers, bravoPlayers }
    const { lobby, host, alphaPlayers, bravoPlayers } = await startedLobby(
    	page,
    	factories,
    );
  2. isHostAlpha = alphaPlayers.some((player) => player.id === host.id)
    const isHostAlpha = alphaPlayers.some((player) => player.id === host.id);
  3. opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0]
    const opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0];

1The other team reports a sweep

Oopponent
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team sweep 2
    await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);

2The host disputes it and undoes the deciding report

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Dispute result
    await lobbyPage.disputeResult();
  3. Undo report
    await lobbyPage.undoReport();
Assert
  1. report score button is visible
    await expect(lobbyPage.locators.reportScoreButton).toBeVisible();
Source
test("the host undoes a disputed result the other team reported", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayers, bravoPlayers } = await startedLobby(
		page,
		factories,
	);
	const isHostAlpha = alphaPlayers.some((player) => player.id === host.id);
	const opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0];
	const lobbyPage = new LobbyPage(page);

	await test.step("The other team reports a sweep", async () => {
		await impersonate(page, opponent.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);
	});

	await test.step("The host disputes it and undoes the deciding report", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.disputeResult();
		await lobbyPage.undoReport();

		await expect(lobbyPage.locators.reportScoreButton).toBeVisible();
	});
})

the host settles a disputed result by confirming it

Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayers, bravoPlayers }
    const { lobby, host, alphaPlayers, bravoPlayers } = await startedLobby(
    	page,
    	factories,
    );
  2. isHostAlpha = alphaPlayers.some((player) => player.id === host.id)
    const isHostAlpha = alphaPlayers.some((player) => player.id === host.id);
  3. opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0]
    const opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0];

1The host reports a sweep for their team

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team sweep 2
    await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);

2The other team disputes it

Oopponent
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Dispute result
    await lobbyPage.disputeResult();

3The host confirms the result, the set counting

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Confirm set as host
    await lobbyPage.confirmSetAsHost();
  3. Open tab “action”
    await lobbyPage.openTab("action");
Assert
  1. report score button is visible
    await expect(lobbyPage.locators.reportScoreButton).toBeVisible();
Act
  1. Open tab “result”
    await lobbyPage.openTab("result");
Assert
  1. tab panel contains “2-0”
    await expect(lobbyPage.locators.tabPanel).toContainText("2-0");
Source
test("the host settles a disputed result by confirming it", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayers, bravoPlayers } = await startedLobby(
		page,
		factories,
	);
	const isHostAlpha = alphaPlayers.some((player) => player.id === host.id);
	const opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0];
	const lobbyPage = new LobbyPage(page);

	await test.step("The host reports a sweep for their team", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);
	});

	await test.step("The other team disputes it", async () => {
		await impersonate(page, opponent.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.disputeResult();
	});

	await test.step("The host confirms the result, the set counting", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.confirmSetAsHost();
		await lobbyPage.openTab("action");

		await expect(lobbyPage.locators.reportScoreButton).toBeVisible();
		await lobbyPage.openTab("result");
		await expect(lobbyPage.locators.tabPanel).toContainText("2-0");
	});
})

Between sets

After a confirmed set the next one starts right away with the teams reshuffled, nobody keeping all of their teammates. In a room bigger than 8 the extra players sit a set out, rotating in for the next one. When the room is short of 8 the waitlist is asked, with a notification, who is ready to take the open spot, and confirming fills it. The first on the waitlist has priority on the spot for 3 minutes, others confirming before them waiting, without the room's pool and pass. Once the priority runs out the spot goes to whoever confirms first. Signing up while a spot is open counts as confirming.

the next set opens on the Rosters tab with the teams reshuffled

Setup
Arrange
  1. Started lobby → { lobby, players, alphaPlayers, bravoPlayers }
    const { lobby, players, alphaPlayers, bravoPlayers } = await startedLobby(
    	page,
    	factories,
    );
LOLogged out
Act
  1. Play set lobby id lobby.id alpha player alphaPlayers[0] bravo player bravoPlayers[0]
    await playSet(page, {
    	lobbyId: lobby.id,
    	alphaPlayer: alphaPlayers[0],
    	bravoPlayer: bravoPlayers[0],
    });
Lobby page
Assert
  1. tab “rosters” has “aria-selected” = “true”
    await expect(lobbyPage.tab("rosters")).toHaveAttribute(
    	"aria-selected",
    	"true",
    );
Act
  1. Roster ids lobbyPage, “Alpha”, players → nextAlphaIds
    const nextAlphaIds = await rosterIds(lobbyPage, "Alpha", players);
Assert
  1. nextAlphaIds does not equal idsOf(alphaPlayers)
    expect(nextAlphaIds).not.toEqual(idsOf(alphaPlayers));
  2. nextAlphaIds does not equal idsOf(bravoPlayers)
    expect(nextAlphaIds).not.toEqual(idsOf(bravoPlayers));
Source
test("the next set opens on the Rosters tab with the teams reshuffled", async ({
	page,
	factories,
}) => {
	const { lobby, players, alphaPlayers, bravoPlayers } = await startedLobby(
		page,
		factories,
	);
	const lobbyPage = new LobbyPage(page);

	await playSet(page, {
		lobbyId: lobby.id,
		alphaPlayer: alphaPlayers[0],
		bravoPlayer: bravoPlayers[0],
	});

	await expect(lobbyPage.tab("rosters")).toHaveAttribute(
		"aria-selected",
		"true",
	);
	const nextAlphaIds = await rosterIds(lobbyPage, "Alpha", players);

	expect(nextAlphaIds).not.toEqual(idsOf(alphaPlayers));
	expect(nextAlphaIds).not.toEqual(idsOf(bravoPlayers));
})

in a room of 9 one sits a set out and plays the next

Setup
Arrange
  1. Started lobby room size 9 → { lobby, alphaPlayer, bravoPlayer, sittingOut }
    const { lobby, alphaPlayer, bravoPlayer, sittingOut } =
    	await startedLobby(page, factories, { roomSize: 9 });
  2. spectator = sittingOut[0]
    const spectator = sittingOut[0];

1The ninth player spectates the first set

Sspectator
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “You're spectating, you'll rotate in”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're spectating, you'll rotate in",
    );
Sspectator
Act
  1. Play set lobby id lobby.id alphaPlayer bravoPlayer
    await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

2They play the next set

Sspectator
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();
Source
test("in a room of 9 one sits a set out and plays the next", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer, bravoPlayer, sittingOut } =
		await startedLobby(page, factories, { roomSize: 9 });
	const spectator = sittingOut[0];
	const lobbyPage = new LobbyPage(page);

	await test.step("The ninth player spectates the first set", async () => {
		await impersonate(page, spectator.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're spectating, you'll rotate in",
		);
	});

	await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

	await test.step("They play the next set", async () => {
		await impersonate(page, spectator.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.tab("action")).toBeVisible();
	});
})

the waitlist is asked to fill a spot that opens up

late sign upalpha playerlobbies.spec.ts:1015
Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer }
    const { lobby, alphaPlayer } = await startedLobby(page, factories);
  2. Create user → lateSignUp
    const lateSignUp = await factories.UserFactory.create();

1A player signing up to the full room is waitlisted

LSlate sign up
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. viewer status contains “You're #1 on the waitlist”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're #1 on the waitlist",
    );

2An Alpha player leaves, opening a spot

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Leave mid set
    await lobbyPage.leaveMidSet();

3The waitlisted player is notified and confirms they're ready

LSlate sign up
Act
  1. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification(`A spot is open in ${LOBBY_NAME}`) is visible
    await expect(
    	notifications.notification(`A spot is open in ${LOBBY_NAME}`),
    ).toBeVisible();
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. ready check is visible
    await expect(lobbyPage.locators.readyCheck).toBeVisible();
Act
  1. Confirm ready
    await lobbyPage.confirmReady();
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();
Source
test("the waitlist is asked to fill a spot that opens up", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer } = await startedLobby(page, factories);
	const lateSignUp = await factories.UserFactory.create();
	const lobbyPage = new LobbyPage(page);

	await test.step("A player signing up to the full room is waitlisted", async () => {
		await impersonate(page, lateSignUp.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.signUp();

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're #1 on the waitlist",
		);
	});

	await test.step("An Alpha player leaves, opening a spot", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.leaveMidSet();
	});

	await test.step("The waitlisted player is notified and confirms they're ready", async () => {
		await impersonate(page, lateSignUp.id);
		const notifications = await openNotifications(page);
		await expect(
			notifications.notification(`A spot is open in ${LOBBY_NAME}`),
		).toBeVisible();

		await lobbyPage.goto(lobby.id);
		await expect(lobbyPage.locators.readyCheck).toBeVisible();
		await lobbyPage.confirmReady();

		await expect(lobbyPage.tab("action")).toBeVisible();
	});
})

the first on the waitlist takes the spot over a faster confirmer

Setup
Arrange
  1. Lobby with open spot → { lobby, waitlist }
    const { lobby, waitlist } = await lobbyWithOpenSpot(page, factories);
  2. [first, , third] = waitlist
    const [first, , third] = waitlist;

1The third on the waitlist confirms first and waits

Tthird
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. waiting banner contains “The waitlist has been asked to fill the open spots”
    await expect(lobbyPage.locators.waitingBanner).toContainText(
    	"The waitlist has been asked to fill the open spots",
    );
Act
  1. Confirm ready
    await lobbyPage.confirmReady();
Assert
  1. ready check contains “Confirmed, waiting for the others”
    await expect(lobbyPage.locators.readyCheck).toContainText(
    	"Confirmed, waiting for the others",
    );
  2. tab “action” is not visible
    await isNotVisible(lobbyPage.tab("action"));

2The first on the waitlist confirms and gets the spot

Ffirst
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Confirm ready
    await lobbyPage.confirmReady();
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();

3The third stays out of the room

Tthird
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. tab “action” is not visible
    await isNotVisible(lobbyPage.tab("action"));
Source
test("the first on the waitlist takes the spot over a faster confirmer", async ({
	page,
	factories,
}) => {
	const { lobby, waitlist } = await lobbyWithOpenSpot(page, factories);
	const [first, , third] = waitlist;
	const lobbyPage = new LobbyPage(page);

	await test.step("The third on the waitlist confirms first and waits", async () => {
		await impersonate(page, third.id);
		await lobbyPage.goto(lobby.id);
		await expect(lobbyPage.locators.waitingBanner).toContainText(
			"The waitlist has been asked to fill the open spots",
		);
		await lobbyPage.confirmReady();

		await expect(lobbyPage.locators.readyCheck).toContainText(
			"Confirmed, waiting for the others",
		);
		await isNotVisible(lobbyPage.tab("action"));
	});

	await test.step("The first on the waitlist confirms and gets the spot", async () => {
		await impersonate(page, first.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.confirmReady();

		await expect(lobbyPage.tab("action")).toBeVisible();
	});

	await test.step("The third stays out of the room", async () => {
		await impersonate(page, third.id);
		await lobbyPage.goto(lobby.id);

		await isNotVisible(lobbyPage.tab("action"));
	});
})

a player checked in but left waiting for a spot doesn't see the room's pool and pass

Setup
Arrange
  1. Lobby with open spot → { lobby, waitlist }
    const { lobby, waitlist } = await lobbyWithOpenSpot(page, factories);
  2. third = waitlist[2]
    const third = waitlist[2];
Tthird
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Confirm ready
    await lobbyPage.confirmReady();
Assert
  1. ready check contains “Confirmed, waiting for the others”
    await expect(lobbyPage.locators.readyCheck).toContainText(
    	"Confirmed, waiting for the others",
    );
  2. room pool is not visible
    await isNotVisible(lobbyPage.locators.roomPool);
  3. room pass is not visible
    await isNotVisible(lobbyPage.locators.roomPass);
Source
test("a player checked in but left waiting for a spot doesn't see the room's pool and pass", async ({
	page,
	factories,
}) => {
	const { lobby, waitlist } = await lobbyWithOpenSpot(page, factories);
	const third = waitlist[2];
	const lobbyPage = new LobbyPage(page);

	await impersonate(page, third.id);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.confirmReady();

	await expect(lobbyPage.locators.readyCheck).toContainText(
		"Confirmed, waiting for the others",
	);
	await isNotVisible(lobbyPage.locators.roomPool);
	await isNotVisible(lobbyPage.locators.roomPass);
})

signing up while the waitlist has priority counts as ready

Setup
Arrange
  1. Lobby with open spot → { lobby }
    const { lobby } = await lobbyWithOpenSpot(page, factories);
  2. Create user → lateSignUp
    const lateSignUp = await factories.UserFactory.create();
LSlate sign up
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. ready check contains “Confirmed, waiting for the others”
    await expect(lobbyPage.locators.readyCheck).toContainText(
    	"Confirmed, waiting for the others",
    );
  2. confirm ready button is not visible
    await isNotVisible(lobbyPage.locators.confirmReadyButton);
Source
test("signing up while the waitlist has priority counts as ready", async ({
	page,
	factories,
}) => {
	const { lobby } = await lobbyWithOpenSpot(page, factories);
	const lateSignUp = await factories.UserFactory.create();
	const lobbyPage = new LobbyPage(page);

	await impersonate(page, lateSignUp.id);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.signUp();

	await expect(lobbyPage.locators.readyCheck).toContainText(
		"Confirmed, waiting for the others",
	);
	await isNotVisible(lobbyPage.locators.confirmReadyButton);
})

signing up once the priority has run out takes the spot right away

Setup
Arrange
  1. Lobby with open spot → { lobby }
    const { lobby } = await lobbyWithOpenSpot(page, factories);
  2. Expire ready checks lobby lobby.id
    await factories.LobbyFactory.expireReadyChecks(lobby.id);
  3. Create user → lateSignUp
    const lateSignUp = await factories.UserFactory.create();
LSlate sign up
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Sign up
    await lobbyPage.signUp();
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();
Source
test("signing up once the priority has run out takes the spot right away", async ({
	page,
	factories,
}) => {
	const { lobby } = await lobbyWithOpenSpot(page, factories);
	await factories.LobbyFactory.expireReadyChecks(lobby.id);
	const lateSignUp = await factories.UserFactory.create();
	const lobbyPage = new LobbyPage(page);

	await impersonate(page, lateSignUp.id);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.signUp();

	await expect(lobbyPage.tab("action")).toBeVisible();
})

once the first's priority runs out the spot goes to whoever confirms first

Setup
Arrange
  1. Lobby with open spot → { lobby, waitlist }
    const { lobby, waitlist } = await lobbyWithOpenSpot(page, factories);
  2. [, second, third] = waitlist
    const [, second, third] = waitlist;
  3. Expire ready checks lobby lobby.id
    await factories.LobbyFactory.expireReadyChecks(lobby.id);

1The third on the waitlist confirms first and gets the spot

Tthird
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Confirm ready
    await lobbyPage.confirmReady();
Assert
  1. tab “action” is visible
    await expect(lobbyPage.tab("action")).toBeVisible();

2The second is too late, the spot taken

Ssecond
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. ready check is not visible
    await isNotVisible(lobbyPage.locators.readyCheck);
  2. viewer status contains “You're #2 on the waitlist”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're #2 on the waitlist",
    );
Source
test("once the first's priority runs out the spot goes to whoever confirms first", async ({
	page,
	factories,
}) => {
	const { lobby, waitlist } = await lobbyWithOpenSpot(page, factories);
	const [, second, third] = waitlist;
	await factories.LobbyFactory.expireReadyChecks(lobby.id);
	const lobbyPage = new LobbyPage(page);

	await test.step("The third on the waitlist confirms first and gets the spot", async () => {
		await impersonate(page, third.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.confirmReady();

		await expect(lobbyPage.tab("action")).toBeVisible();
	});

	await test.step("The second is too late, the spot taken", async () => {
		await impersonate(page, second.id);
		await lobbyPage.goto(lobby.id);

		await isNotVisible(lobbyPage.locators.readyCheck);
		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're #2 on the waitlist",
		);
	});
})

Leaving

Leaving mid-set forfeits it for the leaver's team once a map has been reported, whatever the score: the set shows as won by forfeit and counts as a set win and loss on the Rankings, the room left short of players. Leaving before any map is reported calls the set off, nobody losing it. A player can instead ask to leave once the set is confirmed, leaving the lobby then. Asking to is told in the lobby's chat and marked on the Rosters tab, the mark explaining itself when clicked. Changing their mind is told in the chat too, after which they can't ask to leave again for a while.

leaving mid-set forfeits it and the room waits for players

alpha playerbravo playerhostlobbies.spec.ts:1184
Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayers, bravoPlayer }
    const { lobby, host, alphaPlayers, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );
  2. not the host, who ends the lobby in the end

    alphaPlayer = alphaPlayers.find((player) => player.id !== host.id)!
    const alphaPlayer = alphaPlayers.find((player) => player.id !== host.id)!;

1Alpha wins the first map, then an Alpha player leaves

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team win
    await lobbyPage.reportOwnTeamWin();
  3. Leave mid set
    await lobbyPage.leaveMidSet();

2The others wait for an eighth player, no one on the waitlist to ask

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. waiting banner contains “Waiting for players (7/8)”
    await expect(lobbyPage.locators.waitingBanner).toContainText(
    	"Waiting for players (7/8)",
    );
  2. waiting banner does not contain “The waitlist has been asked to fill the open spots”
    await expect(lobbyPage.locators.waitingBanner).not.toContainText(
    	"The waitlist has been asked to fill the open spots",
    );
  3. no set being played, so no rosters to show

    tab “rosters” is not visible
    await isNotVisible(lobbyPage.tab("rosters"));

3Bravo is awarded the set on the Result and Rankings tabs

BPbravo player
Lobby page
Act
  1. Open tab “result”
    await lobbyPage.openTab("result");
Assert
  1. forfeit note reads “Bravo won by forfeit”
    await expect(lobbyPage.locators.forfeitNote).toHaveText(
    	"Bravo won by forfeit",
    );
Act
  1. Open tab “leaderboard”
    await lobbyPage.openTab("leaderboard");
Assert
  1. rankings row bravoPlayer.name › cell “1-0” is visible
    await expect(
    	lobbyPage
    		.rankingsRow(bravoPlayer.name)
    		.getByRole("cell", { name: "1-0", exact: true }),
    ).toBeVisible();
  2. rankings row alphaPlayer.name › cell “0-1” is visible
    await expect(
    	lobbyPage
    		.rankingsRow(alphaPlayer.name)
    		.getByRole("cell", { name: "0-1", exact: true }),
    ).toBeVisible();

4The Rankings tell who has left the lobby

BPbravo player
Lobby page
Assert
  1. left lobby markers count is 1
    await expect(lobbyPage.locators.leftLobbyMarkers).toHaveCount(1);
Act
  1. Click left lobby marker alphaPlayer.name
    await lobbyPage.leftLobbyMarker(alphaPlayer.name).click();
Assert
  1. left lobby popover reads “Left the lobby”
    await expect(lobbyPage.locators.leftLobbyPopover).toHaveText(
    	"Left the lobby",
    );

5Once the lobby has ended no one is marked as left

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. End lobby
    await lobbyPage.endLobby();
Assert
  1. ended status is visible
    await expect(lobbyPage.locators.endedStatus).toBeVisible();
Act
  1. Open tab “leaderboard”
    await lobbyPage.openTab("leaderboard");
Assert
  1. rankings row alphaPlayer.name is visible
    await expect(lobbyPage.rankingsRow(alphaPlayer.name)).toBeVisible();
  2. left lobby markers count is 0
    await expect(lobbyPage.locators.leftLobbyMarkers).toHaveCount(0);
Source
test("leaving mid-set forfeits it and the room waits for players", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayers, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	// not the host, who ends the lobby in the end
	const alphaPlayer = alphaPlayers.find((player) => player.id !== host.id)!;
	const lobbyPage = new LobbyPage(page);

	await test.step("Alpha wins the first map, then an Alpha player leaves", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportOwnTeamWin();
		await lobbyPage.leaveMidSet();
	});

	await test.step("The others wait for an eighth player, no one on the waitlist to ask", async () => {
		await impersonate(page, bravoPlayer.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.waitingBanner).toContainText(
			"Waiting for players (7/8)",
		);
		await expect(lobbyPage.locators.waitingBanner).not.toContainText(
			"The waitlist has been asked to fill the open spots",
		);
		// no set being played, so no rosters to show
		await isNotVisible(lobbyPage.tab("rosters"));
	});

	await test.step("Bravo is awarded the set on the Result and Rankings tabs", async () => {
		await lobbyPage.openTab("result");
		await expect(lobbyPage.locators.forfeitNote).toHaveText(
			"Bravo won by forfeit",
		);

		await lobbyPage.openTab("leaderboard");
		await expect(
			lobbyPage
				.rankingsRow(bravoPlayer.name)
				.getByRole("cell", { name: "1-0", exact: true }),
		).toBeVisible();
		await expect(
			lobbyPage
				.rankingsRow(alphaPlayer.name)
				.getByRole("cell", { name: "0-1", exact: true }),
		).toBeVisible();
	});

	await test.step("The Rankings tell who has left the lobby", async () => {
		await expect(lobbyPage.locators.leftLobbyMarkers).toHaveCount(1);
		await lobbyPage.leftLobbyMarker(alphaPlayer.name).click();
		await expect(lobbyPage.locators.leftLobbyPopover).toHaveText(
			"Left the lobby",
		);
	});

	await test.step("Once the lobby has ended no one is marked as left", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.endLobby();
		await expect(lobbyPage.locators.endedStatus).toBeVisible();

		await lobbyPage.openTab("leaderboard");
		await expect(lobbyPage.rankingsRow(alphaPlayer.name)).toBeVisible();
		await expect(lobbyPage.locators.leftLobbyMarkers).toHaveCount(0);
	});
})

a player asks to leave once the set is confirmed

alpha playerbravo playerlobbies.spec.ts:1256
Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer, bravoPlayer }
    const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );

1An Alpha player asks to leave after the set and plays it out

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Drop after set
    await lobbyPage.dropAfterSet();
Assert
  1. drop after set button reads “Stay after this set”
    await expect(lobbyPage.locators.dropAfterSetButton).toHaveText(
    	"Stay after this set",
    );
Act
  1. Report own team sweep 2
    await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);

2A Bravo player sees they are leaving and confirms the set

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Open tab “rosters”
    await lobbyPage.openTab("rosters");
Assert
  1. leaving after set markers count is 1
    await expect(lobbyPage.locators.leavingAfterSetMarkers).toHaveCount(1);
Act
  1. Click leaving after set marker alphaPlayer.name
    await lobbyPage.leavingAfterSetMarker(alphaPlayer.name).click();
Assert
  1. leaving after set popover contains `${alphaPlayer.name} leaves the lobby once this set is confirmed`
    await expect(lobbyPage.locators.leavingAfterSetPopover).toContainText(
    	`${alphaPlayer.name} leaves the lobby once this set is confirmed`,
    );
Act
  1. Open tab “action”
    await lobbyPage.openTab("action");
Chat sidebar
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
Assert
  1. message `${alphaPlayer.name} will leave after this set` is visible
    await expect(
    	chat.chat().message(`${alphaPlayer.name} will leave after this set`),
    ).toBeVisible();
Lobby page
Act
  1. Confirm set
    await lobbyPage.confirmSet();
Assert
  1. waiting banner contains “Waiting for players (7/8)”
    await expect(lobbyPage.locators.waitingBanner).toContainText(
    	"Waiting for players (7/8)",
    );

3The Alpha player is out of the lobby

APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. sign up button is visible
    await expect(lobbyPage.locators.signUpButton).toBeVisible();
Source
test("a player asks to leave once the set is confirmed", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await test.step("An Alpha player asks to leave after the set and plays it out", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.dropAfterSet();

		await expect(lobbyPage.locators.dropAfterSetButton).toHaveText(
			"Stay after this set",
		);

		await lobbyPage.reportOwnTeamSweep(MAPS_TO_WIN);
	});

	await test.step("A Bravo player sees they are leaving and confirms the set", async () => {
		await impersonate(page, bravoPlayer.id);
		await lobbyPage.goto(lobby.id, "action");

		await lobbyPage.openTab("rosters");
		await expect(lobbyPage.locators.leavingAfterSetMarkers).toHaveCount(1);
		await lobbyPage.leavingAfterSetMarker(alphaPlayer.name).click();
		await expect(lobbyPage.locators.leavingAfterSetPopover).toContainText(
			`${alphaPlayer.name} leaves the lobby once this set is confirmed`,
		);
		await lobbyPage.openTab("action");

		await chat.selectRoomTab("Lobby");
		await expect(
			chat.chat().message(`${alphaPlayer.name} will leave after this set`),
		).toBeVisible();

		await lobbyPage.confirmSet();

		await expect(lobbyPage.locators.waitingBanner).toContainText(
			"Waiting for players (7/8)",
		);
	});

	await test.step("The Alpha player is out of the lobby", async () => {
		await impersonate(page, alphaPlayer.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.signUpButton).toBeVisible();
	});
})

a player changing their mind about leaving tells the chat and can't ask again right away

Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer }
    const { lobby, alphaPlayer } = await startedLobby(page, factories);
APalpha player
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Drop after set
    await lobbyPage.dropAfterSet();
Assert
  1. drop after set button reads “Stay after this set”
    await expect(lobbyPage.locators.dropAfterSetButton).toHaveText(
    	"Stay after this set",
    );
Act
  1. Drop after set
    await lobbyPage.dropAfterSet();
Assert
  1. drop after set button is disabled
    await expect(lobbyPage.locators.dropAfterSetButton).toBeDisabled();
  2. drop after set button contains /Leave after this set \(\d+s\)/
    await expect(lobbyPage.locators.dropAfterSetButton).toContainText(
    	/Leave after this set \(\d+s\)/,
    );
Chat sidebar
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
Assert
  1. message `${alphaPlayer.name} changed their mind and will stay after this set` is visible
    await expect(
    	chat
    		.chat()
    		.message(
    			`${alphaPlayer.name} changed their mind and will stay after this set`,
    		),
    ).toBeVisible();
Source
test("a player changing their mind about leaving tells the chat and can't ask again right away", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer } = await startedLobby(page, factories);
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await impersonate(page, alphaPlayer.id);
	await lobbyPage.goto(lobby.id, "action");
	await lobbyPage.dropAfterSet();
	await expect(lobbyPage.locators.dropAfterSetButton).toHaveText(
		"Stay after this set",
	);
	await lobbyPage.dropAfterSet();

	await expect(lobbyPage.locators.dropAfterSetButton).toBeDisabled();
	await expect(lobbyPage.locators.dropAfterSetButton).toContainText(
		/Leave after this set \(\d+s\)/,
	);

	await chat.selectRoomTab("Lobby");
	await expect(
		chat
			.chat()
			.message(
				`${alphaPlayer.name} changed their mind and will stay after this set`,
			),
	).toBeVisible();
})

Hosting

The host kicks participants, who are told so and can't sign up for the lobby again, a player kicked mid-set forfeiting it for their team. The host also sits players of the room out of the sets until resumed, changes the best of from the next set on and ends the lobby. The host can hand hosting over to another participant, which the lobby's chat tells everyone. When the host leaves, the participant who signed up the earliest becomes the host and is notified of it.

a kicked player is told so and can't sign up again

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → kicked
    const kicked = await factories.UserFactory.create();
  3. Create lobby host user id host.id signed up user ids kicked.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{ hostUserId: host.id },
    	{ signedUpUserIds: [kicked.id] },
    );
Kkicked
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);

1The host kicks them

Kkicked
Act
  1. Open second user browser, workerBaseURL, host.id → hostSession
    const hostSession = await openSecondUser(
    	browser,
    	workerBaseURL,
    	host.id,
    );
  2. Try
    try {
    	const hostLobbyPage = new LobbyPage(hostSession.page);
    	await hostLobbyPage.goto(lobby.id);
    	await hostLobbyPage.kick(kicked.id);
    
    	await expect(hostLobbyPage.locators.participants).toHaveCount(1);
    } finally {
    	await hostSession.close();
    }
    1. Open the lobby page lobby.id
      await hostLobbyPage.goto(lobby.id);
    2. Kick kicked.id
      await hostLobbyPage.kick(kicked.id);
    3. participants count is 1
      await expect(hostLobbyPage.locators.participants).toHaveCount(1);

2Their open page tells them they were kicked

Kkicked
Lobby page
Assert
  1. viewer status contains “The host kicked you from the lobby”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"The host kicked you from the lobby",
    );
  2. sign up button is not visible
    await isNotVisible(lobbyPage.locators.signUpButton);

3Coming back they still can't sign up

Kkicked
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “The host kicked you from the lobby”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"The host kicked you from the lobby",
    );
  2. sign up button is not visible
    await isNotVisible(lobbyPage.locators.signUpButton);
Source
test("a kicked player is told so and can't sign up again", async ({
	page,
	browser,
	workerBaseURL,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const kicked = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create(
		{ hostUserId: host.id },
		{ signedUpUserIds: [kicked.id] },
	);

	await impersonate(page, kicked.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);

	await test.step("The host kicks them", async () => {
		const hostSession = await openSecondUser(
			browser,
			workerBaseURL,
			host.id,
		);
		try {
			const hostLobbyPage = new LobbyPage(hostSession.page);
			await hostLobbyPage.goto(lobby.id);
			await hostLobbyPage.kick(kicked.id);

			await expect(hostLobbyPage.locators.participants).toHaveCount(1);
		} finally {
			await hostSession.close();
		}
	});

	await test.step("Their open page tells them they were kicked", async () => {
		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"The host kicked you from the lobby",
		);
		await isNotVisible(lobbyPage.locators.signUpButton);
	});

	await test.step("Coming back they still can't sign up", async () => {
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"The host kicked you from the lobby",
		);
		await isNotVisible(lobbyPage.locators.signUpButton);
	});
})

kicking a player mid-set forfeits it for their team

Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayers, bravoPlayers }
    const { lobby, host, alphaPlayers, bravoPlayers } = await startedLobby(
    	page,
    	factories,
    );
  2. isHostAlpha = alphaPlayers.some((player) => player.id === host.id)
    const isHostAlpha = alphaPlayers.some((player) => player.id === host.id);
  3. opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0]
    const opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0];
Hhost
Lobby page
Act
  1. before a map is reported the set would be called off instead

    Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team win
    await lobbyPage.reportOwnTeamWin();
  3. the room's players are on the Rankings tab, with the host's player menu

    Open tab “leaderboard”
    await lobbyPage.openTab("leaderboard");
  4. Kick opponent.id
    await lobbyPage.kick(opponent.id);
  5. Open tab “result”
    await lobbyPage.openTab("result");
Assert
  1. forfeit note reads `${isHostAlpha ? "Alpha" : "Bravo"} won by forfeit`
    await expect(lobbyPage.locators.forfeitNote).toHaveText(
    	`${isHostAlpha ? "Alpha" : "Bravo"} won by forfeit`,
    );
Source
test("kicking a player mid-set forfeits it for their team", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayers, bravoPlayers } = await startedLobby(
		page,
		factories,
	);
	const isHostAlpha = alphaPlayers.some((player) => player.id === host.id);
	const opponent = (isHostAlpha ? bravoPlayers : alphaPlayers)[0];

	await impersonate(page, host.id);
	const lobbyPage = new LobbyPage(page);
	// before a map is reported the set would be called off instead
	await lobbyPage.goto(lobby.id, "action");
	await lobbyPage.reportOwnTeamWin();
	// the room's players are on the Rankings tab, with the host's player menu
	await lobbyPage.openTab("leaderboard");
	await lobbyPage.kick(opponent.id);

	await lobbyPage.openTab("result");
	await expect(lobbyPage.locators.forfeitNote).toHaveText(
		`${isHostAlpha ? "Alpha" : "Bravo"} won by forfeit`,
	);
})

a player sat out by the host sits out the sets until resumed

Setup
Arrange
  1. Started lobby room size 9 → { lobby, host, alphaPlayer, bravoPlayer, alphaPlayers }
    const { lobby, host, alphaPlayer, bravoPlayer, alphaPlayers } =
    	await startedLobby(page, factories, { roomSize: 9 });
  2. satOut = alphaPlayers.find( (player) => player.id !== host.id && player.id !== alphaPl…
    const satOut = alphaPlayers.find(
    	(player) => player.id !== host.id && player.id !== alphaPlayer.id,
    )!;

1The host sits a playing player out

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
  2. Sit out satOut.id
    await lobbyPage.sitOut(satOut.id);
Hhost
Act
  1. Play set lobby id lobby.id alphaPlayer bravoPlayer
    await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

2They sit the next set out

SOsat out
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “The host has you sitting out until they resume you”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"The host has you sitting out until they resume you",
    );

3The host resumes them

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
  2. Resume satOut.id
    await lobbyPage.resume(satOut.id);
SOsat out
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “You're spectating, you'll rotate in”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're spectating, you'll rotate in",
    );
Source
test("a player sat out by the host sits out the sets until resumed", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayer, bravoPlayer, alphaPlayers } =
		await startedLobby(page, factories, { roomSize: 9 });
	const satOut = alphaPlayers.find(
		(player) => player.id !== host.id && player.id !== alphaPlayer.id,
	)!;
	const lobbyPage = new LobbyPage(page);

	await test.step("The host sits a playing player out", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "leaderboard");
		await lobbyPage.sitOut(satOut.id);
	});

	await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

	await test.step("They sit the next set out", async () => {
		await impersonate(page, satOut.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"The host has you sitting out until they resume you",
		);
	});

	await test.step("The host resumes them", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "leaderboard");
		await lobbyPage.resume(satOut.id);

		await impersonate(page, satOut.id);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're spectating, you'll rotate in",
		);
	});
})

a changed best of applies from the next set

Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayer, bravoPlayer }
    const { lobby, host, alphaPlayer, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );

1The host changes the best of mid-set

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Change best of 5
    await lobbyPage.changeBestOf(5);
  3. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. best of 3 is visible
    await expect(lobbyPage.bestOf(BEST_OF)).toBeVisible();
Hhost
Act
  1. Play set lobby id lobby.id alphaPlayer bravoPlayer
    await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

2The next set is a best of 5

Hhost
Lobby page
Assert
  1. best of 5 is visible
    await expect(lobbyPage.bestOf(5)).toBeVisible();
Source
test("a changed best of applies from the next set", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayer, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const lobbyPage = new LobbyPage(page);

	await test.step("The host changes the best of mid-set", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.changeBestOf(5);
		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.bestOf(BEST_OF)).toBeVisible();
	});

	await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

	await test.step("The next set is a best of 5", async () => {
		await expect(lobbyPage.bestOf(5)).toBeVisible();
	});
})

the host makes another participant the host

Setup
Arrange
  1. Started lobby → { lobby, host, players }
    const { lobby, host, players } = await startedLobby(page, factories);
  2. not the earliest to sign up, who'd be the host anyway were the host to leave

    newHost = players.at(-1)!
    const newHost = players.at(-1)!;

1The host hands hosting over, the lobby's chat telling of it

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
  2. Make host newHost.id
    await lobbyPage.makeHost(newHost.id);
Assert
  1. end lobby button is not visible
    await isNotVisible(lobbyPage.locators.endLobbyButton);
Chat sidebar
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
Assert
  1. message `${newHost.name} is now the host` is visible
    await expect(
    	chat.chat().message(`${newHost.name} is now the host`),
    ).toBeVisible();

2The new host is marked on the Rankings tab and can manage the lobby

NHnew host
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
Assert
  1. host marker newHost.name is visible
    await expect(lobbyPage.hostMarker(newHost.name)).toBeVisible();
  2. host marker host.name is not visible
    await isNotVisible(lobbyPage.hostMarker(host.name));
  3. end lobby button is visible
    await expect(lobbyPage.locators.endLobbyButton).toBeVisible();
Source
test("the host makes another participant the host", async ({
	page,
	factories,
}) => {
	const { lobby, host, players } = await startedLobby(page, factories);
	// not the earliest to sign up, who'd be the host anyway were the host to leave
	const newHost = players.at(-1)!;
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await test.step("The host hands hosting over, the lobby's chat telling of it", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "leaderboard");
		await lobbyPage.makeHost(newHost.id);

		await isNotVisible(lobbyPage.locators.endLobbyButton);
		await chat.selectRoomTab("Lobby");
		await expect(
			chat.chat().message(`${newHost.name} is now the host`),
		).toBeVisible();
	});

	await test.step("The new host is marked on the Rankings tab and can manage the lobby", async () => {
		await impersonate(page, newHost.id);
		await lobbyPage.goto(lobby.id, "leaderboard");

		await expect(lobbyPage.hostMarker(newHost.name)).toBeVisible();
		await isNotVisible(lobbyPage.hostMarker(host.name));
		await expect(lobbyPage.locators.endLobbyButton).toBeVisible();
	});
})

the earliest to sign up becomes the host when the host leaves

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create 2 × user → [earliest, latest]
    const [earliest, latest] = await factories.UserFactory.createMany(2);
  3. Create lobby host user id host.id name “Test 8s” signed up user ids earliest.id, latest.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{ hostUserId: host.id, name: LOBBY_NAME },
    	{ signedUpUserIds: [earliest.id, latest.id] },
    );

1The host leaves

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Leave
    await lobbyPage.leave();

2The earliest to sign up is notified and can manage the lobby

Eearliest
Act
  1. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification(`You are now the host of ${LOBBY_NAME}`) is visible
    await expect(
    	notifications.notification(`You are now the host of ${LOBBY_NAME}`),
    ).toBeVisible();
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. end lobby button is visible
    await expect(lobbyPage.locators.endLobbyButton).toBeVisible();
Source
test("the earliest to sign up becomes the host when the host leaves", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const [earliest, latest] = await factories.UserFactory.createMany(2);
	const lobby = await factories.LobbyFactory.create(
		{ hostUserId: host.id, name: LOBBY_NAME },
		{ signedUpUserIds: [earliest.id, latest.id] },
	);
	const lobbyPage = new LobbyPage(page);

	await test.step("The host leaves", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.leave();
	});

	await test.step("The earliest to sign up is notified and can manage the lobby", async () => {
		await impersonate(page, earliest.id);
		const notifications = await openNotifications(page);
		await expect(
			notifications.notification(`You are now the host of ${LOBBY_NAME}`),
		).toBeVisible();

		await lobbyPage.goto(lobby.id);

		await expect(lobbyPage.locators.endLobbyButton).toBeVisible();
	});
})

the host ends the lobby

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create lobby host user id host.id → lobby
    const lobby = await factories.LobbyFactory.create({
    	hostUserId: host.id,
    });
Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. End lobby
    await lobbyPage.endLobby();
Assert
  1. ended status is visible
    await expect(lobbyPage.locators.endedStatus).toBeVisible();
Source
test("the host ends the lobby", async ({ page, factories }) => {
	const host = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create({
		hostUserId: host.id,
	});

	await impersonate(page, host.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.endLobby();

	await expect(lobbyPage.locators.endedStatus).toBeVisible();
})

Applying

A host can make a lobby require applying to join it, when making it or later. Signing up then sends the host an application instead, the applicant taking no spot until the host accepts it, which signs them up like signing up would and notifies them. An applicant can withdraw their application, one the host declines can't apply again. Turning the option off accepts everyone still waiting.

an applicant gets in once the host accepts them

Sendouapplicantlobbies.spec.ts:1582
Setup
Arrange
  1. Create user → applicant
    const applicant = await factories.UserFactory.create();
  2. Set friend code user Sendou
    await factories.UserFactory.setFriendCode(ADMIN_ID);
  3. lobbyId = 0
    let lobbyId = 0;

1The host makes a lobby requiring applying

SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
  2. Fill name with “Test 8s”
    await newLobby.form.fill("name", LOBBY_NAME);
  3. Check is application required
    await newLobby.form.check("isApplicationRequired");
  4. Save
    await newLobby.save();
Lobby page
Assert
  1. application required is visible
    await expect(lobbyPage.locators.applicationRequired).toBeVisible();
  2. lobbyId = Number(page.url().split("/").at(-1))
    lobbyId = Number(page.url().split("/").at(-1));

2Signing up applies, taking no spot

Aapplicant
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);
  2. Apply
    await lobbyPage.apply();
Assert
  1. viewer status contains “You applied”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You applied",
    );
  2. participants count is 1
    await expect(lobbyPage.locators.participants).toHaveCount(1);

3The host accepts the application

SSendou
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);
Assert
  1. applications count is 1
    await expect(lobbyPage.locators.applications).toHaveCount(1);
Act
  1. Accept application applicant.id
    await lobbyPage.acceptApplication(applicant.id);
Assert
  1. applications count is 0
    await expect(lobbyPage.locators.applications).toHaveCount(0);
  2. participants count is 2
    await expect(lobbyPage.locators.participants).toHaveCount(2);

4The applicant is notified and signed up

Aapplicant
Act
  1. Open notifications → notifications
    const notifications = await openNotifications(page);
Assert
  1. notifications.notification(`You're in ${LOBBY_NAME}`) is visible
    await expect(
    	notifications.notification(`You're in ${LOBBY_NAME}`),
    ).toBeVisible();
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);
Assert
  1. viewer status contains “You're signed up”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"You're signed up",
    );
Source
test("an applicant gets in once the host accepts them", async ({
	page,
	factories,
}) => {
	const applicant = await factories.UserFactory.create();
	await factories.UserFactory.setFriendCode(ADMIN_ID);
	const lobbyPage = new LobbyPage(page);
	let lobbyId = 0;

	await test.step("The host makes a lobby requiring applying", async () => {
		await impersonate(page, ADMIN_ID);
		const newLobby = new NewLobbyPage(page);
		await newLobby.goto();
		await newLobby.form.fill("name", LOBBY_NAME);
		await newLobby.form.check("isApplicationRequired");
		await newLobby.save();

		await expect(lobbyPage.locators.applicationRequired).toBeVisible();
		lobbyId = Number(page.url().split("/").at(-1));
	});

	await test.step("Signing up applies, taking no spot", async () => {
		await impersonate(page, applicant.id);
		await lobbyPage.goto(lobbyId);
		await lobbyPage.apply();

		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You applied",
		);
		await expect(lobbyPage.locators.participants).toHaveCount(1);
	});

	await test.step("The host accepts the application", async () => {
		await impersonate(page, ADMIN_ID);
		await lobbyPage.goto(lobbyId);
		await expect(lobbyPage.locators.applications).toHaveCount(1);
		await lobbyPage.acceptApplication(applicant.id);

		await expect(lobbyPage.locators.applications).toHaveCount(0);
		await expect(lobbyPage.locators.participants).toHaveCount(2);
	});

	await test.step("The applicant is notified and signed up", async () => {
		await impersonate(page, applicant.id);
		const notifications = await openNotifications(page);
		await expect(
			notifications.notification(`You're in ${LOBBY_NAME}`),
		).toBeVisible();

		await lobbyPage.goto(lobbyId);
		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"You're signed up",
		);
	});
})

a declined applicant can't apply again

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → applicant
    const applicant = await factories.UserFactory.create();
  3. Create lobby host user id host.id is application required true applied user ids applicant.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{ hostUserId: host.id, isApplicationRequired: true },
    	{ appliedUserIds: [applicant.id] },
    );
Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Decline application applicant.id
    await lobbyPage.declineApplication(applicant.id);
Assert
  1. applications count is 0
    await expect(lobbyPage.locators.applications).toHaveCount(0);
Aapplicant
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “The host declined your application”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"The host declined your application",
    );
  2. apply button is not visible
    await isNotVisible(lobbyPage.locators.applyButton);
Source
test("a declined applicant can't apply again", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const applicant = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create(
		{ hostUserId: host.id, isApplicationRequired: true },
		{ appliedUserIds: [applicant.id] },
	);
	const lobbyPage = new LobbyPage(page);

	await impersonate(page, host.id);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.declineApplication(applicant.id);
	await expect(lobbyPage.locators.applications).toHaveCount(0);

	await impersonate(page, applicant.id);
	await lobbyPage.goto(lobby.id);
	await expect(lobbyPage.locators.viewerStatus).toContainText(
		"The host declined your application",
	);
	await isNotVisible(lobbyPage.locators.applyButton);
})

an applicant withdraws their application

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user → applicant
    const applicant = await factories.UserFactory.create();
  3. Create lobby host user id host.id is application required true applied user ids applicant.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{ hostUserId: host.id, isApplicationRequired: true },
    	{ appliedUserIds: [applicant.id] },
    );
Aapplicant
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Withdraw application
    await lobbyPage.withdrawApplication();
Assert
  1. apply button is visible
    await expect(lobbyPage.locators.applyButton).toBeVisible();
Source
test("an applicant withdraws their application", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const applicant = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create(
		{ hostUserId: host.id, isApplicationRequired: true },
		{ appliedUserIds: [applicant.id] },
	);
	const lobbyPage = new LobbyPage(page);

	await impersonate(page, applicant.id);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.withdrawApplication();

	await expect(lobbyPage.locators.applyButton).toBeVisible();
})

Weapon randomizer

The host picks a weapon randomizer when making the lobby or between sets. When a set starts it rolls 4 weapons for each team, its players deciding who plays which: chaotic any weapons, balanced ones that even out the teams.

the randomizer picked when making the lobby shows on its card and page

Setup
Arrange
  1. Set friend code user Sendou
    await factories.UserFactory.setFriendCode(ADMIN_ID);
SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
  2. Fill name with “Test 8s”
    await newLobby.form.fill("name", LOBBY_NAME);
  3. Select weapon randomizer “Balanced”
    await newLobby.selectWeaponRandomizer("Balanced");
  4. Save
    await newLobby.save();
Lobby page
Assert
  1. weapon randomizer reads “Balanced random”
    await expect(lobbyPage.locators.weaponRandomizer).toHaveText(
    	"Balanced random",
    );
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
Assert
  1. weapon randomizer “Test 8s” reads “Balanced random”
    await expect(lobbies.weaponRandomizer(LOBBY_NAME)).toHaveText(
    	"Balanced random",
    );
Source
test("the randomizer picked when making the lobby shows on its card and page", async ({
	page,
	factories,
}) => {
	await factories.UserFactory.setFriendCode(ADMIN_ID);

	await impersonate(page, ADMIN_ID);
	const newLobby = new NewLobbyPage(page);
	await newLobby.goto();
	await newLobby.form.fill("name", LOBBY_NAME);
	await newLobby.selectWeaponRandomizer("Balanced");
	await newLobby.save();

	const lobbyPage = new LobbyPage(page);
	await expect(lobbyPage.locators.weaponRandomizer).toHaveText(
		"Balanced random",
	);

	const lobbies = new LobbiesPage(page);
	await lobbies.goto();
	await expect(lobbies.weaponRandomizer(LOBBY_NAME)).toHaveText(
		"Balanced random",
	);
})

the host renames the lobby on its edit page, its other settings kept

Setup
Arrange
  1. Set friend code user Sendou
    await factories.UserFactory.setFriendCode(ADMIN_ID);
SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
  2. Fill name with “Test 8s”
    await newLobby.form.fill("name", LOBBY_NAME);
  3. Select weapon randomizer “Balanced”
    await newLobby.selectWeaponRandomizer("Balanced");
  4. Save
    await newLobby.save();
Lobby page
Act
  1. Rename “Renamed 8s”
    await lobbyPage.rename("Renamed 8s");
Assert
  1. heading “Renamed 8s” is visible
    await expect(lobbyPage.heading("Renamed 8s")).toBeVisible();
  2. weapon randomizer reads “Balanced random”
    await expect(lobbyPage.locators.weaponRandomizer).toHaveText(
    	"Balanced random",
    );
Source
test("the host renames the lobby on its edit page, its other settings kept", async ({
	page,
	factories,
}) => {
	await factories.UserFactory.setFriendCode(ADMIN_ID);

	await impersonate(page, ADMIN_ID);
	const newLobby = new NewLobbyPage(page);
	await newLobby.goto();
	await newLobby.form.fill("name", LOBBY_NAME);
	await newLobby.selectWeaponRandomizer("Balanced");
	await newLobby.save();

	const lobbyPage = new LobbyPage(page);
	await lobbyPage.rename("Renamed 8s");

	await expect(lobbyPage.heading("Renamed 8s")).toBeVisible();
	await expect(lobbyPage.locators.weaponRandomizer).toHaveText(
		"Balanced random",
	);
})

each team of a set gets 4 weapons on the Rosters tab

Setup
Arrange
  1. Started lobby weapon randomizer “CHAOTIC”
    await startedLobby(page, factories, { weaponRandomizer: "CHAOTIC" });
LOLogged out
Lobby page
Assert
  1. weapon randomizer reads “Chaotic random”
    await expect(lobbyPage.locators.weaponRandomizer).toHaveText(
    	"Chaotic random",
    );
  2. roster rolled weapons count is 8
    await expect(lobbyPage.locators.rosterRolledWeapons).toHaveCount(8);
Source
test("each team of a set gets 4 weapons on the Rosters tab", async ({
	page,
	factories,
}) => {
	await startedLobby(page, factories, { weaponRandomizer: "CHAOTIC" });
	const lobbyPage = new LobbyPage(page);

	await expect(lobbyPage.locators.weaponRandomizer).toHaveText(
		"Chaotic random",
	);
	await expect(lobbyPage.locators.rosterRolledWeapons).toHaveCount(8);
})

Map pool

The sets' maps are picked from the players' preferences in the modes the host picks, unless the host picks a map pool instead, when making the lobby or between sets: a tournament's or a custom one. Its sets are then played on its maps in plain rotation, so nobody is shown as having voted for them.

a tournament's map pool picked when making the lobby, then a custom one and back to ranked modes by the host

Setup
Arrange
  1. Set friend code user Sendou
    await factories.UserFactory.setFriendCode(ADMIN_ID);
  2. Create tournament author Sendou name “Lobby Warmup Cup” start times dateToDatabaseTimestamp(addDays(new Date(), 1)) map pool maps LOBBY_MAP_POOL.stageModePairs → tournament
    const tournament = await factories.TournamentFactory.create({
    	authorId: ADMIN_ID,
    	name: MAPS_TOURNAMENT_NAME,
    	startTimes: [dateToDatabaseTimestamp(addDays(new Date(), 1))],
    	mapPoolMaps: LOBBY_MAP_POOL.stageModePairs,
    });

1The tournament's pool links to its rules from the page and shows on the card

SSendou
New lobby page
Act
  1. Open the new lobby page
    await newLobby.goto();
  2. Fill name with “Test 8s”
    await newLobby.form.fill("name", LOBBY_NAME);
  3. Select tournament maps “Lobby Warmup Cup”
    await newLobby.selectTournamentMaps(MAPS_TOURNAMENT_NAME);
  4. Save
    await newLobby.save();
Lobby page
Assert
  1. map pool link reads “Lobby Warmup Cup”
    await expect(lobbyPage.locators.mapPoolLink).toHaveText(
    	MAPS_TOURNAMENT_NAME,
    );
  2. map pool link has “href” = tournamentRulesPage(tournament.id)
    await expect(lobbyPage.locators.mapPoolLink).toHaveAttribute(
    	"href",
    	tournamentRulesPage(tournament.id),
    );
Arrange
  1. lobbyId = Number(page.url().split("/").at(-1))
    const lobbyId = Number(page.url().split("/").at(-1));
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
Assert
  1. card “Test 8s” contains “Lobby Warmup Cup”
    await expect(lobbies.card(LOBBY_NAME)).toContainText(
    	MAPS_TOURNAMENT_NAME,
    );
Lobby page
Act
  1. Open the lobby page lobbyId
    await lobbyPage.goto(lobbyId);

2The host switches to a custom pool

SSendou
Lobby page
Act
  1. Change map pool LOBBY_MAP_POOL
    await lobbyPage.changeMapPool(LOBBY_MAP_POOL);
Assert
  1. map pool link reads “3 maps”
    await expect(lobbyPage.locators.mapPoolLink).toHaveText("3 maps");

3The host goes back to the players' preferences in ranked modes

SSendou
Lobby page
Act
  1. Use ranked modes
    await lobbyPage.useRankedModes();
Assert
  1. map pool link is not visible
    await isNotVisible(lobbyPage.locators.mapPoolLink);
Source
test("a tournament's map pool picked when making the lobby, then a custom one and back to ranked modes by the host", async ({
	page,
	factories,
}) => {
	await factories.UserFactory.setFriendCode(ADMIN_ID);
	const tournament = await factories.TournamentFactory.create({
		authorId: ADMIN_ID,
		name: MAPS_TOURNAMENT_NAME,
		startTimes: [dateToDatabaseTimestamp(addDays(new Date(), 1))],
		mapPoolMaps: LOBBY_MAP_POOL.stageModePairs,
	});
	await impersonate(page, ADMIN_ID);
	const lobbyPage = new LobbyPage(page);

	await test.step("The tournament's pool links to its rules from the page and shows on the card", async () => {
		const newLobby = new NewLobbyPage(page);
		await newLobby.goto();
		await newLobby.form.fill("name", LOBBY_NAME);
		await newLobby.selectTournamentMaps(MAPS_TOURNAMENT_NAME);
		await newLobby.save();

		await expect(lobbyPage.locators.mapPoolLink).toHaveText(
			MAPS_TOURNAMENT_NAME,
		);
		await expect(lobbyPage.locators.mapPoolLink).toHaveAttribute(
			"href",
			tournamentRulesPage(tournament.id),
		);
		const lobbyId = Number(page.url().split("/").at(-1));

		const lobbies = new LobbiesPage(page);
		await lobbies.goto();
		await expect(lobbies.card(LOBBY_NAME)).toContainText(
			MAPS_TOURNAMENT_NAME,
		);

		await lobbyPage.goto(lobbyId);
	});

	await test.step("The host switches to a custom pool", async () => {
		await lobbyPage.changeMapPool(LOBBY_MAP_POOL);

		await expect(lobbyPage.locators.mapPoolLink).toHaveText("3 maps");
	});

	await test.step("The host goes back to the players' preferences in ranked modes", async () => {
		await lobbyPage.useRankedModes();

		await isNotVisible(lobbyPage.locators.mapPoolLink);
	});
})

sets are played on the map pool's maps, nobody voting for them

Setup
Arrange
  1. Started lobby is pooling every map true map pool LOBBY_MAP_POOL.stageModePairs
    await startedLobby(page, factories, {
    	isPoolingEveryMap: true,
    	mapPool: LOBBY_MAP_POOL.stageModePairs,
    });
LOLogged out
Lobby page
Assert
  1. current map has “data-testid” = /^banner-map-SZ-[123]$/
    await expect(lobbyPage.locators.currentMap).toHaveAttribute(
    	"data-testid",
    	/^banner-map-SZ-[123]$/,
    );
  2. map voters badge is not visible
    await isNotVisible(lobbyPage.locators.mapVotersBadge);
Source
test("sets are played on the map pool's maps, nobody voting for them", async ({
	page,
	factories,
}) => {
	await startedLobby(page, factories, {
		isPoolingEveryMap: true,
		mapPool: LOBBY_MAP_POOL.stageModePairs,
	});
	const lobbyPage = new LobbyPage(page);

	await expect(lobbyPage.locators.currentMap).toHaveAttribute(
		"data-testid",
		/^banner-map-SZ-[123]$/,
	);
	await isNotVisible(lobbyPage.locators.mapVotersBadge);
})

Chat

The lobby's chat is shared by everyone in it and stays with players who leave after playing a set, only a kick takes it away. While a set is played its two teams also get a chat of their own, fresh for every set.

leaving before playing is noted in the chat and takes it away

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create user discord name “EarlyLeaver” → leaver
    const leaver = await factories.UserFactory.create({
    	discordName: "EarlyLeaver",
    });
  3. Create lobby host user id host.id signed up user ids leaver.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{ hostUserId: host.id },
    	{ signedUpUserIds: [leaver.id] },
    );

1A participant leaves before playing and has no chat anymore

Lleaver
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Assert
  1. open chats count is 1
    await expect(chat.locators.openChats).toHaveCount(1);
Lobby page
Act
  1. Leave
    await lobbyPage.leave();
Assert
  1. sign up button is visible
    await expect(lobbyPage.locators.signUpButton).toBeVisible();
  2. open chats is not visible
    await isNotVisible(chat.locators.openChats);

2The host sees them leave in the chat only

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Assert
  1. message “EarlyLeaver left the lobby” is visible
    await expect(
    	chat.chat().message("EarlyLeaver left the lobby"),
    ).toBeVisible();
  2. left users is not visible
    await isNotVisible(lobbyPage.locators.leftUsers);
Source
test("leaving before playing is noted in the chat and takes it away", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const leaver = await factories.UserFactory.create({
		discordName: "EarlyLeaver",
	});
	const lobby = await factories.LobbyFactory.create(
		{ hostUserId: host.id },
		{ signedUpUserIds: [leaver.id] },
	);
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await test.step("A participant leaves before playing and has no chat anymore", async () => {
		await impersonate(page, leaver.id);
		await lobbyPage.goto(lobby.id);
		await expect(chat.locators.openChats).toHaveCount(1);

		await lobbyPage.leave();
		await expect(lobbyPage.locators.signUpButton).toBeVisible();
		await isNotVisible(chat.locators.openChats);
	});

	await test.step("The host sees them leave in the chat only", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id);

		await expect(
			chat.chat().message("EarlyLeaver left the lobby"),
		).toBeVisible();
		await isNotVisible(lobbyPage.locators.leftUsers);
	});
})

leaving after playing keeps the lobby's chat, being kicked takes it away

Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayers }
    const { lobby, host, alphaPlayers } = await startedLobby(page, factories);
  2. leaver = alphaPlayers.find((player) => player.id !== host.id)!
    const leaver = alphaPlayers.find((player) => player.id !== host.id)!;

1A player leaves mid-set and still writes to the lobby

Lleaver
Lobby page
Act
  1. Open the lobby page lobby.id, “action”
    await lobbyPage.goto(lobby.id, "action");
  2. Report own team win
    await lobbyPage.reportOwnTeamWin();
  3. Leave mid set
    await lobbyPage.leaveMidSet();
Assert
  1. sign up button is visible
    await expect(lobbyPage.locators.signUpButton).toBeVisible();
Chat sidebar
Act
  1. Send “left but still here”
    await chat.chat().send("left but still here");
Assert
  1. message “left but still here” is visible
    await expect(chat.chat().message("left but still here")).toBeVisible();
  2. pending messages count is 0
    await expect(chat.chat().locators.pendingMessages).toHaveCount(0);

2Coming back the chat opens with the lobby

Lleaver
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Assert
  1. message “left but still here” is visible
    await expect(chat.chat().message("left but still here")).toBeVisible();
Lleaver
Act
  1. Lobby chat room ids → { lobbyRoomId }
    const { lobbyRoomId } = await lobbyChatRoomIds(page);

3The host kicks the one who left

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id, “leaderboard”
    await lobbyPage.goto(lobby.id, "leaderboard");
Chat sidebar
Assert
  1. message “left but still here” is visible
    await expect(chat.chat().message("left but still here")).toBeVisible();
Lobby page
Assert
  1. left users count is 1
    await expect(lobbyPage.locators.leftUsers).toHaveCount(1);
Act
  1. Kick left user leaver.id
    await lobbyPage.kickLeftUser(leaver.id);
Assert
  1. left users count is 0
    await expect(lobbyPage.locators.leftUsers).toHaveCount(0);

4The kicked one has no chat anymore

Lleaver
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. viewer status contains “The host kicked you from the lobby”
    await expect(lobbyPage.locators.viewerStatus).toContainText(
    	"The host kicked you from the lobby",
    );
  2. open chats is not visible
    await isNotVisible(chat.locators.openChats);
  3. chatHistoryStatus(page, lobbyRoomId) is 403
    expect(await chatHistoryStatus(page, lobbyRoomId)).toBe(403);
Source
test("leaving after playing keeps the lobby's chat, being kicked takes it away", async ({
	page,
	factories,
}) => {
	const { lobby, host, alphaPlayers } = await startedLobby(page, factories);
	const leaver = alphaPlayers.find((player) => player.id !== host.id)!;
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await test.step("A player leaves mid-set and still writes to the lobby", async () => {
		await impersonate(page, leaver.id);
		await lobbyPage.goto(lobby.id, "action");
		await lobbyPage.reportOwnTeamWin();
		await lobbyPage.leaveMidSet();
		await expect(lobbyPage.locators.signUpButton).toBeVisible();

		await chat.chat().send("left but still here");
		await expect(chat.chat().message("left but still here")).toBeVisible();
		await expect(chat.chat().locators.pendingMessages).toHaveCount(0);
	});

	await test.step("Coming back the chat opens with the lobby", async () => {
		await lobbyPage.goto(lobby.id);

		await expect(chat.chat().message("left but still here")).toBeVisible();
	});

	const { lobbyRoomId } = await lobbyChatRoomIds(page);

	await test.step("The host kicks the one who left", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id, "leaderboard");
		await expect(chat.chat().message("left but still here")).toBeVisible();
		await expect(lobbyPage.locators.leftUsers).toHaveCount(1);

		await lobbyPage.kickLeftUser(leaver.id);
		await expect(lobbyPage.locators.leftUsers).toHaveCount(0);
	});

	await test.step("The kicked one has no chat anymore", async () => {
		await impersonate(page, leaver.id);
		await lobbyPage.goto(lobby.id);
		await expect(lobbyPage.locators.viewerStatus).toContainText(
			"The host kicked you from the lobby",
		);

		await isNotVisible(chat.locators.openChats);
		expect(await chatHistoryStatus(page, lobbyRoomId)).toBe(403);
	});
})

a team's chat reaches only its players

senderteammatebravo playerlobbies.spec.ts:1922
Setup
Arrange
  1. Started lobby → { lobby, alphaPlayers, bravoPlayer }
    const { lobby, alphaPlayers, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );
  2. [sender, teammate] = alphaPlayers
    const [sender, teammate] = alphaPlayers;

1An Alpha player writes to their team and to the lobby

Ssender
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Assert
  1. as tabs while the view is too short to stack them

    split panels count is 2
    await expect(chat.locators.splitPanels).toHaveCount(2);
  2. room tabs reads “Lobby”, “Team”
    await expect(chat.locators.roomTabs).toHaveText(["Lobby", "Team"]);
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
  2. Send “alpha only”
    await chat.chat().send("alpha only");
Assert
  1. message “alpha only” is visible
    await expect(chat.chat().message("alpha only")).toBeVisible();
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
  2. Send “hello lobby”
    await chat.chat().send("hello lobby");
Assert
  1. message “hello lobby” is visible
    await expect(chat.chat().message("hello lobby")).toBeVisible();
  2. message “alpha only” count is 0
    await expect(chat.chat().message("alpha only")).toHaveCount(0);

2Their teammate reads the team message

Tteammate
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
Assert
  1. message “alpha only” is visible
    await expect(chat.chat().message("alpha only")).toBeVisible();

3A Bravo player reads only the lobby message

BPbravo player
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
Assert
  1. message “alpha only” count is 0
    await expect(chat.chat().message("alpha only")).toHaveCount(0);
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
Assert
  1. message “hello lobby” is visible
    await expect(chat.chat().message("hello lobby")).toBeVisible();

4The two chats are one row of the room list

BPbravo player
Chat sidebar
Act
  1. Back to room list
    await chat.backToRoomList();
Assert
  1. room rows count is 1
    await expect(chat.locators.roomRows).toHaveCount(1);
  2. room rows contains “Lobby · Team”
    await expect(chat.locators.roomRows).toContainText("Lobby · Team");
Source
test("a team's chat reaches only its players", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayers, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const [sender, teammate] = alphaPlayers;
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await test.step("An Alpha player writes to their team and to the lobby", async () => {
		await impersonate(page, sender.id);
		await lobbyPage.goto(lobby.id);

		// as tabs while the view is too short to stack them
		await expect(chat.locators.splitPanels).toHaveCount(2);
		await expect(chat.locators.roomTabs).toHaveText(["Lobby", "Team"]);

		await chat.selectRoomTab("Team");
		await chat.chat().send("alpha only");
		await expect(chat.chat().message("alpha only")).toBeVisible();

		await chat.selectRoomTab("Lobby");
		await chat.chat().send("hello lobby");
		await expect(chat.chat().message("hello lobby")).toBeVisible();
		await expect(chat.chat().message("alpha only")).toHaveCount(0);
	});

	await test.step("Their teammate reads the team message", async () => {
		await impersonate(page, teammate.id);
		await lobbyPage.goto(lobby.id);

		await chat.selectRoomTab("Team");
		await expect(chat.chat().message("alpha only")).toBeVisible();
	});

	await test.step("A Bravo player reads only the lobby message", async () => {
		await impersonate(page, bravoPlayer.id);
		await lobbyPage.goto(lobby.id);

		await chat.selectRoomTab("Team");
		await expect(chat.chat().message("alpha only")).toHaveCount(0);

		await chat.selectRoomTab("Lobby");
		await expect(chat.chat().message("hello lobby")).toBeVisible();
	});

	await test.step("The two chats are one row of the room list", async () => {
		await chat.backToRoomList();

		await expect(chat.locators.roomRows).toHaveCount(1);
		await expect(chat.locators.roomRows).toContainText("Lobby · Team");
	});
})

every set starts with fresh team chats

sendernew teammateformer teammatelobbies.spec.ts:1979
Setup
Arrange
  1. Started lobby → { lobby, players, alphaPlayers, bravoPlayers }
    const { lobby, players, alphaPlayers, bravoPlayers } = await startedLobby(
    	page,
    	factories,
    );
  2. sender = alphaPlayers[0]
    const sender = alphaPlayers[0];

1An Alpha player writes to their team and to the lobby in the first set

Ssender
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
  2. Send “first set plan”
    await chat.chat().send("first set plan");
Assert
  1. message “first set plan” is visible
    await expect(chat.chat().message("first set plan")).toBeVisible();
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
  2. Send “hello lobby”
    await chat.chat().send("hello lobby");
Assert
  1. message “hello lobby” is visible
    await expect(chat.chat().message("hello lobby")).toBeVisible();
Ssender
Act
  1. Play set lobby id lobby.id alpha player sender bravo player bravoPlayers[0]
    await playSet(page, {
    	lobbyId: lobby.id,
    	alphaPlayer: sender,
    	bravoPlayer: bravoPlayers[0],
    });
Lobby page
Assert
  1. tab “rosters” has “aria-selected” = “true”
    await expect(lobbyPage.tab("rosters")).toHaveAttribute(
    	"aria-selected",
    	"true",
    );
Act
  1. Roster ids lobbyPage, “Alpha”, players → nextAlphaIds
    const nextAlphaIds = await rosterIds(lobbyPage, "Alpha", players);
Arrange
  1. senderTeamIds = nextAlphaIds.includes(sender.id) ? nextAlphaIds : idsOf(players).filter((id) …
    const senderTeamIds = nextAlphaIds.includes(sender.id)
    	? nextAlphaIds
    	: idsOf(players).filter((id) => !nextAlphaIds.includes(id));
  2. newTeammate = players.find( (player) => player.id !== sender.id && senderTeamIds.includes(p…
    const newTeammate = players.find(
    	(player) =>
    		player.id !== sender.id && senderTeamIds.includes(player.id),
    )!;
  3. the teams were reshuffled, so someone of the first set's team now plays against the sender

    formerTeammate = alphaPlayers.find( (player) => !senderTeamIds.includes(player.id), )!
    const formerTeammate = alphaPlayers.find(
    	(player) => !senderTeamIds.includes(player.id),
    )!;

2The sender's team chat of the next set starts empty

Ssender
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
  2. Send “second set plan”
    await chat.chat().send("second set plan");
Assert
  1. message “second set plan” is visible
    await expect(chat.chat().message("second set plan")).toBeVisible();
  2. message “first set plan” count is 0
    await expect(chat.chat().message("first set plan")).toHaveCount(0);
Act
  1. Select room tab “Lobby”
    await chat.selectRoomTab("Lobby");
Assert
  1. message “hello lobby” is visible
    await expect(chat.chat().message("hello lobby")).toBeVisible();

3Their new teammate reads only the next set's message

NTnew teammate
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
Assert
  1. message “second set plan” is visible
    await expect(chat.chat().message("second set plan")).toBeVisible();
  2. message “first set plan” count is 0
    await expect(chat.chat().message("first set plan")).toHaveCount(0);

4A former teammate now on the other team reads neither

FTformer teammate
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Chat sidebar
Act
  1. Select room tab “Team”
    await chat.selectRoomTab("Team");
  2. Send “other team plan”
    await chat.chat().send("other team plan");
Assert
  1. message “other team plan” is visible
    await expect(chat.chat().message("other team plan")).toBeVisible();
  2. message “second set plan” count is 0
    await expect(chat.chat().message("second set plan")).toHaveCount(0);
  3. message “first set plan” count is 0
    await expect(chat.chat().message("first set plan")).toHaveCount(0);
Source
test("every set starts with fresh team chats", async ({
	page,
	factories,
}) => {
	const { lobby, players, alphaPlayers, bravoPlayers } = await startedLobby(
		page,
		factories,
	);
	const sender = alphaPlayers[0];
	const lobbyPage = new LobbyPage(page);
	const chat = new ChatSidebar(page);

	await test.step("An Alpha player writes to their team and to the lobby in the first set", async () => {
		await impersonate(page, sender.id);
		await lobbyPage.goto(lobby.id);

		await chat.selectRoomTab("Team");
		await chat.chat().send("first set plan");
		await expect(chat.chat().message("first set plan")).toBeVisible();

		await chat.selectRoomTab("Lobby");
		await chat.chat().send("hello lobby");
		await expect(chat.chat().message("hello lobby")).toBeVisible();
	});

	await playSet(page, {
		lobbyId: lobby.id,
		alphaPlayer: sender,
		bravoPlayer: bravoPlayers[0],
	});

	await expect(lobbyPage.tab("rosters")).toHaveAttribute(
		"aria-selected",
		"true",
	);
	const nextAlphaIds = await rosterIds(lobbyPage, "Alpha", players);
	const senderTeamIds = nextAlphaIds.includes(sender.id)
		? nextAlphaIds
		: idsOf(players).filter((id) => !nextAlphaIds.includes(id));
	const newTeammate = players.find(
		(player) =>
			player.id !== sender.id && senderTeamIds.includes(player.id),
	)!;
	// the teams were reshuffled, so someone of the first set's team now plays against the sender
	const formerTeammate = alphaPlayers.find(
		(player) => !senderTeamIds.includes(player.id),
	)!;

	await test.step("The sender's team chat of the next set starts empty", async () => {
		await impersonate(page, sender.id);
		await lobbyPage.goto(lobby.id);

		await chat.selectRoomTab("Team");
		await chat.chat().send("second set plan");
		await expect(chat.chat().message("second set plan")).toBeVisible();
		await expect(chat.chat().message("first set plan")).toHaveCount(0);

		await chat.selectRoomTab("Lobby");
		await expect(chat.chat().message("hello lobby")).toBeVisible();
	});

	await test.step("Their new teammate reads only the next set's message", async () => {
		await impersonate(page, newTeammate.id);
		await lobbyPage.goto(lobby.id);

		await chat.selectRoomTab("Team");
		await expect(chat.chat().message("second set plan")).toBeVisible();
		await expect(chat.chat().message("first set plan")).toHaveCount(0);
	});

	await test.step("A former teammate now on the other team reads neither", async () => {
		await impersonate(page, formerTeammate.id);
		await lobbyPage.goto(lobby.id);

		await chat.selectRoomTab("Team");
		await chat.chat().send("other team plan");
		await expect(chat.chat().message("other team plan")).toBeVisible();
		await expect(chat.chat().message("second set plan")).toHaveCount(0);
		await expect(chat.chat().message("first set plan")).toHaveCount(0);
	});
})

Voice

A player of a set has the lobby's chat and their team's, each with a voice call. When a set starts a call in the team's chat follows the player to their team of the new set, one in the lobby's chat stays put, and a player sitting the set out is dropped from their team's call. Leaving the lobby ends the player's call.

a call in the lobby's chat stays there when the set starts

Setup
Arrange
  1. Lobby awaiting last check in → { lobby, players }
    const { lobby, players } = await lobbyAwaitingLastCheckIn(factories);
  2. caller = players[0]
    const caller = players[0];
LOLogged out
Act
  1. Open second user browser, workerBaseURL, caller.id → callerSession
    const callerSession = await openSecondUser(
    	browser,
    	workerBaseURL,
    	caller.id,
    );
  2. Try
    try {
    	const callerChat = new ChatSidebar(callerSession.page);
    	const callerVoice = new VoicePanel(callerSession.page);
    	let lobbyRoomId = 0;
    
    	await test.step("A player joins the lobby chat's call before the start", async () => {
    		await new LobbyPage(callerSession.page).goto(lobby.id);
    		({ lobbyRoomId } = await lobbyChatRoomIds(callerSession.page));
    
    		await callerVoice.joinVoice(LOBBY_NAME);
    		await expect
    			.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
    			.toEqual([caller.id]);
    	});
    
    	await startLobby(page, { lobby, players });
    
    	await test.step("Once the set starts they are still in the lobby chat's call", async () => {
    		await expect(callerChat.locators.roomTabs).toHaveText([
    			"Lobby",
    			"Team",
    		]);
    
    		await callerVoice.open();
    		await expect(callerVoice.locators.callSection).toContainText(
    			LOBBY_NAME,
    		);
    		await expect(
    			callerVoice.joinableRoom(TEAM_VOICE_TITLE),
    		).toBeVisible();
    		await expect
    			.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
    			.toEqual([caller.id]);
    	});
    } finally {
    	await callerSession.close();
    }
    1. lobbyRoomId = 0
      let lobbyRoomId = 0;
    2. A player joins the lobby chat's call before the start
      await test.step("A player joins the lobby chat's call before the start", async () => {
      	await new LobbyPage(callerSession.page).goto(lobby.id);
      	({ lobbyRoomId } = await lobbyChatRoomIds(callerSession.page));
      
      	await callerVoice.joinVoice(LOBBY_NAME);
      	await expect
      		.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
      		.toEqual([caller.id]);
      });
      1. Open the lobby page lobby.id
        await new LobbyPage(callerSession.page).goto(lobby.id);
      2. Lobby chat room ids callerSession.page → { lobbyRoomId }
        ({ lobbyRoomId } = await lobbyChatRoomIds(callerSession.page));
      3. Join voice “Test 8s”
        await callerVoice.joinVoice(LOBBY_NAME);
      4. () => voiceRoomUserIds(callerSession.page, lobbyRoomId) equals caller.id
        await expect
        	.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
        	.toEqual([caller.id]);
    3. Start lobby lobby players
      await startLobby(page, { lobby, players });
    4. Once the set starts they are still in the lobby chat's call
      await test.step("Once the set starts they are still in the lobby chat's call", async () => {
      	await expect(callerChat.locators.roomTabs).toHaveText([
      		"Lobby",
      		"Team",
      	]);
      
      	await callerVoice.open();
      	await expect(callerVoice.locators.callSection).toContainText(
      		LOBBY_NAME,
      	);
      	await expect(
      		callerVoice.joinableRoom(TEAM_VOICE_TITLE),
      	).toBeVisible();
      	await expect
      		.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
      		.toEqual([caller.id]);
      });
      1. room tabs reads “Lobby”, “Team”
        await expect(callerChat.locators.roomTabs).toHaveText([
        	"Lobby",
        	"Team",
        ]);
      2. Open
        await callerVoice.open();
      3. call section contains “Test 8s”
        await expect(callerVoice.locators.callSection).toContainText(
        	LOBBY_NAME,
        );
      4. joinable room “/Team (Alpha|Bravo)/” is visible
        await expect(
        	callerVoice.joinableRoom(TEAM_VOICE_TITLE),
        ).toBeVisible();
      5. () => voiceRoomUserIds(callerSession.page, lobbyRoomId) equals caller.id
        await expect
        	.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
        	.toEqual([caller.id]);
Source
test("a call in the lobby's chat stays there when the set starts", async ({
	page,
	factories,
	browser,
	workerBaseURL,
}) => {
	const { lobby, players } = await lobbyAwaitingLastCheckIn(factories);
	const caller = players[0];
	const callerSession = await openSecondUser(
		browser,
		workerBaseURL,
		caller.id,
	);
	try {
		const callerChat = new ChatSidebar(callerSession.page);
		const callerVoice = new VoicePanel(callerSession.page);
		let lobbyRoomId = 0;

		await test.step("A player joins the lobby chat's call before the start", async () => {
			await new LobbyPage(callerSession.page).goto(lobby.id);
			({ lobbyRoomId } = await lobbyChatRoomIds(callerSession.page));

			await callerVoice.joinVoice(LOBBY_NAME);
			await expect
				.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
				.toEqual([caller.id]);
		});

		await startLobby(page, { lobby, players });

		await test.step("Once the set starts they are still in the lobby chat's call", async () => {
			await expect(callerChat.locators.roomTabs).toHaveText([
				"Lobby",
				"Team",
			]);

			await callerVoice.open();
			await expect(callerVoice.locators.callSection).toContainText(
				LOBBY_NAME,
			);
			await expect(
				callerVoice.joinableRoom(TEAM_VOICE_TITLE),
			).toBeVisible();
			await expect
				.poll(() => voiceRoomUserIds(callerSession.page, lobbyRoomId))
				.toEqual([caller.id]);
		});
	} finally {
		await callerSession.close();
	}
})

a call in the team's chat moves to the player's team of the next set

Setup
Arrange
  1. Started lobby → { lobby, alphaPlayers, bravoPlayers }
    const { lobby, alphaPlayers, bravoPlayers } = await startedLobby(
    	page,
    	factories,
    );
  2. playSet plays as alphaPlayers[0] on the other page

    caller = alphaPlayers[1]
    const caller = alphaPlayers[1];
LOLogged out
Act
  1. Open second user browser, workerBaseURL, caller.id → callerSession
    const callerSession = await openSecondUser(
    	browser,
    	workerBaseURL,
    	caller.id,
    );
  2. Try
    try {
    	const callerVoice = new VoicePanel(callerSession.page);
    	let firstTeamRoomId = 0;
    
    	await test.step("A player joins their team chat's call", async () => {
    		await new LobbyPage(callerSession.page).goto(lobby.id);
    		firstTeamRoomId = await teamChatRoomId(callerSession.page);
    
    		await callerVoice.joinVoice(TEAM_VOICE_TITLE);
    		await expect
    			.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
    			.toEqual([caller.id]);
    	});
    
    	await playSet(page, {
    		lobbyId: lobby.id,
    		alphaPlayer: alphaPlayers[0],
    		bravoPlayer: bravoPlayers[0],
    	});
    
    	await test.step("In the next set they are in the call of their new team's chat", async () => {
    		// the next set's chats are made after the first's
    		await expect
    			.poll(
    				async () =>
    					(await lobbyChatRoomIds(callerSession.page)).teamRoomId,
    			)
    			.toBeGreaterThan(firstTeamRoomId);
    		const nextTeamRoomId = await teamChatRoomId(callerSession.page);
    
    		await expect
    			.poll(() => voiceRoomUserIds(callerSession.page, nextTeamRoomId))
    			.toEqual([caller.id]);
    		await expect
    			.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
    			.toEqual([]);
    
    		await callerVoice.open();
    		await expect(callerVoice.locators.callSection).toContainText(
    			TEAM_VOICE_TITLE,
    		);
    	});
    } finally {
    	await callerSession.close();
    }
    1. firstTeamRoomId = 0
      let firstTeamRoomId = 0;
    2. A player joins their team chat's call
      await test.step("A player joins their team chat's call", async () => {
      	await new LobbyPage(callerSession.page).goto(lobby.id);
      	firstTeamRoomId = await teamChatRoomId(callerSession.page);
      
      	await callerVoice.joinVoice(TEAM_VOICE_TITLE);
      	await expect
      		.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
      		.toEqual([caller.id]);
      });
      1. Open the lobby page lobby.id
        await new LobbyPage(callerSession.page).goto(lobby.id);
      2. Team chat room id callerSession.page → firstTeamRoomId
        firstTeamRoomId = await teamChatRoomId(callerSession.page);
      3. Join voice “/Team (Alpha|Bravo)/”
        await callerVoice.joinVoice(TEAM_VOICE_TITLE);
      4. () => voiceRoomUserIds(callerSession.page, firstTeamRoomId) equals caller.id
        await expect
        	.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
        	.toEqual([caller.id]);
    3. Play set lobby id lobby.id alpha player alphaPlayers[0] bravo player bravoPlayers[0]
      await playSet(page, {
      	lobbyId: lobby.id,
      	alphaPlayer: alphaPlayers[0],
      	bravoPlayer: bravoPlayers[0],
      });
    4. In the next set they are in the call of their new team's chat
      await test.step("In the next set they are in the call of their new team's chat", async () => {
      	// the next set's chats are made after the first's
      	await expect
      		.poll(
      			async () =>
      				(await lobbyChatRoomIds(callerSession.page)).teamRoomId,
      		)
      		.toBeGreaterThan(firstTeamRoomId);
      	const nextTeamRoomId = await teamChatRoomId(callerSession.page);
      
      	await expect
      		.poll(() => voiceRoomUserIds(callerSession.page, nextTeamRoomId))
      		.toEqual([caller.id]);
      	await expect
      		.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
      		.toEqual([]);
      
      	await callerVoice.open();
      	await expect(callerVoice.locators.callSection).toContainText(
      		TEAM_VOICE_TITLE,
      	);
      });
      1. the next set's chats are made after the first's

        async () => (await lobbyChatRoomIds(callerSession.page)).teamRoomId is more than firstTeamRoomId
        await expect
        	.poll(
        		async () =>
        			(await lobbyChatRoomIds(callerSession.page)).teamRoomId,
        	)
        	.toBeGreaterThan(firstTeamRoomId);
      2. Team chat room id callerSession.page → nextTeamRoomId
        const nextTeamRoomId = await teamChatRoomId(callerSession.page);
      3. () => voiceRoomUserIds(callerSession.page, nextTeamRoomId) equals caller.id
        await expect
        	.poll(() => voiceRoomUserIds(callerSession.page, nextTeamRoomId))
        	.toEqual([caller.id]);
      4. () => voiceRoomUserIds(callerSession.page, firstTeamRoomId) equals
        await expect
        	.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
        	.toEqual([]);
      5. Open
        await callerVoice.open();
      6. call section contains “/Team (Alpha|Bravo)/”
        await expect(callerVoice.locators.callSection).toContainText(
        	TEAM_VOICE_TITLE,
        );
Source
test("a call in the team's chat moves to the player's team of the next set", async ({
	page,
	factories,
	browser,
	workerBaseURL,
}) => {
	const { lobby, alphaPlayers, bravoPlayers } = await startedLobby(
		page,
		factories,
	);
	// playSet plays as alphaPlayers[0] on the other page
	const caller = alphaPlayers[1];
	const callerSession = await openSecondUser(
		browser,
		workerBaseURL,
		caller.id,
	);
	try {
		const callerVoice = new VoicePanel(callerSession.page);
		let firstTeamRoomId = 0;

		await test.step("A player joins their team chat's call", async () => {
			await new LobbyPage(callerSession.page).goto(lobby.id);
			firstTeamRoomId = await teamChatRoomId(callerSession.page);

			await callerVoice.joinVoice(TEAM_VOICE_TITLE);
			await expect
				.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
				.toEqual([caller.id]);
		});

		await playSet(page, {
			lobbyId: lobby.id,
			alphaPlayer: alphaPlayers[0],
			bravoPlayer: bravoPlayers[0],
		});

		await test.step("In the next set they are in the call of their new team's chat", async () => {
			// the next set's chats are made after the first's
			await expect
				.poll(
					async () =>
						(await lobbyChatRoomIds(callerSession.page)).teamRoomId,
				)
				.toBeGreaterThan(firstTeamRoomId);
			const nextTeamRoomId = await teamChatRoomId(callerSession.page);

			await expect
				.poll(() => voiceRoomUserIds(callerSession.page, nextTeamRoomId))
				.toEqual([caller.id]);
			await expect
				.poll(() => voiceRoomUserIds(callerSession.page, firstTeamRoomId))
				.toEqual([]);

			await callerVoice.open();
			await expect(callerVoice.locators.callSection).toContainText(
				TEAM_VOICE_TITLE,
			);
		});
	} finally {
		await callerSession.close();
	}
})

leaving the lobby ends the player's call

Setup
Arrange
  1. Started lobby → { lobby, host, alphaPlayers, bravoPlayer }
    const { lobby, host, alphaPlayers, bravoPlayer } = await startedLobby(
    	page,
    	factories,
    );
  2. leaver = alphaPlayers.find((player) => player.id !== host.id)!
    const leaver = alphaPlayers.find((player) => player.id !== host.id)!;
LOLogged out
Act
  1. Open second user browser, workerBaseURL, bravoPlayer.id → stayerSession
    const stayerSession = await openSecondUser(
    	browser,
    	workerBaseURL,
    	bravoPlayer.id,
    );
  2. Try
    try {
    	const stayerVoice = new VoicePanel(stayerSession.page);
    	let lobbyRoomId = 0;
    
    	await test.step("Two players join the lobby chat's call", async () => {
    		await impersonate(page, leaver.id);
    		await lobbyPage.goto(lobby.id);
    		await voice.joinVoice(LOBBY_NAME);
    
    		await new LobbyPage(stayerSession.page).goto(lobby.id);
    		({ lobbyRoomId } = await lobbyChatRoomIds(stayerSession.page));
    		await stayerVoice.joinVoice(LOBBY_NAME);
    
    		await expect
    			.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
    			.toEqual(idsOf([leaver, bravoPlayer]));
    	});
    
    	await test.step("One leaves the lobby and is out of the call", async () => {
    		await lobbyPage.leaveMidSet();
    
    		await expect
    			.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
    			.toEqual([bravoPlayer.id]);
    		await isNotVisible(voice.locators.leaveVoiceButton);
    	});
    } finally {
    	await stayerSession.close();
    }
    1. lobbyRoomId = 0
      let lobbyRoomId = 0;
    2. Two players join the lobby chat's call
      await test.step("Two players join the lobby chat's call", async () => {
      	await impersonate(page, leaver.id);
      	await lobbyPage.goto(lobby.id);
      	await voice.joinVoice(LOBBY_NAME);
      
      	await new LobbyPage(stayerSession.page).goto(lobby.id);
      	({ lobbyRoomId } = await lobbyChatRoomIds(stayerSession.page));
      	await stayerVoice.joinVoice(LOBBY_NAME);
      
      	await expect
      		.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
      		.toEqual(idsOf([leaver, bravoPlayer]));
      });
      1. await impersonate(page, leaver.id);
      2. Open the lobby page lobby.id
        await lobbyPage.goto(lobby.id);
      3. Join voice “Test 8s”
        await voice.joinVoice(LOBBY_NAME);
      4. Open the lobby page lobby.id
        await new LobbyPage(stayerSession.page).goto(lobby.id);
      5. Lobby chat room ids stayerSession.page → { lobbyRoomId }
        ({ lobbyRoomId } = await lobbyChatRoomIds(stayerSession.page));
      6. Join voice “Test 8s”
        await stayerVoice.joinVoice(LOBBY_NAME);
      7. () => voiceRoomUserIds(stayerSession.page, lobbyRoomId) equals idsOf([leaver, bravoPlayer])
        await expect
        	.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
        	.toEqual(idsOf([leaver, bravoPlayer]));
    3. One leaves the lobby and is out of the call
      await test.step("One leaves the lobby and is out of the call", async () => {
      	await lobbyPage.leaveMidSet();
      
      	await expect
      		.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
      		.toEqual([bravoPlayer.id]);
      	await isNotVisible(voice.locators.leaveVoiceButton);
      });
      1. Leave mid set
        await lobbyPage.leaveMidSet();
      2. () => voiceRoomUserIds(stayerSession.page, lobbyRoomId) equals bravoPlayer.id
        await expect
        	.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
        	.toEqual([bravoPlayer.id]);
      3. leave voice button is not visible
        await isNotVisible(voice.locators.leaveVoiceButton);
Source
test("leaving the lobby ends the player's call", async ({
	page,
	factories,
	browser,
	workerBaseURL,
}) => {
	const { lobby, host, alphaPlayers, bravoPlayer } = await startedLobby(
		page,
		factories,
	);
	const leaver = alphaPlayers.find((player) => player.id !== host.id)!;
	const lobbyPage = new LobbyPage(page);
	const voice = new VoicePanel(page);
	const stayerSession = await openSecondUser(
		browser,
		workerBaseURL,
		bravoPlayer.id,
	);
	try {
		const stayerVoice = new VoicePanel(stayerSession.page);
		let lobbyRoomId = 0;

		await test.step("Two players join the lobby chat's call", async () => {
			await impersonate(page, leaver.id);
			await lobbyPage.goto(lobby.id);
			await voice.joinVoice(LOBBY_NAME);

			await new LobbyPage(stayerSession.page).goto(lobby.id);
			({ lobbyRoomId } = await lobbyChatRoomIds(stayerSession.page));
			await stayerVoice.joinVoice(LOBBY_NAME);

			await expect
				.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
				.toEqual(idsOf([leaver, bravoPlayer]));
		});

		await test.step("One leaves the lobby and is out of the call", async () => {
			await lobbyPage.leaveMidSet();

			await expect
				.poll(() => voiceRoomUserIds(stayerSession.page, lobbyRoomId))
				.toEqual([bravoPlayer.id]);
			await isNotVisible(voice.locators.leaveVoiceButton);
		});
	} finally {
		await stayerSession.close();
	}
})

a call in the team's chat ends for a player sitting out the next set

Setup
Arrange
  1. Started lobby room size 9 → { lobby, host, alphaPlayer, bravoPlayer, alphaPlayers }
    const { lobby, host, alphaPlayer, bravoPlayer, alphaPlayers } =
    	await startedLobby(page, factories, { roomSize: 9 });
  2. satOut = alphaPlayers.find( (player) => player.id !== host.id && player.id !== alphaPl…
    const satOut = alphaPlayers.find(
    	(player) => player.id !== host.id && player.id !== alphaPlayer.id,
    )!;
LOLogged out
Act
  1. Open second user browser, workerBaseURL, satOut.id → satOutSession
    const satOutSession = await openSecondUser(
    	browser,
    	workerBaseURL,
    	satOut.id,
    );
  2. Try
    try {
    	const satOutVoice = new VoicePanel(satOutSession.page);
    	let teamRoomId = 0;
    
    	await test.step("A player joins their team chat's call", async () => {
    		await new LobbyPage(satOutSession.page).goto(lobby.id);
    		teamRoomId = await teamChatRoomId(satOutSession.page);
    
    		await satOutVoice.joinVoice(TEAM_VOICE_TITLE);
    		await expect
    			.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
    			.toEqual([satOut.id]);
    	});
    
    	await test.step("The host sits them out", async () => {
    		const lobbyPage = new LobbyPage(page);
    		await impersonate(page, host.id);
    		await lobbyPage.goto(lobby.id, "leaderboard");
    		await lobbyPage.sitOut(satOut.id);
    	});
    
    	await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });
    
    	await test.step("Their call ends as the next set starts without them", async () => {
    		await expect
    			.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
    			.toEqual([]);
    		await isNotVisible(satOutVoice.locators.leaveVoiceButton);
    	});
    } finally {
    	await satOutSession.close();
    }
    1. teamRoomId = 0
      let teamRoomId = 0;
    2. A player joins their team chat's call
      await test.step("A player joins their team chat's call", async () => {
      	await new LobbyPage(satOutSession.page).goto(lobby.id);
      	teamRoomId = await teamChatRoomId(satOutSession.page);
      
      	await satOutVoice.joinVoice(TEAM_VOICE_TITLE);
      	await expect
      		.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
      		.toEqual([satOut.id]);
      });
      1. Open the lobby page lobby.id
        await new LobbyPage(satOutSession.page).goto(lobby.id);
      2. Team chat room id satOutSession.page → teamRoomId
        teamRoomId = await teamChatRoomId(satOutSession.page);
      3. Join voice “/Team (Alpha|Bravo)/”
        await satOutVoice.joinVoice(TEAM_VOICE_TITLE);
      4. () => voiceRoomUserIds(satOutSession.page, teamRoomId) equals satOut.id
        await expect
        	.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
        	.toEqual([satOut.id]);
    3. The host sits them out
      await test.step("The host sits them out", async () => {
      	const lobbyPage = new LobbyPage(page);
      	await impersonate(page, host.id);
      	await lobbyPage.goto(lobby.id, "leaderboard");
      	await lobbyPage.sitOut(satOut.id);
      });
      1. await impersonate(page, host.id);
      2. Open the lobby page lobby.id, “leaderboard”
        await lobbyPage.goto(lobby.id, "leaderboard");
      3. Sit out satOut.id
        await lobbyPage.sitOut(satOut.id);
    4. Play set lobby id lobby.id alphaPlayer bravoPlayer
      await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });
    5. Their call ends as the next set starts without them
      await test.step("Their call ends as the next set starts without them", async () => {
      	await expect
      		.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
      		.toEqual([]);
      	await isNotVisible(satOutVoice.locators.leaveVoiceButton);
      });
      1. () => voiceRoomUserIds(satOutSession.page, teamRoomId) equals
        await expect
        	.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
        	.toEqual([]);
      2. leave voice button is not visible
        await isNotVisible(satOutVoice.locators.leaveVoiceButton);
Source
test("a call in the team's chat ends for a player sitting out the next set", async ({
	page,
	factories,
	browser,
	workerBaseURL,
}) => {
	const { lobby, host, alphaPlayer, bravoPlayer, alphaPlayers } =
		await startedLobby(page, factories, { roomSize: 9 });
	const satOut = alphaPlayers.find(
		(player) => player.id !== host.id && player.id !== alphaPlayer.id,
	)!;
	const satOutSession = await openSecondUser(
		browser,
		workerBaseURL,
		satOut.id,
	);
	try {
		const satOutVoice = new VoicePanel(satOutSession.page);
		let teamRoomId = 0;

		await test.step("A player joins their team chat's call", async () => {
			await new LobbyPage(satOutSession.page).goto(lobby.id);
			teamRoomId = await teamChatRoomId(satOutSession.page);

			await satOutVoice.joinVoice(TEAM_VOICE_TITLE);
			await expect
				.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
				.toEqual([satOut.id]);
		});

		await test.step("The host sits them out", async () => {
			const lobbyPage = new LobbyPage(page);
			await impersonate(page, host.id);
			await lobbyPage.goto(lobby.id, "leaderboard");
			await lobbyPage.sitOut(satOut.id);
		});

		await playSet(page, { lobbyId: lobby.id, alphaPlayer, bravoPlayer });

		await test.step("Their call ends as the next set starts without them", async () => {
			await expect
				.poll(() => voiceRoomUserIds(satOutSession.page, teamRoomId))
				.toEqual([]);
			await isNotVisible(satOutVoice.locators.leaveVoiceButton);
		});
	} finally {
		await satOutSession.close();
	}
})

Closing

A started lobby closes on its own after 2 hours waiting for players or 2 hours without a map reported, moving to the Ended tab of its players' lobby list. It also ends when everyone has left after the start.

a lobby waiting for players for 2 hours closes

Setup
Arrange
  1. Create ROOM_SIZE - 1 × user → [host, ...others]
    const [host, ...others] = await factories.UserFactory.createMany(
    	ROOM_SIZE - 1,
    );
  2. Create lobby host user id host.id name “Test 8s” starts at dateToDatabaseTimestamp(subHours(new Date(), 3)) pending since dateToDatabaseTimestamp( subMinutes(new Date(), 2 * 60 + 1), ) signed up user ids others.map((user) => user.id) checked in user ids [host, ...others].map((user) => user.id)
    await factories.LobbyFactory.create(
    	{
    		hostUserId: host.id,
    		name: LOBBY_NAME,
    		startsAt: dateToDatabaseTimestamp(subHours(new Date(), 3)),
    		pendingSince: dateToDatabaseTimestamp(
    			subMinutes(new Date(), 2 * 60 + 1),
    		),
    	},
    	{
    		signedUpUserIds: others.map((user) => user.id),
    		checkedInUserIds: [host, ...others].map((user) => user.id),
    	},
    );
Hhost
Act
  1. Run routine “Lobbies”
    await runRoutine(page, "Lobbies");
Lobbies page
Act
  1. Open the lobbies page
    await lobbies.goto();
  2. Open tab “ended”
    await lobbies.openTab("ended");
Assert
  1. card “Test 8s” is visible
    await expect(lobbies.card(LOBBY_NAME)).toBeVisible();
Source
test("a lobby waiting for players for 2 hours closes", async ({
	page,
	factories,
}) => {
	const [host, ...others] = await factories.UserFactory.createMany(
		ROOM_SIZE - 1,
	);
	await factories.LobbyFactory.create(
		{
			hostUserId: host.id,
			name: LOBBY_NAME,
			startsAt: dateToDatabaseTimestamp(subHours(new Date(), 3)),
			pendingSince: dateToDatabaseTimestamp(
				subMinutes(new Date(), 2 * 60 + 1),
			),
		},
		{
			signedUpUserIds: others.map((user) => user.id),
			checkedInUserIds: [host, ...others].map((user) => user.id),
		},
	);

	await impersonate(page, host.id);
	await runRoutine(page, "Lobbies");

	const lobbies = new LobbiesPage(page);
	await lobbies.goto();
	await lobbies.openTab("ended");

	await expect(lobbies.card(LOBBY_NAME)).toBeVisible();
})

a set without a map reported for 2 hours closes the lobby

Setup
Arrange
  1. Started lobby → { lobby, alphaPlayer }
    const { lobby, alphaPlayer } = await startedLobby(page, factories);
  2. Backdate sets lobby lobby.id subMinutes(new Date(), 2 * 60 + 1)
    await factories.LobbyFactory.backdateSets(
    	lobby.id,
    	subMinutes(new Date(), 2 * 60 + 1),
    );
APalpha player
Act
  1. Run routine “Lobbies”
    await runRoutine(page, "Lobbies");
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Assert
  1. ended status is visible
    await expect(lobbyPage.locators.endedStatus).toBeVisible();
Source
test("a set without a map reported for 2 hours closes the lobby", async ({
	page,
	factories,
}) => {
	const { lobby, alphaPlayer } = await startedLobby(page, factories);
	await factories.LobbyFactory.backdateSets(
		lobby.id,
		subMinutes(new Date(), 2 * 60 + 1),
	);

	await impersonate(page, alphaPlayer.id);
	await runRoutine(page, "Lobbies");

	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);

	await expect(lobbyPage.locators.endedStatus).toBeVisible();
})

a lobby everyone left before its start is deleted

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create lobby host user id host.id → lobby
    const lobby = await factories.LobbyFactory.create({
    	hostUserId: host.id,
    });

1The host, the only one in it, leaves and lands on the lobby list

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Leave
    await lobbyPage.leave();
Assert
  1. the page URL is lobbiesPage()
    await expect(page).toHaveURL(lobbiesPage());

2The lobby is gone

Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
Error page
Assert
  1. not found heading is visible
    await expect(
    	new ErrorPage(page).locators.notFoundHeading,
    ).toBeVisible();
Source
test("a lobby everyone left before its start is deleted", async ({
	page,
	factories,
}) => {
	const host = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create({
		hostUserId: host.id,
	});
	const lobbyPage = new LobbyPage(page);

	await test.step("The host, the only one in it, leaves and lands on the lobby list", async () => {
		await impersonate(page, host.id);
		await lobbyPage.goto(lobby.id);
		await lobbyPage.leave();

		await expect(page).toHaveURL(lobbiesPage());
	});

	await test.step("The lobby is gone", async () => {
		await lobbyPage.goto(lobby.id);

		await expect(
			new ErrorPage(page).locators.notFoundHeading,
		).toBeVisible();
	});
})

a started lobby everyone left ends

Setup
Arrange
  1. Create user → host
    const host = await factories.UserFactory.create();
  2. Create lobby host user id host.id starts at dateToDatabaseTimestamp(subMinutes(new Date(), 1)) checked in user ids host.id → lobby
    const lobby = await factories.LobbyFactory.create(
    	{
    		hostUserId: host.id,
    		startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 1)),
    	},
    	{ checkedInUserIds: [host.id] },
    );
Hhost
Lobby page
Act
  1. Open the lobby page lobby.id
    await lobbyPage.goto(lobby.id);
  2. Leave
    await lobbyPage.leave();
Assert
  1. ended status is visible
    await expect(lobbyPage.locators.endedStatus).toBeVisible();
Source
test("a started lobby everyone left ends", async ({ page, factories }) => {
	const host = await factories.UserFactory.create();
	const lobby = await factories.LobbyFactory.create(
		{
			hostUserId: host.id,
			startsAt: dateToDatabaseTimestamp(subMinutes(new Date(), 1)),
		},
		{ checkedInUserIds: [host.id] },
	);

	await impersonate(page, host.id);
	const lobbyPage = new LobbyPage(page);
	await lobbyPage.goto(lobby.id);
	await lobbyPage.leave();

	await expect(lobbyPage.locators.endedStatus).toBeVisible();
})