From b4a22820e7a868429d25b2c0c75582eb25bf2154 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Fri, 18 Apr 2025 23:48:08 +0200 Subject: [PATCH 1/2] tests are not using magic values as well... --- frontend/tests/cox.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/tests/cox.spec.ts b/frontend/tests/cox.spec.ts index 3ef645e..74cb6f6 100644 --- a/frontend/tests/cox.spec.ts +++ b/frontend/tests/cox.spec.ts @@ -126,9 +126,7 @@ test.describe("cox can edit trips", () => { await expect(sharedPage.locator("#sidebar")).toContainText( "Freie Plätze: 3", ); - await sharedPage.getByRole("spinbutton").click(); - await sharedPage.getByRole("spinbutton").fill("0"); - await sharedPage.getByRole("button", { name: "Speichern" }).click(); + await sharedPage.getByRole("button", { name: "Ausfahrt absagen" }).click(); await expect(sharedPage.locator("body")).toContainText( "Ausfahrt erfolgreich aktualisiert.", ); -- 2.47.2 From 9b31ea981ad63ea7a774f13f5f102a5a5262a356 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Sat, 19 Apr 2025 00:21:51 +0200 Subject: [PATCH 2/2] hack in frontend test not working, as we can' hack a cancellation with setting rowers=0 --- frontend/tests/cox.spec.ts | 59 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/frontend/tests/cox.spec.ts b/frontend/tests/cox.spec.ts index 74cb6f6..89da881 100644 --- a/frontend/tests/cox.spec.ts +++ b/frontend/tests/cox.spec.ts @@ -121,16 +121,69 @@ test.describe("cox can edit trips", () => { }); test("call off trip", async () => { + // Someone registers... + await sharedPage.goto("/auth/logout"); + await sharedPage.goto("/auth"); + await sharedPage.getByPlaceholder("Name").click(); + await sharedPage.getByPlaceholder("Name").fill("rower"); + await sharedPage.getByPlaceholder("Name").press("Tab"); + await sharedPage.getByPlaceholder("Passwort").fill("rower"); + await sharedPage.getByPlaceholder("Passwort").press("Enter"); + await sharedPage.goto("/planned"); + await sharedPage.getByRole('link', { name: 'Mitrudern' }).nth(1).click(); + + + // Login as cox again + await sharedPage.goto("/auth/logout"); + await sharedPage.goto("/auth"); + await sharedPage.getByPlaceholder("Name").click(); + await sharedPage.getByPlaceholder("Name").fill("cox"); + await sharedPage.getByPlaceholder("Name").press("Tab"); + await sharedPage.getByPlaceholder("Passwort").fill("cox"); + await sharedPage.getByPlaceholder("Passwort").press("Enter"); + + await sharedPage.goto("/planned"); + + + // ... now I can cancel trip await sharedPage.getByRole("link", { name: "Details" }).nth(1).click(); - await expect(sharedPage.locator("#sidebar")).toContainText( - "Freie Plätze: 3", - ); await sharedPage.getByRole("button", { name: "Ausfahrt absagen" }).click(); await expect(sharedPage.locator("body")).toContainText( "Ausfahrt erfolgreich aktualisiert.", ); await expect(sharedPage.locator("body")).toContainText("(Absage cox)"); + + + // Done with the test -> cancel the cancellation of the trip, otherwise the afterAll function below fails + await sharedPage.getByRole("link", { name: "Details" }).nth(1).click(); + await sharedPage.getByRole("spinbutton").click(); + await sharedPage.getByRole("spinbutton").fill("3"); + await sharedPage.getByRole("button", { name: "Speichern" }).click(); + + + + // deregistering + await sharedPage.goto("/auth/logout"); + await sharedPage.goto("/auth"); + await sharedPage.getByPlaceholder("Name").click(); + await sharedPage.getByPlaceholder("Name").fill("rower"); + await sharedPage.getByPlaceholder("Name").press("Tab"); + await sharedPage.getByPlaceholder("Passwort").fill("rower"); + await sharedPage.getByPlaceholder("Passwort").press("Enter"); + + await sharedPage.goto("/planned"); + await sharedPage.getByRole('link', { name: 'Abmelden' }).click(); + + + // now cox can delete trip again in afterAll + await sharedPage.goto("/auth/logout"); + await sharedPage.goto("/auth"); + await sharedPage.getByPlaceholder("Name").click(); + await sharedPage.getByPlaceholder("Name").fill("cox"); + await sharedPage.getByPlaceholder("Name").press("Tab"); + await sharedPage.getByPlaceholder("Passwort").fill("cox"); + await sharedPage.getByPlaceholder("Passwort").press("Enter"); }); test.afterAll(async () => { -- 2.47.2