From 6a581aac645a3121dc705396887208abc3890ebd Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 19 Aug 2024 15:05:36 +0200 Subject: [PATCH 1/8] verify, that boat is not on water on adding log entry; Fixes #625 --- src/model/boat.rs | 34 ++++++++++++++++++++++++++++++++++ src/model/logbook.rs | 8 ++++++++ src/tera/log.rs | 1 + 3 files changed, 43 insertions(+) diff --git a/src/model/boat.rs b/src/model/boat.rs index fe87f65..a851180 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -1,5 +1,6 @@ use std::ops::DerefMut; +use chrono::NaiveDateTime; use itertools::Itertools; use rocket::serde::{Deserialize, Serialize}; use rocket::FromForm; @@ -391,6 +392,39 @@ ORDER BY amount_seats DESC .await .ok() } + + pub async fn on_water_between( + &self, + db: &mut Transaction<'_, Sqlite>, + dep: NaiveDateTime, + arr: NaiveDateTime, + ) -> bool { + let dep = dep.format("%Y-%m-%dT%H:%M").to_string(); + let arr = arr.format("%Y-%m-%dT%H:%M").to_string(); + + sqlx::query!( + "SELECT COUNT(*) AS overlap_count +FROM logbook +WHERE boat_id = ? + AND ( + (departure <= ? AND arrival >= ?) -- Existing entry covers the entire new period + OR (departure >= ? AND departure < ?) -- Existing entry starts during the new period + OR (arrival > ? AND arrival <= ?) -- Existing entry ends during the new period + );", + self.id, + arr, + arr, + dep, + dep, + dep, + arr + ) + .fetch_one(db.deref_mut()) + .await + .unwrap() + .overlap_count + > 0 + } } #[cfg(test)] diff --git a/src/model/logbook.rs b/src/model/logbook.rs index cac3fdc..a45a3cc 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -142,6 +142,7 @@ pub enum LogbookUpdateError { TooFast(i64, i64), AlreadyFinalized, ExternalSteeringPersonMustSteerOrShipmaster, + BoatAlreadyOnWater, } #[derive(Debug, PartialEq)] @@ -196,6 +197,7 @@ impl From for LogbookCreateError { LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster => { LogbookCreateError::ExternalSteeringPersonMustSteerOrShipmaster } + LogbookUpdateError::BoatAlreadyOnWater => LogbookCreateError::BoatAlreadyOnWater, } } } @@ -573,6 +575,12 @@ ORDER BY departure DESC return Err(LogbookUpdateError::ArrivalNotAfterDeparture); } + if !boat.external { + if boat.on_water_between(db, dep, arr).await { + return Err(LogbookUpdateError::BoatAlreadyOnWater); + }; + } + let duration_in_mins = (arr.and_utc().timestamp() - dep.and_utc().timestamp()) / 60; // Not possible to row < 1 min / 500 m = < 2 min / km let possible_distance_km = duration_in_mins / 2; diff --git a/src/tera/log.rs b/src/tera/log.rs index 98e49d5..b21b78a 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -347,6 +347,7 @@ async fn home_logbook( Err(LogbookUpdateError::TooFast(km, min)) => Flash::error(Redirect::to("/log"), format!("KM zu groß für die eingegebene Dauer ({km} km in {min} Minuten). Bitte überprüfe deine Start- und Endzeit und versuche es erneut.")), Err(LogbookUpdateError::AlreadyFinalized) => Flash::error(Redirect::to("/log"), "Logbucheintrag wurde bereits abgeschlossen."), Err(LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster) => Flash::error(Redirect::to("/log"), "Wenn du eine 'Externe Steuerperson' hinzufügst, muss diese steuern oder Schiffsführer sein!"), + Err(LogbookUpdateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), "Das Boot war in diesem Zeitraum schon am Wasser. Bitte überprüfe das Datum und die Zeit."), Err(e) => Flash::error( Redirect::to("/log"), format!("Eintrag {logbook_id} konnte nicht abgesendet werden (Fehler: {e:?})!"), -- 2.45.2 From 5782a36b6933eb2357c2572d11ad84d18efaf8a5 Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 19 Aug 2024 16:11:03 +0200 Subject: [PATCH 2/8] 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'); -- 2.45.2 From 54085f3f13fcd625517981ede6ebc2a1f9d26641 Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 19 Aug 2024 16:29:50 +0200 Subject: [PATCH 3/8] fix seeds (again) --- frontend/tests/log.spec.ts | 16 ++++++++-------- seeds.sql | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index dad2e03..b13c1ed 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -109,9 +109,9 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { 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").fill("Vorstandsmitglied"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); @@ -219,9 +219,9 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { await page.goto("/auth"); // Login as admin await page.getByPlaceholder("Name").click(); - await page.getByPlaceholder("Name").fill("admin"); + await page.getByPlaceholder("Name").fill("Vorstandsmitglied"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); @@ -296,9 +296,9 @@ test("Cox can start and finish trip with cox steering only", async ({ page }, te 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").fill("Vorstandsmitglied"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); @@ -365,9 +365,9 @@ test("Kiosk can start and finish trip in one stop", async ({ page }, testInfo) = await page.goto("/auth"); // Login as admin await page.getByPlaceholder("Name").click(); - await page.getByPlaceholder("Name").fill("admin"); + await page.getByPlaceholder("Name").fill("Vorstandsmitglied"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("admin"); + await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); diff --git a/seeds.sql b/seeds.sql index 540d77e..98b51be 100644 --- a/seeds.sql +++ b/seeds.sql @@ -16,7 +16,6 @@ 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'); -- 2.45.2 From b9b81ea46c0e81d0bdc18329e92cb388c2f177ff Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 20 Aug 2024 09:56:33 +0200 Subject: [PATCH 4/8] try again tests --- frontend/tests/log.spec.ts | 8 ++++---- seeds.sql | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index b13c1ed..802de5f 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -109,7 +109,7 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await page.getByRole('link', { name: 'Ausloggen' }).click(); // Login as admin await page.getByPlaceholder("Name").click(); - await page.getByPlaceholder("Name").fill("Vorstandsmitglied"); + await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); @@ -219,7 +219,7 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { await page.goto("/auth"); // Login as admin await page.getByPlaceholder("Name").click(); - await page.getByPlaceholder("Name").fill("Vorstandsmitglied"); + await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); @@ -296,7 +296,7 @@ test("Cox can start and finish trip with cox steering only", async ({ page }, te await page.getByRole('link', { name: 'Ausloggen' }).click(); // Login as admin await page.getByPlaceholder("Name").click(); - await page.getByPlaceholder("Name").fill("Vorstandsmitglied"); + await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); @@ -365,7 +365,7 @@ test("Kiosk can start and finish trip in one stop", async ({ page }, testInfo) = await page.goto("/auth"); // Login as admin await page.getByPlaceholder("Name").click(); - await page.getByPlaceholder("Name").fill("Vorstandsmitglied"); + await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); await page.getByPlaceholder("Passwort").fill("rower"); await page.getByPlaceholder("Passwort").press("Enter"); diff --git a/seeds.sql b/seeds.sql index 98b51be..d89090a 100644 --- a/seeds.sql +++ b/seeds.sql @@ -37,7 +37,12 @@ INSERT INTO "user_role" (user_id, role_id) VALUES(8,5); INSERT INTO "user_role" (user_id, role_id) VALUES(8,7); INSERT INTO "user" (name, pw) VALUES('Vorstandsmitglied', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$jWKzDmI0jqT2dqINFt6/1NjVF4Dx15n07PL1ZMBmFsY'); INSERT INTO "user_role" (user_id, role_id) VALUES(9,5); -INSERT INTO "user_role" (user_id, role_id) VALUES(9,9); +INSERT INTO "user" (name, pw) VALUES('main', '$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 "trip_details" (planned_starting_time, max_people, day, notes) VALUES('10:00', 2, '1970-01-01', 'trip_details for a planned event'); INSERT INTO "planned_event" (name, planned_amount_cox, trip_details_id) VALUES('test-planned-event', 2, 1); -- 2.45.2 From ab9e82118716fb56dfaac67cdabd9bbbc86b5066 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 20 Aug 2024 10:06:16 +0200 Subject: [PATCH 5/8] fix seeds --- seeds.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/seeds.sql b/seeds.sql index d89090a..1285e98 100644 --- a/seeds.sql +++ b/seeds.sql @@ -38,11 +38,11 @@ INSERT INTO "user_role" (user_id, role_id) VALUES(8,7); INSERT INTO "user" (name, pw) VALUES('Vorstandsmitglied', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$jWKzDmI0jqT2dqINFt6/1NjVF4Dx15n07PL1ZMBmFsY'); INSERT INTO "user_role" (user_id, role_id) VALUES(9,5); INSERT INTO "user" (name, pw) VALUES('main', '$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_role" (user_id, role_id) VALUES(9,1); +INSERT INTO "user_role" (user_id, role_id) VALUES(9,2); +INSERT INTO "user_role" (user_id, role_id) VALUES(9,5); +INSERT INTO "user_role" (user_id, role_id) VALUES(9,6); +INSERT INTO "user_role" (user_id, role_id) VALUES(9,9); INSERT INTO "trip_details" (planned_starting_time, max_people, day, notes) VALUES('10:00', 2, '1970-01-01', 'trip_details for a planned event'); INSERT INTO "planned_event" (name, planned_amount_cox, trip_details_id) VALUES('test-planned-event', 2, 1); -- 2.45.2 From f8c23fc276e02575573e47686b59068619f38204 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 20 Aug 2024 10:32:34 +0200 Subject: [PATCH 6/8] fix seeds --- seeds.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/seeds.sql b/seeds.sql index 1285e98..d3c3384 100644 --- a/seeds.sql +++ b/seeds.sql @@ -38,11 +38,11 @@ INSERT INTO "user_role" (user_id, role_id) VALUES(8,7); INSERT INTO "user" (name, pw) VALUES('Vorstandsmitglied', '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$jWKzDmI0jqT2dqINFt6/1NjVF4Dx15n07PL1ZMBmFsY'); INSERT INTO "user_role" (user_id, role_id) VALUES(9,5); INSERT INTO "user" (name, pw) VALUES('main', '$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(9,1); -INSERT INTO "user_role" (user_id, role_id) VALUES(9,2); -INSERT INTO "user_role" (user_id, role_id) VALUES(9,5); -INSERT INTO "user_role" (user_id, role_id) VALUES(9,6); -INSERT INTO "user_role" (user_id, role_id) VALUES(9,9); +INSERT INTO "user_role" (user_id, role_id) VALUES(10,1); +INSERT INTO "user_role" (user_id, role_id) VALUES(10,2); +INSERT INTO "user_role" (user_id, role_id) VALUES(10,5); +INSERT INTO "user_role" (user_id, role_id) VALUES(10,6); +INSERT INTO "user_role" (user_id, role_id) VALUES(10,9); INSERT INTO "trip_details" (planned_starting_time, max_people, day, notes) VALUES('10:00', 2, '1970-01-01', 'trip_details for a planned event'); INSERT INTO "planned_event" (name, planned_amount_cox, trip_details_id) VALUES('test-planned-event', 2, 1); -- 2.45.2 From 2debba381e286df779f19ac398699b1cc7a84571 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Aug 2024 16:47:35 +0200 Subject: [PATCH 7/8] user proper pw in tests... --- frontend/tests/log.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index 802de5f..efa53f0 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -111,7 +111,7 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await page.getByPlaceholder("Name").click(); await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("rower"); + await page.getByPlaceholder("Passwort").fill("admin"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); @@ -221,7 +221,7 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { await page.getByPlaceholder("Name").click(); await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("rower"); + await page.getByPlaceholder("Passwort").fill("admin"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); @@ -298,7 +298,7 @@ test("Cox can start and finish trip with cox steering only", async ({ page }, te await page.getByPlaceholder("Name").click(); await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("rower"); + await page.getByPlaceholder("Passwort").fill("admin"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); @@ -367,7 +367,7 @@ test("Kiosk can start and finish trip in one stop", async ({ page }, testInfo) = await page.getByPlaceholder("Name").click(); await page.getByPlaceholder("Name").fill("main"); await page.getByPlaceholder("Name").press("Tab"); - await page.getByPlaceholder("Passwort").fill("rower"); + await page.getByPlaceholder("Passwort").fill("admin"); await page.getByPlaceholder("Passwort").press("Enter"); await page.goto("/log/show"); -- 2.45.2 From 147497f49028cd9db3d8a7f59440419af3bccf55 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Aug 2024 16:53:14 +0200 Subject: [PATCH 8/8] fix tests (incorporate new cox in seeds.sql) --- src/model/user.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/user.rs b/src/model/user.rs index 6a450f5..49d828c 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -1106,7 +1106,7 @@ mod test { fn test_cox() { let pool = testdb!(); let res = User::cox(&pool).await; - assert_eq!(res.len(), 3); + assert_eq!(res.len(), 4); } #[sqlx::test] -- 2.45.2