Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ artifacts
classes/Visualizer/Gutenberg/build
classes/Visualizer/ChartBuilder/build
classes/Visualizer/D3Renderer/build

# Local wp-env port pinning (per-checkout).
.wp-env.override.json
3 changes: 1 addition & 2 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
],
"themes": [],
"mappings": {
"wp-content/mu-plugins/visualizer-e2e-enable-database-source.php": "./tests/e2e/config/enable-database-source.php",
"wp-content/mu-plugins/visualizer-e2e-force-lazy-render.php": "./tests/e2e/config/force-lazy-render.php"
"wp-content/mu-plugins": "./tests/e2e/config/mu-plugins"
},
"config": {
"WP_DEBUG": true,
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@ import os from 'os';
import { fileURLToPath } from 'url';
import { defineConfig, devices } from '@playwright/test';

// The tests instance may be pinned to a non-default port in .wp-env.override.json
// (8889 is often taken by another checkout). Target whatever wp-env actually bound.
let testsPort = process.env.WP_ENV_TESTS_PORT;
try {
testsPort ??= require( '../../.wp-env.override.json' ).testsPort;
} catch ( e ) {} // No override file, fall back to the wp-env default.
testsPort = Number( testsPort ) || 8889;
process.env.WP_BASE_URL ??= `http://localhost:${ testsPort }`;

/**
* WordPress dependencies
*/
const baseConfig = require( '@wordpress/scripts/config/playwright.config' );

const config = defineConfig( {
...baseConfig,
webServer: { ...baseConfig.webServer, port: testsPort },
reporter: process.env.CI
? [ [ 'github' ], [ './config/flaky-tests-reporter.js' ] ]
: 'list',
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/specs/lazy-render.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ test.describe( 'Lazy rendered charts (frontend)', () => {
}

async function triggerLazyLoader( page ) {
// Scripts are swapped to `data-visualizer-script` placeholders.
await expect( page.locator( 'script[data-visualizer-script]' ).first() ).toBeAttached();
// Assert lazy rendering is on via the container class, not the
// `data-visualizer-script` placeholders: those are swapped away by the
// first user interaction, and Chromium fires a real `mouseover` right
// after navigation whenever the cursor sits over the page.
await expect( page.locator( '.visualizer-lazy-render' ).first() ).toBeAttached();

// The loader starts on the first user interaction.
await page.evaluate( () => window.dispatchEvent( new Event( 'scroll' ) ) );
Expand Down
Loading