diff --git a/README.md b/README.md index c741aed..5a291ae 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,7 @@ compress files at the time and the test was run over VPN. Turning on compression | Unit (backend) | Vitest | Parsing of X-Wines CSV files, building SQL for search, filtering and sorting, review validation, and passwords, sessions and rate limiting | 147 in 17 files (42 tests, 4 files skipped: they need a test database) | | End-to-end | Playwright with axe-core, desktop and mobile | Landing, search and detail pages with a stubbed API: one request per page load, debounce, search, filters, sorting, load more, reload, back button, from search to wine and back, the filter dialog on mobile, no hits, wine not found, API errors, keyboard use, reflow at 320 px, the wine lists (also after a reload, with login on the way, and the move of an old list), «Min side» from login to logout with the top 4 chosen with the keyboard, and no axe violations (WCAG 2.1 AA) | 86 (2 skipped) | | API | Vitest with Apollo Server (`executeOperation`) | Login, reviews, wine lists, the top 4 and the demo user through real GraphQL requests, with a fake browser per user that keeps the cookie. The review tests run against a separate test database (`TEST_DATABASE_URL`), see [API](docs/api.md#database-tests) | Count again | +| End-to-end with the backend | Playwright, desktop | The same pages against the real backend and a PostgreSQL test database (`TEST_DATABASE_URL`), with nothing stubbed: search, filter, sorting and «Last inn flere» on the 100 test wines, a new user with login, logout and a wrong password, a review from search to «Min side», a favourite that follows the user to another browser, and two users who review the same wine. See [API](docs/api.md#end-to-end-tests-with-the-backend) | 11 in 5 files | Counted on 16 November 2026. The skipped backend tests run the user store against a real database, and need `TEST_DATABASE_URL`. @@ -364,6 +365,7 @@ Run `npm run test:coverage` in `frontend/` to see the full report. It prints a l cd frontend npm run test:run npm run e2e # first time: npx playwright install chromium +npm run e2e:api # against the real backend; needs TEST_DATABASE_URL, see docs/api.md cd ../backend npm test diff --git a/backend/package.json b/backend/package.json index ce6dfb1..43464c9 100644 --- a/backend/package.json +++ b/backend/package.json @@ -16,6 +16,7 @@ "test": "vitest run", "db:seed:test": "tsx src/scripts/seed-xwines.ts data/xwines-test/wines.csv data/xwines-test/ratings.csv", "db:seed:demo": "tsx src/scripts/seed-demo-user.ts", + "db:e2e:clean": "tsx src/scripts/delete-e2e-users.ts", "db:migrate": "node-pg-migrate up", "db:migrate:down": "node-pg-migrate down", "db:migrate:create": "node-pg-migrate create --migration-file-language sql" diff --git a/backend/src/scripts/delete-e2e-users.ts b/backend/src/scripts/delete-e2e-users.ts new file mode 100644 index 0000000..cebdb1b --- /dev/null +++ b/backend/src/scripts/delete-e2e-users.ts @@ -0,0 +1,18 @@ +// Removes the users the end-to-end tests made in an earlier run, with their reviews and lists. +// Usage: npm run db:e2e:clean. Playwright runs it against the test database before the tests +// (see frontend/playwright.api.config.ts). It only touches usernames that start with "e2e_". +import { pool } from '../db'; + +async function main() { + const { rowCount } = await pool.query( + String.raw`DELETE FROM app_user WHERE username LIKE 'e2e\_%'`, + ); + console.log(`Deleted ${rowCount ?? 0} users from earlier end-to-end runs.`); +} + +main() + .catch((error: unknown) => { + console.error(error instanceof Error ? error.message : error); + process.exitCode = 1; + }) + .finally(() => pool.end()); diff --git a/docs/api.md b/docs/api.md index c66cbd6..9fa02fc 100644 --- a/docs/api.md +++ b/docs/api.md @@ -435,4 +435,24 @@ TEST_DATABASE_URL=postgresql://vinmonopolet_app:PASSWORD@localhost:5432/vinmonop On Windows PowerShell, set the variable first: `$env:TEST_DATABASE_URL="postgresql://..."`, then `npm test`. +## End-to-end tests with the backend + +The Playwright tests in `frontend/e2e/` stub the API. The tests in `frontend/e2e-api/` do not: a +click in the browser goes through the frontend, GraphQL and the backend to PostgreSQL and back. They +use the same test database as the database tests above: + +```bash +cd frontend +TEST_DATABASE_URL=postgresql://vinmonopolet_app:PASSWORD@localhost:5432/vinmonopolet_test npm run e2e:api +``` + +Without `TEST_DATABASE_URL` the tests are skipped. `npm run check -- --e2e` from the repository root +runs them too. + +Playwright starts its own backend on port 3101 and its own frontend on port 4174 +(`frontend/playwright.api.config.ts`), so your dev servers can keep running, and the tests never use +the database in `backend/.env`. Before the tests, the backend runs the migrations, loads the 100 +wines in `backend/data/xwines-test`, and deletes the users from earlier runs. Every test makes its +own user with a name that starts with `e2e_`, so the tests can run at the same time. + See [manual testing](manual-testing.md) for how to test users and user data by hand. diff --git a/docs/workflow.md b/docs/workflow.md index 1571764..3d546b0 100644 --- a/docs/workflow.md +++ b/docs/workflow.md @@ -19,7 +19,7 @@ Run from the repository root: | ------------------------ | ------------------------------------------------------------------------------------------- | | `npm run check` | Prettier, ESLint, TypeScript, tests with coverage and build, for `frontend/` and `backend/` | | `npm run check -- --fix` | Runs Prettier and ESLint fixes first | -| `npm run check -- --e2e` | Also runs the Playwright tests | +| `npm run check -- --e2e` | Also runs the Playwright tests, and those against the real backend if `TEST_DATABASE_URL` is set | - Every step runs, even after a failure. Steps a package lacks show as «not set up». - The output ends with a summary, the coverage numbers and a link to the report. diff --git a/frontend/e2e-api/auth.spec.ts b/frontend/e2e-api/auth.spec.ts new file mode 100644 index 0000000..d927a34 --- /dev/null +++ b/frontend/e2e-api/auth.spec.ts @@ -0,0 +1,62 @@ +import { expect, test, type Page } from '@playwright/test'; +import { + expectLoggedIn, + logIn, + logOut, + needsTestDatabase, + PASSWORD, + register, +} from './support/app'; + +/* Users and sessions against the real backend: the password hash and the session are in PostgreSQL. */ +needsTestDatabase(); + +const menu = (page: Page) => page.getByRole('navigation', { name: 'Hovedmeny' }); + +test('en ny bruker er fortsatt logget inn etter omlasting, og kan logge ut og inn igjen', async ({ + page, +}) => { + const username = await register(page); + + // The session cookie is all the browser has. The server finds the user from it. + await page.reload(); + await expectLoggedIn(page, username); + + await logOut(page); + await page.reload(); + await expect(menu(page).getByRole('link', { name: 'Logg inn' })).toBeVisible(); + + await logIn(page, username); + await expectLoggedIn(page, username); +}); + +test('feil passord gir en feilmelding og logger ikke inn', async ({ page }) => { + const username = await register(page); + await logOut(page); + + await logIn(page, username, `${PASSWORD}-feil`); + await expect(page.getByRole('main').getByRole('alert')).toContainText( + /brukernavn eller passord/i, + ); + await expect(menu(page).getByRole('link', { name: 'Logg inn' })).toBeVisible(); +}); + +test('et brukernavn kan bare brukes én gang', async ({ page, browser }) => { + const username = await register(page); + + // Someone else, in their own browser, tries the same name. + const other = await browser.newContext(); + const otherPage = await other.newPage(); + await otherPage.goto('./konto'); + await otherPage.getByRole('main').getByRole('button', { name: 'Lag bruker' }).click(); + await otherPage.getByRole('textbox', { name: 'Brukernavn' }).fill(username); + await otherPage.getByLabel('Passord').fill(PASSWORD); + await otherPage.getByRole('main').getByRole('button', { name: 'Lag bruker' }).click(); + + await expect(otherPage.getByRole('textbox', { name: 'Brukernavn' })).toHaveAttribute( + 'aria-invalid', + 'true', + ); + await expect(menu(otherPage).getByRole('link', { name: 'Logg inn' })).toBeVisible(); + await other.close(); +}); diff --git a/frontend/e2e-api/journey.spec.ts b/frontend/e2e-api/journey.spec.ts new file mode 100644 index 0000000..b883c69 --- /dev/null +++ b/frontend/e2e-api/journey.spec.ts @@ -0,0 +1,43 @@ +import { expect, test } from '@playwright/test'; +import { needsTestDatabase, register } from './support/app'; + +/* + * The main way through the site, against the real backend and PostgreSQL: search, open a wine, + * save a review and find it on «Min side». + */ +needsTestDatabase(); + +test('søk, åpne en vin, gi en dom og finn den igjen på «Min side»', async ({ page }) => { + await register(page); + + await page.goto('./sok'); + await page.getByRole('searchbox', { name: 'Søk etter vin' }).fill('merlot'); + await expect(page.getByRole('main').getByRole('status').first()).toContainText('for «merlot»'); + await page.getByRole('link', { name: 'Origem Merlot' }).click(); + await expect(page.getByRole('heading', { level: 1, name: 'Origem Merlot' })).toBeVisible(); + + const reviews = page.getByRole('region', { name: 'Vurderinger' }); + await expect(reviews.getByText('Ingen dommer ennå')).toBeVisible(); + // The radio buttons are hidden behind the stars, so the click goes to the label. + await reviews.getByText('4 av 5 stjerner', { exact: true }).click({ force: true }); + await reviews.getByLabel('Kommentar (valgfritt)').fill('Myk og god til pizza.'); + await reviews.getByRole('button', { name: 'Lagre dommen' }).click(); + await expect(reviews.getByRole('status')).toHaveText('Dommen er lagret.'); + await expect(reviews.getByText('4,0 av 5 · 1 dom')).toBeVisible(); + + await page + .getByRole('navigation', { name: 'Hovedmeny' }) + .getByRole('link', { name: 'Min side' }) + .click(); + const myReviews = page.getByRole('region', { name: 'Mine dommer' }); + await expect(myReviews.getByRole('link', { name: 'Origem Merlot' })).toBeVisible(); + await expect(myReviews.getByText('Myk og god til pizza.')).toBeVisible(); + // A reviewed wine is also put on «Har prøvd». + await expect( + page.getByRole('region', { name: 'Har prøvd' }).getByRole('link', { name: 'Origem Merlot' }), + ).toBeVisible(); + + // Still there after a reload, so it came from the database and not from the page's memory. + await page.reload(); + await expect(myReviews.getByText('Myk og god til pizza.')).toBeVisible(); +}); diff --git a/frontend/e2e-api/lists.spec.ts b/frontend/e2e-api/lists.spec.ts new file mode 100644 index 0000000..ada007c --- /dev/null +++ b/frontend/e2e-api/lists.spec.ts @@ -0,0 +1,55 @@ +import { expect, test } from '@playwright/test'; +import { expectLoggedIn, logIn, needsTestDatabase, register } from './support/app'; + +/* The lists against the real backend: a saved wine is stored on the server, not in the browser. */ +needsTestDatabase(); + +test('en favoritt lagres på serveren og følger brukeren til en annen nettleser', async ({ + page, + browser, +}) => { + const username = await register(page); + + await page.goto('./vin/102079'); + await expect(page.getByRole('heading', { level: 1, name: 'Maré Alta' })).toBeVisible(); + const favourite = page.getByRole('button', { name: 'Favoritt', exact: true }); + await favourite.click(); + await expect(favourite).toHaveAttribute('aria-pressed', 'true'); + + await page.reload(); + await expect(favourite).toHaveAttribute('aria-pressed', 'true'); + + // A browser that has never seen this user: all it knows comes from the server. + const other = await browser.newContext(); + const otherPage = await other.newPage(); + await logIn(otherPage, username); + await expectLoggedIn(otherPage, username); + await otherPage.goto('./mine/favoritter'); + await expect(otherPage.getByRole('link', { name: 'Maré Alta' })).toBeVisible(); + await other.close(); + + // Taken off again, and gone after a reload. + await favourite.click(); + await expect(favourite).toHaveAttribute('aria-pressed', 'false'); + await page.goto('./mine/favoritter'); + await expect(page.getByText(/Du har ingen favoritter ennå/)).toBeVisible(); +}); + +test('«Har prøvd» tar vinen av «Vil prøve»', async ({ page }) => { + await register(page); + await page.goto('./vin/102902'); + const wantToTry = page.getByRole('button', { name: 'Vil prøve', exact: true }); + const tried = page.getByRole('button', { name: 'Har prøvd', exact: true }); + + await wantToTry.click(); + await expect(wantToTry).toHaveAttribute('aria-pressed', 'true'); + await tried.click(); + await expect(tried).toHaveAttribute('aria-pressed', 'true'); + await expect(wantToTry).toHaveAttribute('aria-pressed', 'false'); + + // The server did the move, so the two list pages agree after a fresh load. + await page.goto('./mine/har-provd'); + await expect(page.getByRole('link', { name: 'Pátria Alentejo Selection Reserva' })).toBeVisible(); + await page.goto('./mine/vil-prove'); + await expect(page.getByText(/Du har ikke lagret noen viner ennå/)).toBeVisible(); +}); diff --git a/frontend/e2e-api/reviews.spec.ts b/frontend/e2e-api/reviews.spec.ts new file mode 100644 index 0000000..167a4ab --- /dev/null +++ b/frontend/e2e-api/reviews.spec.ts @@ -0,0 +1,52 @@ +import { expect, test, type Page } from '@playwright/test'; +import { needsTestDatabase, register } from './support/app'; + +/* Reviews against the real backend: two users, each in their own browser, review the same wine. */ +needsTestDatabase(); + +const WINE = './vin/100191'; // Reserva Chardonnay. No other test reviews it. +const reviews = (page: Page) => page.getByRole('region', { name: 'Vurderinger' }); + +async function give(page: Page, stars: string, button: 'Lagre dommen' | 'Oppdater dommen') { + // The radio buttons are hidden behind the stars, so the click goes to the label. + await reviews(page).getByText(`${stars} av 5 stjerner`, { exact: true }).click({ force: true }); + await reviews(page).getByRole('button', { name: button }).click(); + await expect(reviews(page).getByRole('status')).toHaveText('Dommen er lagret.'); +} + +test('en annen bruker ser dommen, og snittet følger med når dommer endres og slettes', async ({ + page, + browser, +}) => { + const kari = await register(page); + await page.goto(WINE); + await reviews(page).getByLabel('Kommentar (valgfritt)').fill('Frisk og fin.'); + await give(page, '5', 'Lagre dommen'); + await expect(reviews(page).getByText('5,0 av 5 · 1 dom')).toBeVisible(); + + const other = await browser.newContext(); + const otherPage = await other.newPage(); + await register(otherPage); + await otherPage.goto(WINE); + + // The other user sees the first review, with who wrote it. + const list = otherPage.getByRole('list', { name: 'Studentenes dommer' }); + await expect(list.getByRole('listitem')).toHaveCount(1); + await expect(list).toContainText(kari); + await expect(list).toContainText('Frisk og fin.'); + + await give(otherPage, '3', 'Lagre dommen'); + await expect(reviews(otherPage).getByText('4,0 av 5 · 2 dommer')).toBeVisible(); + + await give(otherPage, '4', 'Oppdater dommen'); + await expect(reviews(otherPage).getByText('4,5 av 5 · 2 dommer')).toBeVisible(); + + await reviews(otherPage).getByRole('button', { name: 'Slett dommen' }).click(); + await expect(reviews(otherPage).getByRole('status')).toHaveText('Dommen er slettet.'); + await expect(reviews(otherPage).getByText('5,0 av 5 · 1 dom')).toBeVisible(); + await other.close(); + + // The first user sees the same after a reload. + await page.reload(); + await expect(reviews(page).getByText('5,0 av 5 · 1 dom')).toBeVisible(); +}); diff --git a/frontend/e2e-api/search.spec.ts b/frontend/e2e-api/search.spec.ts new file mode 100644 index 0000000..f2c7f51 --- /dev/null +++ b/frontend/e2e-api/search.spec.ts @@ -0,0 +1,63 @@ +import { expect, test, type Page } from '@playwright/test'; +import { needsTestDatabase } from './support/app'; + +/* + * Search, filter, sorting and paging against the real backend. The test database has the 100 + * wines in backend/data/xwines-test, so the numbers below are known. + */ +needsTestDatabase(); + +const status = (page: Page) => page.getByRole('main').getByRole('status').first(); +const results = (page: Page) => page.getByRole('list', { name: 'Søkeresultater' }); + +test('finner en vin fra ord i navnet', async ({ page }) => { + await page.goto('./sok'); + await page.getByRole('searchbox', { name: 'Søk etter vin' }).fill('Reserva TAWNY'); + await expect(status(page)).toHaveText('Viser 1 av 1 vin for «Reserva TAWNY»'); + await expect( + results(page).getByRole('link', { name: 'Dona Antonia Porto Reserva Tawny' }), + ).toBeVisible(); +}); + +test('sier fra når ingen viner passer', async ({ page }) => { + await page.goto('./sok?q=finnesikke'); + await expect(page.getByText('Ingen viner passer til «finnesikke».')).toBeVisible(); +}); + +test('filter og sortering gjelder hele katalogen, ikke bare de vinene som er lastet', async ({ + page, +}) => { + await page.goto('./sok'); + await expect(status(page)).toHaveText('Viser 24 av 100 viner'); + + // 53 of the 100 wines are red. Only 24 are on the page, so the count comes from the database. + await page.getByRole('checkbox', { name: /Rødvin/ }).check(); + await expect(status(page)).toHaveText('Viser 24 av 53 viner'); + await expect(results(page).getByRole('article')).toHaveCount(24); + await expect(results(page).getByText(/^Rødvin · /)).toHaveCount(24); + + await page.getByRole('link', { name: 'Fjern filteret Rødvin' }).click(); + await expect(status(page)).toHaveText('Viser 24 av 100 viner'); + await page.getByRole('combobox', { name: 'Sorter etter' }).selectOption({ label: 'Navn A–Å' }); + await expect(results(page).getByRole('article').first()).toContainText( + 'Al Poggio Chardonnay di Toscana', + ); +}); + +test('«Last inn flere» henter resten av vinene uten å vise noen to ganger', async ({ page }) => { + await page.goto('./sok'); + await expect(status(page)).toHaveText('Viser 24 av 100 viner'); + + for (const shown of [48, 72, 96, 100]) { + await page.getByRole('button', { name: 'Last inn flere' }).click(); + await expect(status(page)).toHaveText(`Viser ${shown} av 100 viner`); + } + await expect(page.getByRole('button', { name: 'Last inn flere' })).toBeHidden(); + + const links = await results(page) + .getByRole('article') + .getByRole('link') + .evaluateAll((all) => all.map((link) => link.getAttribute('href'))); + expect(links).toHaveLength(100); + expect(new Set(links).size).toBe(100); +}); diff --git a/frontend/e2e-api/support/app.ts b/frontend/e2e-api/support/app.ts new file mode 100644 index 0000000..48258cb --- /dev/null +++ b/frontend/e2e-api/support/app.ts @@ -0,0 +1,57 @@ +import { expect, test, type Page } from '@playwright/test'; + +/** Call at the top of each spec: without a test database there is no backend to test against. */ +export function needsTestDatabase() { + test.skip( + !process.env.TEST_DATABASE_URL, + 'Needs TEST_DATABASE_URL. See «Database tests» in docs/api.md.', + ); +} + +export const PASSWORD = 'langt-nok-passord'; + +/** + * A username no other test has. It starts with "e2e_", which the backend's db:e2e:clean script + * looks for when it removes the users from earlier runs. + */ +export function newUsername() { + return `e2e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`; +} + +async function fillCredentials(page: Page, username: string, password: string) { + await page.getByRole('textbox', { name: 'Brukernavn' }).fill(username); + await page.getByLabel('Passord').fill(password); +} + +/** Makes a new user on the account page. The user is logged in afterwards. */ +export async function register(page: Page, username = newUsername()) { + await page.goto('./konto'); + await page.getByRole('main').getByRole('button', { name: 'Lag bruker' }).click(); + await expect(page.getByRole('heading', { level: 1, name: 'Lag bruker' })).toBeVisible(); + await fillCredentials(page, username, PASSWORD); + await page.getByRole('main').getByRole('button', { name: 'Lag bruker' }).click(); + await expectLoggedIn(page, username); + return username; +} + +/** Fills in the login form on the account page and sends it. */ +export async function logIn(page: Page, username: string, password = PASSWORD) { + await page.goto('./konto'); + await fillCredentials(page, username, password); + await page.getByRole('main').getByRole('button', { name: 'Logg inn' }).click(); +} + +/** Logs out with the button on the account page. */ +export async function logOut(page: Page) { + await page.goto('./konto'); + await page.getByRole('button', { name: 'Logg ut' }).click(); + await expect( + page.getByRole('navigation', { name: 'Hovedmeny' }).getByRole('link', { name: 'Logg inn' }), + ).toBeVisible(); +} + +/** The header shows the username once the page knows who is logged in. */ +export const expectLoggedIn = (page: Page, username: string) => + expect( + page.getByRole('navigation', { name: 'Hovedmeny' }).getByRole('link', { name: username }), + ).toBeVisible(); diff --git a/frontend/package.json b/frontend/package.json index 720db89..fe818fb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,6 +15,7 @@ "test:coverage": "node scripts/coverage.mjs", "typecheck": "tsc -b --noEmit", "e2e": "playwright test", + "e2e:api": "playwright test --config playwright.api.config.ts", "voiceover": "node scripts/voiceover.mjs" }, "dependencies": { diff --git a/frontend/playwright.api.config.ts b/frontend/playwright.api.config.ts new file mode 100644 index 0000000..369603c --- /dev/null +++ b/frontend/playwright.api.config.ts @@ -0,0 +1,46 @@ +import { defineConfig, devices } from '@playwright/test'; + +/* + * The end-to-end tests in e2e-api/ use the real backend and a real PostgreSQL database, so a + * click in the browser goes all the way to the database and back. The tests in e2e/ stub the + * API instead (playwright.config.ts). + * + * They need TEST_DATABASE_URL, the same test database as the backend's *.db.test.ts files + * (see «Database tests» in docs/api.md). Without it the tests are skipped. + * + * Playwright starts its own backend and its own frontend on ports that the dev servers do not + * use. It never reuses a server that is already running, so the tests can not end up in the + * database in backend/.env. + */ +const BACKEND_PORT = 3101; +const FRONTEND_PORT = 4174; +const BACKEND_URL = `http://127.0.0.1:${BACKEND_PORT}`; +const testDatabase = process.env.TEST_DATABASE_URL; + +export default defineConfig({ + testDir: './e2e-api', + use: { + baseURL: `http://localhost:${FRONTEND_PORT}/project2/`, + }, + projects: [{ name: 'desktop', use: { ...devices['Desktop Chrome'] } }], + webServer: testDatabase + ? [ + { + // Creates the tables, loads the 100 test wines and removes the users from earlier + // runs. Every step is safe to repeat. + command: + 'npm run db:migrate && npm run db:seed:test && npm run db:e2e:clean && npm start', + cwd: '../backend', + env: { DATABASE_URL: testDatabase, PORT: String(BACKEND_PORT) }, + url: `${BACKEND_URL}/`, + reuseExistingServer: false, + }, + { + command: `npm run build && npm run preview -- --port ${FRONTEND_PORT} --strictPort`, + env: { BACKEND_URL }, + url: `http://localhost:${FRONTEND_PORT}/project2/`, + reuseExistingServer: false, + }, + ] + : undefined, +}); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 34e8383..5c06c13 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -2,18 +2,22 @@ import react, { reactCompilerPreset } from '@vitejs/plugin-react'; import babel from '@rolldown/plugin-babel'; import { defineConfig } from 'vite'; +// The backend the dev server and `vite preview` send API requests to. The end-to-end tests +// against the real backend set BACKEND_URL to their own backend (playwright.api.config.ts). +const backend = process.env.BACKEND_URL ?? 'http://localhost:3001'; + export default defineConfig({ base: '/project2/', plugins: [react(), babel({ presets: [reactCompilerPreset()] })], server: { proxy: { '/api/hello': { - target: 'http://localhost:3001', + target: backend, rewrite: () => '/', }, // BASE_URL is part of the path, so the frontend calls /project2/graphql. '/project2/graphql': { - target: 'http://localhost:3001', + target: backend, rewrite: () => '/graphql', }, }, diff --git a/scripts/check.mjs b/scripts/check.mjs index 0aa97fd..06c9378 100644 --- a/scripts/check.mjs +++ b/scripts/check.mjs @@ -5,7 +5,8 @@ // // npm run check all checks // npm run check -- --fix run Prettier and ESLint fixes first -// npm run check -- --e2e also run the Playwright tests +// npm run check -- --e2e also run the Playwright tests. With TEST_DATABASE_URL set, the +// tests against the real backend run too (see docs/api.md) // // A step is skipped when its npm script does not exist in that package (for example // lint in the backend before ESLint is set up). Every step runs even if an earlier one @@ -26,6 +27,8 @@ const STEPS = [ { pkg: 'frontend', name: 'Tests + coverage', script: 'test:coverage' }, { pkg: 'frontend', name: 'Build', script: 'build' }, { pkg: 'frontend', name: 'E2E (Playwright)', script: 'e2e', only: '--e2e' }, + // Against the real backend and the test database. Skips itself without TEST_DATABASE_URL. + { pkg: 'frontend', name: 'E2E with backend', script: 'e2e:api', only: '--e2e' }, { pkg: 'backend', name: 'Prettier', script: 'format:check', fix: 'format' }, { pkg: 'backend', name: 'ESLint', script: 'lint', fix: 'lint -- --fix' }, { pkg: 'backend', name: 'TypeScript', script: 'typecheck' },