import { STAFF_TEST_ID } from "~/db/seed/constants"; import { ADMIN_DISCORD_ID } from "~/features/admin/admin-constants"; import { tournamentAdminPage, tournamentAdminRegistrationEditPage, tournamentAdminRegistrationPage, } from "~/utils/urls"; import { expect, impersonate, modalClickConfirmButton, navigate, seed, selectTournament, selectUser, submit, test, waitForPOSTResponse, } from "./helpers/playwright"; const TOURNAMENT_ID = 1; const auditPage = `${tournamentAdminPage(TOURNAMENT_ID)}/audit`; test.describe("Tournament admin team management", () => { test("edits a registration, checks a team in and out, unregisters it and records it in the audit log", async ({ page, }) => { await seed(page); await impersonate(page); // --- Edit registration: rename the first team --- await navigate({ page, url: tournamentAdminRegistrationEditPage(TOURNAMENT_ID, 1), }); await expect( page.getByRole("heading", { name: "Edit registration" }), ).toBeVisible(); await page.getByLabel("Team name").fill("Renamed Team"); await submit(page); // back on the team list, the rename is reflected await expect(page.getByLabel("Search teams")).toBeVisible(); await expect( page.getByTestId("team-name").filter({ hasText: "Renamed Team" }), ).toBeVisible(); const firstRowActions = page .getByTestId("team-row") .first() .getByLabel("Actions"); // --- Check the team in (fetcher JSON submit fired from the menu) --- await firstRowActions.click(); await waitForPOSTResponse(page, async () => { await page.getByRole("menuitem", { name: /^Check in/ }).click(); }); // --- Check the team out --- await firstRowActions.click(); await waitForPOSTResponse(page, async () => { await page.getByRole("menuitem", { name: /^Check out/ }).click(); }); // --- Unregister the team (confirm dialog) --- await firstRowActions.click(); await page.getByRole("menuitem", { name: "Unregister" }).click(); await expect( page.getByRole("heading", { name: /Unregister .* and delete its registration info\?/, }), ).toBeVisible(); await modalClickConfirmButton(page); // --- Audit log records the actions (target table cells, not the // event-filter