From eb483d9959ddfbfd93f93cffce32906ba01845df Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 4 Mar 2024 14:04:13 +0100 Subject: [PATCH] also verify logbook entry successfully created --- frontend/tests/cox.spec.ts | 2 +- frontend/tests/log.spec.ts | 81 ++++++++++++++++++++++++++++++++++++++ seeds.sql | 2 + 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/frontend/tests/cox.spec.ts b/frontend/tests/cox.spec.ts index 54f8f1f..c66783f 100644 --- a/frontend/tests/cox.spec.ts +++ b/frontend/tests/cox.spec.ts @@ -15,7 +15,7 @@ test("cox can create and delete trip", async ({ page }) => { await page.locator("#sidebar #planned_starting_time").press("Tab"); await page.getByRole("spinbutton").fill("5"); await page.getByRole("button", { name: "Erstellen", exact: true }).click(); - await expect(page.locator("body")).toContainText("18:00 Uhr (cox) Details"); + await expect(page.locator("body")).toContainText("18:00 Uhr (cox ) Details"); await page.goto("http://localhost:8000/planned"); await page.getByRole("link", { name: "Details" }).click(); diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index e1ceb39..ca9057c 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -82,4 +82,85 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await expect(page.locator("body")).toContainText( "Ausfahrt korrekt eingetragen", ); + + await page.goto('http://localhost:8000/log/show'); + await expect(page.locator('body')).toContainText('Joe'); + await expect(page.locator('body')).toContainText('(cox2 )'); + await expect(page.locator('body')).toContainText('Ottensheim (25 km)'); + await expect(page.locator('body')).toContainText('Ruderer: rower2'); +}); + +test("Kiosk can start and cancel trip", async ({ page }, testInfo) => { + await page.goto("http://localhost:8000/log/kiosk/ekrv2019/Linz"); + if (testInfo.project.name.includes("Mobile")) { + // No left boat selector on mobile views + await page.getByText("Kaputtes Boot :-( (7 x)").nth(1).click(); + await page.getByRole("option", { name: "Joe" }).click(); + } else { + await page.getByText("Joe", { exact: true }).click(); + } + await page.getByPlaceholder("Ruderer auswählen").click(); + await page.getByRole("option", { name: "rower2" }).click(); + await page.getByRole("option", { name: "cox2" }).click(); + await expect(page.getByRole("listbox")).toContainText( + "Nur 2 Ruderer können hinzugefügt werden", + ); + await expect(page.locator("#shipmaster-newrowerjs")).toContainText("cox"); + await expect(page.locator("#steering_person-newrowerjs")).toContainText( + "rower2 cox", + ); + await page.getByRole("button", { name: "Ausfahrt eintragen" }).click(); + await expect(page.locator("body")).toContainText( + "Ausfahrt erfolgreich hinzugefügt", + ); + await expect(page.locator("body")).toContainText("Joe"); + + await page.getByRole("link", { name: "Joe" }).click(); + page.once("dialog", (dialog) => { + dialog.accept().catch(() => {}); + }); + await page.getByRole("link", { name: "Löschen" }).click(); +}); + +test("Kiosk can start and finish trip", async ({ page }, testInfo) => { + await page.goto("http://localhost:8000/log/kiosk/ekrv2019/Linz"); + + if (testInfo.project.name.includes("Mobile")) { + // No left boat selector on mobile views + await page.getByText("Kaputtes Boot :-( (7 x)").nth(1).click(); + await page.getByRole("option", { name: "Joe" }).click(); + } else { + await page.getByText("Joe", { exact: true }).click(); + } + await page.getByPlaceholder("Ruderer auswählen").click(); + await page.getByRole("option", { name: "rower2" }).click(); + await page.getByRole("option", { name: "cox2" }).click(); + await expect(page.getByRole("listbox")).toContainText( + "Nur 2 Ruderer können hinzugefügt werden", + ); + await expect(page.locator("#shipmaster-newrowerjs")).toContainText("cox"); + await expect(page.locator("#steering_person-newrowerjs")).toContainText( + "rower2 cox", + ); + await page.getByRole("button", { name: "Ausfahrt eintragen" }).click(); + await expect(page.locator("body")).toContainText( + "Ausfahrt erfolgreich hinzugefügt", + ); + await expect(page.locator("body")).toContainText("Joe"); + + await page.goto("http://localhost:8000/log"); + await page.waitForTimeout(60000); + await page.locator("div:nth-child(2) > .border-0").click(); + await page.getByRole("combobox", { name: "Destination" }).click(); + await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); + await page.getByRole("button", { name: "Ausfahrt beenden" }).click(); + await expect(page.locator("body")).toContainText( + "Ausfahrt korrekt eingetragen", + ); + + await page.getByRole('link', { name: 'Logbuch' }).click(); + await expect(page.locator('body')).toContainText('Joe'); + await expect(page.locator('body')).toContainText('(cox2 )'); + await expect(page.locator('body')).toContainText('Ottensheim (25 km)'); + await expect(page.locator('body')).toContainText('Ruderer: rower2'); }); diff --git a/seeds.sql b/seeds.sql index 7999357..1fef9af 100644 --- a/seeds.sql +++ b/seeds.sql @@ -5,6 +5,7 @@ INSERT INTO "role" (name) VALUES ('tech'); INSERT INTO "role" (name) VALUES ('Donau Linz'); INSERT INTO "role" (name) VALUES ('planned_event'); INSERT INTO "role" (name) VALUES ('Rennrudern'); +INSERT INTO "role" (name) VALUES ('paid'); INSERT INTO "user" (name, pw) VALUES('admin', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$4P4NCw4Ukhv80/eQYTsarHhnw61JuL1KMx/L9dm82YM'); INSERT INTO "user_role" (user_id, role_id) VALUES(1,1); INSERT INTO "user_role" (user_id, role_id) VALUES(1,2); @@ -18,6 +19,7 @@ INSERT INTO "user_role" (user_id, role_id) VALUES(3,3); INSERT INTO "user" (name, pw) VALUES('cox', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$lnWzHx3DdqS9GQyWYel82kIotZuK2wk9EyfhPFtjNzs'); INSERT INTO "user_role" (user_id, role_id) VALUES(4,5); INSERT INTO "user_role" (user_id, role_id) VALUES(4,2); +INSERT INTO "user_role" (user_id, role_id) VALUES(4,8); INSERT INTO "user" (name) VALUES('new'); INSERT INTO "user_role" (user_id, role_id) VALUES(5,5); INSERT INTO "user" (name, pw) VALUES('cox2', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$lnWzHx3DdqS9GQyWYel82kIotZuK2wk9EyfhPFtjNzs');