2024-03-04 13:28:42 +01:00
|
|
|
import { test, expect, Page } from "@playwright/test";
|
|
|
|
|
|
|
|
test("cox can create and delete trip", async ({ page }) => {
|
2024-03-05 00:53:09 +01:00
|
|
|
await page.goto("/auth");
|
2024-03-04 13:28:42 +01:00
|
|
|
await page.getByPlaceholder("Name").click();
|
|
|
|
await page.getByPlaceholder("Name").fill("cox");
|
|
|
|
await page.getByPlaceholder("Name").press("Tab");
|
|
|
|
await page.getByPlaceholder("Passwort").fill("cox");
|
|
|
|
await page.getByPlaceholder("Passwort").press("Enter");
|
2024-03-24 14:02:22 +01:00
|
|
|
await page.locator('li').filter({ hasText: 'Geplante Ausfahrten' }).getByRole('link').click();
|
2024-03-04 13:28:42 +01:00
|
|
|
await page.locator(".relative").first().click();
|
|
|
|
await page.locator("#sidebar #planned_starting_time").click();
|
|
|
|
await page.locator("#sidebar #planned_starting_time").fill("18:00");
|
|
|
|
await page.locator("#sidebar #planned_starting_time").press("Tab");
|
|
|
|
await page.locator("#sidebar #planned_starting_time").press("Tab");
|
|
|
|
await page.getByRole("spinbutton").fill("5");
|
|
|
|
await page.getByRole("button", { name: "Erstellen", exact: true }).click();
|
2024-03-04 14:25:14 +01:00
|
|
|
await expect(page.locator("body")).toContainText("18:00 Uhr (cox) Details");
|
2024-03-04 13:28:42 +01:00
|
|
|
|
2024-03-05 00:53:09 +01:00
|
|
|
await page.goto("/planned");
|
2024-03-04 13:28:42 +01:00
|
|
|
await page.getByRole("link", { name: "Details" }).click();
|
|
|
|
await page.getByRole("link", { name: "Termin löschen" }).click();
|
|
|
|
await expect(page.locator("body")).toContainText("Erfolgreich gelöscht!");
|
2024-01-16 22:29:57 +01:00
|
|
|
});
|
|
|
|
|
2024-01-16 23:43:36 +01:00
|
|
|
// TODO: group -> cox can create trips
|
|
|
|
// TODO: cox can help/register at trips/events
|
|
|
|
|
2024-03-04 13:28:42 +01:00
|
|
|
test.describe("cox can edit trips", () => {
|
2024-01-16 22:52:31 +01:00
|
|
|
let sharedPage: Page;
|
2024-01-16 22:29:57 +01:00
|
|
|
|
2024-03-05 00:46:19 +01:00
|
|
|
test.beforeAll(async ({ browser }) => {
|
2024-01-16 22:29:57 +01:00
|
|
|
const page = await browser.newPage();
|
|
|
|
|
2024-03-05 00:53:09 +01:00
|
|
|
await page.goto("/auth");
|
2024-03-04 13:28:42 +01:00
|
|
|
await page.getByPlaceholder("Name").click();
|
|
|
|
await page.getByPlaceholder("Name").fill("cox");
|
|
|
|
await page.getByPlaceholder("Name").press("Tab");
|
|
|
|
await page.getByPlaceholder("Passwort").fill("cox");
|
|
|
|
await page.getByPlaceholder("Passwort").press("Enter");
|
2024-03-24 14:02:22 +01:00
|
|
|
await page.locator('li').filter({ hasText: 'Geplante Ausfahrten' }).getByRole('link').click();
|
2024-03-04 13:28:42 +01:00
|
|
|
await page.locator(".relative").first().click();
|
|
|
|
await page.locator("#sidebar #planned_starting_time").click();
|
|
|
|
await page.locator("#sidebar #planned_starting_time").fill("18:00");
|
|
|
|
await page.locator("#sidebar #planned_starting_time").press("Tab");
|
|
|
|
await page.locator("#sidebar #planned_starting_time").press("Tab");
|
|
|
|
await page.getByRole("spinbutton").fill("5");
|
|
|
|
await page.getByRole("button", { name: "Erstellen", exact: true }).click();
|
2024-01-16 22:29:57 +01:00
|
|
|
|
|
|
|
sharedPage = page;
|
|
|
|
});
|
|
|
|
|
2024-03-04 13:28:42 +01:00
|
|
|
test("edit remarks", async () => {
|
2024-03-05 00:53:09 +01:00
|
|
|
await sharedPage.goto("/planned");
|
2024-03-04 13:28:42 +01:00
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await sharedPage.locator("#sidebar #notes").click();
|
|
|
|
await sharedPage.locator("#sidebar #notes").fill("Meine Anmerkung");
|
|
|
|
await sharedPage.getByRole("button", { name: "Speichern" }).click();
|
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
|
|
|
"Meine Anmerkung",
|
|
|
|
);
|
|
|
|
|
|
|
|
await sharedPage
|
|
|
|
.getByRole("button", { name: "Ausfahrt erstellen schließen" })
|
|
|
|
.click();
|
2024-01-16 22:29:57 +01:00
|
|
|
});
|
|
|
|
|
2024-03-04 13:28:42 +01:00
|
|
|
test("add and remove guest", async () => {
|
2024-03-05 00:53:09 +01:00
|
|
|
await sharedPage.goto("/planned");
|
2024-03-04 13:28:42 +01:00
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await sharedPage.locator("#sidebar #user_note").click();
|
|
|
|
await sharedPage.locator("#sidebar #user_note").fill("Mein Gast");
|
|
|
|
await sharedPage.getByRole("button", { name: "Gast hinzufügen" }).click();
|
|
|
|
await expect(sharedPage.locator("body")).toContainText(
|
|
|
|
"Erfolgreich angemeldet!",
|
|
|
|
);
|
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
|
|
|
"Freie Plätze: 4",
|
|
|
|
);
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
|
|
|
"Mein Gast (Gast) Abmelden",
|
|
|
|
);
|
|
|
|
await expect(
|
|
|
|
sharedPage.getByRole("link", { name: "Termin löschen" }),
|
|
|
|
).not.toBeVisible();
|
|
|
|
|
|
|
|
await sharedPage.getByRole("link", { name: "Abmelden" }).click();
|
|
|
|
await expect(sharedPage.locator("body")).toContainText(
|
|
|
|
"Erfolgreich abgemeldet!",
|
|
|
|
);
|
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
|
|
|
"Freie Plätze: 5",
|
|
|
|
);
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
|
|
|
"Keine Ruderer angemeldet",
|
|
|
|
);
|
|
|
|
await expect(
|
|
|
|
sharedPage.getByRole("link", { name: "Termin löschen" }),
|
|
|
|
).toBeVisible();
|
|
|
|
|
|
|
|
await sharedPage
|
|
|
|
.getByRole("button", { name: "Ausfahrt erstellen schließen" })
|
|
|
|
.click();
|
2024-01-16 22:29:57 +01:00
|
|
|
});
|
|
|
|
|
2024-03-04 13:28:42 +01:00
|
|
|
test("change amount rower", async () => {
|
2024-03-05 00:53:09 +01:00
|
|
|
await sharedPage.goto("/planned");
|
2024-03-04 13:28:42 +01:00
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
|
|
|
"Freie Plätze: 5",
|
|
|
|
);
|
|
|
|
await sharedPage.getByRole("spinbutton").click();
|
|
|
|
await sharedPage.getByRole("spinbutton").fill("3");
|
|
|
|
await sharedPage.getByRole("button", { name: "Speichern" }).click();
|
|
|
|
await expect(sharedPage.locator("body")).toContainText(
|
|
|
|
"Ausfahrt erfolgreich aktualisiert.",
|
|
|
|
);
|
2024-01-16 22:29:57 +01:00
|
|
|
});
|
|
|
|
|
2024-03-04 13:28:42 +01:00
|
|
|
test("call off trip", async () => {
|
2024-03-05 00:53:09 +01:00
|
|
|
await sharedPage.goto("/planned");
|
2024-03-04 13:28:42 +01:00
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await expect(sharedPage.locator("#sidebar")).toContainText(
|
2024-03-05 00:46:19 +01:00
|
|
|
"Freie Plätze: 3",
|
2024-03-04 13:28:42 +01:00
|
|
|
);
|
|
|
|
await sharedPage.getByRole("spinbutton").click();
|
|
|
|
await sharedPage.getByRole("spinbutton").fill("0");
|
|
|
|
await sharedPage.getByRole("button", { name: "Speichern" }).click();
|
|
|
|
await expect(sharedPage.locator("body")).toContainText(
|
|
|
|
"Ausfahrt erfolgreich aktualisiert.",
|
|
|
|
);
|
2024-03-04 14:26:42 +01:00
|
|
|
await expect(sharedPage.locator("body")).toContainText("(Absage cox)");
|
2024-01-16 22:29:57 +01:00
|
|
|
});
|
|
|
|
|
2024-03-05 00:46:19 +01:00
|
|
|
test.afterAll(async () => {
|
2024-03-05 00:53:09 +01:00
|
|
|
await sharedPage.goto("/planned");
|
2024-03-04 13:28:42 +01:00
|
|
|
await sharedPage.getByRole("link", { name: "Details" }).click();
|
|
|
|
await sharedPage.getByRole("link", { name: "Termin löschen" }).click();
|
2024-01-16 22:29:57 +01:00
|
|
|
await sharedPage.close();
|
|
|
|
});
|
2024-01-16 23:43:36 +01:00
|
|
|
|
|
|
|
// TODO: 'Immer anzeigen' (also verify the functionality), 'Gesperrt' + type
|
2024-01-16 22:29:57 +01:00
|
|
|
});
|