only allow realistic values for logbook entries #536

Merged
philipp merged 2 commits from sanity-check-timing into main 2024-05-22 22:41:36 +02:00
Showing only changes of commit 446e48020e - Show all commits

View File

@ -67,6 +67,16 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => {
await expect(page.getByRole("listbox")).toContainText( await expect(page.getByRole("listbox")).toContainText(
"Nur 2 Ruderer können hinzugefügt werden", "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("#shipmaster-newrowerjs")).toContainText("cox");
await expect(page.locator("#steering_person-newrowerjs")).toContainText( await expect(page.locator("#steering_person-newrowerjs")).toContainText(
"rower2 cox", "rower2 cox",
@ -80,15 +90,6 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => {
await page.goto("/log"); await page.goto("/log");
await page.locator("div:nth-child(2) > .border-0").click(); 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" }).click();
await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim");
await page.getByRole("button", { name: "Ausfahrt beenden" }).click(); 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( await expect(page.getByRole("listbox")).toContainText(
"Nur 2 Ruderer können hinzugefügt werden", "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("#shipmaster-newrowerjs")).toContainText("cox");
await expect(page.locator("#steering_person-newrowerjs")).toContainText( await expect(page.locator("#steering_person-newrowerjs")).toContainText(
"rower2 cox", "rower2 cox",
@ -166,15 +177,6 @@ test("Kiosk can start and finish trip", async ({ page }, testInfo) => {
await page.goto("/log"); 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 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" }).click();
await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim"); await page.getByRole("combobox", { name: "Destination" }).fill("Ottensheim");
await page.getByRole("button", { name: "Ausfahrt beenden" }).click(); await page.getByRole("button", { name: "Ausfahrt beenden" }).click();