Skip to content

Commit

Permalink
chore(): update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Limerio committed Mar 24, 2024
1 parent c596bca commit fd589af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 50 deletions.
2 changes: 1 addition & 1 deletion playwright.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
50 changes: 1 addition & 49 deletions tests/home.spec.js
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand All @@ -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()
})
4 changes: 4 additions & 0 deletions tests/places/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit fd589af

Please sign in to comment.