From a7aac139fe6cf3e282bc947f31d399260f011f2d Mon Sep 17 00:00:00 2001 From: safina57 Date: Mon, 9 Nov 2026 14:23:16 +0100 Subject: [PATCH] test(frontend): add a Playwright e2e suite for the desktop and mobile layouts --- frontend/.gitignore | 5 ++ frontend/e2e/desktop.spec.ts | 149 ++++++++++++++++++++++++++++++++++ frontend/e2e/live.spec.ts | 20 +++++ frontend/e2e/mobile.spec.ts | 135 ++++++++++++++++++++++++++++++ frontend/e2e/shared.spec.ts | 88 ++++++++++++++++++++ frontend/e2e/support.ts | 132 ++++++++++++++++++++++++++++++ frontend/package.json | 5 +- frontend/playwright.config.ts | 34 ++++++++ frontend/pnpm-lock.yaml | 28 +++++++ frontend/tsconfig.e2e.json | 20 +++++ frontend/tsconfig.json | 6 +- frontend/vite.config.ts | 1 + 12 files changed, 621 insertions(+), 2 deletions(-) create mode 100644 frontend/e2e/desktop.spec.ts create mode 100644 frontend/e2e/live.spec.ts create mode 100644 frontend/e2e/mobile.spec.ts create mode 100644 frontend/e2e/shared.spec.ts create mode 100644 frontend/e2e/support.ts create mode 100644 frontend/playwright.config.ts create mode 100644 frontend/tsconfig.e2e.json diff --git a/frontend/.gitignore b/frontend/.gitignore index a547bf3..0f915ca 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -22,3 +22,8 @@ dist-ssr *.njsproj *.sln *.sw? + +# Playwright +test-results/ +playwright-report/ +blob-report/ diff --git a/frontend/e2e/desktop.spec.ts b/frontend/e2e/desktop.spec.ts new file mode 100644 index 0000000..71424a2 --- /dev/null +++ b/frontend/e2e/desktop.spec.ts @@ -0,0 +1,149 @@ +import { expect, test, type Page } from '@playwright/test'; +import { + citations, + realTrials, + seedReturningVisitor, + sendMessage, + shortTitle, + stubChat, + type WireTrial, +} from './support'; + +const summary = (page: Page) => page.locator('[data-tour="summary"]'); +const mapPins = (page: Page) => page.getByRole('button', { name: /^\d+ trials? — / }); +const contextChip = (page: Page) => page.getByRole('button', { name: /^Remove .+ from context$/ }); + +async function chatTurn(page: Page, trials: WireTrial[]) { + const sent = await stubChat(page, { + message: `Two trials may fit: [${trials[0].trial_ref}] and [${trials[1].trial_ref}].`, + trials, + followUps: ['What are the eligibility requirements?'], + }); + await sendMessage(page, 'breast cancer trials in Toronto'); + await expect(citations(page).first()).toBeVisible(); + return sent; +} + +test.beforeEach(async ({ page }) => { + await seedReturningVisitor(page); + await page.goto('/'); +}); + +test('a chat turn cites trials, pins them on the map and opens one in the summary', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + + await expect(citations(page)).toHaveCount(2); + await expect(page.getByRole('button', { name: 'Contact research team' }).first()).toBeVisible(); + await expect( + page.getByRole('button', { name: 'What are the eligibility requirements?' }) + ).toBeVisible(); + await expect(mapPins(page).first()).toBeVisible(); + await expect(page.getByText('Trials will appear here as you chat.')).toHaveCount(0); + + await citations(page).first().click(); + await expect(summary(page).getByRole('heading', { level: 2 })).toBeVisible(); + await expect(summary(page).getByText('Status')).toBeVisible(); + await expect(summary(page).getByText('No trial selected')).toHaveCount(0); + + await summary(page).getByRole('button', { name: 'Close' }).click(); + await expect(summary(page).getByText('No trial selected')).toBeVisible(); +}); + +test('a map pin lists its trials and opens the chosen one', async ({ page, request }) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + + await mapPins(page).first().click(); + const popup = page.locator('.trial-cluster-popup'); + await expect(popup).toBeVisible(); + await popup.getByRole('option').first().click(); + + await expect(summary(page).getByText('No trial selected')).toHaveCount(0); + await expect(summary(page).getByRole('heading', { level: 2 })).toBeVisible(); +}); + +test('a trial added to the chat rides along with every message until removed', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + const sent = await chatTurn(page, trials); + + await citations(page).first().click(); + await summary(page) + .getByRole('button', { name: /^Ask .+ about this trial$/ }) + .click(); + await expect(summary(page).getByRole('button', { name: 'Added to your chat' })).toBeDisabled(); + await expect(contextChip(page)).toHaveCount(1); + + await sendMessage(page, 'what are the side effects?'); + await expect.poll(() => sent.length).toBe(2); + expect(sent[1]).toContain(trials[0].trial_ref); + + const userMessage = page.locator('.is-user').filter({ hasText: 'what are the side effects?' }); + await expect(userMessage.getByRole('button', { name: /^Show .+ on the map$/ })).toBeVisible(); + + await contextChip(page).click(); + await expect(contextChip(page)).toHaveCount(0); + await sendMessage(page, 'anything else?'); + await expect.poll(() => sent.length).toBe(3); + expect(sent[2]).not.toContain(trials[0].trial_ref); +}); + +test('a saved trial survives a new conversation and reopens onto the map and chat', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + + await citations(page).first().click(); + await summary(page).getByRole('button', { name: 'Save this trial' }).click(); + await expect( + summary(page).getByRole('button', { name: 'Remove from saved trials' }) + ).toBeVisible(); + + await page.getByRole('button', { name: 'New conversation' }).click(); + await expect(page.getByText('Trials will appear here as you chat.')).toBeVisible(); + await expect(summary(page).getByText('No trial selected')).toBeVisible(); + + await page.getByRole('button', { name: 'Saved trials (1)' }).click(); + const sheet = page.getByRole('dialog', { name: /Saved trials/ }); + await sheet.getByText(shortTitle(trials[0])).click(); + + await expect(sheet).toBeHidden(); + await expect(summary(page).getByText('No trial selected')).toHaveCount(0); + await expect(mapPins(page).first()).toBeVisible(); + await expect(contextChip(page)).toHaveCount(1); +}); + +test('a saved trial exports as a PDF', async ({ page, request }) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + await citations(page).first().click(); + await summary(page).getByRole('button', { name: 'Save this trial' }).click(); + + await page.getByRole('button', { name: 'Saved trials (1)' }).click(); + const download = page.waitForEvent('download'); + await page.getByRole('button', { name: 'Export all as PDF' }).click(); + + expect((await download).suggestedFilename()).toMatch(/\.pdf$/); +}); + +test('the contact dialog opens from the summary with live site data', async ({ page, request }) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + await citations(page).first().click(); + + await summary(page).getByRole('button', { name: 'Contact research team' }).click(); + const dialog = page.getByRole('dialog', { name: 'Contact the research team' }); + await expect(dialog).toBeVisible(); + await expect(dialog.getByText('Talk to your own care team first')).toBeVisible(); + await expect( + dialog.getByText('Contact details could not be loaded. Please try again.') + ).toHaveCount(0); +}); diff --git a/frontend/e2e/live.spec.ts b/frontend/e2e/live.spec.ts new file mode 100644 index 0000000..472c224 --- /dev/null +++ b/frontend/e2e/live.spec.ts @@ -0,0 +1,20 @@ +import { expect, test } from '@playwright/test'; +import { citations, seedReturningVisitor, sendMessage } from './support'; + +// Calls the real agent (paid LLM tokens, slow, nondeterministic): run with E2E_LIVE=1. +test.skip(!process.env.E2E_LIVE, 'set E2E_LIVE=1 to exercise the real agent'); + +test('the real agent answers a search with cited trials', async ({ page }) => { + test.setTimeout(180_000); + await seedReturningVisitor(page); + await page.goto('/'); + if ((page.viewportSize()?.width ?? 0) < 768) + await page.locator('[data-tour="mobile-search"]').click(); + + await sendMessage( + page, + 'I am 54 with stage 3 breast cancer in Toronto. Are there recruiting trials for me?' + ); + + await expect(citations(page).first()).toBeVisible({ timeout: 150_000 }); +}); diff --git a/frontend/e2e/mobile.spec.ts b/frontend/e2e/mobile.spec.ts new file mode 100644 index 0000000..a6ae55e --- /dev/null +++ b/frontend/e2e/mobile.spec.ts @@ -0,0 +1,135 @@ +import { expect, test, type Page } from '@playwright/test'; +import { + chatInput, + citations, + realTrials, + seedReturningVisitor, + sendMessage, + shortTitle, + stubChat, + type WireTrial, +} from './support'; + +const cards = (page: Page) => page.locator('[data-tour="mobile-cards"]'); +const drawer = (page: Page) => page.locator('[data-tour="mobile-trial"]'); +const contextChip = (page: Page) => page.getByRole('button', { name: /^Remove .+ from context$/ }); + +async function chatTurn(page: Page, trials: WireTrial[]) { + const sent = await stubChat(page, { + message: `Two trials may fit: [${trials[0].trial_ref}] and [${trials[1].trial_ref}].`, + trials, + title: 'Breast cancer trials in Toronto', + }); + await page.locator('[data-tour="mobile-search"]').click(); + await expect(chatInput(page)).toBeVisible(); + await sendMessage(page, 'breast cancer trials in Toronto'); + await expect(citations(page).first()).toBeVisible(); + return sent; +} + +test.beforeEach(async ({ page }) => { + await seedReturningVisitor(page); + await page.goto('/'); +}); + +test('the phone opens on the map, and the search bar opens the chat', async ({ page }) => { + await expect(page.getByText('Trials will appear here as you chat.')).toBeVisible(); + await expect(page.locator('[data-tour="mobile-search"]')).toHaveText( + 'Tell me about your situation to find trials' + ); + + await page.locator('[data-tour="mobile-search"]').click(); + await expect(chatInput(page)).toBeVisible(); + await expect(page.getByText(/How can I help you today\?/)).toBeVisible(); +}); + +test('a cited trial collapses the chat onto its card, which opens the details drawer', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + await expect(page.locator('[data-tour="mobile-search"]')).toHaveText( + 'Breast cancer trials in Toronto' + ); + + await citations(page).first().click(); + const selected = cards(page).locator('[data-selected="true"]'); + await expect(selected).toBeVisible(); + await expect(selected).toContainText(shortTitle(trials[0])); + + await selected.click(); + await expect(drawer(page)).toBeVisible(); + await expect( + drawer(page).getByRole('heading', { + name: trials[0].official_title_en ?? shortTitle(trials[0]), + }) + ).toBeVisible(); + await expect(drawer(page).getByText('Status')).toBeVisible(); +}); + +test('asking about a trial from the drawer returns to the chat with it attached', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + const sent = await chatTurn(page, trials); + + await citations(page).first().click(); + await cards(page).locator('[data-selected="true"]').click(); + await drawer(page) + .getByRole('button', { name: /^Ask .+ about this trial$/ }) + .click(); + + await expect(drawer(page)).toBeHidden(); + await expect(contextChip(page)).toHaveCount(1); + await expect(chatInput(page)).toBeVisible(); + + await sendMessage(page, 'what are the side effects?'); + await expect.poll(() => sent.length).toBe(2); + expect(sent[1]).toContain(trials[0].trial_ref); +}); + +test('a trial saved from the drawer shows up in the menu and the saved list', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + + await citations(page).first().click(); + await cards(page).locator('[data-selected="true"]').click(); + await drawer(page).getByRole('button', { name: 'Save this trial' }).click(); + await expect( + drawer(page).getByRole('button', { name: 'Remove from saved trials' }) + ).toBeVisible(); + await drawer(page).getByRole('button', { name: 'Close' }).click(); + await expect(drawer(page)).toBeHidden(); + + await page.getByRole('button', { name: 'Menu' }).click(); + const savedRow = page.getByRole('button', { name: /^Saved trials/ }); + await expect(savedRow).toContainText('1'); + await savedRow.click(); + await expect( + page.getByRole('dialog', { name: /Saved trials/ }).getByText(shortTitle(trials[0])) + ).toBeVisible(); +}); + +test('the map controls and legend sit level with each other, clear of the search bar', async ({ + page, + request, +}) => { + const trials = await realTrials(request, 2); + await chatTurn(page, trials); + await citations(page).first().click(); + + const searchBar = await page.locator('[data-tour="mobile-search"]').boundingBox(); + const zoom = await page.locator('.mapboxgl-ctrl-group').boundingBox(); + const legend = await page.getByRole('list').filter({ hasText: 'Opening soon' }).boundingBox(); + expect(searchBar && zoom && legend).toBeTruthy(); + if (!searchBar || !zoom || !legend) return; + + expect(zoom.y).toBeGreaterThan(searchBar.y + searchBar.height); + expect(Math.abs(legend.y + legend.height / 2 - (zoom.y + zoom.height / 2))).toBeLessThan(4); + await expect(page.getByRole('button', { name: 'Coverage area' })).toHaveCount(0); +}); diff --git a/frontend/e2e/shared.spec.ts b/frontend/e2e/shared.spec.ts new file mode 100644 index 0000000..d03c731 --- /dev/null +++ b/frontend/e2e/shared.spec.ts @@ -0,0 +1,88 @@ +import { expect, test, type Page } from '@playwright/test'; +import frCa from '../src/i18n/locales/fr-CA'; +import { chatInput, finishTour, seedReturningVisitor } from './support'; + +const isMobile = (page: Page) => (page.viewportSize()?.width ?? 0) < 768; + +async function openMenu(page: Page) { + await page.getByRole('button', { name: 'Menu' }).click(); +} + +test('a first visit goes through consent, language and the full tour, then never again', async ({ + page, +}) => { + await page.goto('/'); + + const agree = page.getByRole('button', { name: 'Continue' }); + await expect(agree).toBeDisabled(); + await page.getByRole('checkbox').click(); + await agree.click(); + + await expect(page.getByRole('heading', { name: 'Choose your language' })).toBeVisible(); + await page.getByRole('button', { name: 'Use English' }).click(); + + const steps = await finishTour(page); + expect(steps).toBeGreaterThan(8); + + // The tour hands back the empty workspace it found. + await expect(page.getByText('Trials will appear here as you chat.')).toBeVisible(); + await expect(page.getByText(/How can I help you today\?/)).toBeAttached(); + await expect(page.locator('.driver-popover')).toHaveCount(0); + + await page.reload(); + await expect(page.getByRole('button', { name: 'Continue' })).toHaveCount(0); + await expect(page.getByRole('heading', { name: 'Choose your language' })).toHaveCount(0); + await expect(page.locator('.driver-popover')).toHaveCount(0); +}); + +test.describe('returning visitor', () => { + test.beforeEach(async ({ page }) => { + await seedReturningVisitor(page); + await page.goto('/'); + }); + + test('the theme toggle switches to dark and survives a reload', async ({ page }) => { + if (isMobile(page)) { + await openMenu(page); + await page.getByRole('button', { name: 'Switch to Dark theme' }).click(); + await page.keyboard.press('Escape'); + } else { + await page.getByRole('button', { name: 'Switch to Dark theme' }).click(); + } + await expect(page.locator('html')).toHaveClass(/dark/); + + await page.reload(); + await expect(page.locator('html')).toHaveClass(/dark/); + }); + + test('choosing a language translates the UI and English switches it back', async ({ page }) => { + const openLanguages = async (label: string) => { + if (isMobile(page)) { + await openMenu(page); + await page.getByRole('button', { name: new RegExp(`^${label}`) }).click(); + } else { + await page.getByRole('button', { name: label, exact: true }).click(); + } + }; + + await openLanguages('Language'); + await page.getByRole('button', { name: /Français/ }).click(); + await expect(page.locator('html')).toHaveAttribute('lang', 'fr-CA'); + await expect(chatInput(page)).toHaveCount(0); + await expect(page.getByPlaceholder(frCa.chat.placeholder)).toBeAttached(); + + await page.keyboard.press('Escape'); + await openLanguages(frCa.header.language); + await page.getByRole('button', { name: frCa.header.useEnglish }).click(); + await expect(page.locator('html')).toHaveAttribute('lang', 'en'); + await expect(chatInput(page)).toBeAttached(); + }); + + test('the terms page and an unknown route render', async ({ page }) => { + await page.goto('/terms'); + await expect(page.getByRole('heading', { name: 'Terms of Use', exact: true })).toBeVisible(); + + await page.goto('/no-such-page'); + await expect(page.getByText('404')).toBeVisible(); + }); +}); diff --git a/frontend/e2e/support.ts b/frontend/e2e/support.ts new file mode 100644 index 0000000..04403fd --- /dev/null +++ b/frontend/e2e/support.ts @@ -0,0 +1,132 @@ +import { expect, type APIRequestContext, type Page } from '@playwright/test'; +import { TERMS_VERSION } from '../src/lib/consent'; + +export const API_URL = process.env.E2E_API_URL ?? 'http://localhost:8000'; + +/** A trial as the backend sends it: snake_case, straight into the canned stream. */ +export interface WireTrial { + trial_ref: string; + nct_number: string | null; + acronym_or_protocol_id: string | null; + short_title_en: string | null; + official_title_en: string | null; + sites: { lat: number | null; lon: number | null; state: string | null }[]; +} + +/** Real recruiting trials with geocoded sites, so pins, summaries and contacts use live data. */ +export async function realTrials(request: APIRequestContext, count: number): Promise { + const response = await request.get(`${API_URL}/debug/trials`, { + params: { statuses: 'recruiting', limit: 25 }, + }); + expect(response.ok(), 'the backend must be running in a non-production environment').toBe(true); + const trials = ((await response.json()) as WireTrial[]).filter( + (trial) => trial.short_title_en && trial.sites.some((site) => site.lat !== null) + ); + expect(trials.length).toBeGreaterThanOrEqual(count); + return trials.slice(0, count); +} + +export function shortTitle(trial: WireTrial): string { + return trial.short_title_en as string; +} + +interface CannedReply { + message: string; + trials: WireTrial[]; + followUps?: string[]; + title?: string; +} + +/** Answers every chat turn with `reply` instead of calling the LLM; returns the messages sent. */ +export async function stubChat(page: Page, reply: CannedReply): Promise { + const sent: string[] = []; + await page.route('**/chat/stream', async (route) => { + sent.push((route.request().postDataJSON() as { user_message: string }).user_message); + const events = [ + { + type: 'AgentResponse', + data: { message: reply.message, used_trial_refs: [], follow_up_questions: [] }, + }, + { + type: 'ChatResult', + data: { + message: reply.message, + trials: reply.trials, + follow_up_questions: reply.followUps ?? [], + observation_id: 'e2e-observation', + conversation_title: reply.title ?? null, + }, + }, + ]; + await route.fulfill({ + status: 200, + contentType: 'text/event-stream', + body: events.map((event) => `data: ${JSON.stringify(event)}\n\n`).join(''), + }); + }); + return sent; +} + +/** A visitor who already agreed, chose English and saw the tour; set once so reloads keep later changes. */ +export async function seedReturningVisitor(page: Page): Promise { + await page.addInitScript((termsVersion) => { + if (localStorage.getItem('ctc.termsConsent')) return; + localStorage.setItem('ctc.termsConsent', termsVersion); + localStorage.setItem( + 'ctc-app', + JSON.stringify({ + state: { + theme: 'light', + language: 'en', + hasChosenLanguage: true, + hasSeenTour: true, + bookmarkedTrialRefs: [], + }, + version: 0, + }) + ); + }, TERMS_VERSION); +} + +export function citations(page: Page) { + return page.getByRole('button', { name: /^Show .+ on the map$/ }); +} + +export function chatInput(page: Page) { + return page.getByPlaceholder('Describe your situation or ask about a trial...'); +} + +export async function sendMessage(page: Page, text: string): Promise { + await chatInput(page).fill(text); + await chatInput(page).press('Enter'); +} + +/** Clicks through every driver.js step until the tour closes. */ +export async function finishTour(page: Page): Promise { + const popover = page.locator('.driver-popover'); + const next = popover.locator('.driver-popover-next-btn'); + const title = popover.locator('.driver-popover-title'); + const steps = { count: 0, done: false }; + // Steps that move the sheet or drawer advance on a timer, and the popover blinks out between steps. + const reachedNextStep = async (before: string | null) => { + const deadline = Date.now() + STEP_SETTLE_MS; + while (Date.now() < deadline) { + if ((await popover.isVisible()) && (await title.textContent()) !== before) return true; + await page.waitForTimeout(100); + } + return false; + }; + + await expect(popover).toBeVisible(); + while (!steps.done) { + const before = await title.textContent(); + await next.click(); + steps.count += 1; + steps.done = !(await reachedNextStep(before)); + expect(steps.count).toBeLessThan(25); + } + await expect(popover).toHaveCount(0); + return steps.count; +} + +const STEP_SETTLE_MS = 3000; diff --git a/frontend/package.json b/frontend/package.json index f0dd4ef..efe42c6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,7 +10,9 @@ "format": "prettier --write .", "preview": "vite preview", "test": "vitest run", - "test:watch": "vitest" + "test:watch": "vitest", + "e2e": "playwright test", + "e2e:ui": "playwright test --ui" }, "lint-staged": { "*.{ts,tsx}": [ @@ -61,6 +63,7 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", + "@playwright/test": "^1.65.0", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.1", diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts new file mode 100644 index 0000000..83b4fd9 --- /dev/null +++ b/frontend/playwright.config.ts @@ -0,0 +1,34 @@ +import { defineConfig, devices } from '@playwright/test'; + +// The backend must already be running against a populated database (see frontend/CLAUDE.md, E2E). +const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:5173'; + +export default defineConfig({ + testDir: './e2e', + fullyParallel: true, + forbidOnly: Boolean(process.env.CI), + retries: process.env.CI ? 1 : 0, + reporter: [['list'], ['html', { open: 'never' }]], + use: { + baseURL, + trace: 'retain-on-failure', + screenshot: 'only-on-failure', + }, + projects: [ + { + name: 'desktop', + testIgnore: /mobile\.spec\.ts/, + use: { ...devices['Desktop Chrome'], viewport: { width: 1440, height: 900 } }, + }, + { + name: 'mobile', + testIgnore: /desktop\.spec\.ts/, + use: { ...devices['Pixel 7'] }, + }, + ], + webServer: { + command: 'pnpm dev --port 5173 --strictPort', + url: baseURL, + reuseExistingServer: true, + }, +}); diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 3b4e770..0692813 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -132,6 +132,9 @@ importers: '@eslint/js': specifier: ^10.0.1 version: 10.0.1(eslint@10.5.0(jiti@2.7.0)) + '@playwright/test': + specifier: ^1.65.0 + version: 1.65.0 '@testing-library/jest-dom': specifier: ^6.9.1 version: 6.9.1 @@ -602,6 +605,11 @@ packages: '@oxc-project/types@0.154.0': resolution: {integrity: sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==} + '@playwright/test@1.65.0': + resolution: {integrity: sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==} + engines: {node: '>=20'} + hasBin: true + '@radix-ui/number@1.1.2': resolution: {integrity: sha512-ceTwaxc4I5IOi97DgCotl3pqiyRGvffcc0oOsE2dQYaJOFIDsDt4VWG6xEbg1QePv9QWausCEIppud/tJ1wNig==} @@ -3889,6 +3897,16 @@ packages: resolution: {integrity: sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==} engines: {node: '>=8'} + playwright-core@1.65.0: + resolution: {integrity: sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==} + engines: {node: '>=20'} + hasBin: true + + playwright@1.65.0: + resolution: {integrity: sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==} + engines: {node: '>=20'} + hasBin: true + png-js@2.0.0: resolution: {integrity: sha512-GdzJuUMc6ZSpxFJWVxtOH1bzYHym+TOnveqUjb+VJIbZWbZzyiRGFiKhbiielfpYbgMlhHVhsJ0FTazfuRFkMA==} @@ -5332,6 +5350,10 @@ snapshots: '@oxc-project/types@0.154.0': {} + '@playwright/test@1.65.0': + dependencies: + playwright: 1.65.0 + '@radix-ui/number@1.1.2': {} '@radix-ui/primitive@1.1.4': {} @@ -8832,6 +8854,12 @@ snapshots: dependencies: find-up: 3.0.0 + playwright-core@1.65.0: {} + + playwright@1.65.0: + dependencies: + playwright-core: 1.65.0 + png-js@2.0.0: dependencies: fflate: 0.8.3 diff --git a/frontend/tsconfig.e2e.json b/frontend/tsconfig.e2e.json new file mode 100644 index 0000000..8339afd --- /dev/null +++ b/frontend/tsconfig.e2e.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.e2e.tsbuildinfo", + "target": "es2023", + "lib": ["ES2023", "DOM"], + "module": "esnext", + "types": ["node"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true + }, + "include": ["e2e", "playwright.config.ts"] +} diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 16971f8..3295217 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,6 +1,10 @@ { "files": [], - "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.e2e.json" } + ], "compilerOptions": { "paths": { "@/*": ["./src/*"] diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 22a0bdc..e5e379b 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -19,6 +19,7 @@ export default defineConfig({ globals: true, environment: 'jsdom', setupFiles: ['./src/test/setup.ts'], + include: ['src/**/*.test.{ts,tsx}'], css: true, env: { VITE_MAPBOX_TOKEN: '',