Skip to content

Tournament lfg · E2E tests

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

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

Tournament LFG

player adds their own sub post and deletes it

Renders/to/:id/to/:id/looking

Setup
Arrange
  1. registration is closed (start time in the past) so the subs view is shown

    Create tournament author Sendou start times dateToDatabaseTimestamp(subDays(new Date(), 1)) → tournament
    const tournament = await factories.TournamentFactory.create({
    	authorId: ADMIN_ID,
    	startTimes: [dateToDatabaseTimestamp(subDays(new Date(), 1))],
    });
  2. Create user discord name “Subby Sam” → sub
    const sub = await factories.UserFactory.create({
    	discordName: SUB_NAME,
    });
Ssub
Tournament subs page
Act
  1. Open the tournament subs page tournament.id
    await subs.goto(tournament.id);
Assert
  1. no posts text is visible
    await expect(subs.locators.noPostsText).toBeVisible();
Act
  1. Open add post dialog
    await subs.openAddPostDialog();
Assert
  1. add post dialog heading is visible
    await expect(subs.locators.addPostDialogHeading).toBeVisible();
Act
  1. Fill message with “Free after 8pm”
    await subs.addSubForm.fill("message", SUB_MESSAGE);
  2. Submit
    await subs.addSubForm.submit();
Assert
  1. sub post text “Subby Sam” is visible
    await expect(subs.subPostText(SUB_NAME)).toBeVisible();
  2. sub post text “Free after 8pm” is visible
    await expect(subs.subPostText(SUB_MESSAGE)).toBeVisible();
  3. a second post by the same user is not offered

    add post button is not visible
    await isNotVisible(subs.locators.addPostButton);
Act
  1. Delete own post
    await subs.deleteOwnPost();
Assert
  1. no posts text is visible
    await expect(subs.locators.noPostsText).toBeVisible();
  2. add post button is visible
    await expect(subs.locators.addPostButton).toBeVisible();
Source
test("player adds their own sub post and deletes it", async ({
	page,
	factories,
}) => {
	// registration is closed (start time in the past) so the subs view is shown
	const tournament = await factories.TournamentFactory.create({
		authorId: ADMIN_ID,
		startTimes: [dateToDatabaseTimestamp(subDays(new Date(), 1))],
	});
	const sub = await factories.UserFactory.create({
		discordName: SUB_NAME,
	});

	await impersonate(page, sub.id);

	const subs = new TournamentSubsPage(page);
	await subs.goto(tournament.id);

	await expect(subs.locators.noPostsText).toBeVisible();

	await subs.openAddPostDialog();
	await expect(subs.locators.addPostDialogHeading).toBeVisible();

	await subs.addSubForm.fill("message", SUB_MESSAGE);
	await subs.addSubForm.submit();

	await expect(subs.subPostText(SUB_NAME)).toBeVisible();
	await expect(subs.subPostText(SUB_MESSAGE)).toBeVisible();
	// a second post by the same user is not offered
	await isNotVisible(subs.locators.addPostButton);

	await subs.deleteOwnPost();

	await expect(subs.locators.noPostsText).toBeVisible();
	await expect(subs.locators.addPostButton).toBeVisible();
})

player changes their sub preference without leaving the queue

Renders/to/:id/to/:id/looking

Setup
Arrange
  1. registration is open (start time in the future) so the groups view is shown

    Create tournament author Sendou start times dateToDatabaseTimestamp(addDays(new Date(), 1)) → tournament
    const tournament = await factories.TournamentFactory.create({
    	authorId: ADMIN_ID,
    	startTimes: [dateToDatabaseTimestamp(addDays(new Date(), 1))],
    });
  2. Create user discord name “Subby Sam” → sub
    const sub = await factories.UserFactory.create({
    	discordName: SUB_NAME,
    });
Ssub
Tournament looking page
Act
  1. Open the tournament looking page tournament.id
    await looking.goto(tournament.id);
  2. Submit
    await looking.joinQueueForm.submit();
Assert
  1. stay as sub switch is not checked
    await expect(looking.locators.stayAsSubSwitch).not.toBeChecked();
Act
  1. Toggle stay as sub
    await looking.toggleStayAsSub();
  2. Open the tournament looking page tournament.id
    await looking.goto(tournament.id);
Assert
  1. stay as sub switch is checked
    await expect(looking.locators.stayAsSubSwitch).toBeChecked();
