Skip to content

Commit

Permalink
Merge pull request #32 from fac28/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
GeorgeKlemperer authored Oct 25, 2023
2 parents 5723e2b + 86a1bd7 commit 55f43e5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
7 changes: 0 additions & 7 deletions __tests__/check.test.js

This file was deleted.

15 changes: 0 additions & 15 deletions __tests__/index.test.js

This file was deleted.

25 changes: 25 additions & 0 deletions _pwtests/tests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test, expect } from '@playwright/test'

test('should navigate to the listings page', async ({ page }) => {
// Start from the index page (the baseURL is set via the webServer in the playwright.config.ts)
await page.goto('http://localhost:3000/')
// Find an element with the text 'About Page' and click on it
await page.click('text=See the collection')
// The new URL should be "/about" (baseURL is used there)
await expect(page).toHaveURL('http://localhost:3000/listings')
// The new page should contain an h1 with "Art Vandelay"
await expect(page.locator('h1')).toContainText('Art Vandelay')
})

test('should navigate to the first product page', async ({ page }) => {
await page.goto('http://localhost:3000/listings')
await page.click('img')
await expect(page).toHaveURL('http://localhost:3000/listings/1')
await expect(page.locator('h2')).toContainText('The Night Watch')
})

test('header should navigate to the hoome page', async ({ page }) => {
await page.goto('http://localhost:3000/listings/1')
await page.click('h1')
await expect(page).toHaveURL('http://localhost:3000')
})
1 change: 1 addition & 0 deletions app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getRandomImage } from './_lib/models/random-image.js'

export default function Home() {
const isHomePage = true

return (
<main className='bg-purple' style={{ width: '100vw' }}>
<div className='flex items-center justify-between'>
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
"private": true,
"scripts": {
"dev": "DB_FILE=db.sqlite next dev",
"build": "next build",
"start": "next start",
"build": "DB_FILE=db.sqlite next build",
"start": "DB_FILE=db.sqlite next start",
"seed": "DB_FILE=db.sqlite node app/_lib/database/seed.js",
"seed fly": "DB_FILE=/data/db.sqlite node app/_lib/database/seed.js",
"test": "jest --watch",
"test:e2e": "playwright test",
"test:e2e": "DB_FILE=db.sqlite playwright test",
"lint": "next lint",
"prepare": "husky install"
"prepare": "husky install",
"bat": "DB_FILE=db.sqlite start-server-and-test start http://localhost:3000 test:e2e"
},
"dependencies": {
"better-sqlite3": "^9.0.0",
"next": "13.5.6",
"react": "^18",
"react-dom": "^18",
"react-icons": "^4.11.0"
"react-icons": "^4.11.0",
"sharp": "^0.32.6"
},
"devDependencies": {
"@flydotio/dockerfile": "^0.4.10",
Expand All @@ -33,6 +35,7 @@
"jest-environment-jsdom": "^29.7.0",
"postcss": "^8",
"prettier": "^3.0.3",
"start-server-and-test": "^2.0.1",
"tailwindcss": "^3"
},
"husky": {
Expand Down
Empty file added playwright.config.ts
Empty file.

0 comments on commit 55f43e5

Please sign in to comment.