From e0b6f90500d71d31a885ee914bb7d9e95dbfe929 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 7 Mar 2024 18:31:02 +0200 Subject: [PATCH] Fix not being able to undo score in round robin --- app/features/sendouq/q-schemas.server.ts | 10 ++-- app/modules/brackets-manager/reset.ts | 17 ++++--- e2e/tournament-bracket.spec.ts | 58 +++++++++++++++++++++++- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/app/features/sendouq/q-schemas.server.ts b/app/features/sendouq/q-schemas.server.ts index f400490b1..eb60f35d3 100644 --- a/app/features/sendouq/q-schemas.server.ts +++ b/app/features/sendouq/q-schemas.server.ts @@ -26,12 +26,10 @@ export const frontPageSchema = z.union([ }), z.object({ _action: _action("ADD_FRIEND_CODE"), - friendCode: z - .string() - .regex(FRIEND_CODE_REGEXP, { - message: - "Invalid friend code. Did you include dashes? Example: 1234-5678-9012", - }), + friendCode: z.string().regex(FRIEND_CODE_REGEXP, { + message: + "Invalid friend code. Did you include dashes? Example: 1234-5678-9012", + }), }), ]); diff --git a/app/modules/brackets-manager/reset.ts b/app/modules/brackets-manager/reset.ts index 112aed100..dc59a3982 100644 --- a/app/modules/brackets-manager/reset.ts +++ b/app/modules/brackets-manager/reset.ts @@ -24,13 +24,16 @@ export class Reset extends BaseUpdater { stored.round_id, ); const matchLocation = helpers.getMatchLocation(stage.type, group.number); - const nextMatches = this.getNextMatches( - stored, - matchLocation, - stage, - roundNumber, - roundCount, - ); + const nextMatches = + stage.type !== "round_robin" + ? this.getNextMatches( + stored, + matchLocation, + stage, + roundNumber, + roundCount, + ) + : []; if ( nextMatches.some( diff --git a/e2e/tournament-bracket.spec.ts b/e2e/tournament-bracket.spec.ts index dd032016f..63c146283 100644 --- a/e2e/tournament-bracket.spec.ts +++ b/e2e/tournament-bracket.spec.ts @@ -339,7 +339,9 @@ test.describe("Tournament bracket", () => { await page.getByLabel("Action").selectOption("CHECK_IN"); await page.getByLabel("Team").selectOption("216"); - await page.getByLabel("Bracket").selectOption("Underground bracket"); + await page + .getByLabel("Bracket", { exact: true }) + .selectOption("Underground bracket"); await submit(page); await navigate({ @@ -391,6 +393,60 @@ test.describe("Tournament bracket", () => { ).toHaveCount(3); }); + test("reopens round robin match and changes score", async ({ page }) => { + const tournamentId = 3; + + await seed(page); + await impersonate(page); + + await navigate({ + page, + url: tournamentBracketsPage({ tournamentId }), + }); + + await page.getByTestId("finalize-bracket-button").click(); + + // set situation where match A is completed and its participants also completed their follow up matches B & C + // and then we go back and change the winner of A + await navigateToMatch(page, 8); + await reportResult({ + page, + amountOfMapsToReport: 2, + sidesWithMoreThanFourPlayers: ["first"], + points: [100, 0], + }); + await backToBracket(page); + + await navigateToMatch(page, 9); + await reportResult({ + page, + amountOfMapsToReport: 2, + sidesWithMoreThanFourPlayers: ["last"], + points: [100, 0], + }); + await backToBracket(page); + + await navigateToMatch(page, 10); + await reportResult({ + page, + amountOfMapsToReport: 2, + sidesWithMoreThanFourPlayers: ["last"], + points: [100, 0], + }); + await backToBracket(page); + + await navigateToMatch(page, 8); + await page.getByTestId("reopen-match-button").click(); + await page.getByTestId("undo-score-button").click(); + await reportResult({ + page, + amountOfMapsToReport: 2, + sidesWithMoreThanFourPlayers: ["first"], + points: [0, 100], + winner: 2, + }); + }); + test("locks/unlocks matches & sets match as casted", async ({ page }) => { const tournamentId = 2;