Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CD #56

Merged
merged 1 commit into from
Mar 25, 2024
Merged

CD #56

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
})