From 5782a36b6933eb2357c2572d11ad84d18efaf8a5 Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 19 Aug 2024 16:11:03 +0200 Subject: [PATCH] fix tests, they used to rely on boat travelling multiple times at the same time... --- frontend/tests/log.spec.ts | 93 +++++++++++++++++++++++++++++++++++++- seeds.sql | 2 + 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index d2789c5..dad2e03 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -102,6 +102,28 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await expect(page.locator('body')).toContainText('(cox2)'); await expect(page.locator('body')).toContainText('Ottensheim (25 km)'); await expect(page.locator('body')).toContainText('Ruderer: cox2, rower2'); + + + //Ausloggen... + await page.getByRole('banner').getByRole('link', { name: 'Logbuch' }).click(); + await page.getByRole('link', { name: 'Ausloggen' }).click(); + // Login as admin + await page.getByPlaceholder("Name").click(); + await page.getByPlaceholder("Name").fill("admin"); + await page.getByPlaceholder("Name").press("Tab"); + await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").press("Enter"); + + await page.goto("/log/show"); + await page.getByText('(cox2)').click(); + page.once("dialog", (dialog) => { + dialog.accept().catch(() => {}); + }); + await page.getByRole('link', { name: 'Löschen' }).click(); + + //Ausloggen... + await page.getByRole('banner').getByRole('link', { name: 'Logbuch' }).click(); + await page.getByRole('link', { name: 'Ausloggen' }).click(); }); test("Kiosk can start and cancel trip", async ({ page }, testInfo) => { @@ -189,6 +211,29 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { await expect(page.locator('body')).toContainText('(cox2)'); await expect(page.locator('body')).toContainText('Ottensheim (25 km)'); await expect(page.locator('body')).toContainText('Ruderer: cox2, rower2'); + + + + //Ausloggen... + await page.context().clearCookies(); + await page.goto("/auth"); + // Login as admin + await page.getByPlaceholder("Name").click(); + await page.getByPlaceholder("Name").fill("admin"); + await page.getByPlaceholder("Name").press("Tab"); + await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").press("Enter"); + + await page.goto("/log/show"); + await page.getByText('(cox2)').click(); + page.once("dialog", (dialog) => { + dialog.accept().catch(() => {}); + }); + await page.getByRole('link', { name: 'Löschen' }).click(); + + //Ausloggen... + await page.getByRole('banner').getByRole('link', { name: 'Logbuch' }).click(); + await page.getByRole('link', { name: 'Ausloggen' }).click(); }); test("Cox can start and finish trip with cox steering only", async ({ page }, testInfo) => { @@ -241,8 +286,31 @@ test("Cox can start and finish trip with cox steering only", async ({ page }, te await page.goto('/log/show'); await expect(page.locator('body')).toContainText('cox_only_steering_boat'); - await expect(page.locator('body')).toContainText('(cox2)'); + await expect(page.locator('body')).toContainText('(cox2 - handgesteuert)'); await expect(page.locator('body')).toContainText('Ottensheim (25 km)'); + + + + //Ausloggen... + await page.getByRole('banner').getByRole('link', { name: 'Logbuch' }).click(); + await page.getByRole('link', { name: 'Ausloggen' }).click(); + // Login as admin + await page.getByPlaceholder("Name").click(); + await page.getByPlaceholder("Name").fill("admin"); + await page.getByPlaceholder("Name").press("Tab"); + await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").press("Enter"); + + await page.goto("/log/show"); + await page.getByText('(cox2 - handgesteuert)').click(); + page.once("dialog", (dialog) => { + dialog.accept().catch(() => {}); + }); + await page.getByRole('link', { name: 'Löschen' }).click(); + + //Ausloggen... + await page.getByRole('banner').getByRole('link', { name: 'Logbuch' }).click(); + await page.getByRole('link', { name: 'Ausloggen' }).click(); }); test("Kiosk can start and finish trip in one stop", async ({ page }, testInfo) => { @@ -289,4 +357,27 @@ test("Kiosk can start and finish trip in one stop", async ({ page }, testInfo) = await expect(page.locator('body')).toContainText('(cox2)'); await expect(page.locator('body')).toContainText('a (1 km)'); await expect(page.locator('body')).toContainText('Ruderer: cox2, rower2'); + + + + //Ausloggen... + await page.context().clearCookies(); + await page.goto("/auth"); + // Login as admin + await page.getByPlaceholder("Name").click(); + await page.getByPlaceholder("Name").fill("admin"); + await page.getByPlaceholder("Name").press("Tab"); + await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").press("Enter"); + + await page.goto("/log/show"); + await page.getByText('(cox2)').click(); + page.once("dialog", (dialog) => { + dialog.accept().catch(() => {}); + }); + await page.getByRole('link', { name: 'Löschen' }).click(); + + //Ausloggen... + await page.getByRole('banner').getByRole('link', { name: 'Logbuch' }).click(); + await page.getByRole('link', { name: 'Ausloggen' }).click(); }); diff --git a/seeds.sql b/seeds.sql index 0331795..540d77e 100644 --- a/seeds.sql +++ b/seeds.sql @@ -10,11 +10,13 @@ INSERT INTO "role" (name) VALUES ('Vorstand'); INSERT INTO "role" (name) VALUES ('Bootsführer'); INSERT INTO "role" (name) VALUES ('schnupperant'); INSERT INTO "role" (name) VALUES ('kassier'); +INSERT INTO "role" (name) VALUES ('schriftfuehrer'); 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); INSERT INTO "user_role" (user_id, role_id) VALUES(1,5); INSERT INTO "user_role" (user_id, role_id) VALUES(1,6); +INSERT INTO "user_role" (user_id, role_id) VALUES(1,9); INSERT INTO "user" (name, pw) VALUES('rower', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$jWKzDmI0jqT2dqINFt6/1NjVF4Dx15n07PL1ZMBmFsY'); INSERT INTO "user_role" (user_id, role_id) VALUES(2,5); INSERT INTO "user" (name, pw) VALUES('guest', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$GF6gizbI79Bh0zA9its8S0gram956v+YIV8w8VpwJnQ');