diff --git a/playwright.config.cjs b/playwright.config.cjs index 9265b9d..363d39a 100644 --- a/playwright.config.cjs +++ b/playwright.config.cjs @@ -62,7 +62,7 @@ module.exports = defineConfig({ ], webServer: { - command: "npm run build && npm start", + command: "npm run dev", url: "http://127.0.0.1:3000", reuseExistingServer: !process.env.CI, }, diff --git a/tests/home.spec.js b/tests/home.spec.js index 9473515..6c77b23 100644 --- a/tests/home.spec.js +++ b/tests/home.spec.js @@ -1,27 +1,7 @@ -import { expect, test } from "@playwright/test" +import { test } from "@playwright/test" test.beforeEach(async ({ page }) => { await page.goto("/", { waitUntil: "networkidle" }) - await page.waitForRequest("/api/places") -}) - -test("Logo", async ({ page }) => { - expect( - await page.getByRole("link", { name: "Chooseyourplace" }).selectText(), - ).toBeFalsy() -}) - -test("Theme", async ({ page }) => { - await page.getByRole("button", { name: "Toggle theme" }).click() - await page.getByRole("menuitem", { name: "Light" }).click() - await expect(page.locator("html")).toHaveClass("light") - - await page.getByRole("button", { name: "Toggle theme" }).click() - await page.getByRole("menuitem", { name: "Dark" }).click() - await expect(page.locator("html")).toHaveClass("dark") - - await page.getByRole("button", { name: "Toggle theme" }).click() - await page.getByRole("menuitem", { name: "System" }).click() }) test("Create place with dialog", async ({ page }) => { @@ -46,31 +26,3 @@ test("Create place with dialog", async ({ page }) => { await page.getByLabel("Create a place").getByText("Bar").click() await page.getByRole("button", { name: "Finish" }).click() }) - -test("Languages", async ({ page }) => { - await page.getByLabel("EnglishEnglish").click() - await page.getByLabel("Français").click() - expect(page.getByLabel("FrançaisFrançais")).toBeVisible() - expect(page.getByLabel("EnglishEnglish")).not.toBeVisible() - - expect(page.getByRole("heading", { name: "Liste des lieux" })).toBeVisible() - expect( - page.getByRole("heading", { name: "List of places" }), - ).not.toBeVisible() - - await page.getByLabel("FrançaisFrançais").click() - await page.getByText("English").click() - expect( - page.getByRole("heading", { name: "Liste des lieux" }), - ).not.toBeVisible() - expect(page.getByRole("heading", { name: "List of places" })).toBeVisible() -}) - -test("Pagination", async ({ page }) => { - await expect(page.getByRole("button", { name: "Previous" })).toBeDisabled() - await page.getByRole("button", { name: "Next" }).click() - - await expect(page.getByRole("button", { name: "Previous" })).toBeEnabled() - await page.getByRole("button", { name: "Previous" }).click() - await expect(page.getByRole("button", { name: "Previous" })).toBeDisabled() -}) diff --git a/tests/places/create.spec.js b/tests/places/create.spec.js index 63fc6ed..49e5dbb 100644 --- a/tests/places/create.spec.js +++ b/tests/places/create.spec.js @@ -24,6 +24,7 @@ test("Create a bar place", async ({ page }) => { await page.getByLabel("1").click() await page.getByRole("button", { name: "Next" }).click() await page.getByRole("button", { name: "Finish" }).click() + await page.getByRole("heading", { name: "List of places" }).isVisible() await page.getByPlaceholder("Search by name...").click() await page.getByPlaceholder("Search by name...").fill("Random bar") await page.getByRole("cell", { name: "Random bar" }).click() @@ -53,6 +54,7 @@ test("Create a museum place", async ({ page }) => { await page.getByPlaceholder("Give the price of the museum").fill("") await page.getByRole("button", { name: "Next" }).click() await page.getByRole("button", { name: "Finish" }).click() + await page.getByRole("heading", { name: "List of places" }).isVisible() await page.getByPlaceholder("Search by name...").click() await page.getByPlaceholder("Search by name...").fill("Random Museum") await page.getByRole("cell", { name: "Random Museum" }).click() @@ -82,6 +84,7 @@ test("Create a restaurant place", async ({ page }) => { await page.getByLabel("1").click() await page.getByRole("button", { name: "Next" }).click() await page.getByRole("button", { name: "Finish" }).click() + await page.getByRole("heading", { name: "List of places" }).isVisible() await page.getByPlaceholder("Search by name...").click() await page.getByPlaceholder("Search by name...").fill("Random Restaurant") await page.getByRole("cell", { name: "Random Restaurant" }).click() @@ -111,6 +114,7 @@ test("Create a park place", async ({ page }) => { await page.getByPlaceholder("Give the price of the park").fill("") await page.getByRole("button", { name: "Next" }).click() await page.getByRole("button", { name: "Finish" }).click() + await page.getByRole("heading", { name: "List of places" }).isVisible() await page.getByPlaceholder("Search by name...").click() await page.getByPlaceholder("Search by name...").fill("Random park") await page.getByRole("cell", { name: "Random Park" }).click()