Repository navigation
5.2 Web E2E Tests
Relevant source files
The following files were used as context for generating this wiki page:
This page details the web end-to-end (E2E) testing suite for VariantScope. It covers the Playwright test configuration (playwright.config.js), headless WebGL rendering via SwiftShader playwright.config.js:6-10, test execution flows against core biological genes (web.spec.js), shared automation helpers (helpers.js), partial state and network resilience tests (web-states.spec.js), and automated screenshot generation for documentation (web-screenshots.spec.js).
The test runner is configured in playwright.config.js to execute tests against a production-like Vite preview server running on port 4180 playwright.config.js:41-47. Because headless Chromium instances typically lack hardware GPU acceleration in continuous integration (CI) environments, VariantScope injects software WebGL flags (--use-angle=swiftshader, --enable-unsafe-swiftshader, --ignore-gpu-blocklist) playwright.config.js:6-10 to ensure the 3D molecular viewer (viewer3d.js) initializes successfully.
The runner is configured with a 4-hour global timeout, a 240-second test timeout, and single-worker execution (workers: 1) to prevent API rate-limiting issues when querying live public bioinformatics endpoints playwright.config.js:14-20.
graph TD
A["playwright.config.js"] --> B["webServer (npm run build:e2e)"]
B --> C["Vite Preview Server (port 4180)"]
C --> D["Playwright Web Project (web*.spec.js)"]
D --> E["Headless Chromium + WEBGL_ARGS"]
E --> F["Software SwiftShader WebGL"]
classDef default fill:#fff,stroke:#333,stroke-width:2px;
Figure 1: Playwright Test Environment and Web Server Bootstrap
Sources: playwright.config.js:1-48
The tests/e2e/web.spec.js suite verifies end-to-end functionality across four well-studied clinical genes: BRCA1, TP53, CFTR, and MLH1 tests/e2e/web.spec.js:17-38. Each gene suite runs serially inside a browser context (viewport: 1400x1000) tests/e2e/web.spec.js:44-55.
-
Console & Page Error Monitoring:
watchErrors(page)listens for unhandled exceptions or console errors, ignoring transient NCBI network noise tests/e2e/helpers.js:10-22, tests/e2e/web.spec.js:60-62. -
3D Structure & pLDDT Color Bands: Asserts that the
#viewer canvasis visible tests/e2e/web.spec.js:65 and that AlphaFold pLDDT confidence metrics are correctly colored across bands (very-high, confident, low, very-low) tests/e2e/web.spec.js:64-79. -
Plot & Table Rendering: Validates canvas ink density (
canvasInk) tests/e2e/helpers.js:119-126, tests/e2e/web.spec.js:82, table row counts tests/e2e/web.spec.js:83, pagination tests/e2e/web.spec.js:84, and statistical summary cards tests/e2e/web.spec.js:85-89. -
Coordinate Mapping: Iterates through known pathogenic missense variants (e.g.,
p.Cys61GlyforBRCA1,p.Arg175HisforTP53) to verify that selecting a variant updates the 3D model residue attribute (data-selected-residue), table selection state, and lollipop plot highlighting tests/e2e/web.spec.js:92-106. - Bidirectional Selection Synchronization: Simulates clicks on lollipop plot points and 3D molecular spheres to confirm synchronized selection state across the table, plot, and viewer tests/e2e/web.spec.js:108-161.
Sources: tests/e2e/web.spec.js:1-161, tests/e2e/helpers.js:10-22, tests/e2e/helpers.js:119-126
The tests/e2e/helpers.js module exposes helper utilities used across web and state test suites.
graph TD
A["search(page, symbol)"] --> B["loadGene(page, symbol)"]
B --> C["waitSettled(page)"]
C --> D["PANELS Validation ('ready')"]
D --> E["selectInTable(page, change)"]
E --> F["plddtBandShares(page)"]
classDef default fill:#fff,stroke:#333,stroke-width:2px;
Figure 2: Helper Functions & UI Interactivity Flow
-
watchErrors(page, expectedFailures): Intercepts console error messages andpageerrorevents, isolating transient NCBI eutils noise from true application failures tests/e2e/helpers.js:10-22. -
search(page, symbol): Fills#gene-inputwith a gene symbol and triggers the Enter keypress tests/e2e/helpers.js:24-28. -
waitSettled(page): Polls all DOM elements with[data-panel]attributes until none remain in theloadingstate, returning a dictionary of all panel states (stats,viewer,constraint,meaning,plot,table) tests/e2e/helpers.js:35-47. -
loadGene(page, symbol): CombinessearchandwaitSettled, asserting that every panel reaches thereadystate and that the 3D canvas is mounted tests/e2e/helpers.js:50-64. -
selectInTable(page, change): Filters the variant data table by protein change, clicks the target row, and returns its unique data identifier (data-id) tests/e2e/helpers.js:66-73. -
plddtBandShares(page): Takes a screenshot of the 3D viewer element, decodes the base64 PNG data into an offscreen canvas context, and calculates the proportional area of each AlphaFold confidence color band tests/e2e/helpers.js:75-116. -
canvasInk(page, selector): Evaluates non-transparent pixel count on a chart canvas to verify successful chart rendering tests/e2e/helpers.js:119-126.
Sources: tests/e2e/helpers.js:1-127
The tests/e2e/web-states.spec.js file validates how VariantScope gracefully handles network partitions, blocked API routes, slow responses, and different device viewports.
-
gnomAD Blocked: Simulates a network failure on
gnomad.broadinstitute.org. The constraint panel enters anerrorstate with a Retry button, a warning banner appears, and variant badge rarity falls back tounknownrather than displaying inaccurate frequencies tests/e2e/web-states.spec.js:13-45. -
ClinVar Blocked: Intercepts
eutils.ncbi.nlm.nih.gov, causing variant-dependent panels (stats,meaning,plot,table) to show errors tests/e2e/web-states.spec.js:47-62. Unblocking the route and clicking the panel'sRetrybutton successfully recovers all panels back to thereadystate tests/e2e/web-states.spec.js:63-71. -
AlphaFold Blocked: Simulates failure on
alphafold.ebi.ac.uk. The 3D viewer displays an error state while tabular and statistical views continue functioning with pLDDT columns marked asnot availabletests/e2e/web-states.spec.js:73-98. -
UniProt Blocked: Intercepts
rest.uniprot.org, displaying a top-level banner error preventing searches until resolved and retried tests/e2e/web-states.spec.js:100-114. -
Slow Network & Progress Tracking: Introduces an 8-second artificial delay on AlphaFold and gnomAD routes, verifying skeleton shimmer animations and live ClinVar progress counters (
Loading ClinVar: x / y) tests/e2e/web-states.spec.js:116-139. -
Mobile & Dark Mode Layout: Tests responsive layout rules at
390x844resolution, confirming zero horizontal overflow, correct element stacking order (3D viewer preceding summary panels), and theme switching (data-theme=dark) tests/e2e/web-states.spec.js:141-169.
Sources: tests/e2e/web-states.spec.js:1-169
The tests/e2e/web-screenshots.spec.js script automates the capture of reference documentation assets for the repository tests/e2e/web-screenshots.spec.js:1-53.
It loads BRCA1 and TP53, selects a prominent hotspot variant (p.Arg1699Trp and p.Arg175His), waits for camera zoom animations to settle, and saves full-page screenshots into docs/screenshots for:
- Desktop Light Mode (
{gene}-desktop-light.png) tests/e2e/web-screenshots.spec.js:17-29 - Desktop Dark Mode (
{gene}-desktop-dark.png) tests/e2e/web-screenshots.spec.js:30-34 - Mobile Viewport (
{gene}-mobile.pngat390x844) tests/e2e/web-screenshots.spec.js:37-52
Sources: tests/e2e/web-screenshots.spec.js:1-54
Content imported from DeepWiki.