Tournament LFG player adds their own sub post and deletes it Renders/to/:id /to/:id/looking
Tournament subs page Arrange
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 ))],
});Create user discord name “Subby Sam” → sub
const sub = await factories.UserFactory .create ({
discordName: SUB_NAME ,
});Tournament subs page Act
Open the tournament subs page tournament.id
await subs.goto (tournament.id);Assert
no posts text is visible
await expect (subs.locators.noPostsText).toBeVisible ();Act
Open add post dialog
await subs.openAddPostDialog ();Assert
add post dialog heading is visible
await expect (subs.locators.addPostDialogHeading).toBeVisible ();Act
Fill message with “Free after 8pm”
await subs.addSubForm.fill ("message" , SUB_MESSAGE );Submit
await subs.addSubForm.submit ();Assert
sub post text “Subby Sam” is visible
await expect (subs.subPostText (SUB_NAME )).toBeVisible ();sub post text “Free after 8pm” is visible
await expect (subs.subPostText (SUB_MESSAGE )).toBeVisible ();a second post by the same user is not offered
add post button is not visible
await isNotVisible (subs.locators.addPostButton);Act
Delete own post
await subs.deleteOwnPost ();Assert
no posts text is visible
await expect (subs.locators.noPostsText).toBeVisible ();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
Tournament looking page Arrange
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 ))],
});Create user discord name “Subby Sam” → sub
const sub = await factories.UserFactory .create ({
discordName: SUB_NAME ,
});Tournament looking page Act
Open the tournament looking page tournament.id
await looking.goto (tournament.id);Submit
await looking.joinQueueForm.submit ();Assert
stay as sub switch is not checked
await expect (looking.locators.stayAsSubSwitch).not.toBeChecked ();Act
Toggle stay as sub
await looking.toggleStayAsSub ();Open the tournament looking page tournament.id
await looking.goto (tournament.id);Assert
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
Tournament subs page Arrange
Create tournament author Sendou start times startedTournamentTimes () → tournament
const tournament = await factories.TournamentFactory .create ({
authorId: ADMIN_ID ,
startTimes: startedTournamentTimes (),
});Create teams tournament.id, teamSeeds (2 )
await createTeams (factories, tournament.id, teamSeeds (2 ));Create user discord name “Subby Sam” → stayingSub
const stayingSub = await factories.UserFactory .create ({
discordName: SUB_NAME ,
});Create user discord name “Leaving Lee” → notStayingPlayer
const notStayingPlayer = await factories.UserFactory .create ({
discordName: NOT_STAYING_NAME ,
});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 ,
});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 ,
});Start bracket tournament tournament.id
await factories.TournamentFactory .startBracket (tournament.id);Tournament subs page Act
Open the tournament subs page tournament.id
await subs.goto (tournament.id);Assert
sub post text “Subby Sam” is visible
await expect (subs.subPostText (SUB_NAME )).toBeVisible ();sub post text “Leaving Lee” is not visible
await isNotVisible (subs.subPostText (NOT_STAYING_NAME ));Act
Delete own post
await subs.deleteOwnPost ();Assert
no posts text is visible
await expect (subs.locators.noPostsText).toBeVisible ();Act
Open add post dialog
await subs.openAddPostDialog ();Fill message with “Free after 8pm”
await subs.addSubForm.fill ("message" , SUB_MESSAGE );Submit
await subs.addSubForm.submit ();Assert
sub post text “Subby Sam” is visible
await expect (subs.subPostText (SUB_NAME )).toBeVisible ();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 ();
})TournamentSubsPage.gotoe2e/pages/tournament/tournament-subs-page.ts:27
No JSDoc
async goto (tournamentId: number ) {
await navigate ({ page: this .page, url: tournamentSubsPage (tournamentId) });
}TournamentSubsPage.locators.noPostsTexte2e/pages/tournament/tournament-subs-page.ts:23
No JSDoc
page.getByText ("No subs available" ) TournamentSubsPage.openAddPostDialoge2e/pages/tournament/tournament-subs-page.ts:40
No JSDoc
openAddPostDialog () {
return this .locators.addPostButton.click ();
}TournamentSubsPage.locators.addPostDialogHeadinge2e/pages/tournament/tournament-subs-page.ts:20
No JSDoc
page.getByRole ("heading" , {
name: "Add yourself as sub" ,
}) addSubFormSchema.messageapp/features/tournament-lfg/tournament-lfg-schemas.ts:17
No JSDoc
message: noteFieldSchema TournamentSubsPage.subPostTexte2e/pages/tournament/tournament-subs-page.ts:31
No JSDoc
subPostText (text: string ) {
// the poster's name is also in the side nav (as the logged in user) and
// in the closed mobile "You" panel
return this .page
.getByRole ("main" )
.getByText (text)
.filter ({ visible: true });
}TournamentSubsPage.locators.addPostButtone2e/pages/tournament/tournament-subs-page.ts:17
No JSDoc
page.getByRole ("button" , {
name: "Add yourself as sub" ,
}) isNotVisiblee2e/helpers/playwright.ts:745
No JSDoc
export function isNotVisible (locator: Locator ) {
return expect (locator).toHaveCount (0 );
}TournamentSubsPage.deleteOwnPoste2e/pages/tournament/tournament-subs-page.ts:44
No JSDoc
async deleteOwnPost () {
await this .page.getByRole ("button" , { name: "Delete" }).click ();
await modalClickConfirmButton (this .page);
}TournamentSubsPagee2e/pages/tournament/tournament-subs-page.ts:8
TournamentLookingPage.gotoe2e/pages/tournament/tournament-looking-page.ts:23
No JSDoc
goto (tournamentId: number ) {
return navigate ({ page: this .page, url: tournamentSubsPage (tournamentId) });
}TournamentLookingPage.locators.stayAsSubSwitche2e/pages/tournament/tournament-looking-page.ts:19
No JSDoc
this .stayAsSubSwitchLabel.getByRole ("switch" )TournamentLookingPage.toggleStayAsSube2e/pages/tournament/tournament-looking-page.ts:27
No JSDoc
toggleStayAsSub () {
return waitForPOSTResponse (this .page, () =>
// the switch input itself is visually hidden behind its indicator
this .stayAsSubSwitchLabel.click (),
);
}TournamentLookingPagee2e/pages/tournament/tournament-looking-page.ts:8
createTeamse2e/helpers/tournament.ts:232
export async function createTeams (
factories: Factories ,
tournamentId: number ,
seeds: TeamSeed [],
) {
const teams: Awaited <
ReturnType <typeof factories.TournamentTeamFactory .create>
>[] = [];
for (const [i, seed] of seeds.entries ()) {
const presetMembers = seed.members ?? [];
const rosterSize = seed.rosterSize ?? ROSTER_SIZE ;
const fillerUsers = await factories.UserFactory .createMany (
rosterSize - presetMembers.length,
);
// …