Skip to content

Commit

Permalink
chore(): add home spec and update playwright config
Browse files Browse the repository at this point in the history
  • Loading branch information
Limerio committed Mar 25, 2024
1 parent f086e77 commit 1baf28c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ jobs:
run: npx playwright install --with-deps
- name: Test database deployment
run: docker-compose up -d
- name: Seeding
run: npm run seed
- name: Run Playwright tests
run: npm run test:e2e
19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"seed": "node --env-file .env scripts/seed.js",
"test": "vitest run",
"test:watch": "vitest",
"test:e2e": "cross-env NEXT_PUBLIC_API_MOCKING=enabled playwright test -c ./playwright.config.cjs",
"test:e2e:ui": "cross-env NEXT_PUBLIC_API_MOCKING=enabled playwright test -c ./playwright.config.cjs --ui"
"test:e2e": "playwright test -c ./playwright.config.cjs",
"test:e2e:ui": "playwright test -c ./playwright.config.cjs --ui"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
Expand Down Expand Up @@ -57,7 +57,6 @@
"@types/node": "^20.11.30",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.0.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.3",
"eslint-config-prettier": "^9.1.0",
Expand Down
5 changes: 4 additions & 1 deletion scripts/seed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { faker } from "@faker-js/faker"
import { MongoClient } from "mongodb"
import { artisticMovements, typesOfBuilding } from "../src/utils/constants.js"
import {
artisticMovements,
typesOfBuilding,
} from "../src/features/places/utils/constants.js"
import { generateArray } from "../src/utils/functions.js"

const uri = process.env.DATABASE_URL
Expand Down
50 changes: 50 additions & 0 deletions tests/home.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { expect, test } from "@playwright/test"

test.beforeEach(async ({ page }) => {
await page.goto("/", { waitUntil: "networkidle" })
})

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 }) => {
await page.getByRole("button", { name: "Add" }).click()
await page.getByLabel("Building").click()
await page.getByLabel("Bar").click()
await page.getByPlaceholder("Name of the building....").click()
await page.getByPlaceholder("Name of the building....").fill("Random Name")
await page.getByPlaceholder("Name of the building....").press("Tab")
await page
.getByPlaceholder("Which city are the building ?")
.fill("Random City")
await page.getByPlaceholder("Which city are the building ?").press("Tab")
await page.getByPlaceholder("What is the zipcode ?").fill("12345")
await page.getByPlaceholder("What is the zipcode ?").press("Tab")
await page.getByPlaceholder("Which country are the").fill("Random Country")
await page.getByRole("button", { name: "Next" }).click()
await page.getByLabel("Bar").click()
await page.getByLabel("Cocktail").getByText("Cocktail").click()

await page.getByRole("button", { name: "Next" }).click()
await page.getByLabel("Create a place").getByText("Bar").click()
await page.getByRole("button", { name: "Finish" }).click()
})

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()
})

0 comments on commit 1baf28c

Please sign in to comment.