Source
test("player changes their sub preference without leaving the queue", async ({
	page,
	factories,
}) => {
	// registration is open (start time in the future) so the groups view is shown
	const tournament = await factories.TournamentFactory.create({
		authorId: ADMIN_ID,
		startTimes: [dateToDatabaseTimestamp(addDays(new Date(), 1))],
	});
	const sub = await factories.UserFactory.create({
		discordName: SUB_NAME,
	});

	await impersonate(page, sub.id);

	const looking = new TournamentLookingPage(page);
	await looking.goto(tournament.id);

	await looking.joinQueueForm.submit();

	await expect(looking.locators.stayAsSubSwitch).not.toBeChecked();

	await looking.toggleStayAsSub();

	await looking.goto(tournament.id);
	await expect(looking.locators.stayAsSubSwitch).toBeChecked();
})

player who preferred to stay as sub keeps their post once the tournament starts and can replace it

Renders/to/:id/to/:id/looking

Setup
Arrange
  1. Create tournament author Sendou start times startedTournamentTimes() → tournament
    const tournament = await factories.TournamentFactory.create({
    	authorId: ADMIN_ID,
    	startTimes: startedTournamentTimes(),
    });
  2. Create teams tournament.id, teamSeeds(2)
    await createTeams(factories, tournament.id, teamSeeds(2));
  3. Create user discord name “Subby Sam” → stayingSub
    const stayingSub = await factories.UserFactory.create({
    	discordName: SUB_NAME,
    });
  4. Create user discord name “Leaving Lee” → notStayingPlayer
    const notStayingPlayer = await factories.UserFactory.create({
    	discordName: NOT_STAYING_NAME,
    });
  5. Create tournament LFG team tournament id tournament.id user id stayingSub.id is stay as sub true
    await factories.TournamentLFGTeamFactory.create({
    	tournamentId: tournament.id,
    	userId: stayingSub.id,
    	isStayAsSub: true,
    });
  6. Create tournament LFG team tournament id tournament.id user id notStayingPlayer.id is stay as sub false
    await factories.TournamentLFGTeamFactory.create({
    	tournamentId: tournament.id,
    	userId: notStayingPlayer.id,
    	isStayAsSub: false,
    });
  7. Start bracket tournament tournament.id
    await factories.TournamentFactory.startBracket(tournament.id);
SSstaying sub
Tournament subs page
Act
  1. Open the tournament subs page tournament.id
    await subs.goto(tournament.id);
Assert
  1. sub post text “Subby Sam” is visible
    await expect(subs.subPostText(SUB_NAME)).toBeVisible();
  2. sub post text “Leaving Lee” is not visible
    await isNotVisible(subs.subPostText(NOT_STAYING_NAME));
Act
  1. Delete own post
    await subs.deleteOwnPost();
Assert
  1. no posts text is visible
    await expect(subs.locators.noPostsText).toBeVisible();
Act
  1. Open add post dialog
    await subs.openAddPostDialog();
  2. Fill message with “Free after 8pm”
    await subs.addSubForm.fill("message", SUB_MESSAGE);
  3. Submit
    await subs.addSubForm.submit();
Assert
  1. sub post text “Subby Sam” is visible
    await expect(subs.subPostText(SUB_NAME)).toBeVisible();
  2. sub post text “Free after 8pm” is visible
    await expect(subs.subPostText(SUB_MESSAGE)).toBeVisible();
Source
test("player who preferred to stay as sub keeps their post once the tournament starts and can replace it", async ({
	page,
	factories,
}) => {
	const tournament = await factories.TournamentFactory.create({
		authorId: ADMIN_ID,
		startTimes: startedTournamentTimes(),
	});
	await createTeams(factories, tournament.id, teamSeeds(2));

	const stayingSub = await factories.UserFactory.create({
		discordName: SUB_NAME,
	});
	const notStayingPlayer = await factories.UserFactory.create({
		discordName: NOT_STAYING_NAME,
	});
	await factories.TournamentLFGTeamFactory.create({
		tournamentId: tournament.id,
		userId: stayingSub.id,
		isStayAsSub: true,
	});
	await factories.TournamentLFGTeamFactory.create({
		tournamentId: tournament.id,
		userId: notStayingPlayer.id,
		isStayAsSub: false,
	});

	await factories.TournamentFactory.startBracket(tournament.id);

	await impersonate(page, stayingSub.id);

	const subs = new TournamentSubsPage(page);
	await subs.goto(tournament.id);

	await expect(subs.subPostText(SUB_NAME)).toBeVisible();
	await isNotVisible(subs.subPostText(NOT_STAYING_NAME));

	await subs.deleteOwnPost();

	await expect(subs.locators.noPostsText).toBeVisible();

	await subs.openAddPostDialog();
	await subs.addSubForm.fill("message", SUB_MESSAGE);
	await subs.addSubForm.submit();

	await expect(subs.subPostText(SUB_NAME)).toBeVisible();
	await expect(subs.subPostText(SUB_MESSAGE)).toBeVisible();
})