From 446e48020ef114d3f3dc665247cf4d21a92ab600 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 22 May 2024 22:28:33 +0200 Subject: [PATCH] test fails due to new sanity check (25km in 1 min :-)); started trip 2 hours ago now in tests --- frontend/tests/log.spec.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index f835e84..bc74ec4 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -67,6 +67,16 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await expect(page.getByRole("listbox")).toContainText( "Nur 2 Ruderer können hinzugefügt werden", ); + + // Trip starts 2 hours ago + const datetimeSelector = '#departure'; + const currentValue = await page.$eval(datetimeSelector, el => el.value); + const currentDate = new Date(currentValue); + currentDate.setMinutes(currentDate.getMinutes()); + currentDate.setHours(currentDate.getHours() - new Date().getTimezoneOffset()/60 - 2); + const newDatetime = currentDate.toISOString().slice(0, 16); + await page.$eval(datetimeSelector, (el, value) => el.value = value, newDatetime); + await expect(page.locator("#shipmaster-newrowerjs")).toContainText("cox"); await expect(page.locator("#steering_person-newrowerjs")).toContainText( "rower2 cox", @@ -80,15 +90,6 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await page.goto("/log"); await page.locator("div:nth-child(2) > .border-0").click(); - // Add a minute - const datetimeSelector = '#arrivaljs'; - const currentValue = await page.$eval(datetimeSelector, el => el.value); - const currentDate = new Date(currentValue); - currentDate.setMinutes(currentDate.getMinutes() + 1); - currentDate.setHours(currentDate.getHours() - new Date().getTimezoneOffset()/60); - const newDatetime = currentDate.toISOString().slice(0, 16); - await page.$eval(datetimeSelector, (el, value) => el.value = value, newDatetime); - await page.getByRole("combobox", { name: "Destination" }).click(); await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); await page.getByRole("button", { name: "Ausfahrt beenden" }).click(); @@ -153,6 +154,16 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { await expect(page.getByRole("listbox")).toContainText( "Nur 2 Ruderer können hinzugefügt werden", ); + + // Trip starts 2 hours ago + const datetimeSelector = '#departure'; + const currentValue = await page.$eval(datetimeSelector, el => el.value); + const currentDate = new Date(currentValue); + currentDate.setMinutes(currentDate.getMinutes()); + currentDate.setHours(currentDate.getHours() - new Date().getTimezoneOffset()/60 - 2); + const newDatetime = currentDate.toISOString().slice(0, 16); + await page.$eval(datetimeSelector, (el, value) => el.value = value, newDatetime); + await expect(page.locator("#shipmaster-newrowerjs")).toContainText("cox"); await expect(page.locator("#steering_person-newrowerjs")).toContainText( "rower2 cox", @@ -166,15 +177,6 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => { await page.goto("/log"); 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 - const datetimeSelector = '#arrivaljs'; - const currentValue = await page.$eval(datetimeSelector, el => el.value); - const currentDate = new Date(currentValue); - currentDate.setMinutes(currentDate.getMinutes() + 1); - currentDate.setHours(currentDate.getHours() - new Date().getTimezoneOffset()/60); - const newDatetime = currentDate.toISOString().slice(0, 16); - await page.$eval(datetimeSelector, (el, value) => el.value = value, newDatetime); - await page.getByRole("combobox", { name: "Destination" }).click(); await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); await page.getByRole("button", { name: "Ausfahrt beenden" }).click();