diff --git a/.github/workflows/backend-checks.yml b/.github/workflows/backend-checks.yml index 023af7a..eb390c7 100644 --- a/.github/workflows/backend-checks.yml +++ b/.github/workflows/backend-checks.yml @@ -92,9 +92,10 @@ jobs: - name: Upload test results to Codecov if: ${{ !cancelled() && hashFiles('backend/junit.xml') != '' }} - uses: codecov/test-results-action@v1.2.1 + uses: codecov/codecov-action@v7.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} + report_type: test_results files: backend/junit.xml flags: backend name: backend-tests diff --git a/.github/workflows/frontend-checks.yml b/.github/workflows/frontend-checks.yml index 0f7e135..a0f99f8 100644 --- a/.github/workflows/frontend-checks.yml +++ b/.github/workflows/frontend-checks.yml @@ -22,7 +22,10 @@ concurrency: jobs: test: runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 30 + + env: + CI: "true" defaults: run: @@ -42,8 +45,67 @@ jobs: - name: Install dependencies run: npm ci - - name: Run frontend checks - run: npm run check - env: - CI: "true" - VITE_API_URL: /api + - name: Run Oxlint + run: npm run lint:ci + + - name: Run Vitest tests + run: | + npm run test:coverage -- \ + --reporter=default \ + --reporter=github-actions \ + --reporter=junit \ + --outputFile.junit=junit.xml + + - name: Normalize coverage paths + run: sed -i 's|^SF:src/|SF:frontend/src/|' coverage/lcov.info + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v7.1.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: frontend/coverage/lcov.info + flags: frontend + name: frontend-coverage + disable_search: true + fail_ci_if_error: false + + - name: Upload Vitest results to Codecov + if: ${{ !cancelled() && hashFiles('frontend/junit.xml') != '' }} + uses: codecov/codecov-action@v7.1.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + report_type: test_results + files: frontend/junit.xml + flags: frontend + name: frontend-tests + disable_search: true + fail_ci_if_error: false + + - name: Install Playwright Chromium + run: npx playwright install --with-deps chromium + + - name: Run Playwright tests + run: npm run test:e2e + + - name: Upload Playwright report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v7 + with: + name: playwright-report + path: | + frontend/playwright-report/ + frontend/test-results/ + retention-days: 30 + if-no-files-found: ignore + + - name: Upload Playwright results to Codecov + if: ${{ !cancelled() && hashFiles('frontend/test-results/junit.xml') != '' }} + uses: codecov/codecov-action@v7.1.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + report_type: test_results + files: frontend/test-results/junit.xml + flags: frontend-e2e + name: frontend-e2e-tests + disable_search: true + fail_ci_if_error: false diff --git a/README.md b/README.md index 0d46472..41c94d4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ [![Backend checks](https://github.com/SCAI-BIO/PDataViewer/actions/workflows/backend-checks.yml/badge.svg?branch=main)](https://github.com/SCAI-BIO/PDataViewer/actions/workflows/backend-checks.yml) [![Backend coverage](https://codecov.io/gh/SCAI-BIO/PDataViewer/branch/main/graph/badge.svg?flag=backend)](https://codecov.io/gh/SCAI-BIO/PDataViewer) [![Frontend checks](https://github.com/SCAI-BIO/PDataViewer/actions/workflows/frontend-checks.yml/badge.svg?branch=main)](https://github.com/SCAI-BIO/PDataViewer/actions/workflows/frontend-checks.yml) +[![Frontend coverage](https://codecov.io/gh/SCAI-BIO/PDataViewer/branch/main/graph/badge.svg?flag=frontend)](https://codecov.io/gh/SCAI-BIO/PDataViewer) [![Version](https://img.shields.io/github/v/release/SCAI-BIO/PDataViewer)](https://github.com/SCAI-BIO/PDataViewer/releases) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![DOI](https://zenodo.org/badge/785700235.svg)](https://zenodo.org/doi/10.5281/zenodo.13629127) @@ -422,14 +423,43 @@ docker compose down ### Frontend Checks -The frontend defines one command for CI-compatible linting, testing, type checking, and production bundling: +Run the standard local development checks: ```bash cd frontend npm run check ``` -This runs `lint:ci` (Oxlint with warnings denied), `test:run` (Vitest once), and `build` (`tsc -b && vite build`). Individual checks can also be run with `npm run lint`, `npm run typecheck`, `npm run test:run`, and `npm run build`. The frontend workflow can use the same `npm run check` command. +This runs Oxlint, Vitest, TypeScript validation, and the +Vite production build. + +Run tests with coverage enforcement: + +```bash +npm run test:coverage +``` + +The frontend requires at least 90% statement coverage, +80% branch coverage, 95% function coverage, and 95% +line coverage. + +For browser-based end-to-end testing, install Chromium +and execute Playwright: + +```bash +npx playwright install chromium +npm run test:e2e +``` + +Automated frontend tests use synthetic API responses and +do not require a running backend. + +GitHub Actions runs linting, Vitest with coverage +enforcement, the production build, and Playwright tests. +Coverage and test results are uploaded to Codecov. + +See the [frontend documentation](frontend/README.md) +for additional testing commands and configuration. ### Backend Linting diff --git a/codecov.yml b/codecov.yml index 73b34cf..ad1bbf2 100644 --- a/codecov.yml +++ b/codecov.yml @@ -13,6 +13,13 @@ coverage: - backend informational: true + frontend: + target: 95% + threshold: 0% + flags: + - frontend + informational: true + patch: default: informational: true @@ -24,12 +31,24 @@ coverage: - backend informational: true + frontend: + target: 95% + threshold: 0% + flags: + - frontend + informational: true + flags: backend: paths: - backend/src/pdataviewer/ carryforward: true + frontend: + paths: + - frontend/src/ + carryforward: true + comment: layout: "diff, flags, files" behavior: default diff --git a/frontend/.gitignore b/frontend/.gitignore index f59fa7d..42f58c9 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -23,4 +23,13 @@ dist-ssr *.sln *.sw? +# Test and coverage reports +coverage/ +junit.xml + +# Playwright +playwright-report/ +test-results/ +playwright/.cache/ + .env.production \ No newline at end of file diff --git a/frontend/README.md b/frontend/README.md index 500d513..effc66d 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -12,6 +12,7 @@ PDataViewer provides interactive tools for exploring the Parkinson's disease dat - **Mappings:** Visualize semantic relationships between variables across cohort studies. - **Longitudinal:** Explore measurement availability across follow-up visits. - **Contact Us:** Find information about the PDataViewer team. +- **Race Distribution:** Explore recorded race selections across cohort studies. The frontend communicates with the PDataViewer FastAPI backend. @@ -24,15 +25,18 @@ The frontend communicates with the PDataViewer FastAPI backend. - [TanStack Query](https://tanstack.com/query/latest) for API requests and caching - [TanStack Table](https://tanstack.com/table/latest) for data tables - [Apache ECharts](https://echarts.apache.org/) and [D3](https://d3js.org/) for visualizations -- [Vitest](https://vitest.dev/) for testing +- [Vitest](https://vitest.dev/) for unit and integration testing +- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) for component testing +- [Mock Service Worker](https://mswjs.io/) for API request mocking +- [Playwright](https://playwright.dev/) for browser-based end-to-end testing - [Oxlint](https://oxc.rs/docs/guide/usage/linter) for linting ## Requirements - [Node.js](https://nodejs.org/) 26 recommended; see the `engines` field in `package.json` for other supported versions - npm -- A running PDataViewer FastAPI backend for data-dependent features -- Docker (optional, for containerized deployment) +- A running PDataViewer FastAPI backend for data-dependent application features (not required for automated frontend tests) +- Chromium installed through Playwright for end-to-end testing Project dependencies are installed locally with npm. No global React or Vite installation is required. @@ -52,9 +56,9 @@ When modifying dependencies, use `npm install` and commit the updated `package.j The frontend uses one Vite build-time variable: -| Variable | Required for production Docker build | Description | -| --- | --- | --- | -| `VITE_API_URL` | Yes | Browser-accessible base URL of the PDataViewer API | +| Variable | Required for production Docker build | Description | +| -------------- | ------------------------------------ | -------------------------------------------------- | +| `VITE_API_URL` | Yes | Browser-accessible base URL of the PDataViewer API | ### Local development @@ -173,28 +177,152 @@ When the backend runs in another Compose service, configure the development prox ## Development Checks -Run all frontend checks with the same command intended for CI: +Run the standard local development checks: ```bash npm run check ``` -This executes the following checks in order: +This runs Oxlint with warnings treated as errors, the Vitest +suite, TypeScript validation, and the Vite production build. -1. `npm run lint:ci` — Oxlint with warnings treated as errors. -2. `npm run test:run` — Vitest in non-watch mode. -3. `npm run build` — TypeScript project build followed by the Vite production build. +### Unit and Integration Testing -Individual commands are also available: +The frontend uses Vitest, React Testing Library, and Mock +Service Worker (MSW) to test application behavior. -| Command | Purpose | -| --- | --- | -| `npm run lint` | Run Oxlint | -| `npm run lint:fix` | Apply available automatic lint fixes | -| `npm run typecheck` | Run `tsc -b` | -| `npm run test` | Start Vitest in development mode | -| `npm run test:run` | Run Vitest once | -| `npm run build` | Type-check and build production assets | +Tests are colocated with their implementations under `src/`. +Shared testing utilities and synthetic API fixtures are +located in `src/test/`. + +```bash +npm run test +``` + +Run the complete suite once: + +```bash +npm run test:run +``` + +Run the complete suite with coverage: + +```bash +npm run test:coverage +``` + +Coverage is collected using V8 and must satisfy the following +global thresholds: + +| Metric | Minimum coverage | +| ---------- | ---------------: | +| Statements | 90% | +| Branches | 80% | +| Functions | 95% | +| Lines | 95% | + +Generated UI primitives in `src/components/ui/`, test files, +test infrastructure, and TypeScript declaration files are +excluded from coverage measurement. + +The coverage report is available at `coverage/index.html`. + +### End-to-End Testing + +Playwright tests are located in `e2e/` and execute against +the compiled production application. + +Install the required Chromium browser: + +```bash +npx playwright install chromium +``` + +On Linux, install the browser and its system dependencies: + +```bash +npx playwright install --with-deps chromium +``` + +Run all browser tests: + +```bash +npm run test:e2e +``` + +Playwright automatically builds the application and starts +the Vite preview server. No separately running FastAPI +backend, PostgreSQL database, or Keycloak instance is +required. + +The suite uses two browser projects: + +- `desktop`: Desktop Chromium. +- `mobile`: Chromium with Pixel 7 device emulation. + +Browser requests are intercepted using the shared MSW +handlers. External network requests, including Google +Analytics, are blocked. + +The end-to-end suite covers navigation, responsive layouts, +cohort comparison, study ranking, biomarker distributions, +longitudinal measurements, semantic mappings, race +distribution, SVG exports, and analytics consent. + +### Available Commands + +| Command | Purpose | +| ------------------------- | -------------------------------------- | +| `npm run lint` | Run Oxlint | +| `npm run lint:fix` | Apply automatic lint fixes | +| `npm run lint:ci` | Run linting with warnings denied | +| `npm run typecheck` | Validate TypeScript projects | +| `npm run test` | Run Vitest in watch mode | +| `npm run test:run` | Run Vitest once | +| `npm run test:coverage` | Run Vitest with coverage enforcement | +| `npm run test:e2e` | Run Playwright tests | +| `npm run test:e2e:ui` | Open Playwright's interactive UI | +| `npm run test:e2e:headed` | Run tests in a visible browser | +| `npm run test:e2e:report` | Open the Playwright HTML report | +| `npm run build` | Type-check and build production assets | +| `npm run check` | Run standard local development checks | + +Individual browser specifications and projects can be +selected through the Playwright CLI: + +```bash +npm run test:e2e -- --project=desktop +npm run test:e2e -- --project=mobile +npm run test:e2e -- biomarkers.spec.ts +``` + +### Continuous Integration + +The GitHub Actions frontend workflow performs: + +1. Dependency installation using `npm ci`. +2. Oxlint validation. +3. Vitest tests with coverage enforcement. +4. Coverage and test-result uploads to Codecov. +5. Playwright Chromium installation. +6. Production build and end-to-end testing. +7. Playwright report and diagnostic artifact uploads. + +Vitest coverage and Playwright test results are reported +separately. Browser tests do not contribute to Vitest's +source-code coverage measurements. + +Playwright reports, failure screenshots, and traces are +available through GitHub Actions artifacts. + +A complete local verification can be performed with: + +```bash +npm run lint:ci +npm run typecheck +npm run test:coverage +npm run test:e2e +``` ## Application Structure @@ -239,3 +367,7 @@ Different API URLs require separate production builds unless runtime frontend co - [Vite Documentation](https://vite.dev/guide/) - [PDataViewer Repository](https://github.com/SCAI-BIO/PDataViewer) - [PDataViewer Documentation](https://github.com/SCAI-BIO/PDataViewer/wiki) + +``` + +``` diff --git a/frontend/e2e/analytics.spec.ts b/frontend/e2e/analytics.spec.ts new file mode 100644 index 0000000..b3a2e98 --- /dev/null +++ b/frontend/e2e/analytics.spec.ts @@ -0,0 +1,423 @@ +import type { Page } from "@playwright/test"; + +import { CONSENT_STORAGE_KEY } from "../src/lib/analytics"; + +import { expect, test } from "./fixtures"; + +const DENIED_CONSENT = { + analytics_storage: "denied", + ad_storage: "denied", + ad_user_data: "denied", + ad_personalization: "denied", +}; + +function getBanner(page: Page) { + return page.getByRole("region", { + name: "Optional analytics", + }); +} + +function getAnalyticsScript(page: Page) { + return page.locator("script#pdataviewer-ga4"); +} + +function getAnalyticsRequests(requests: readonly string[]) { + return requests.filter((url) => + url.startsWith("https://www.googletagmanager.com/gtag/js?"), + ); +} + +async function readConsent(page: Page) { + return page.evaluate( + (key) => window.localStorage.getItem(key), + CONSENT_STORAGE_KEY, + ); +} + +async function readDataLayer(page: Page) { + return page.evaluate(() => window.dataLayer ?? []); +} + +async function getPageViews(page: Page) { + return page.evaluate(() => + (window.dataLayer ?? []).filter( + ([command, event]) => command === "event" && event === "page_view", + ), + ); +} + +async function openContactPage(page: Page) { + await page.goto("/#/contact-us"); + + await expect( + page.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); +} + +async function expectNoAnalytics(page: Page) { + await expect(getAnalyticsScript(page)).toHaveCount(0); + + expect(await readDataLayer(page)).toEqual([]); +} + +test("does not initialize analytics before consent and persists rejection across reloads", async ({ + page, + network, +}) => { + await openContactPage(page); + + const banner = getBanner(page); + + await expect(banner).toBeVisible(); + + expect(await readConsent(page)).toBeNull(); + + await expectNoAnalytics(page); + + expect(getAnalyticsRequests(network.blockedExternalRequests)).toEqual([]); + + await banner + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect(banner).toBeHidden(); + + expect(await readConsent(page)).toBe("denied"); + + await expectNoAnalytics(page); + + await page.reload(); + + await expect( + page.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); + + await expect(banner).toBeHidden(); + + expect(await readConsent(page)).toBe("denied"); + + await page + .getByRole("link", { + name: "PDataViewer home", + }) + .click(); + + await expect(page).toHaveURL(/#\/$/); + + await expect( + page.getByRole("heading", { + name: "Explore Parkinson's disease cohort data", + level: 1, + }), + ).toBeVisible(); + + await expectNoAnalytics(page); + + expect(getAnalyticsRequests(network.blockedExternalRequests)).toEqual([]); + + // Users can reopen and close preferences without changing consent. + await page + .getByRole("button", { + name: "Analytics Preferences", + }) + .click(); + + await expect(banner).toBeVisible(); + + await banner + .getByRole("button", { + name: "Close preferences", + }) + .click(); + + await expect(banner).toBeHidden(); + + expect(await readConsent(page)).toBe("denied"); + + await expectNoAnalytics(page); +}); + +test("initializes analytics after consent without exposing research parameters or duplicating page views", async ({ + page, + network, +}) => { + await page.goto("/#/plot-longitudinal?cohort=Study+A&variables=Age"); + + await expect( + page.getByRole("heading", { + name: "Measurement Availability by Variable", + level: 1, + }), + ).toBeVisible(); + + const banner = getBanner(page); + + const origin = new URL(page.url()).origin; + const safeLocation = `${origin}/#/plot-longitudinal`; + + await expectNoAnalytics(page); + + await banner + .getByRole("button", { + name: "Allow analytics", + }) + .click(); + + await expect(banner).toBeHidden(); + + expect(await readConsent(page)).toBe("granted"); + + await expect(getAnalyticsScript(page)).toHaveCount(1); + + await expect + .poll(() => getAnalyticsRequests(network.blockedExternalRequests)) + .toHaveLength(1); + + const commands = await readDataLayer(page); + + // Denied defaults must precede analytics consent. + expect(commands.slice(0, 2)).toEqual([ + ["consent", "default", DENIED_CONSENT], + [ + "consent", + "update", + { + ...DENIED_CONSENT, + analytics_storage: "granted", + }, + ], + ]); + + expect(commands).toEqual( + expect.arrayContaining([ + [ + "config", + expect.any(String), + expect.objectContaining({ + send_page_view: false, + cookie_prefix: "pdv", + cookie_domain: "none", + allow_google_signals: false, + allow_ad_personalization_signals: false, + page_location: safeLocation, + page_title: "Variable-specific Follow-up | PDataViewer", + }), + ], + ]), + ); + + const firstPageView = [ + "event", + "page_view", + expect.objectContaining({ + page_location: safeLocation, + page_title: "Variable-specific Follow-up | PDataViewer", + }), + ]; + + await expect.poll(() => getPageViews(page)).toEqual([firstPageView]); + + const documentStart = await page.evaluate(() => performance.timeOrigin); + + // Changing research parameters must not generate another page view. + await page.goto("/#/plot-longitudinal?cohort=Study+B&variables=Age"); + + await expect( + page + .getByRole("region", { + name: "Selected study information", + }) + .getByText("Study B", { exact: true }), + ).toBeVisible(); + + expect(await page.evaluate(() => performance.timeOrigin)).toBe(documentStart); + + expect(await getPageViews(page)).toEqual([firstPageView]); + + // Navigating to a different feature generates a new page view. + await page + .getByRole("navigation", { + name: "About links", + }) + .getByRole("link", { + name: "Contact Us", + }) + .click(); + + await expect(page).toHaveURL(/#\/contact-us$/); + + await expect + .poll(() => getPageViews(page)) + .toEqual([ + firstPageView, + [ + "event", + "page_view", + expect.objectContaining({ + page_location: `${origin}/#/contact-us`, + page_title: "Contact Us | PDataViewer", + }), + ], + ]); + + await expect(getAnalyticsScript(page)).toHaveCount(1); + + expect(getAnalyticsRequests(network.blockedExternalRequests)).toHaveLength(1); +}); + +test("synchronizes consent across tabs and reloads both documents when consent is withdrawn", async ({ + page, + context, + network, +}) => { + await openContactPage(page); + + const secondPage = await context.newPage(); + + await openContactPage(secondPage); + + const firstBanner = getBanner(page); + const secondBanner = getBanner(secondPage); + + await expect(firstBanner).toBeVisible(); + await expect(secondBanner).toBeVisible(); + + await expectNoAnalytics(page); + await expectNoAnalytics(secondPage); + + // Grant consent in the first tab. + await firstBanner + .getByRole("button", { + name: "Allow analytics", + }) + .click(); + + await expect(firstBanner).toBeHidden(); + + // The actual browser storage event updates the second tab. + await expect(secondBanner).toBeHidden(); + + expect(await readConsent(page)).toBe("granted"); + expect(await readConsent(secondPage)).toBe("granted"); + + await expect(getAnalyticsScript(page)).toHaveCount(1); + + await expect(getAnalyticsScript(secondPage)).toHaveCount(1); + + await expect + .poll(() => getAnalyticsRequests(network.blockedExternalRequests)) + .toHaveLength(2); + + const origin = new URL(page.url()).origin; + + // Simulate first-party analytics cookies without running Google code. + await context.addCookies([ + { + name: "pdv_ga", + value: "test-client", + url: `${origin}/`, + }, + { + name: "pdv_ga_session", + value: "test-session", + url: `${origin}/`, + }, + { + name: "unrelated_cookie", + value: "preserve-me", + url: `${origin}/`, + }, + ]); + + const cookiesBefore = await context.cookies(origin); + + expect(cookiesBefore.map(({ name }) => name)).toEqual( + expect.arrayContaining(["pdv_ga", "pdv_ga_session", "unrelated_cookie"]), + ); + + const firstDocumentStart = await page.evaluate(() => performance.timeOrigin); + + const secondDocumentStart = await secondPage.evaluate( + () => performance.timeOrigin, + ); + + // Withdraw consent from the second tab. + await secondPage + .getByRole("button", { + name: "Analytics Preferences", + }) + .click(); + + await expect(secondBanner).toBeVisible(); + + // Both previously consenting documents must actually reload. + await Promise.all([ + page.waitForEvent("load"), + secondPage.waitForEvent("load"), + secondBanner + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(), + ]); + + await expect + .poll(() => page.evaluate(() => performance.timeOrigin)) + .not.toBe(firstDocumentStart); + + await expect + .poll(() => secondPage.evaluate(() => performance.timeOrigin)) + .not.toBe(secondDocumentStart); + + await expect( + page.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); + + await expect( + secondPage.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); + + expect(await readConsent(page)).toBe("denied"); + + expect(await readConsent(secondPage)).toBe("denied"); + + await expect(firstBanner).toBeHidden(); + await expect(secondBanner).toBeHidden(); + + await expectNoAnalytics(page); + await expectNoAnalytics(secondPage); + + const cookiesAfter = await context.cookies(origin); + + expect(cookiesAfter.filter(({ name }) => name.startsWith("pdv_"))).toEqual( + [], + ); + + expect(cookiesAfter).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + name: "unrelated_cookie", + value: "preserve-me", + }), + ]), + ); + + // Neither document should reinitialize analytics after withdrawal. + expect(getAnalyticsRequests(network.blockedExternalRequests)).toHaveLength(2); + + await secondPage.close(); +}); diff --git a/frontend/e2e/biomarkers.spec.ts b/frontend/e2e/biomarkers.spec.ts new file mode 100644 index 0000000..f6ca99b --- /dev/null +++ b/frontend/e2e/biomarkers.spec.ts @@ -0,0 +1,330 @@ +import { readFile } from "node:fs/promises"; + +import type { Page } from "@playwright/test"; + +import { expect, test } from "./fixtures"; + +const HC = "Study A (HC Group)"; +const PD = "Study A (PD Group)"; +const STUDY_B_PD = "Study B (PD Group)"; + +async function selectBiomarker(page: Page, biomarker: string) { + const input = page.getByRole("combobox", { + name: "Biomarker", + exact: true, + }); + + await expect(input).toBeEnabled(); + + await input.fill(biomarker); + + await page + .getByRole("option", { + name: biomarker, + exact: true, + }) + .click(); +} + +async function selectGroup(page: Page, group: string) { + const input = page.getByRole("combobox", { + name: "Cohort and diagnosis groups", + }); + + await expect(input).toBeEnabled(); + + await input.fill(group); + + await page + .getByRole("option", { + name: group, + exact: true, + }) + .click(); + + await input.press("Escape"); +} + +test.beforeEach(async ({ page }) => { + await page.goto("/#/biomarkers"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect( + page.getByRole("heading", { + name: "Biomarkers", + level: 1, + }), + ).toBeVisible(); +}); + +test("compares biomarker distributions, exports an SVG and resets dependent selections", async ({ + page, + network, +}) => { + const cohorts = page.getByRole("region", { + name: "Cohorts with measurements", + }); + + const comparison = page.getByRole("region", { + name: "Distribution comparison", + }); + + const boxplot = comparison.getByRole("region", { + name: "Biomarker boxplot", + }); + + const figure = boxplot.getByRole("figure"); + const caption = figure.locator("figcaption"); + + await expect(cohorts).toBeHidden(); + await expect(comparison).toBeHidden(); + + await selectBiomarker(page, "Age"); + + await expect(cohorts.getByRole("listitem")).toHaveText([ + "Study A", + "Study B", + ]); + + await selectGroup(page, HC); + await selectGroup(page, PD); + + await expect(page.getByText("2 selected")).toBeVisible(); + + await expect( + comparison.getByRole("heading", { + name: "Age", + exact: true, + }), + ).toBeVisible(); + + await expect(figure.locator("svg")).toBeVisible(); + + await expect(caption).toContainText( + `Age. Boxplot comparison of ${HC}, ${PD}.`, + ); + + // Verify numerical summaries derived from the API data. + await comparison.getByText("Summary statistics", { exact: true }).click(); + + const medians = comparison + .locator("dl > div") + .filter({ + has: page.getByText("Median", { exact: true }), + }) + .getByRole("definition"); + + await expect(medians).toHaveText(["55", "70"]); + + const observations = comparison + .locator("dl > div") + .filter({ + has: page.getByText("Observations (n)", { + exact: true, + }), + }) + .getByRole("definition"); + + await expect(observations).toHaveText(["3", "3"]); + + // Download the actual SVG generated by ECharts. + const [download] = await Promise.all([ + page.waitForEvent("download"), + comparison.getByRole("button", { name: "Export SVG" }).click(), + ]); + + expect(download.suggestedFilename()).toBe("age.svg"); + expect(await download.failure()).toBeNull(); + + const exportedSvg = await readFile(await download.path(), "utf8"); + + expect(exportedSvg).toMatch(/]/); + expect(exportedSvg).toContain(""); + expect(exportedSvg).toContain(" { + test.skip(({ isMobile }) => !isMobile, "Mobile comparison only"); + + test("controls visible distributions without changing the research selection", async ({ + page, + }) => { + await selectBiomarker(page, "Age"); + + const comparison = page.getByRole("region", { + name: "Distribution comparison", + }); + + const boxplot = comparison.getByRole("region", { + name: "Biomarker boxplot", + }); + + const caption = boxplot.locator("figcaption"); + + await selectGroup(page, HC); + await selectGroup(page, PD); + await selectGroup(page, STUDY_B_PD); + + await expect(page.getByText("3 selected")).toBeVisible(); + + await expect(comparison.getByText("Comparing 2 of 3 groups")).toBeVisible(); + + await expect(caption).toContainText(`Boxplot comparison of ${HC}, ${PD}.`); + + await comparison + .getByText("Choose groups to compare", { + exact: true, + }) + .click(); + + const hc = comparison.getByRole("checkbox", { + name: HC, + exact: true, + }); + + const pd = comparison.getByRole("checkbox", { + name: PD, + exact: true, + }); + + const studyBPd = comparison.getByRole("checkbox", { + name: STUDY_B_PD, + exact: true, + }); + + await expect(hc).toBeChecked(); + await expect(pd).toBeChecked(); + await expect(studyBPd).not.toBeChecked(); + + await comparison.getByRole("button", { name: "Show all" }).click(); + + await expect(comparison.getByText("Comparing 3 of 3 groups")).toBeVisible(); + await expect(studyBPd).toBeChecked(); + + await expect(caption).toContainText( + `Boxplot comparison of ${HC}, ${PD}, ${STUDY_B_PD}.`, + ); + + // All three distributions require internal chart scrolling. + await expect + .poll(() => + boxplot.evaluate( + (element) => element.scrollWidth - element.clientWidth, + ), + ) + .toBeGreaterThan(0); + + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); + + // Keep only Study B visible. + await hc.uncheck(); + await pd.uncheck(); + await expect(comparison.getByText("Comparing 1 of 3 groups")).toBeVisible(); + await expect(caption).toContainText(`Boxplot comparison of ${STUDY_B_PD}.`); + await expect(studyBPd).toBeChecked(); + await expect(studyBPd).toBeDisabled(); + + await expect( + comparison + .getByRole("list", { + name: "Cohort color legend", + }) + .getByRole("listitem"), + ).toHaveText(["Study B"]); + + // Hiding distributions must not remove selected groups. + await expect(page.getByText("3 selected")).toBeVisible(); + + await comparison + .getByRole("button", { + name: "Reset selection", + }) + .click(); + + await expect(hc).toBeChecked(); + await expect(pd).toBeChecked(); + await expect(studyBPd).not.toBeChecked(); + await expect(comparison.getByText("Comparing 2 of 3 groups")).toBeVisible(); + await expect(page.getByText("3 selected")).toBeVisible(); + }); +}); diff --git a/frontend/e2e/cohorts.spec.ts b/frontend/e2e/cohorts.spec.ts new file mode 100644 index 0000000..1e98ac0 --- /dev/null +++ b/frontend/e2e/cohorts.spec.ts @@ -0,0 +1,247 @@ +import { expect, test } from "./fixtures"; + +test.beforeEach(async ({ page }) => { + await page.goto("/#/cohorts"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect( + page.getByRole("region", { + name: "Cohort overview", + }), + ).toBeVisible(); +}); + +test.describe("desktop cohort comparison", () => { + test.skip(({ isMobile }) => isMobile, "Desktop comparison only"); + + test("sorts cohorts using the comparison table and exposes data access links", async ({ + page, + }) => { + const table = page.getByRole("table", { + name: "Cohort study comparison", + }); + + const cohortNames = table.locator("tbody tr > td:first-child"); + + const cohortHeader = table.getByRole("columnheader", { + name: "Cohort", + exact: true, + }); + + const participantsHeader = table.getByRole("columnheader", { + name: "Participants", + exact: true, + }); + + const sortButton = participantsHeader.getByRole("button"); + + await expect(table).toBeVisible(); + + await expect(cohortNames).toHaveText(["Study A", "Study B"]); + + await expect(cohortHeader).toHaveAttribute("aria-sort", "ascending"); + + await sortButton.click(); + + await expect(cohortNames).toHaveText(["Study B", "Study A"]); + + await expect(participantsHeader).toHaveAttribute("aria-sort", "ascending"); + + await sortButton.click(); + + await expect(cohortNames).toHaveText(["Study A", "Study B"]); + + await expect(participantsHeader).toHaveAttribute("aria-sort", "descending"); + + await expect(cohortHeader).not.toHaveAttribute("aria-sort"); + + const accessLink = table.getByRole("link", { + name: "Apply for data access to Study A", + exact: true, + }); + + await expect(accessLink).toHaveAttribute( + "href", + "https://example.test/study-a", + ); + + await expect(accessLink).toHaveAttribute("target", "_blank"); + + await expect(accessLink).toHaveAttribute("rel", "noopener noreferrer"); + + await expect( + table.getByRole("link", { + name: "Apply for data access to Study B", + }), + ).toHaveCount(0); + }); +}); + +test.describe("mobile cohort comparison", () => { + test.skip(({ isMobile }) => !isMobile, "Mobile comparison only"); + + test("preserves sorting across cards and tables with horizontally scrollable comparisons", async ({ + page, + }) => { + const overview = page.getByRole("region", { + name: "Cohort overview", + }); + + const cards = overview.getByRole("article"); + const cardNames = cards.getByRole("heading", { + level: 2, + }); + + const table = overview.getByRole("table", { + name: "Cohort study comparison", + }); + + const sortBy = overview.getByRole("combobox", { + name: "Sort by", + }); + + await expect(cards).toHaveCount(2); + + await expect(cardNames).toHaveText(["Study A", "Study B"]); + + await expect(table).toBeHidden(); + + // Expand and collapse a cohort's study details. + const studyA = cards.filter({ + has: page.getByRole("heading", { + name: "Study A", + exact: true, + }), + }); + + const details = studyA.getByText("Study details", { + exact: true, + }); + + await expect(studyA.getByText("12 months")).toBeHidden(); + + await details.click(); + + await expect(studyA.getByText("12 months")).toBeVisible(); + + await details.click(); + + await expect(studyA.getByText("12 months")).toBeHidden(); + + // Sort the cards by participant count. + await sortBy.selectOption("participants"); + + await expect(cardNames).toHaveText(["Study B", "Study A"]); + + // Switch to the table without losing sorting. + await overview.getByRole("button", { name: "Compare in table" }).click(); + + await expect(table).toBeVisible(); + await expect(cards).toHaveCount(0); + + const cohortNames = table.locator("tbody tr > td:first-child"); + + await expect(cohortNames).toHaveText(["Study B", "Study A"]); + + await expect( + table.getByRole("columnheader", { + name: "Participants", + exact: true, + }), + ).toHaveAttribute("aria-sort", "ascending"); + + await expect(sortBy).toHaveValue("participants"); + + // Verify that the table scrolls within its own container. + const scrollRegion = overview.getByRole("region", { + name: "Cohort comparison table", + }); + + await page.evaluate(async () => { + await document.fonts.ready; + }); + + await expect + .poll(() => + scrollRegion.evaluate( + (element) => element.scrollWidth - element.clientWidth, + ), + ) + .toBeGreaterThan(0); + + const stickyHeader = table.getByRole("columnheader", { + name: "Cohort", + exact: true, + }); + + const initialLeft = await stickyHeader.evaluate( + (element) => element.getBoundingClientRect().left, + ); + + await scrollRegion.evaluate((element) => { + element.scrollLeft = element.scrollWidth; + }); + + await expect + .poll(() => scrollRegion.evaluate((element) => element.scrollLeft)) + .toBeGreaterThan(0); + + // The cohort column must remain pinned during scrolling. + await expect + .poll(async () => { + const currentLeft = await stickyHeader.evaluate( + (element) => element.getBoundingClientRect().left, + ); + + return Math.abs(currentLeft - initialLeft); + }) + .toBeLessThanOrEqual(1); + + // Horizontal scrolling must not overflow the entire page. + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); + + // Reverse sorting while the table is active. + await overview + .getByRole("button", { + name: "Currently sorting ascending. Switch to descending.", + }) + .click(); + + await expect(cohortNames).toHaveText(["Study A", "Study B"]); + + await expect( + table.getByRole("columnheader", { + name: "Participants", + exact: true, + }), + ).toHaveAttribute("aria-sort", "descending"); + + // Returning to cards must preserve the new sort order. + await overview.getByRole("button", { name: "Show cards" }).click(); + + await expect(table).toBeHidden(); + + await expect(cardNames).toHaveText(["Study A", "Study B"]); + + await expect(sortBy).toHaveValue("participants"); + + await expect( + overview.getByRole("button", { + name: "Currently sorting descending. Switch to ascending.", + }), + ).toBeVisible(); + }); +}); diff --git a/frontend/e2e/fixtures.ts b/frontend/e2e/fixtures.ts new file mode 100644 index 0000000..2a4ef37 --- /dev/null +++ b/frontend/e2e/fixtures.ts @@ -0,0 +1,102 @@ +import { test as base } from "@playwright/test"; +import { getResponse } from "msw"; + +import { handlers, TEST_API_URL } from "../src/test/mocks/handlers"; + +interface NetworkLog { + readonly apiRequests: string[]; + readonly unhandledApiRequests: string[]; + readonly blockedExternalRequests: string[]; +} + +interface TestFixtures { + network: NetworkLog; +} + +export const test = base.extend({ + network: [ + async ({ context, baseURL }, useFixture) => { + if (!baseURL) { + throw new Error("Playwright baseURL is not configured"); + } + + const origin = new URL(baseURL).origin; + + const network: NetworkLog = { + apiRequests: [], + unhandledApiRequests: [], + blockedExternalRequests: [], + }; + + await context.route("**/*", async (route) => { + const request = route.request(); + const url = new URL(request.url()); + + // Prevent requests to analytics and other external services. + if (url.origin !== origin) { + network.blockedExternalRequests.push(url.href); + + await route.abort(); + return; + } + + // Allow the application and its static assets to load normally. + const isApiRequest = + url.pathname === "/api" || url.pathname.startsWith("/api/"); + + if (!isApiRequest) { + await route.continue(); + return; + } + + const method = request.method(); + const requestPath = `${url.pathname}${url.search}`; + + const description = `${method} ${requestPath}`; + + network.apiRequests.push(description); + + // Translate the browser URL to the origin expected + // by the existing MSW request handlers. + const mockRequest = new Request(new URL(requestPath, TEST_API_URL), { + method, + headers: request.headers(), + body: request.postData() ?? undefined, + }); + + const response = await getResponse(handlers, mockRequest); + + if (!response) { + network.unhandledApiRequests.push(description); + + await route.fulfill({ + status: 501, + json: { + detail: `Unhandled API request: ${description}`, + }, + }); + + return; + } + + await route.fulfill({ + status: response.status, + contentType: + response.headers.get("content-type") ?? "application/json", + body: await response.text(), + }); + }); + + await useFixture(network); + + if (network.unhandledApiRequests.length > 0) { + throw new Error( + "Unhandled API requests:\n" + network.unhandledApiRequests.join("\n"), + ); + } + }, + { auto: true }, + ], +}); + +export { expect } from "@playwright/test"; diff --git a/frontend/e2e/longitudinal.spec.ts b/frontend/e2e/longitudinal.spec.ts new file mode 100644 index 0000000..b2386b4 --- /dev/null +++ b/frontend/e2e/longitudinal.spec.ts @@ -0,0 +1,349 @@ +import { readFile } from "node:fs/promises"; + +import type { Page } from "@playwright/test"; + +import { mockLongitudinalData } from "../src/test/mocks/handlers"; + +import { expect, test } from "./fixtures"; + +async function openPage(page: Page) { + await page.goto("/#/longitudinal"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect( + page.getByRole("heading", { + name: "Longitudinal Measurement Availability", + level: 1, + }), + ).toBeVisible(); +} + +async function selectVariable(page: Page, variable: string) { + const input = page.getByRole("combobox", { + name: "Variable", + exact: true, + }); + + await expect(input).toBeEnabled(); + + await input.fill(variable); + + await page + .getByRole("option", { + name: variable, + exact: true, + }) + .click(); +} + +test("loads the default longitudinal variable, exports the chart and supports changing the selection", async ({ + page, + network, +}) => { + await openPage(page); + + const variable = page.getByRole("combobox", { + name: "Variable", + exact: true, + }); + + const visualization = page.getByRole("region", { + name: "Longitudinal visualization", + }); + + const figure = visualization.getByRole("figure"); + const svg = figure.locator("svg"); + const caption = figure.locator("figcaption"); + + await expect(variable).toHaveValue("Study Visit"); + + await expect( + visualization.getByRole("heading", { + name: "Measurement availability: Study Visit", + exact: true, + }), + ).toBeVisible(); + + await expect(visualization).toHaveAttribute("aria-busy", "false"); + + await expect(svg).toBeVisible(); + + await expect(caption).toContainText( + "Retention percentage over time for Study A, Study B.", + ); + + await expect(caption).toContainText( + "The dashed horizontal line marks 50% retention.", + ); + + expect(network.apiRequests).toEqual( + expect.arrayContaining([ + "GET /api/longitudinal/", + "GET /api/longitudinal/Study%20Visit", + ]), + ); + + // Export the actual longitudinal chart. + const [download] = await Promise.all([ + page.waitForEvent("download"), + visualization.getByRole("button", { name: "Export SVG" }).click(), + ]); + + expect(download.suggestedFilename()).toBe( + "measurement-availability-study-visit.svg", + ); + + expect(await download.failure()).toBeNull(); + + const exportedSvg = await readFile(await download.path(), "utf8"); + + expect(exportedSvg).toMatch(/]/); + expect(exportedSvg).toContain(""); + expect(exportedSvg).toContain(" { + test.skip(({ isMobile }) => !isMobile, "Mobile comparison only"); + + test("preserves cohort visibility preferences across viewport changes", async ({ + page, + }) => { + // Add a third synthetic cohort to exercise the mobile + // comparison limit and Show all functionality. + await page.route("**/api/longitudinal/Study%20Visit", async (route) => { + await route.fulfill({ + json: [ + ...mockLongitudinalData, + { + months: 0, + cohort: "Study C", + patientCount: 45, + totalPatientCount: 50, + }, + { + months: 12, + cohort: "Study C", + patientCount: 35, + totalPatientCount: 50, + }, + ], + }); + }); + + await openPage(page); + + const visualization = page.getByRole("region", { + name: "Longitudinal visualization", + }); + + const figure = visualization.getByRole("figure"); + const svg = figure.locator("svg"); + const caption = figure.locator("figcaption"); + + const legend = visualization.getByRole("list", { + name: "Visible cohort series", + }); + + await expect(svg).toBeVisible(); + + await expect( + visualization.getByText("Comparing 2 of 3 cohorts"), + ).toBeVisible(); + + await expect(legend.getByRole("listitem")).toHaveText([ + "Study A", + "Study B", + ]); + + await expect(caption).toContainText( + "Retention percentage over time for Study A, Study B.", + ); + + await visualization + .getByText("Choose cohorts to compare", { + exact: true, + }) + .click(); + + const studyA = visualization.getByRole("checkbox", { + name: "Study A", + exact: true, + }); + + const studyB = visualization.getByRole("checkbox", { + name: "Study B", + exact: true, + }); + + const studyC = visualization.getByRole("checkbox", { + name: "Study C", + exact: true, + }); + + await expect(studyA).toBeChecked(); + await expect(studyB).toBeChecked(); + await expect(studyC).not.toBeChecked(); + + await visualization.getByRole("button", { name: "Show all" }).click(); + + await expect( + visualization.getByText("Comparing 3 of 3 cohorts"), + ).toBeVisible(); + + await expect(studyC).toBeChecked(); + + await expect(legend.getByRole("listitem")).toHaveText([ + "Study A", + "Study B", + "Study C", + ]); + + // Keep only Study C visible. + await studyA.uncheck(); + await studyB.uncheck(); + + await expect( + visualization.getByText("Comparing 1 of 3 cohorts"), + ).toBeVisible(); + + await expect(studyC).toBeChecked(); + await expect(studyC).toBeDisabled(); + + await expect(legend.getByRole("listitem")).toHaveText(["Study C"]); + + await expect(caption).toContainText( + "Retention percentage over time for Study C.", + ); + + const mobileViewport = page.viewportSize(); + + if (!mobileViewport) { + throw new Error("Mobile viewport is not configured"); + } + + const mobileChartWidth = await svg.evaluate( + (element) => element.getBoundingClientRect().width, + ); + + // Cross the application's 640px mobile breakpoint. + await page.setViewportSize({ + width: 900, + height: mobileViewport.height, + }); + + await expect( + visualization.getByText("Choose cohorts to compare", { + exact: true, + }), + ).toBeHidden(); + + await expect(legend).toBeHidden(); + + // All cohorts are visible outside the compact chart layout. + await expect(caption).toContainText( + "Retention percentage over time for Study A, Study B, Study C.", + ); + + await expect + .poll(() => + svg.evaluate((element) => element.getBoundingClientRect().width), + ) + .toBeGreaterThan(mobileChartWidth); + + // Restore the mobile viewport. + await page.setViewportSize(mobileViewport); + + await expect( + visualization.getByText("Comparing 1 of 3 cohorts"), + ).toBeVisible(); + + await expect(legend.getByRole("listitem")).toHaveText(["Study C"]); + + await expect(caption).toContainText( + "Retention percentage over time for Study C.", + ); + + // Restore the default mobile cohort selection. + await visualization + .getByText("Choose cohorts to compare", { + exact: true, + }) + .click(); + + await visualization + .getByRole("button", { + name: "Reset selection", + }) + .click(); + + await expect(studyA).toBeChecked(); + await expect(studyB).toBeChecked(); + await expect(studyC).not.toBeChecked(); + + await expect( + visualization.getByText("Comparing 2 of 3 cohorts"), + ).toBeVisible(); + + await expect(legend.getByRole("listitem")).toHaveText([ + "Study A", + "Study B", + ]); + + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); + }); +}); diff --git a/frontend/e2e/mappings.spec.ts b/frontend/e2e/mappings.spec.ts new file mode 100644 index 0000000..c91c642 --- /dev/null +++ b/frontend/e2e/mappings.spec.ts @@ -0,0 +1,433 @@ +import type { Locator, Page } from "@playwright/test"; + +import type { ChordDiagramData } from "../src/features/mappings/types"; + +import { expect, test } from "./fixtures"; + +async function openPage(page: Page) { + await page.goto("/#/mappings"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect( + page.getByRole("heading", { + name: "Variable Mappings", + level: 1, + }), + ).toBeVisible(); +} + +async function expectUnclippedDiagram(svg: Locator) { + await expect(svg).toBeVisible(); + + await expect(svg).not.toHaveAttribute("viewBox", "-450 -450 900 900"); + + // Verify that the measured SVG content fits inside its viewBox. + await expect + .poll(() => + svg.evaluate((element) => { + if (!(element instanceof SVGSVGElement)) { + throw new Error("Expected an SVG element"); + } + + const content = element.querySelector(":scope > g"); + + if (!(content instanceof SVGGraphicsElement)) { + throw new Error("SVG diagram content is unavailable"); + } + + const bounds = content.getBBox(); + const viewBox = element.viewBox.baseVal; + + return Math.min( + bounds.x - viewBox.x, + bounds.y - viewBox.y, + viewBox.x + viewBox.width - bounds.x - bounds.width, + viewBox.y + viewBox.height - bounds.y - bounds.height, + ); + }), + ) + .toBeGreaterThanOrEqual(-1); +} + +function createPaginatedMappings(): ChordDiagramData { + const links = Array.from({ length: 21 }, (_, index) => { + const number = String(index + 1).padStart(2, "0"); + + return { + source: `Variable A ${number}`, + target: `Variable B ${number}`, + }; + }); + + return { + nodes: links.flatMap(({ source, target }) => [ + { name: source, group: "Study A" }, + { name: target, group: "Study B" }, + ]), + links, + }; +} + +test("renders mappings, supports accessible variable selection and switches modalities", async ({ + page, + network, +}) => { + await openPage(page); + + const modalities = page.getByRole("group", { + name: "Select a mapping modality", + }); + + const demographics = modalities.getByRole("button", { + name: "Demographics", + exact: true, + }); + + const clinical = modalities.getByRole("button", { + name: "Clinical", + exact: true, + }); + + const visualization = page.getByRole("region", { + name: "Variable mapping visualization", + }); + + const svg = visualization.getByRole("figure").locator("svg"); + + await expect(visualization).toBeHidden(); + + await expect(demographics).toHaveAttribute("aria-pressed", "false"); + + await demographics.click(); + + await expect(demographics).toHaveAttribute("aria-pressed", "true"); + + await expect( + page.getByRole("heading", { + name: "Demographics mappings", + exact: true, + }), + ).toBeVisible(); + + await page.evaluate(async () => { + await document.fonts.ready; + }); + + await expectUnclippedDiagram(svg); + + await expect(svg).toHaveAccessibleName("Demographics variable mappings"); + + const bands = svg.locator(".group-highlight > path"); + const ribbons = svg.locator(".mapping-ribbons > path"); + + await expect(bands).toHaveCount(2); + await expect(ribbons).toHaveCount(1); + + await expect(ribbons).toHaveAttribute("d", /^M/); + await expect(ribbons).toHaveAttribute("fill", "#0066cc"); + + await expect(svg.locator(".variable-labels > text")).toHaveText([ + "Age", + "Enrollment age", + ]); + + await expect( + page.getByRole("navigation", { + name: "Mapping diagram pagination", + }), + ).toBeHidden(); + + // Use the accessible alternative to direct SVG interaction. + await visualization + .getByText("Browse variables (2)", { exact: true }) + .click(); + + const age = visualization.getByRole("button", { + name: /^Age\s*Study A$/, + }); + + await expect(age).toHaveAttribute("aria-pressed", "false"); + + await age.click(); + + const panel = page.getByRole("complementary", { + name: "Mappings for Age (Study A)", + }); + + await expect(panel).toBeVisible(); + + await expect(age).toHaveAttribute("aria-pressed", "true"); + + await expect( + panel.getByText("1 mapped variable", { exact: true }), + ).toBeVisible(); + + await expect( + panel.getByText("Enrollment age", { exact: true }), + ).toBeVisible(); + + await expect(panel.getByRole("listitem")).toHaveCount(1); + + await expect(ribbons).toHaveAttribute("fill", "#000000"); + + await panel.getByRole("button", { name: "Close" }).click(); + + await expect(panel).toBeHidden(); + + await expect(age).toHaveAttribute("aria-pressed", "false"); + + await expect(ribbons).toHaveAttribute("fill", "#0066cc"); + + // Clinical has no mappings in the shared fixture. + await clinical.click(); + + await expect(clinical).toHaveAttribute("aria-pressed", "true"); + + await expect(demographics).toHaveAttribute("aria-pressed", "false"); + + await expect( + page.getByText("No mappings available", { exact: true }), + ).toBeVisible(); + + await expect(visualization).toBeHidden(); + + // Returning to Demographics restores its diagram. + await demographics.click(); + + await expectUnclippedDiagram(svg); + await expect(ribbons).toHaveCount(1); + + await expect( + visualization.getByRole("button", { + name: /^Age\s*Study A$/, + }), + ).toBeHidden(); + + expect(network.apiRequests).toEqual( + expect.arrayContaining([ + "GET /api/cdm/modalities", + "GET /api/visualization/chords/?modality=Demographics", + "GET /api/visualization/chords/?modality=Clinical", + ]), + ); +}); + +test("paginates dense mapping diagrams without losing connected variables", async ({ + page, +}) => { + await page.route( + (url) => + url.pathname === "/api/visualization/chords/" && + url.searchParams.get("modality") === "Demographics", + async (route) => { + await route.fulfill({ + json: createPaginatedMappings(), + }); + }, + ); + + await openPage(page); + + const demographics = page.getByRole("button", { + name: "Demographics", + exact: true, + }); + + await demographics.click(); + + const pagination = page.getByRole("navigation", { + name: "Mapping diagram pagination", + }); + + const previous = pagination.getByRole("button", { + name: "Previous diagram", + }); + + const next = pagination.getByRole("button", { + name: "Next diagram", + }); + + const visualization = page.getByRole("region", { + name: "Variable mapping visualization", + }); + + const svg = visualization.getByRole("figure").locator("svg"); + + const labels = svg.locator(".variable-labels > text"); + const ribbons = svg.locator(".mapping-ribbons > path"); + + await expect(pagination.getByText("Page 1 of 2")).toBeVisible(); + + await expect(previous).toBeDisabled(); + await expect(next).toBeEnabled(); + + await expect(labels).toHaveCount(40); + await expect(ribbons).toHaveCount(20); + + await expect(labels.filter({ hasText: /^Variable A 01$/ })).toHaveCount(1); + + await expect(labels.filter({ hasText: /^Variable A 21$/ })).toHaveCount(0); + + await page.evaluate(async () => { + await document.fonts.ready; + }); + + await expectUnclippedDiagram(svg); + + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); + + await next.click(); + + await expect(pagination.getByText("Page 2 of 2")).toBeVisible(); + + await expect(previous).toBeEnabled(); + await expect(next).toBeDisabled(); + + await expect(labels).toHaveText(["Variable A 21", "Variable B 21"]); + + await expect(ribbons).toHaveCount(1); + + await expectUnclippedDiagram(svg); + + await visualization + .getByText("Browse variables (2)", { exact: true }) + .click(); + + await visualization + .getByRole("button", { + name: /^Variable A 21\s*Study A$/, + }) + .click(); + + const panel = page.getByRole("complementary", { + name: "Mappings for Variable A 21 (Study A)", + }); + + await expect(panel).toBeVisible(); + + await expect(panel.getByText("Variable B 21", { exact: true })).toBeVisible(); + + await panel.getByRole("button", { name: "Close" }).click(); + + await previous.click(); + + await expect(pagination.getByText("Page 1 of 2")).toBeVisible(); + + await expect(labels).toHaveCount(40); + await expect(ribbons).toHaveCount(20); + + // The new diagram must have its own variable browser. + await expect( + visualization.getByText("Browse variables (40)", { + exact: true, + }), + ).toBeVisible(); + + await expect(panel).toBeHidden(); + + await next.click(); + + await expect(pagination.getByText("Page 2 of 2")).toBeVisible(); + + // Changing modalities resets pagination. + await page + .getByRole("button", { + name: "Clinical", + exact: true, + }) + .click(); + + await expect( + page.getByText("No mappings available", { exact: true }), + ).toBeVisible(); + + await expect(pagination).toBeHidden(); + + await demographics.click(); + + await expect(pagination.getByText("Page 1 of 2")).toBeVisible(); + + await expect(previous).toBeDisabled(); + await expect(labels).toHaveCount(40); + await expect(ribbons).toHaveCount(20); +}); + +test.describe("desktop chord interactions", () => { + test.skip(({ isMobile }) => isMobile, "Desktop pointer interaction only"); + + test("highlights mappings through real SVG pointer interactions", async ({ + page, + }) => { + await openPage(page); + + await page + .getByRole("button", { + name: "Demographics", + exact: true, + }) + .click(); + + const visualization = page.getByRole("region", { + name: "Variable mapping visualization", + }); + + const svg = visualization.getByRole("figure").locator("svg"); + + const age = svg + .locator(".variable-labels > text") + .filter({ hasText: /^Age$/ }); + + const ribbon = svg.locator(".mapping-ribbons > path"); + + const panel = page.getByRole("complementary", { + name: "Mappings for Age (Study A)", + }); + + await expect(age).toBeVisible(); + + await expect(ribbon).toHaveAttribute("fill", "#0066cc"); + + await age.hover(); + + await expect(age).toHaveAttribute("font-weight", "700"); + await expect(ribbon).toHaveAttribute("fill", "#000000"); + + await expect(panel).toBeHidden(); + + // Hover alone must not select the variable. + await page.mouse.move(0, 0); + + await expect(age).toHaveAttribute("font-weight", "400"); + await expect(ribbon).toHaveAttribute("fill", "#0066cc"); + + await age.click(); + + await expect(panel).toBeVisible(); + + await page.mouse.move(0, 0); + + // Selection persists when the pointer leaves the variable. + await expect(panel).toBeVisible(); + await expect(age).toHaveAttribute("font-weight", "700"); + await expect(ribbon).toHaveAttribute("fill", "#000000"); + + await panel.getByRole("button", { name: "Close" }).click(); + + await expect(panel).toBeHidden(); + await expect(age).toHaveAttribute("font-weight", "400"); + await expect(ribbon).toHaveAttribute("fill", "#0066cc"); + }); +}); diff --git a/frontend/e2e/navigation.spec.ts b/frontend/e2e/navigation.spec.ts new file mode 100644 index 0000000..f0abd11 --- /dev/null +++ b/frontend/e2e/navigation.spec.ts @@ -0,0 +1,384 @@ +import type { Page } from "@playwright/test"; + +import { expect, test } from "./fixtures"; + +const HOME_HEADING = "Explore Parkinson's disease cohort data"; + +async function openPage(page: Page, path = "/") { + await page.goto(`/#${path}`); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); +} + +async function expectNoHorizontalOverflow(page: Page) { + await page.evaluate(async () => { + await document.fonts.ready; + }); + + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); +} + +test.describe("desktop navigation", () => { + test.skip(({ isMobile }) => isMobile, "Desktop navigation only"); + + test("displays desktop navigation and highlights the active route", async ({ + page, + }) => { + await openPage(page); + + const navigation = page.getByRole("navigation", { + name: "Main navigation", + }); + + await expect(navigation).toBeVisible(); + + await expect( + page.getByRole("button", { name: "Navigation menu" }), + ).toBeHidden(); + + await expect(navigation.getByRole("link")).toHaveText([ + "Cohorts", + "Biomarkers", + "Study Picker", + "Longitudinal", + "Mappings", + "Race", + "Contact Us", + ]); + + const cohorts = navigation.getByRole("link", { + name: "Cohorts", + exact: true, + }); + + await cohorts.click(); + + await expect(page).toHaveURL(/#\/cohorts$/); + + await expect( + page.getByRole("heading", { + name: "Cohort Studies", + level: 1, + }), + ).toBeVisible(); + + await expect(cohorts).toHaveAttribute("aria-current", "page"); + + await expect( + page.getByRole("table", { + name: "Cohort study comparison", + }), + ).toBeVisible(); + + await expectNoHorizontalOverflow(page); + + const biomarkers = navigation.getByRole("link", { + name: "Biomarkers", + exact: true, + }); + + await biomarkers.click(); + + await expect(page).toHaveURL(/#\/biomarkers$/); + + await expect( + page.getByRole("heading", { + name: "Biomarkers", + level: 1, + }), + ).toBeVisible(); + + await expect(biomarkers).toHaveAttribute("aria-current", "page"); + + await expect(cohorts).not.toHaveAttribute("aria-current", "page"); + }); +}); + +test.describe("mobile navigation", () => { + test.skip(({ isMobile }) => !isMobile, "Mobile navigation only"); + + test("displays the mobile menu and navigates to the selected feature", async ({ + page, + }) => { + await openPage(page); + + await expect( + page.getByRole("navigation", { + name: "Main navigation", + }), + ).toBeHidden(); + + const trigger = page.getByRole("button", { + name: "Navigation menu", + }); + + await expect(trigger).toBeVisible(); + + await trigger.click(); + + const menu = page.getByRole("menu", { + name: "Main navigation", + }); + + await expect(menu).toBeVisible(); + + await expect(trigger).toHaveAttribute("aria-expanded", "true"); + + await expect(menu.getByRole("menuitem")).toHaveText([ + "Home", + "Cohorts", + "Biomarkers", + "Study Picker", + "Longitudinal", + "Mappings", + "Race", + "Contact Us", + ]); + + await expect( + menu.getByRole("menuitem", { name: "Home", exact: true }), + ).toHaveAttribute("aria-current", "page"); + + await menu + .getByRole("menuitem", { + name: "Cohorts", + exact: true, + }) + .click(); + + await expect(page).toHaveURL(/#\/cohorts$/); + + await expect( + page.getByRole("heading", { + name: "Cohort Studies", + level: 1, + }), + ).toBeVisible(); + + await expect(menu).toBeHidden(); + + await expect(trigger).toHaveAttribute("aria-expanded", "false"); + + const overview = page.getByRole("region", { + name: "Cohort overview", + }); + + await expect(overview).toBeVisible(); + + await expect( + overview.getByRole("button", { + name: "Compare in table", + }), + ).toBeVisible(); + + await expect( + page.getByRole("table", { + name: "Cohort study comparison", + }), + ).toBeHidden(); + + await expectNoHorizontalOverflow(page); + + await trigger.click(); + + await expect( + menu.getByRole("menuitem", { + name: "Cohorts", + exact: true, + }), + ).toHaveAttribute("aria-current", "page"); + + await menu + .getByRole("menuitem", { + name: "Home", + exact: true, + }) + .click(); + + await expect(page).toHaveURL(/#\/$/); + + await expect( + page.getByRole("heading", { + name: HOME_HEADING, + level: 1, + }), + ).toBeVisible(); + + await expect(menu).toBeHidden(); + }); +}); + +test("supports browser history and returning home", async ({ page }) => { + await openPage(page); + + await page.getByRole("link", { name: "Browse cohorts" }).click(); + + await expect(page).toHaveURL(/#\/cohorts$/); + + await expect( + page.getByRole("heading", { + name: "Cohort Studies", + level: 1, + }), + ).toBeVisible(); + + await page + .getByRole("navigation", { name: "About links" }) + .getByRole("link", { name: "Contact Us" }) + .click(); + + await expect(page).toHaveURL(/#\/contact-us$/); + + await expect( + page.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); + + await expectNoHorizontalOverflow(page); + + await page.goBack(); + + await expect(page).toHaveURL(/#\/cohorts$/); + + await expect( + page.getByRole("heading", { + name: "Cohort Studies", + level: 1, + }), + ).toBeVisible(); + + await page.goForward(); + + await expect(page).toHaveURL(/#\/contact-us$/); + + await expect( + page.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); + + await page.getByRole("link", { name: "PDataViewer home" }).click(); + + await expect(page).toHaveURL(/#\/$/); + + await expect( + page.getByRole("heading", { + name: HOME_HEADING, + level: 1, + }), + ).toBeVisible(); + + await expect( + page.getByRole("region", { + name: "PDataViewer at a glance", + }), + ).toHaveAttribute("aria-busy", "false"); + + await expectNoHorizontalOverflow(page); +}); + +test("preserves direct follow-up URLs and selected variables after reload", async ({ + page, +}) => { + const path = + "/plot-longitudinal?cohort=Study+A&variables=Age&variables=Study+Visit"; + + await openPage(page, path); + + const information = page.getByRole("region", { + name: "Selected study information", + }); + + const results = page.getByRole("region", { + name: "Longitudinal measurement results", + }); + + await expect( + page.getByRole("heading", { + name: "Measurement Availability by Variable", + level: 1, + }), + ).toBeVisible(); + + await expect(information.getByText("Study A", { exact: true })).toBeVisible(); + + await information.getByText("Selected variables (2)").click(); + + await expect(information.getByRole("listitem")).toHaveText([ + "Age", + "Study Visit", + ]); + + await expect( + results.getByRole("heading", { + name: "Measurement availability — Study A", + }), + ).toBeVisible(); + + const directUrl = page.url(); + + expect(new URL(directUrl).hash).toBe(`#${path}`); + + await page.reload(); + + await expect(page).toHaveURL(directUrl); + + await expect(information.getByText("Study A", { exact: true })).toBeVisible(); + + await information.getByText("Selected variables (2)").click(); + + await expect(information.getByRole("listitem")).toHaveText([ + "Age", + "Study Visit", + ]); + + await expect( + results.getByRole("heading", { + name: "Measurement availability — Study A", + }), + ).toBeVisible(); + + await expect( + page.getByRole("region", { + name: "Optional analytics", + }), + ).toBeHidden(); + + await expectNoHorizontalOverflow(page); +}); + +test("redirects unknown routes to the homepage", async ({ page }) => { + await openPage(page, "/unknown-route"); + + await expect(page).toHaveURL(/#\/$/); + + await expect( + page.getByRole("heading", { + name: HOME_HEADING, + level: 1, + }), + ).toBeVisible(); + + await expect( + page.getByRole("region", { + name: "PDataViewer at a glance", + }), + ).toHaveAttribute("aria-busy", "false"); + + await expectNoHorizontalOverflow(page); +}); diff --git a/frontend/e2e/races.spec.ts b/frontend/e2e/races.spec.ts new file mode 100644 index 0000000..fc23744 --- /dev/null +++ b/frontend/e2e/races.spec.ts @@ -0,0 +1,278 @@ +import { readFile } from "node:fs/promises"; + +import type { Locator, Page } from "@playwright/test"; + +import { expect, test } from "./fixtures"; + +async function openPage(page: Page) { + await page.goto("/#/races"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect( + page.getByRole("heading", { + name: "Race Distribution", + level: 1, + }), + ).toBeVisible(); +} + +async function selectCohort(page: Page, cohort: string) { + const input = page.getByRole("combobox", { + name: "Cohort", + exact: true, + }); + + await expect(input).toBeEnabled(); + + await input.fill(cohort); + + await page + .getByRole("option", { + name: cohort, + exact: true, + }) + .click(); +} + +async function getChartPaths(svg: Locator) { + return svg + .locator("path[d]") + .evaluateAll((paths) => paths.map((path) => path.getAttribute("d"))); +} + +test("filters race distributions by cohort, updates the chart and exports an SVG", async ({ + page, + network, +}) => { + await openPage(page); + + const cohort = page.getByRole("combobox", { + name: "Cohort", + exact: true, + }); + + const distribution = page.getByRole("region", { + name: "Selection distribution", + }); + + const breakdown = distribution.getByRole("list", { + name: "Race selection breakdown", + }); + + const figure = distribution.getByRole("figure"); + const svg = figure.locator("svg"); + + await expect(cohort).toHaveValue(""); + await expect(cohort).toHaveAttribute("placeholder", "All cohorts"); + + await expect(svg).toBeVisible(); + + await expect(distribution.getByText("125", { exact: true })).toBeVisible(); + + await expect( + distribution.getByText("Across 2 selected cohorts", { exact: true }), + ).toBeVisible(); + + await expect(breakdown.getByRole("listitem")).toHaveText([ + /White\s*76\.0%\s*95$/, + /Asian\s*24\.0%\s*30$/, + ]); + + await expect( + distribution.getByText( + "Shares are calculated from selected race responses, not unique participants.", + { exact: true }, + ), + ).toBeVisible(); + + await expect.poll(() => svg.locator("path[d]").count()).toBeGreaterThan(0); + + const aggregatePaths = await getChartPaths(svg); + + expect(network.apiRequests).toEqual( + expect.arrayContaining([ + "GET /api/races/cohorts", + "GET /api/races/distribution?cohorts=Study+A&cohorts=Study+B", + ]), + ); + + // Filter to Study A. + await selectCohort(page, "Study A"); + + await expect(cohort).toHaveValue("Study A"); + + await expect(distribution.getByText("80", { exact: true })).toBeVisible(); + + await expect( + distribution.getByText("Across 1 selected cohort", { exact: true }), + ).toBeVisible(); + + await expect(breakdown.getByRole("listitem")).toHaveText([ + /White\s*75\.0%\s*60$/, + /Asian\s*25\.0%\s*20$/, + ]); + + await expect(svg).toBeVisible(); + + // The actual chart geometry must change after filtering. + await expect.poll(() => getChartPaths(svg)).not.toEqual(aggregatePaths); + + expect(network.apiRequests).toContain( + "GET /api/races/distribution?cohorts=Study+A", + ); + + // Switch directly to Study B. + await selectCohort(page, "Study B"); + + await expect(cohort).toHaveValue("Study B"); + + await expect(distribution.getByText("45", { exact: true })).toBeVisible(); + + await expect(breakdown.getByRole("listitem")).toHaveText([ + /White\s*77\.8%\s*35$/, + /Asian\s*22\.2%\s*10$/, + ]); + + await expect(svg).toBeVisible(); + + expect(network.apiRequests).toContain( + "GET /api/races/distribution?cohorts=Study+B", + ); + + // Export the filtered chart. + const [download] = await Promise.all([ + page.waitForEvent("download"), + distribution.getByRole("button", { name: "Export SVG" }).click(), + ]); + + expect(download.suggestedFilename()).toBe("race-distribution.svg"); + + expect(await download.failure()).toBeNull(); + + const exportedSvg = await readFile(await download.path(), "utf8"); + + expect(exportedSvg).toMatch(/]/); + expect(exportedSvg).toContain(""); + expect(exportedSvg).toContain(" { + await document.fonts.ready; + }); + + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); +}); + +test("removes the previous chart when a cohort has no positive selections and restores it when the filter is cleared", async ({ + page, +}) => { + // Override only Study B with a response containing + // no positive race selections. + await page.route( + (url) => + url.pathname === "/api/races/distribution" && + url.searchParams.getAll("cohorts").length === 1 && + url.searchParams.get("cohorts") === "Study B", + async (route) => { + await route.fulfill({ + json: [ + { + name: "White", + value: 0, + validCount: 0, + unknownCount: 3, + missingCount: 47, + }, + { + name: "Asian", + value: 0, + validCount: 0, + unknownCount: 3, + missingCount: 47, + }, + ], + }); + }, + ); + + await openPage(page); + + const distribution = page.getByRole("region", { + name: "Selection distribution", + }); + + const svg = distribution.getByRole("figure").locator("svg"); + + const exportButton = distribution.getByRole("button", { + name: "Export SVG", + }); + + const emptyState = distribution.getByText("No race selections found", { + exact: true, + }); + + await expect(svg).toBeVisible(); + await expect(exportButton).toBeVisible(); + await expect(emptyState).toBeHidden(); + + await selectCohort(page, "Study B"); + + await expect(emptyState).toBeVisible(); + + await expect(svg).toHaveCount(0); + await expect(exportButton).toHaveCount(0); + + await expect( + distribution.getByRole("list", { + name: "Race selection breakdown", + }), + ).toHaveCount(0); + + // The empty response must not prevent further comparisons. + await page + .getByRole("button", { + name: "Clear cohort selection", + }) + .click(); + + await expect(emptyState).toBeHidden(); + + await expect(svg).toBeVisible(); + await expect(exportButton).toBeVisible(); + + await expect(distribution.getByText("125", { exact: true })).toBeVisible(); +}); diff --git a/frontend/e2e/smoke.spec.ts b/frontend/e2e/smoke.spec.ts new file mode 100644 index 0000000..429ea09 --- /dev/null +++ b/frontend/e2e/smoke.spec.ts @@ -0,0 +1,83 @@ +import { expect, test } from "./fixtures"; + +test("loads the production application and displays the contact page", async ({ + page, + network, +}) => { + await page.goto("/#/contact-us"); + + await expect( + page.getByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeVisible(); + + await expect( + page.getByRole("link", { + name: "PDataViewer home", + }), + ).toBeVisible(); + + const consent = page.getByRole("region", { + name: "Optional analytics", + }); + + await expect(consent).toBeVisible(); + + await consent + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect(consent).toBeHidden(); + + await expect( + page.getByRole("region", { + name: "PDataViewer team", + }), + ).toBeVisible(); + + expect(network.apiRequests).toEqual([]); + expect(network.blockedExternalRequests).toEqual([]); +}); + +test("loads homepage statistics through the shared API handlers", async ({ + page, + network, +}) => { + await page.goto("/#/"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + const statistics = page.getByRole("region", { + name: "PDataViewer at a glance", + }); + + await expect(statistics).toHaveAttribute("aria-busy", "false"); + + await expect(statistics.getByRole("definition")).toHaveText([ + "2", + "150", + "2", + "2", + ]); + + await expect(statistics.getByText("Loading statistics...")).toBeHidden(); + + expect(network.apiRequests).toEqual( + expect.arrayContaining([ + "GET /api/cohorts/", + "GET /api/cohorts/metadata", + "GET /api/cdm/variables", + "GET /api/cdm/modalities", + ]), + ); + + expect(network.blockedExternalRequests).toEqual([]); +}); diff --git a/frontend/e2e/study-picker.spec.ts b/frontend/e2e/study-picker.spec.ts new file mode 100644 index 0000000..315c4ad --- /dev/null +++ b/frontend/e2e/study-picker.spec.ts @@ -0,0 +1,295 @@ +import type { Page } from "@playwright/test"; + +import { expect, test } from "./fixtures"; + +async function selectVariable(page: Page, variable: string) { + const input = page.getByRole("combobox", { + name: "Variables of interest", + }); + + await expect(input).toBeEnabled(); + + await input.fill(variable); + + await page + .getByRole("option", { + name: variable, + exact: true, + }) + .click(); + + await input.press("Escape"); +} + +test.beforeEach(async ({ page }) => { + await page.goto("/#/study-picker"); + + await page + .getByRole("button", { + name: "Reject optional analytics", + }) + .click(); + + await expect( + page.getByRole("heading", { + name: "Study Picker", + level: 1, + }), + ).toBeVisible(); + + await expect( + page.getByRole("combobox", { + name: "Variables of interest", + }), + ).toBeEnabled(); +}); + +test("ranks selected variables and opens cohort-specific longitudinal measurements", async ({ + page, + network, +}) => { + const rankButton = page.getByRole("button", { + name: "Rank cohorts", + }); + + const results = page.getByRole("region", { + name: "Cohort ranking results", + }); + + await expect(rankButton).toBeDisabled(); + await expect(results).toBeHidden(); + + await selectVariable(page, "Age"); + await selectVariable(page, "Motor score"); + + await expect(page.getByText("2 selected")).toBeVisible(); + await expect(rankButton).toBeEnabled(); + + // Verify that the actual browser submits the selected variables. + const [rankingRequest] = await Promise.all([ + page.waitForRequest( + (request) => + request.method() === "POST" && + new URL(request.url()).pathname === "/api/study-picker/rank", + ), + rankButton.click(), + ]); + + const submittedVariables: unknown = rankingRequest.postDataJSON(); + + expect(submittedVariables).toEqual(["Age", "Motor score"]); + + await expect(results).toBeVisible(); + + await expect( + results + .getByText("2/2 (100.0%)", { exact: true }) + .filter({ visible: true }), + ).toBeVisible(); + + await expect( + results.getByText("1/2 (50.0%)", { exact: true }).filter({ visible: true }), + ).toBeVisible(); + + const studyA = results.getByRole("link", { + name: "View longitudinal measurement availability for Study A (opens in a new tab)", + }); + + const studyB = results.getByRole("link", { + name: "View longitudinal measurement availability for Study B (opens in a new tab)", + }); + + await expect(studyA).toHaveAttribute( + "href", + /#\/plot-longitudinal\?cohort=Study\+A&variables=Age&variables=Motor\+score$/, + ); + + // Study B is missing Motor score. Only Age should be passed. + await expect(studyB).toHaveAttribute( + "href", + /#\/plot-longitudinal\?cohort=Study\+B&variables=Age$/, + ); + + await expect(studyB).toHaveAttribute("target", "_blank"); + + await expect(studyB).toHaveAttribute("rel", "noopener noreferrer"); + + // Open the actual new browser tab. + const [followUpPage] = await Promise.all([ + page.waitForEvent("popup"), + studyB.click(), + ]); + + await expect(followUpPage).toHaveURL( + /#\/plot-longitudinal\?cohort=Study\+B&variables=Age$/, + ); + + await expect( + followUpPage.getByRole("heading", { + name: "Measurement Availability by Variable", + level: 1, + }), + ).toBeVisible(); + + const information = followUpPage.getByRole("region", { + name: "Selected study information", + }); + + await expect(information.getByText("Study B", { exact: true })).toBeVisible(); + + await information.getByText("Selected variables (1)").click(); + + await expect(information.getByRole("listitem")).toHaveText(["Age"]); + + const measurements = followUpPage.getByRole("region", { + name: "Longitudinal measurement results", + }); + + await expect( + measurements.getByRole("heading", { + name: "Measurement availability — Study B", + }), + ).toBeVisible(); + + await expect(measurements.getByRole("figure").locator("svg")).toBeVisible(); + + expect(network.apiRequests).toContain("GET /api/longitudinal/Age/Study%20B"); + + expect(network.apiRequests).not.toContain( + "GET /api/longitudinal/Motor%20score/Study%20B", + ); + + await followUpPage.close(); + + // The original research selection remains available. + await expect(page).toHaveURL(/#\/study-picker$/); + await expect(results).toBeVisible(); + await expect(page.getByText("2 selected")).toBeVisible(); + + // Editing the selection invalidates the previous rankings. + await page.getByRole("button", { name: "Remove Motor score" }).click(); + + await expect(results).toBeHidden(); + await expect(page.getByText("1 selected")).toBeVisible(); + + await rankButton.click(); + + await expect( + results + .getByText("1/1 (100.0%)", { exact: true }) + .filter({ visible: true }), + ).toHaveCount(2); + + await page.getByRole("button", { name: "Clear all" }).click(); + + await expect(rankButton).toBeDisabled(); + await expect(results).toBeHidden(); +}); + +test.describe("mobile ranking comparison", () => { + test.skip(({ isMobile }) => !isMobile, "Mobile comparison only"); + + test("compares ranked cohorts using cards and the responsive table", async ({ + page, + }) => { + await selectVariable(page, "Age"); + await selectVariable(page, "Motor score"); + + await page.getByRole("button", { name: "Rank cohorts" }).click(); + + const results = page.getByRole("region", { + name: "Ranked cohorts", + }); + + const cards = results.getByRole("article"); + + const table = results.getByRole("table", { + name: "Cohorts ranked by variable availability", + }); + + await expect(cards.getByRole("heading", { level: 3 })).toHaveText([ + "Study A", + "Study B", + ]); + + await expect(table).toBeHidden(); + + const studyA = cards.filter({ + has: page.getByRole("heading", { + name: "Study A", + exact: true, + }), + }); + + const studyB = cards.filter({ + has: page.getByRole("heading", { + name: "Study B", + exact: true, + }), + }); + + await expect( + studyA.getByText("All selected variables found"), + ).toBeVisible(); + + await expect(studyB.getByText("Motor score", { exact: true })).toBeHidden(); + + await studyB + .getByText("Missing variables", { + exact: true, + }) + .click(); + + await expect( + studyB.getByText("Motor score", { exact: true }), + ).toBeVisible(); + + await results + .getByRole("button", { + name: "Compare in table", + }) + .click(); + + await expect(table).toBeVisible(); + await expect(cards).toHaveCount(0); + + const studyBRow = table.getByRole("row").filter({ + hasText: "Study B", + }); + + await expect( + studyBRow.getByRole("cell", { + name: "1/2 (50.0%)", + exact: true, + }), + ).toBeVisible(); + + await expect( + studyBRow.getByRole("cell", { + name: "Motor score", + exact: true, + }), + ).toBeVisible(); + + await expect + .poll(() => + page.evaluate( + () => + document.documentElement.scrollWidth - + document.documentElement.clientWidth, + ), + ) + .toBeLessThanOrEqual(1); + + await results.getByRole("button", { name: "Show cards" }).click(); + + await expect(table).toBeHidden(); + + await expect(cards.getByRole("heading", { level: 3 })).toHaveText([ + "Study A", + "Study B", + ]); + + await expect(page.getByText("2 selected")).toBeVisible(); + }); +}); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 9d33006..1e4e55e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -24,8 +24,13 @@ }, "devDependencies": { "@babel/core": "^8.1.3", + "@playwright/test": "^1.65.1", "@rolldown/plugin-babel": "^0.3.1", "@tailwindcss/vite": "^4.3.5", + "@testing-library/dom": "^10.4.2", + "@testing-library/jest-dom": "^8.0.0", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.13", "@types/babel__core": "^7.20.5", "@types/d3-chord": "^3.0.6", "@types/d3-shape": "^3.2.0", @@ -35,7 +40,10 @@ "@vitejs/devtools": "^0.8.3", "@vitejs/devtools-rolldown": "^0.8.0", "@vitejs/plugin-react": "^6.3.0", + "@vitest/coverage-v8": "^5.1.2", "babel-plugin-react-compiler": "^1.0.0", + "jsdom": "^31.0.1", + "msw": "^3.0.8", "oxlint": "^1.95.0", "oxlint-tsgolint": "^7.0.2009", "tailwindcss": "^4.3.3", @@ -48,6 +56,13 @@ "node": "^22.12.0 || ^24.0.0 || >=26.0.0" } }, + "node_modules/@adobe/css-tools": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.5.0.tgz", + "integrity": "sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@babel/code-frame": { "version": "8.0.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-8.0.6.tgz", @@ -579,6 +594,16 @@ } } }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/@devframes/agentic": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@devframes/agentic/-/agentic-1.3.5.tgz", @@ -796,6 +821,24 @@ } } }, + "node_modules/@exodus/bytes": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz", + "integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, "node_modules/@floating-ui/core": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", @@ -843,6 +886,94 @@ "url": "https://github.com/sponsors/ayuhito" } }, + "node_modules/@inquirer/ansi": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.1.1.tgz", + "integrity": "sha512-WwCc5T9554vU/M3W6mztOJvZK/5RgMwQsGlSZSZpKA/H2IfsTWIPdn1WiS8+HHjhe3H0IsmQCXUlDbvGM6vvuA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + } + }, + "node_modules/@inquirer/confirm": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.4.1.tgz", + "integrity": "sha512-ZLvGnS/+OtditM3RxULWDI3FVl3lR8mvh1ljZ8GCK8XKyfjI6Fq+ni6/2gbbH6n3gj6tinfNbE3QPplZ/xNVtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^12.1.1", + "@inquirer/type": "4.3.1" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/core": { + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-12.1.1.tgz", + "integrity": "sha512-JrVSjoB/+B4le+A/0GyZGv/oIK30KgGNUA0eVtEMNQLUmdpizfyXM0zglUZnwTtHLjpKGRlU/q6Iv5z2GYQw9w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^2.1.1", + "@inquirer/figures": "^2.1.1", + "@inquirer/type": "4.3.1", + "cli-width": "^4.1.0", + "fast-string-width": "^3.0.2", + "fast-wrap-ansi": "^0.2.0", + "mute-stream": "^3.0.0", + "signal-exit": "^4.1.0" + }, + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/@inquirer/figures": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.1.1.tgz", + "integrity": "sha512-63AOoKi9Wlsd1G+X5dKRg15GzN/WIEf0VghxHkcVn9JswideMlwq40qJMAO3II6JyhpDZPmi3CmVKjwOSYBAmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + } + }, + "node_modules/@inquirer/type": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.3.1.tgz", + "integrity": "sha512-WzfM7UPG5F8fhKPey5pTkAZQrGcGjOHbm6YLotuDdiuAkXEHiHSZh59yNeZs4RyrMHcZEZrl+GOcuLzzfLKJqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=23.5.0 || ^22.13.0 || ^20.17.0" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -952,6 +1083,41 @@ "node": ">=20" } }, + "node_modules/@msw/url": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@msw/url/-/url-0.1.3.tgz", + "integrity": "sha512-IvN0kCVRFtr12gBS3Nk8PRqjWjE/80ydze2DNQ0Z74ZjnMDWibVoaYFqGv9vR2LoiUfcVgEVaBWLFyp15M5YJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@mswjs/interceptors": { + "version": "0.45.14", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.45.14.tgz", + "integrity": "sha512-2y8lEnhEKzgxSoALB7ibIPpUJ68YqWmvGjYO2D6Z4dAmMAr7kG9Poh6HiW1poT+okHGSr6LgsbqO8rDDH7MsSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@open-draft/until": "^3.0.1", + "@types/debug": "^4.1.13", + "debug": "^4.4.3", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.3", + "rettime": "^0.11.12" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@open-draft/until": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-3.0.1.tgz", + "integrity": "sha512-s7/9ELP4aP9YZtW7RJaa0Xf3RISaRH9+EFN18FtykJYRHGNrl8f9ymvoNXzjhrjmftFvkQudtuDU9RYhk0xs3A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/kettanaito" + } + }, "node_modules/@oxc-project/types": { "version": "0.160.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.160.0.tgz", @@ -1393,6 +1559,22 @@ "node": "^20.19.0 || >=22.12.0" } }, + "node_modules/@playwright/test": { + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz", + "integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.65.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@remix-run/route-pattern": { "version": "0.22.1", "resolved": "https://registry.npmjs.org/@remix-run/route-pattern/-/route-pattern-0.22.1.tgz", @@ -2181,6 +2363,153 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@testing-library/dom": { + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.2.tgz", + "integrity": "sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "picocolors": "1.1.1", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/dom/node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@testing-library/dom/node_modules/@babel/runtime": { + "version": "7.29.16", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.16.tgz", + "integrity": "sha512-LKBjGopxrQE0aFucNL69OyyyF143MOWUULEOftU3oCgyD35Sy84UUpVnt/sNvTb7ZmCyALSt7om+fojlW35zYQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@testing-library/dom/node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/jest-dom": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-8.0.0.tgz", + "integrity": "sha512-Nu45KEeFgP/ydCMipnisMblq6YHViqEFi3fKN0a40s+zdKDDD7vEPCEavS0i7i4RxmclcEIL8q2o42pu+WgNgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "picocolors": "^1.1.1", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=22", + "npm": ">=6", + "yarn": ">=1" + }, + "peerDependencies": { + "@testing-library/dom": ">=10 <11", + "vitest": ">=5 <6" + }, + "peerDependenciesMeta": { + "vitest": { + "optional": true + } + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/react": { + "version": "16.3.3", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.3.tgz", + "integrity": "sha512-Uo193NgQbPMz6lrrhtRQQFcMC6Re/ELLFbbuVL30WDlZxlpZf9/lMHTAVxPRLw1q1iu9OJmR1c2BLiENRstdBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0 || ^19.0.0", + "@types/react-dom": "^18.0.0 || ^19.0.0", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@testing-library/react/node_modules/@babel/runtime": { + "version": "7.29.16", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.16.tgz", + "integrity": "sha512-LKBjGopxrQE0aFucNL69OyyyF143MOWUULEOftU3oCgyD35Sy84UUpVnt/sNvTb7ZmCyALSt7om+fojlW35zYQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@testing-library/user-event": { + "version": "14.6.13", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.13.tgz", + "integrity": "sha512-2LVZGptuB5un1Cu/u31o9adkCwbsUTMp4B4p04xupI7uobvTIpgKidSdShqZiReo/mQmvR9xjgdgTgge4oAbYA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "peerDependencies": { + "@testing-library/dom": ">=7.21.4" + } + }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -2268,6 +2597,16 @@ "@types/d3-path": "*" } }, + "node_modules/@types/debug": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", + "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, "node_modules/@types/deep-eql": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", @@ -2296,6 +2635,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "26.6.11", "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.11.tgz", @@ -2326,6 +2672,16 @@ "@types/react": "^19.3.0" } }, + "node_modules/@types/set-cookie-parser": { + "version": "2.4.10", + "resolved": "https://registry.npmjs.org/@types/set-cookie-parser/-/set-cookie-parser-2.4.10.tgz", + "integrity": "sha512-GGmQVGpQWUe5qglJozEjZV/5dyxbOOZ0LHe/lqyWssB88Y4svNfst0uqBVscdDeIKl5Jy5+aPSvy7mI9tYRguw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@typescript/typescript-aix-ppc64": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", @@ -2786,6 +3142,58 @@ } } }, + "node_modules/@vitest/coverage-v8": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.1.2.tgz", + "integrity": "sha512-VG0JLv0T4kr1fR6QAfe8PTou+Frc4t0u4j+oKgDH3djJpFawzBfGyX14/z56NXoCTNem3OEphzCJhc4DkE62xQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/istanbul-lib-coverage": "^2.1.1", + "@vitest/istanbul-lib-report": "^2.1.1", + "ast-v8-to-istanbul": "^1.0.8", + "magicast": "^0.5.5", + "obug": "^3.0.0", + "std-env": "^4.3.0", + "tinyrainbow": "^3.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "5.1.2", + "vitest": "5.1.2" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/istanbul-lib-coverage": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-2.1.1.tgz", + "integrity": "sha512-pF9nMHHuyQzyEXdkWX3d4wElEKjymfL5TEoofegJn/jK2WjmTLOcJKfJ7/YwYGYdbZf8Ebrt4VDUoBPiTuO9zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22" + } + }, + "node_modules/@vitest/istanbul-lib-report": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-2.1.1.tgz", + "integrity": "sha512-Qba+8OpQQAbWrmq3u1olh6jqE/vyW4OYJe6TLrrTBpXhjJhbY7Os69wyVvMQmNA64KJhGd5nQ/c7l4io8tPCHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/istanbul-lib-coverage": "2.1.1" + }, + "engines": { + "node": ">=22" + } + }, "node_modules/@vitest/mocker": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.2.tgz", @@ -2837,6 +3245,39 @@ "node": ">=0.4.0" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "dequal": "^2.0.3" + } + }, "node_modules/artichokie": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/artichokie/-/artichokie-0.4.5.tgz", @@ -2861,6 +3302,18 @@ "node": ">=12" } }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.8.tgz", + "integrity": "sha512-lPdpagk13ANXV+HClJEpCZM7kUsl5XcvgqKzZhaj6Ve1ZFICcY2sGhAN1n1vT0tML6EclT7bfVgTxqL57Gkpow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, "node_modules/babel-plugin-react-compiler": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-1.0.0.tgz", @@ -2884,8 +3337,35 @@ "node": ">=6.0.0" } }, - "node_modules/browserslist": { - "version": "4.29.5", + "node_modules/bcp-47": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.2.tgz", + "integrity": "sha512-wsv86UuNFuPnVieKLyECTT+CP1WSAHeoIg5P3xu2kA9Z+7fVPoKt7dxzSeEhtJel0AI+NW3fIW3KtTKQKUCngg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-match": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz", + "integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/browserslist": { + "version": "4.29.5", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.5.tgz", "integrity": "sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==", "dev": true, @@ -2971,6 +3451,49 @@ "url": "https://polar.sh/cva" } }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 12" + } + }, + "node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", @@ -3006,6 +3529,20 @@ "dev": true, "license": "MIT" }, + "node_modules/cookie": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-2.0.2.tgz", + "integrity": "sha512-SL0cVuEdETEp7pN0FuZb01toc3vnODEfVUCooxG1SJN0yIirh7JMb9X9bvfCFf0vzzbT68RdbKDHYTiWy7a7iw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/cookie-es": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/cookie-es/-/cookie-es-3.1.1.tgz", @@ -3013,9 +3550,9 @@ "license": "MIT" }, "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.2.tgz", + "integrity": "sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==", "dev": true, "license": "MIT", "dependencies": { @@ -3042,6 +3579,13 @@ } } }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true, + "license": "MIT" + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", @@ -3082,6 +3626,55 @@ "node": ">=12" } }, + "node_modules/data-urls": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz", + "integrity": "sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.1.2" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/destr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.5.tgz", @@ -3127,6 +3720,13 @@ } } }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "license": "MIT" + }, "node_modules/echarts": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/echarts/-/echarts-6.1.0.tgz", @@ -3150,6 +3750,13 @@ "dev": true, "license": "ISC" }, + "node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "dev": true, + "license": "MIT" + }, "node_modules/empathic": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/empathic/-/empathic-2.1.0.tgz", @@ -3174,6 +3781,19 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es-module-lexer": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", @@ -3241,6 +3861,33 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-string-truncated-width": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz", + "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-string-width": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz", + "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-string-truncated-width": "^3.0.2" + } + }, + "node_modules/fast-wrap-ansi": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/fast-wrap-ansi/-/fast-wrap-ansi-0.2.2.tgz", + "integrity": "sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-string-width": "^3.0.2" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -3294,6 +3941,29 @@ "node": ">=6.9.0" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -3330,6 +4000,30 @@ } } }, + "node_modules/headers-polyfill": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-5.0.1.tgz", + "integrity": "sha512-1TJ6Fih/b8h5TIcv+1+Hw0PDQWJTKDKzFZzcKOiW1wJza3XoAQlkCuXLbymPYB8+ZQyw8mHvdw560e8zVFIWyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/set-cookie-parser": "^2.4.10", + "set-cookie-parser": "^3.0.1" + } + }, + "node_modules/html-encoding-sniffer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz", + "integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.15.1" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" + } + }, "node_modules/import-meta-resolve": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz", @@ -3341,6 +4035,67 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-node-process": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", + "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -3375,6 +4130,44 @@ "dev": true, "license": "MIT" }, + "node_modules/jsdom": { + "version": "31.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz", + "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.16.0", + "bcp-47": "^2.1.2", + "bcp-47-match": "^2.0.3", + "data-urls": "^8.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^7.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.3", + "parse5": "^8.1.0", + "parse5-parser-stream": "^8.1.0", + "saxes": "^6.0.0", + "tough-cookie": "^6.0.2", + "undici": "^8.12.3", + "w3c-xmlserializer": "^6.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.3.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + }, + "peerDependencies": { + "@napi-rs/canvas": "^1.0.13" + }, + "peerDependenciesMeta": { + "@napi-rs/canvas": { + "optional": true + } + } + }, "node_modules/jsesc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", @@ -3692,6 +4485,16 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/lru-cache": { + "version": "11.5.4", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.4.tgz", + "integrity": "sha512-B8nJCTi8JuSaDBg0tBdnImV6j5O2CXaqKfdj24ZTCFbyivN8KZ2Z+RL3aHjwJAfLutD9cNnObG4SIgW4gMufiw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/lucide-react": { "version": "1.82.0", "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.82.0.tgz", @@ -3707,6 +4510,16 @@ } } }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "bin": { + "lz-string": "bin/bin.js" + } + }, "node_modules/magic-string": { "version": "1.4.5", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", @@ -3717,6 +4530,28 @@ "@jridgewell/sourcemap-codec": "^1.6.0" } }, + "node_modules/magicast": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.5.tgz", + "integrity": "sha512-UicdXN8zQ3JHlxVq+28afMXPr1z7WNY6+7EJnzTdQWkTAlMLF5fNCCKxJHBQwGaNGR11581EiQmQzx73+MvszA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "source-map-js": "^1.2.1" + } + }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/mlly": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.2.tgz", @@ -3749,6 +4584,69 @@ "pathe": "^2.0.1" } }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/msw": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/msw/-/msw-3.0.8.tgz", + "integrity": "sha512-impdVoyKxfwDM1v9gr9wAsAPYbPgt+xv58pHduptDEA6pPERX8bNRqEyvv+7CWObpqVDUg2PWeitdvj7Xk22Fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/confirm": "^6.0.11", + "@msw/url": "^0.1.3", + "@mswjs/interceptors": "^0.45.11", + "cookie": "^2.0.1", + "headers-polyfill": "^5.0.1", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.3", + "rettime": "^0.11.12", + "tough-cookie": "^6.0.2", + "type-fest": "^5.5.0", + "until-async": "^3.0.2", + "yargs": "^18.2.0" + }, + "bin": { + "msw": "cli/index.js" + }, + "engines": { + "node": ">=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/mswjs" + }, + "peerDependencies": { + "graphql": ">=16", + "typescript": ">=5.9.x", + "vite": ">=6" + }, + "peerDependenciesMeta": { + "graphql": { + "optional": true + }, + "typescript": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/mute-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz", + "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, "node_modules/nanoid": { "version": "3.3.20", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", @@ -3817,6 +4715,13 @@ "node": ">=12.20.0" } }, + "node_modules/outvariant": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", + "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", + "dev": true, + "license": "MIT" + }, "node_modules/oxlint": { "version": "1.95.0", "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.95.0.tgz", @@ -3891,6 +4796,32 @@ "dev": true, "license": "MIT" }, + "node_modules/parse5": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^9.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz", + "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse5": "^8.1.1" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -3950,6 +4881,35 @@ "pathe": "^2.0.3" } }, + "node_modules/playwright": { + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz", + "integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.65.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz", + "integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/postcss": { "version": "8.5.34", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.34.tgz", @@ -3979,6 +4939,31 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/quansync": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/quansync/-/quansync-1.0.0.tgz", @@ -4017,6 +5002,13 @@ "react": "^19.3.1" } }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, + "license": "MIT" + }, "node_modules/react-router": { "version": "8.5.3", "resolved": "https://registry.npmjs.org/react-router/-/react-router-8.5.3.tgz", @@ -4047,12 +5039,33 @@ } } }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/reselect": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.3.0.tgz", "integrity": "sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg==", "license": "MIT" }, + "node_modules/rettime": { + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/rettime/-/rettime-0.11.13.tgz", + "integrity": "sha512-kzDWDmrxn6KPqqyFaBcXtV+GzaUzgYulSrWBetyxsPZjlXabWoeg3uZJU+zK/TnFUtkWC2Yw7J/VAWYnzy0tRA==", + "dev": true, + "license": "MIT" + }, "node_modules/rolldown": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.3.4.tgz", @@ -4098,12 +5111,32 @@ "node": ">=20.19.0" } }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/scheduler": { "version": "0.28.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", "license": "MIT" }, + "node_modules/set-cookie-parser": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-3.2.3.tgz", + "integrity": "sha512-bDO7NdAkLprNt3BNl3LAh0oVnOS5+WspzxOxiboo7vRIyTqj2pvFmNWYEFynSGQgpJ+7yG/9nc/aSG20UDBUpg==", + "dev": true, + "license": "MIT" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4127,6 +5160,19 @@ "node": ">=8" } }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/source-map-js": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", @@ -4157,6 +5203,78 @@ "dev": true, "license": "MIT" }, + "node_modules/string-width": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi/node_modules/ansi-regex": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.6.0.tgz", + "integrity": "sha512-XZ5apbzreCbXSKwPjJstu8R0zOi247w3XYwWxtwBXgpZrCyc1Ka7p9/xY0A9/diMewmHbEKz+FIraWaEWjlN5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tagged-tag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/tagged-tag/-/tagged-tag-1.0.0.tgz", + "integrity": "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/tailwindcss": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.5.tgz", @@ -4215,6 +5333,62 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tinyrainbow": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.2.0.tgz", + "integrity": "sha512-LgO3D9yZJjApUiuUfl9iFAwrtaX4+lok3wJIqttGoKCHlWUqHqbQpnxCf82L8FjgKsh4iGo78hqJwgL8F6To2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tldts": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.6.4.tgz", + "integrity": "sha512-wp+ZdvQyov404xynNcjbXoJyeGM28W/aCwMmry/rJ+Y0SsObukJYkWwuxWGbNpIjeqMaEbNUtXPNtPPfI5cTFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.6.4" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.6.4.tgz", + "integrity": "sha512-QywQ9lgQyZMuc3NVlqmuxHOhlwirSdvgD/vDLvX8dZYcYgy1cdri5rY/TXDHcF4J3VBSdJLcJNIJI6zGJ7jE+w==", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz", + "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz", + "integrity": "sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/tw-animate-css": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/tw-animate-css/-/tw-animate-css-1.4.0.tgz", @@ -4225,6 +5399,22 @@ "url": "https://github.com/sponsors/Wombosvideo" } }, + "node_modules/type-fest": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-5.10.0.tgz", + "integrity": "sha512-NoSdpq/WEiAg5sjmBkmV/hfxv6HJH4NqPNrqjtSO5CwRmpsDfaf4begxW34KdJykH/l1yHtwBWQkCRdoXO8mPA==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "dependencies": { + "tagged-tag": "^1.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typescript": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", @@ -4267,6 +5457,16 @@ "dev": true, "license": "MIT" }, + "node_modules/undici": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.14.0.tgz", + "integrity": "sha512-MqM6wqORYo0jb1WFUwFKZTFWFz6VeBMPj9op5Hq+RvlrQjISQCyLEfx5+/iqOLWC/LL1HliJ5t0NP1BgYpXeVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/undici-types": { "version": "8.9.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", @@ -4274,6 +5474,16 @@ "dev": true, "license": "MIT" }, + "node_modules/until-async": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/until-async/-/until-async-3.0.3.tgz", + "integrity": "sha512-Ix78tBf1shsd8V8zc+msjiUk8Yf6upBuqR9iTgcWTyNFkTPy7hMonnsG/W6jhu53vrNTB0VZHxSNayRHrF+Auw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/kettanaito" + } + }, "node_modules/update-browserslist-db": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", @@ -4489,6 +5699,54 @@ } } }, + "node_modules/w3c-xmlserializer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz", + "integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "17.3.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz", + "integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.16.0", + "tr46": "^7.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -4518,6 +5776,110 @@ "node": ">=20.11" } }, + "node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", + "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^8.2.1", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, "node_modules/zigpty": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/zigpty/-/zigpty-0.2.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index b74d729..2bc3de2 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,7 +15,12 @@ "typecheck": "tsc -b", "preview": "vite preview", "test": "vitest", + "test:e2e": "playwright test", + "test:e2e:ui": "playwright test --ui", + "test:e2e:headed": "playwright test --headed", + "test:e2e:report": "playwright show-report", "test:run": "vitest run", + "test:coverage": "vitest run --coverage", "check": "npm run lint:ci && npm run test:run && npm run build" }, "dependencies": { @@ -35,8 +40,13 @@ }, "devDependencies": { "@babel/core": "^8.1.3", + "@playwright/test": "^1.65.1", "@rolldown/plugin-babel": "^0.3.1", "@tailwindcss/vite": "^4.3.5", + "@testing-library/dom": "^10.4.2", + "@testing-library/jest-dom": "^8.0.0", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.13", "@types/babel__core": "^7.20.5", "@types/d3-chord": "^3.0.6", "@types/d3-shape": "^3.2.0", @@ -46,7 +56,10 @@ "@vitejs/devtools": "^0.8.3", "@vitejs/devtools-rolldown": "^0.8.0", "@vitejs/plugin-react": "^6.3.0", + "@vitest/coverage-v8": "^5.1.2", "babel-plugin-react-compiler": "^1.0.0", + "jsdom": "^31.0.1", + "msw": "^3.0.8", "oxlint": "^1.95.0", "oxlint-tsgolint": "^7.0.2009", "tailwindcss": "^4.3.3", diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts new file mode 100644 index 0000000..3214448 --- /dev/null +++ b/frontend/playwright.config.ts @@ -0,0 +1,56 @@ +import { defineConfig, devices } from "@playwright/test"; + +const BASE_URL = "http://127.0.0.1:4173"; +const isCI = Boolean(process.env.CI); + +export default defineConfig({ + testDir: "./e2e", + testMatch: "**/*.spec.ts", + tsconfig: "./tsconfig.e2e.json", + fullyParallel: true, + forbidOnly: isCI, + retries: isCI ? 1 : 0, + workers: isCI ? 1 : undefined, + timeout: 30_000, + expect: { timeout: 5_000 }, + reporter: isCI + ? [ + ["github"], + ["junit", { outputFile: "test-results/junit.xml" }], + ["html", { open: "never" }], + ] + : [["list"], ["html", { open: "never" }]], + outputDir: "test-results", + use: { + baseURL: BASE_URL, + trace: "retain-on-failure", + screenshot: "only-on-failure", + serviceWorkers: "block", + }, + projects: [ + { + name: "desktop", + use: { + ...devices["Desktop Chrome"], + browserName: "chromium", + }, + }, + { + name: "mobile", + use: { + ...devices["Pixel 7"], + browserName: "chromium", + }, + }, + ], + webServer: { + command: + "npm run build && npm run preview -- --host 127.0.0.1 --port 4173 --strictPort", + url: BASE_URL, + reuseExistingServer: false, + timeout: 120_000, + env: { + VITE_API_URL: "/api", + }, + }, +}); diff --git a/frontend/src/app/providers/AppProviders.test.tsx b/frontend/src/app/providers/AppProviders.test.tsx new file mode 100644 index 0000000..b94106f --- /dev/null +++ b/frontend/src/app/providers/AppProviders.test.tsx @@ -0,0 +1,52 @@ +// @vitest-environment jsdom + +import { QueryClient, useQueryClient } from "@tanstack/react-query"; +import { renderHook } from "@testing-library/react"; +import { expect, it, onTestFinished } from "vitest"; + +import { AppProviders } from "./AppProviders"; + +it("provides a QueryClient with the production query defaults", () => { + const { result } = renderHook(useQueryClient, { + wrapper: AppProviders, + }); + + expect(result.current).toBeInstanceOf(QueryClient); + + expect(result.current.getDefaultOptions().queries).toMatchObject({ + staleTime: 60_000, + retry: 1, + }); +}); + +it("preserves the query client and cached data across renders and remounts", () => { + const { result, rerender, unmount } = renderHook(useQueryClient, { + wrapper: AppProviders, + }); + + const client = result.current; + + onTestFinished(() => { + client.clear(); + }); + + const queryKey = ["provider-test", "cohorts"]; + const cohorts = ["Study A", "Study B"]; + + client.setQueryData(queryKey, cohorts); + + rerender(); + + expect(result.current).toBe(client); + expect(result.current.getQueryData(queryKey)).toEqual(cohorts); + + unmount(); + + const remounted = renderHook(useQueryClient, { + wrapper: AppProviders, + }); + + expect(remounted.result.current).toBe(client); + + expect(remounted.result.current.getQueryData(queryKey)).toEqual(cohorts); +}); diff --git a/frontend/src/app/router.test.tsx b/frontend/src/app/router.test.tsx new file mode 100644 index 0000000..1a518f6 --- /dev/null +++ b/frontend/src/app/router.test.tsx @@ -0,0 +1,320 @@ +// @vitest-environment jsdom + +import { screen, waitFor, within } from "@testing-library/react"; +import { http, HttpResponse } from "msw"; +import { afterEach, beforeEach, expect, it, vi } from "vitest"; + +import type * as AnalyticsModule from "@/lib/analytics"; +import { CONSENT_STORAGE_KEY, type AnalyticsConsent } from "@/lib/analytics"; +import { TEST_API_URL } from "@/test/mocks/handlers"; +import { server } from "@/test/mocks/server"; +import { renderWithProviders } from "@/test/render"; + +import { AppRouter } from "./router"; + +const ROUTE_LOAD_TIMEOUT = 5_000; + +const mocks = vi.hoisted(() => ({ + enableAnalytics: vi.fn<(pathname: string) => void>(), + trackPageView: vi.fn<(pathname: string) => void>(), + disableAnalytics: vi.fn<() => void>(), + reload: vi.fn<() => void>(), +})); + +vi.mock("@/lib/analytics", async (importOriginal) => ({ + ...(await importOriginal()), + analyticsConfigured: true, + enableAnalytics: mocks.enableAnalytics, + trackPageView: mocks.trackPageView, + disableAnalytics: mocks.disableAnalytics, + reloadAfterAnalyticsWithdrawal: mocks.reload, +})); + +const HOME_HEADING = "Explore Parkinson's disease cohort data"; + +beforeEach(() => { + vi.clearAllMocks(); + vi.stubGlobal("BASE_UI_ANIMATIONS_DISABLED", true); + + window.localStorage.clear(); + + // Prevent automatically rendered charts in router-level tests. + // Chart rendering is covered by dedicated component tests. + server.use( + http.get(`${TEST_API_URL}/longitudinal/:variable`, () => + HttpResponse.json([]), + ), + http.get(`${TEST_API_URL}/longitudinal/:variable/:cohort`, () => + HttpResponse.json([]), + ), + http.get(`${TEST_API_URL}/races/distribution`, () => HttpResponse.json([])), + ); +}); + +afterEach(() => { + window.localStorage.clear(); + window.history.replaceState(null, "", "/"); +}); + +function setup(route = "/", consent: AnalyticsConsent = "denied") { + window.history.replaceState(null, "", `/#${route}`); + + if (consent !== null) { + window.localStorage.setItem(CONSENT_STORAGE_KEY, consent); + } + + return renderWithProviders(, { + route: null, + }); +} + +function getAppHeader() { + const header = screen + .getByRole("link", { name: "PDataViewer home" }) + .closest("header"); + + if (!header) { + throw new Error("Application header not found"); + } + + return header; +} + +function getAppFooter() { + const footer = screen + .getByRole("navigation", { name: "Legal links" }) + .closest("footer"); + + if (!footer) { + throw new Error("Application footer not found"); + } + + return footer; +} + +it("preserves the shared layout while the contact page loads", async () => { + setup("/contact-us"); + + expect(screen.getByText("Loading page...")).toBeInTheDocument(); + + const header = getAppHeader(); + const footer = getAppFooter(); + + expect( + await screen.findByRole("heading", { + name: "Meet the Team", + level: 1, + }), + ).toBeInTheDocument(); + + expect(getAppHeader()).toBe(header); + expect(getAppFooter()).toBe(footer); + + expect(screen.queryByText("Loading page...")).not.toBeInTheDocument(); +}); + +it.each([ + { + path: "/", + heading: HOME_HEADING, + }, + { + path: "/cohorts", + heading: "Cohort Studies", + }, + { + path: "/biomarkers", + heading: "Biomarkers", + }, + { + path: "/study-picker", + heading: "Study Picker", + }, + { + path: "/longitudinal", + heading: "Longitudinal Measurement Availability", + }, + { + path: "/mappings", + heading: "Variable Mappings", + }, + { + path: "/races", + heading: "Race Distribution", + }, +])("renders the application route $path", async ({ path, heading }) => { + const { queryClient } = setup(path); + + expect( + await screen.findByRole( + "heading", + { + name: heading, + level: 1, + }, + { timeout: ROUTE_LOAD_TIMEOUT }, + ), + ).toBeInTheDocument(); + + expect(getAppHeader()).toBeInTheDocument(); + expect(getAppFooter()).toBeInTheDocument(); + + expect(window.location.hash).toBe(`#${path}`); + + expect( + screen.queryByRole("region", { + name: "Optional analytics", + }), + ).not.toBeInTheDocument(); + + expect(mocks.enableAnalytics).not.toHaveBeenCalled(); + expect(mocks.trackPageView).not.toHaveBeenCalled(); + + await waitFor(() => { + expect(queryClient.isFetching()).toBe(0); + }); +}); + +it("supports direct navigation to a variable-specific follow-up URL", async () => { + const path = + "/plot-longitudinal?cohort=Study+A&variables=Age&variables=Study+Visit"; + + setup(path); + + expect( + await screen.findByRole("heading", { + name: "Measurement Availability by Variable", + level: 1, + }), + ).toBeInTheDocument(); + + const information = screen.getByRole("region", { + name: "Selected study information", + }); + + expect(within(information).getByText("Study A")).toBeInTheDocument(); + + expect( + within(information).getByText("Selected variables (2)"), + ).toBeInTheDocument(); + + expect( + await screen.findByText("No measurements to visualize"), + ).toBeInTheDocument(); + + expect(window.location.hash).toBe(`#${path}`); +}); + +it("preserves the layout and analytics preferences across navigation", async () => { + const { user, queryClient } = setup(); + + const header = getAppHeader(); + const footer = getAppFooter(); + + await user.click( + within(footer).getByRole("button", { + name: "Analytics Preferences", + }), + ); + + const preferences = screen.getByRole("region", { + name: "Optional analytics", + }); + + expect(preferences).toBeInTheDocument(); + + await user.click( + screen.getByRole("link", { + name: "Browse cohorts", + }), + ); + + expect( + await screen.findByRole("heading", { + name: "Cohort Studies", + level: 1, + }), + ).toBeInTheDocument(); + + expect(window.location.hash).toBe("#/cohorts"); + + expect(getAppHeader()).toBe(header); + expect(getAppFooter()).toBe(footer); + + expect( + screen.getByRole("region", { + name: "Optional analytics", + }), + ).toBe(preferences); + + const navigation = within(header).getByRole("navigation", { + name: "Main navigation", + }); + + expect( + within(navigation).getByRole("link", { + name: "Cohorts", + }), + ).toHaveAttribute("aria-current", "page"); + + expect(mocks.trackPageView).not.toHaveBeenCalled(); + + await user.click( + within(preferences).getByRole("button", { + name: "Allow analytics", + }), + ); + + expect(preferences).not.toBeInTheDocument(); + + expect(window.localStorage.getItem(CONSENT_STORAGE_KEY)).toBe("granted"); + + expect(mocks.trackPageView).toHaveBeenCalledExactlyOnceWith("/cohorts"); + + await user.click( + within(header).getByRole("link", { + name: "PDataViewer home", + }), + ); + + expect( + await screen.findByRole("heading", { + name: HOME_HEADING, + level: 1, + }), + ).toBeInTheDocument(); + + expect(window.location.hash).toBe("#/"); + + expect(getAppHeader()).toBe(header); + expect(getAppFooter()).toBe(footer); + + expect(mocks.trackPageView.mock.calls).toEqual([["/cohorts"], ["/"]]); + + await waitFor(() => { + expect(queryClient.isFetching()).toBe(0); + }); +}); + +it("redirects unknown routes to the homepage without adding a history entry", async () => { + const historyLength = window.history.length; + + const { queryClient } = setup("/unknown-route"); + + expect( + await screen.findByRole("heading", { + name: HOME_HEADING, + level: 1, + }), + ).toBeInTheDocument(); + + expect(window.location.hash).toBe("#/"); + expect(window.history.length).toBe(historyLength); + + expect(getAppHeader()).toBeInTheDocument(); + expect(getAppFooter()).toBeInTheDocument(); + + await waitFor(() => { + expect(queryClient.isFetching()).toBe(0); + }); +}); diff --git a/frontend/src/app/router.tsx b/frontend/src/app/router.tsx index 730b867..7ab2482 100644 --- a/frontend/src/app/router.tsx +++ b/frontend/src/app/router.tsx @@ -84,7 +84,14 @@ export function AppRouter() { } /> - } /> + }> + + + } + /> { + const { container } = render( + , + ); + + const indicator = container.firstElementChild; + + expect(indicator).toHaveAttribute("aria-hidden", "true"); + expect(indicator).toHaveClass("rounded-full", "custom-class"); + expect(indicator).toHaveStyle({ + backgroundColor: "rgb(37, 99, 235)", + }); +}); + +it("supports square indicators", () => { + const { container } = render( + , + ); + + expect(container.firstElementChild).toHaveClass("rounded-sm"); + expect(container.firstElementChild).not.toHaveClass("rounded-full"); +}); + +it.each([undefined, null, ""])( + "renders nothing when the color is %s", + (color) => { + const { container } = render(); + + expect(container).toBeEmptyDOMElement(); + }, +); diff --git a/frontend/src/components/feedback/EmptyState.test.tsx b/frontend/src/components/feedback/EmptyState.test.tsx new file mode 100644 index 0000000..e17a74f --- /dev/null +++ b/frontend/src/components/feedback/EmptyState.test.tsx @@ -0,0 +1,51 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { expect, it, vi } from "vitest"; + +import { EmptyState } from "./EmptyState"; + +it("renders the message without optional content", () => { + render(); + + expect(screen.getByText("No data available")).toBeInTheDocument(); + expect(screen.queryByRole("button")).not.toBeInTheDocument(); +}); + +it("renders a rich description and custom class", () => { + const { container } = render( + + Try selecting another variable. + + } + className="custom-class" + />, + ); + + expect(screen.getByText("another variable")).toBeInTheDocument(); + expect(container.firstElementChild).toHaveClass("custom-class"); +}); + +it("renders an interactive action", async () => { + const user = userEvent.setup(); + const onAction = vi.fn<() => void>(); + + render( + + Change selection + + } + />, + ); + + await user.click(screen.getByRole("button", { name: "Change selection" })); + + expect(onAction).toHaveBeenCalledTimes(1); +}); diff --git a/frontend/src/components/feedback/ErrorState.test.tsx b/frontend/src/components/feedback/ErrorState.test.tsx new file mode 100644 index 0000000..4db7b14 --- /dev/null +++ b/frontend/src/components/feedback/ErrorState.test.tsx @@ -0,0 +1,65 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { expect, it, vi } from "vitest"; + +import { ErrorState } from "./ErrorState"; + +it("renders an accessible error without a retry action", () => { + render(); + + expect(screen.getByRole("alert")).toHaveTextContent("Could not load data"); + expect(screen.queryByRole("button")).not.toBeInTheDocument(); +}); + +it("renders additional error details and supports retrying", async () => { + const user = userEvent.setup(); + const onRetry = vi.fn<() => void>(); + + render( + +

Server unavailable

+
, + ); + + expect(screen.getByRole("alert")).toHaveTextContent("Request failed"); + expect(screen.getByText("Server unavailable")).toBeInTheDocument(); + + await user.click(screen.getByRole("button", { name: "Retry" })); + + expect(onRetry).toHaveBeenCalledTimes(1); +}); + +it("supports polite announcements, inverse styling and custom retry labels", async () => { + const user = userEvent.setup(); + const onRetry = vi.fn<() => void>(); + + const { container } = render( + +

Previously loaded data remains available.

+
, + ); + + const error = container.firstElementChild; + + expect(error).toHaveAttribute("aria-live", "polite"); + expect(error).toHaveClass("border-white/30", "custom-class"); + expect(screen.queryByRole("alert")).not.toBeInTheDocument(); + + expect(screen.getByText("Statistics unavailable")).toBeInTheDocument(); + expect( + screen.getByText("Previously loaded data remains available."), + ).toBeInTheDocument(); + + await user.click(screen.getByRole("button", { name: "Retry refresh" })); + + expect(onRetry).toHaveBeenCalledTimes(1); +}); diff --git a/frontend/src/components/feedback/LoadingState.test.tsx b/frontend/src/components/feedback/LoadingState.test.tsx new file mode 100644 index 0000000..da52653 --- /dev/null +++ b/frontend/src/components/feedback/LoadingState.test.tsx @@ -0,0 +1,29 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import { expect, it } from "vitest"; + +import { LoadingState } from "./LoadingState"; + +it("renders an accessible loading message with a decorative spinner", () => { + render(); + + const status = screen.getByRole("status"); + + expect(status).toHaveTextContent("Loading measurements..."); + expect(status.querySelector("svg")).toHaveAttribute("aria-hidden", "true"); +}); + +it("supports custom classes and updates the loading message", () => { + const { rerender } = render( + , + ); + + expect(screen.getByRole("status")).toHaveClass("custom-class"); + + rerender( + , + ); + + expect(screen.getByRole("status")).toHaveTextContent("Loading cohorts..."); +}); diff --git a/frontend/src/components/forms/MultiSelectCombobox.test.tsx b/frontend/src/components/forms/MultiSelectCombobox.test.tsx new file mode 100644 index 0000000..f05087e --- /dev/null +++ b/frontend/src/components/forms/MultiSelectCombobox.test.tsx @@ -0,0 +1,182 @@ +// @vitest-environment jsdom + +import { render, screen, waitFor } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { useState, type ComponentProps } from "react"; +import { beforeEach, expect, it, vi } from "vitest"; + +import { MultiSelectCombobox } from "./MultiSelectCombobox"; + +type Props = ComponentProps; + +beforeEach(() => { + vi.stubGlobal("BASE_UI_ANIMATIONS_DISABLED", true); +}); + +function ControlledCombobox({ + value: initialValue, + onValueChange, + ...props +}: Props) { + const [value, setValue] = useState(initialValue); + + return ( + { + setValue(next); + onValueChange(next); + }} + /> + ); +} + +function setup(overrides: Partial = {}) { + const user = userEvent.setup(); + const onValueChange = vi.fn<(value: string[]) => void>(); + + const props: Props = { + id: "variables", + label: "Variables", + items: ["Age", "Motor score", "Study Visit"], + value: [], + onValueChange, + ...overrides, + }; + + render(); + + return { + user, + onValueChange, + input: screen.getByRole("combobox", { name: "Variables" }), + }; +} + +it("selects multiple options and keeps the dropdown open", async () => { + const { user, input, onValueChange } = setup(); + + await user.type(input, "age"); + + await user.click(await screen.findByRole("option", { name: "Age" })); + + expect(onValueChange).toHaveBeenLastCalledWith(["Age"]); + expect(input).toHaveAttribute("aria-expanded", "true"); + expect(screen.getByText("1 selected")).toBeInTheDocument(); + + await user.clear(input); + await user.type(input, "motor"); + + const option = await screen.findByRole("option", { + name: "Motor score", + }); + + await waitFor(() => { + expect(input).toHaveAttribute("aria-activedescendant", option.id); + }); + + await user.keyboard("{Enter}"); + + expect(onValueChange).toHaveBeenLastCalledWith(["Age", "Motor score"]); + + expect(screen.getByText("2 selected")).toBeInTheDocument(); + expect(input).toHaveAttribute("placeholder", "Add another..."); +}); + +it.each([false, true])( + "removes individual selections and clears all with hideLabel=%s", + async (hideLabel) => { + const { user, input, onValueChange } = setup({ + value: ["Age", "Motor score"], + hideLabel, + }); + + expect(screen.getByText("2 selected")).toBeInTheDocument(); + expect(input).toHaveAttribute("placeholder", "Add another..."); + + await user.click(screen.getByRole("button", { name: "Remove Age" })); + + expect(onValueChange).toHaveBeenLastCalledWith(["Motor score"]); + expect(screen.getByText("1 selected")).toBeInTheDocument(); + + expect( + screen.queryByRole("button", { name: "Remove Age" }), + ).not.toBeInTheDocument(); + + await user.click(screen.getByRole("button", { name: "Clear all" })); + + expect(onValueChange).toHaveBeenLastCalledWith([]); + + expect(screen.queryByText("1 selected")).not.toBeInTheDocument(); + expect( + screen.queryByRole("button", { name: "Clear all" }), + ).not.toBeInTheDocument(); + + expect(input).toHaveAttribute("placeholder", "Search..."); + }, +); + +it("supports helper text, custom placeholders and empty search results", async () => { + const { user, input } = setup({ + placeholder: "Search variables", + description: "Select variables to compare.", + emptyMessage: "No variables match.", + }); + + expect(input).toHaveAttribute("placeholder", "Search variables"); + expect(input).toHaveAccessibleDescription("Select variables to compare."); + + await user.type(input, "nonexistent"); + + expect(await screen.findByText("No variables match.")).toBeInTheDocument(); + + expect(screen.queryByRole("option")).not.toBeInTheDocument(); +}); + +it.each([ + { + isLoading: true, + placeholder: "Loading options...", + announcements: ["Loading available options."], + }, + { + isLoading: false, + placeholder: "No options available", + announcements: [], + }, +])( + "disables empty comboboxes with isLoading=$isLoading", + ({ isLoading, placeholder, announcements }) => { + const { input } = setup({ items: [], isLoading }); + + expect(input).toBeDisabled(); + expect(input).toHaveAttribute("placeholder", placeholder); + + expect( + screen.queryAllByRole("status").map((status) => status.textContent), + ).toEqual(announcements); + }, +); + +it("disables selection, removal and clearing when explicitly disabled", () => { + const { input } = setup({ + value: ["Age", "Motor score"], + disabled: true, + }); + + expect(input).toBeDisabled(); + expect(screen.getByRole("button", { name: "Remove Age" })).toBeDisabled(); + expect( + screen.getByRole("button", { name: "Remove Motor score" }), + ).toBeDisabled(); + expect(screen.getByRole("button", { name: "Clear all" })).toBeDisabled(); +}); + +it("keeps existing options available during loading", () => { + const { input } = setup({ isLoading: true }); + + expect(input).toBeEnabled(); + expect(input).toHaveAttribute("placeholder", "Search..."); + expect(screen.queryByRole("status")).not.toBeInTheDocument(); +}); diff --git a/frontend/src/components/forms/SingleSelectCombobox.test.tsx b/frontend/src/components/forms/SingleSelectCombobox.test.tsx new file mode 100644 index 0000000..b825d95 --- /dev/null +++ b/frontend/src/components/forms/SingleSelectCombobox.test.tsx @@ -0,0 +1,164 @@ +// @vitest-environment jsdom + +import { render, screen, waitFor } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import type { ComponentProps } from "react"; +import { beforeEach, expect, it, vi } from "vitest"; + +import { SingleSelectCombobox } from "./SingleSelectCombobox"; + +beforeEach(() => { + vi.stubGlobal("BASE_UI_ANIMATIONS_DISABLED", true); +}); + +function setup( + overrides: Partial> = {}, +) { + const user = userEvent.setup(); + const onValueChange = vi.fn<(value: string) => void>(); + + const props = { + id: "variable", + label: "Variable", + items: ["Age", "Motor score", "Study Visit"], + value: "", + onValueChange, + ...overrides, + }; + + const view = render(); + + return { + ...view, + props, + user, + onValueChange, + input: screen.getByRole("combobox", { name: "Variable" }), + }; +} + +it("searches and selects an option using a pointer", async () => { + const { user, input, onValueChange, rerender, props } = setup(); + + await user.type(input, "motor"); + + const option = await screen.findByRole("option", { + name: "Motor score", + }); + + expect(screen.queryByRole("option", { name: "Age" })).not.toBeInTheDocument(); + + await user.click(option); + + expect(onValueChange).toHaveBeenLastCalledWith("Motor score"); + + rerender(); + + expect(input).toHaveValue("Motor score"); +}); + +it("searches and selects an option using the keyboard", async () => { + const { user, input, onValueChange } = setup(); + + await user.type(input, "motor"); + + const option = await screen.findByRole("option", { + name: "Motor score", + }); + + await waitFor(() => { + expect(input).toHaveAttribute("aria-activedescendant", option.id); + }); + + await user.keyboard("{Enter}"); + + expect(onValueChange).toHaveBeenLastCalledWith("Motor score"); +}); + +it.each([ + { + isLoading: true, + placeholder: "Loading options...", + announcements: ["Loading available options."], + }, + { + isLoading: false, + placeholder: "No options available", + announcements: [], + }, +])( + "disables empty comboboxes with isLoading=$isLoading", + ({ isLoading, placeholder, announcements }) => { + const { input } = setup({ items: [], isLoading }); + + expect(input).toBeDisabled(); + expect(input).toHaveAttribute("placeholder", placeholder); + + expect( + screen.queryAllByRole("status").map((status) => status.textContent), + ).toEqual(announcements); + }, +); + +it("supports helper text, custom placeholders and empty search results", async () => { + const { user, input } = setup({ + placeholder: "Search variables", + description: "Select a variable to compare.", + emptyMessage: "No variables match.", + }); + + expect(input).toHaveAttribute("placeholder", "Search variables"); + expect(input).toHaveAccessibleDescription("Select a variable to compare."); + + await user.type(input, "nonexistent"); + + expect(await screen.findByText("No variables match.")).toBeInTheDocument(); + + expect(screen.queryByRole("option")).not.toBeInTheDocument(); +}); + +it.each([ + { hideLabel: false, buttonName: "Clear selection" }, + { hideLabel: true, buttonName: "Clear variable selection" }, +])( + "clears the selection with hideLabel=$hideLabel", + async ({ hideLabel, buttonName }) => { + const { user, input, onValueChange, rerender, props } = setup({ + value: "Age", + hideLabel, + }); + + expect(input).toHaveValue("Age"); + + await user.click(screen.getByRole("button", { name: buttonName })); + + expect(onValueChange).toHaveBeenLastCalledWith(""); + + rerender(); + + expect(input).toHaveValue(""); + expect( + screen.queryByRole("button", { name: buttonName }), + ).not.toBeInTheDocument(); + }, +); + +it("disables selection and clearing when explicitly disabled", () => { + const { input } = setup({ + value: "Age", + disabled: true, + }); + + expect(input).toBeDisabled(); + expect( + screen.getByRole("button", { name: "Clear selection" }), + ).toBeDisabled(); +}); + +it("keeps existing options available during loading", () => { + const { input } = setup({ isLoading: true }); + + expect(input).toBeEnabled(); + expect(input).toHaveAttribute("placeholder", "Search..."); + expect(screen.queryByRole("status")).not.toBeInTheDocument(); +}); diff --git a/frontend/src/components/layout/Footer.test.tsx b/frontend/src/components/layout/Footer.test.tsx new file mode 100644 index 0000000..bf4b005 --- /dev/null +++ b/frontend/src/components/layout/Footer.test.tsx @@ -0,0 +1,96 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { MemoryRouter, useLocation } from "react-router"; +import { expect, it, vi } from "vitest"; + +import { AnalyticsConsentContext } from "@/components/privacy/analytics-consent-context"; + +import { Footer } from "./Footer"; + +function LocationProbe() { + const { pathname } = useLocation(); + + return {pathname}; +} + +function setup(analyticsAvailable = true) { + const user = userEvent.setup(); + const openPreferences = vi.fn<() => void>(); + + render( + + +