diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index 98f4c14..c3f37f0 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -74,8 +74,16 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { 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(); + // Add a minute + await page.locator('#arrivaljs').click(); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('ArrowUp'); + await page.getByRole("combobox", { name: "Destination" }).click(); await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); await page.getByRole("button", { name: "Ausfahrt beenden" }).click(); @@ -149,8 +157,16 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { 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) > .pt-2 > div > div > div:nth-child(2) > .border-0').click(); // 2 trips currently running, try to close second one + + // Add a minute + await page.locator('#arrivaljs').click(); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('Tab'); + await page.locator('#arrivaljs').press('ArrowUp'); + await page.getByRole("combobox", { name: "Destination" }).click(); await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); await page.getByRole("button", { name: "Ausfahrt beenden" }).click(); diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 805c4ae..e8c911d 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -1,6 +1,6 @@ use std::ops::DerefMut; -use chrono::{Datelike, NaiveDateTime, Utc}; +use chrono::{Datelike, Local, NaiveDateTime}; use rocket::FromForm; use serde::Serialize; use sqlx::{FromRow, Sqlite, SqlitePool, Transaction}; @@ -259,7 +259,7 @@ ORDER BY departure DESC } pub async fn completed(db: &SqlitePool) -> Vec { - let year = chrono::Utc::now().year(); + let year = chrono::Local::now().year(); let logs = sqlx::query_as( &format!(" SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype @@ -504,7 +504,7 @@ ORDER BY departure DESC if arr.timestamp() <= dep.timestamp() { return Err(LogbookUpdateError::ArrivalNotAfterDeparture); } - let today = Utc::now().date_naive(); + let today = Local::now().date_naive(); let day_diff = today - arr.date(); let day_diff = day_diff.num_days(); if day_diff >= 7 && !user.has_role_tx(db, "admin").await { diff --git a/src/model/notification.rs b/src/model/notification.rs index d345f74..5c6c26d 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, Local, NaiveDateTime, TimeZone, Utc}; +use chrono::{DateTime, Local, NaiveDateTime, TimeZone}; use serde::{Deserialize, Serialize}; use sqlx::{FromRow, SqlitePool}; diff --git a/src/model/stat.rs b/src/model/stat.rs index 81b2a83..c53c267 100644 --- a/src/model/stat.rs +++ b/src/model/stat.rs @@ -13,7 +13,7 @@ impl Stat { pub async fn boats(db: &SqlitePool, year: Option) -> Vec { let year = match year { Some(year) => year, - None => chrono::Utc::now().year(), + None => chrono::Local::now().year(), }; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) sqlx::query(&format!( @@ -39,7 +39,7 @@ ORDER BY rowed_km DESC; pub async fn guest(db: &SqlitePool, year: Option) -> Stat { let year = match year { Some(year) => year, - None => chrono::Utc::now().year(), + None => chrono::Local::now().year(), }; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) let rowed_km = sqlx::query(&format!( @@ -90,7 +90,7 @@ AND l.arrival LIKE '{year}-%'; pub async fn people(db: &SqlitePool, year: Option) -> Vec { let year = match year { Some(year) => year, - None => chrono::Utc::now().year(), + None => chrono::Local::now().year(), }; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) sqlx::query(&format!(