Groups -> SE tournament E2E test Closes #1647

This commit is contained in:
Kalle 2024-01-31 22:53:58 +02:00
parent 24f7105e0c
commit 3fdac9fddd
4 changed files with 160 additions and 11 deletions

View File

@ -114,6 +114,7 @@ export function TeamRosterInputs({
setPoints(newPoints);
}}
presentational={presentational}
testId={`points-input-${teamI + 1}`}
/>
) : null}
</div>
@ -194,10 +195,12 @@ function PointInput({
value,
onChange,
presentational,
testId,
}: {
value: number;
onChange: (newPoint: number) => void;
presentational: boolean;
testId?: string;
}) {
const id = React.useId();
@ -220,6 +223,7 @@ function PointInput({
value={value}
required
id={id}
data-testid={testId}
/>
<Label htmlFor={id} spaced={false}>
Points

View File

@ -517,6 +517,7 @@ function BracketCheckinButton({ bracketIdx }: { bracketIdx: number }) {
size="tiny"
_action="BRACKET_CHECK_IN"
state={fetcher.state}
testId="check-in-bracket-button"
>
Check-in & join the bracket
</SubmitButton>
@ -603,6 +604,7 @@ function FinalStandings({ standings }: { standings: Standing[] }) {
className="tournament-bracket__standing"
key={standing.team.id}
data-placement={standing.placement}
data-testid={`standing-${standing.placement}`}
>
<div>
<Placement placement={standing.placement} size={40} />

View File

@ -250,6 +250,7 @@ export default function TournamentAdminPage() {
to={calendarEditPage(tournament.ctx.eventId)}
size="tiny"
variant="outlined"
testId="edit-event-info-button"
>
Edit event info
</LinkButton>

View File

@ -9,6 +9,7 @@ import {
submit,
} from "~/utils/playwright";
import {
tournamentAdminPage,
tournamentBracketsPage,
tournamentPage,
userResultsPage,
@ -22,12 +23,25 @@ const navigateToMatch = async (page: Page, matchId: number) => {
}).toPass();
};
const reportResult = async (
page: Page,
amountOfMapsToReport: 1 | 2 | 4,
sidesWithMoreThanFourPlayers: ("first" | "last")[] = ["last"],
winner: 1 | 2 = 1,
) => {
const reportResult = async ({
page,
amountOfMapsToReport,
sidesWithMoreThanFourPlayers = ["last"],
winner = 1,
points,
}: {
page: Page;
amountOfMapsToReport: 1 | 2 | 3 | 4;
sidesWithMoreThanFourPlayers?: ("first" | "last")[];
winner?: 1 | 2;
points?: [number, number];
}) => {
const fillPointsInput = async () => {
if (!points) return;
await page.getByTestId("points-input-1").fill(String(points[0]));
await page.getByTestId("points-input-2").fill(String(points[1]));
};
await page.getByTestId("tab-Report score").click();
if (sidesWithMoreThanFourPlayers.includes("first")) {
@ -43,12 +57,15 @@ const reportResult = async (
await page.getByTestId("player-checkbox-3").last().click();
}
await fillPointsInput();
await page.getByTestId(`winner-radio-${winner}`).click();
await page.getByTestId("report-score-button").click();
await expect(page.getByText(winner === 1 ? "1-0" : "0-1")).toBeVisible();
if (amountOfMapsToReport >= 2) {
await page.getByTestId(`winner-radio-${winner}`).click();
await fillPointsInput();
await page.getByTestId("report-score-button").click();
if (amountOfMapsToReport === 2) {
@ -56,10 +73,21 @@ const reportResult = async (
}
}
if (amountOfMapsToReport === 3) {
await expect(page.getByText("2-0")).toBeVisible();
await page.getByTestId(`winner-radio-${winner}`).click();
await fillPointsInput();
await page.getByTestId("report-score-button").click();
await expect(page.getByTestId("report-timestamp")).toBeVisible();
}
if (amountOfMapsToReport === 4) {
await expect(page.getByText("2-0")).toBeVisible();
await page.getByTestId(`winner-radio-${winner}`).click();
await fillPointsInput();
await page.getByTestId("report-score-button").click();
await expect(page.getByText("3-0")).toBeVisible();
@ -99,7 +127,7 @@ test.describe("Tournament bracket", () => {
// 1)
await page.locator('[data-match-id="5"]').click();
await reportResult(page, tournamentId);
await reportResult({ page, amountOfMapsToReport: tournamentId });
await backToBracket(page);
// 2)
@ -109,12 +137,16 @@ test.describe("Tournament bracket", () => {
url: tournamentBracketsPage({ tournamentId }),
});
await navigateToMatch(page, 6);
await reportResult(page, 2);
await reportResult({ page, amountOfMapsToReport: 2 });
await backToBracket(page);
// 3)
await navigateToMatch(page, 18);
await reportResult(page, 1, ["first", "last"]);
await reportResult({
page,
amountOfMapsToReport: 1,
sidesWithMoreThanFourPlayers: ["first", "last"],
});
await backToBracket(page);
// 4)
@ -142,7 +174,12 @@ test.describe("Tournament bracket", () => {
await navigateToMatch(page, 5);
await page.getByTestId("undo-score-button").click();
await expectScore(page, [0, 0]);
await reportResult(page, 2, ["last"], 2);
await reportResult({
page,
amountOfMapsToReport: 2,
sidesWithMoreThanFourPlayers: ["last"],
winner: 2,
});
await backToBracket(page);
await expect(
page.locator("[data-round-id='5'] [data-participant-id='102']"),
@ -211,7 +248,11 @@ test.describe("Tournament bracket", () => {
await page.getByTestId("finalize-bracket-button").click();
await page.locator('[data-match-id="1"]').click();
await reportResult(page, 4, []);
await reportResult({
page,
amountOfMapsToReport: 4,
sidesWithMoreThanFourPlayers: [],
});
await backToBracket(page);
await page.getByTestId("finalize-tournament-button").click();
@ -224,4 +265,105 @@ test.describe("Tournament bracket", () => {
await expect(page.getByText("In The Zone 22")).toBeVisible();
});
test("completes and finalizes a small tournament (RR->SE w/ underground bracket)", async ({
page,
}) => {
const tournamentId = 3;
await seed(page);
await impersonate(page);
await navigate({
page,
url: tournamentPage(tournamentId),
});
await page.getByTestId("admin-tab").click();
await page.getByLabel("Action").selectOption("CHECK_OUT");
for (let id = 202; id < 210; id++) {
await page.getByLabel("Team").selectOption(String(id));
await submit(page);
}
await page.getByTestId("edit-event-info-button").click();
await page
.getByLabel("Amount of teams advancing per group")
.selectOption("1");
await submit(page);
await page.getByTestId("brackets-tab").click();
await page.getByTestId("finalize-bracket-button").click();
for (const id of [2, 4, 6, 7, 8, 9, 10, 11, 12]) {
await navigateToMatch(page, id);
await reportResult({
page,
amountOfMapsToReport: 2,
sidesWithMoreThanFourPlayers: ["first", "last"],
points: [100, 0],
});
await backToBracket(page);
}
// captain of one of the underground bracket teams
await impersonate(page, 52);
await navigate({
page,
url: tournamentBracketsPage({ tournamentId }),
});
await page.getByText("Underground bracket").click();
await page.getByTestId("check-in-bracket-button").click();
await impersonate(page);
await navigate({
page,
url: tournamentAdminPage(tournamentId),
});
await page.getByLabel("Action").selectOption("CHECK_IN");
await page.getByLabel("Team").selectOption("216");
await page.getByLabel("Bracket").selectOption("Underground bracket");
await submit(page);
await navigate({
page,
url: tournamentBracketsPage({ tournamentId, bracketIdx: 2 }),
});
await page.getByTestId("finalize-bracket-button").click();
await navigateToMatch(page, 13);
await reportResult({
page,
amountOfMapsToReport: 3,
sidesWithMoreThanFourPlayers: ["first", "last"],
});
await navigate({
page,
url: tournamentBracketsPage({ tournamentId, bracketIdx: 1 }),
});
await page.getByTestId("finalize-bracket-button").click();
await navigateToMatch(page, 14);
await reportResult({
page,
amountOfMapsToReport: 3,
sidesWithMoreThanFourPlayers: ["first", "last"],
});
await backToBracket(page);
await page.getByTestId("finalize-tournament-button").click();
await page.getByTestId("confirm-button").click();
await expect(page.getByTestId("standing-1")).toBeVisible();
await isNotVisible(page.getByTestId("standing-3"));
await navigateToMatch(page, 14);
await isNotVisible(page.getByTestId("reopen-match-button"));
});
});