test: harden Related Stories browser acceptance

This commit is contained in:
chrnx committed 2026-08-12 22:05:39 -05:00
1 parent 3a34a9990f
commit 52099a7ca1
3 files changed
+60 -11

No files matched your search

+6 -11
View File
@@ -1,6 +1,8 @@
import { expect, test } from '@playwright/test';
import { injectAxe } from 'axe-playwright';
import { containsPhpDiagnostic } from './response-diagnostics.mjs';
async function logIn( page ) {
await page.goto( '/wp-login.php' );
await page.locator( '#user_login' ).fill( 'admin' );
@@ -50,15 +52,8 @@ function tabShortcut( browserName, reverse = false ) {
async function scrollRailNatively( page, track, browserName ) {
await track.hover();
if ( browserName === 'webkit' ) {
await track.evaluate( ( element ) => {
const card = element.querySelector( '.chrnx-related-card' );
const style = window.getComputedStyle( element );
const gap = Number.parseFloat( style.columnGap || style.gap ) || 0;
element.scrollBy( {
left: card.getBoundingClientRect().width + gap,
behavior: 'auto',
} );
} );
await track.focus();
await page.keyboard.press( 'ArrowRight' );
return;
}
await page.mouse.wheel( 240, 0 );
@@ -506,7 +501,7 @@ test( 'interaction buttons move exactly one card and update both disabled edges'
await expect( next ).toBeEnabled();
} );
test( 'interaction native horizontal wheel scrolling remains available', async ( {
test( 'interaction native horizontal scrolling remains available through real user input', async ( {
page,
browserName,
} ) => {
@@ -679,7 +674,7 @@ test( 'permalink every rendered related card reaches a same-origin published HTT
await page.locator( `#related-stories-5-grid a[href="${ href }"]` ).click();
const response = await responsePromise;
expect( response.status() ).toBe( 200 );
expect( await response.text() ).not.toMatch( /PHP (?:Warning|Notice)|Fatal error/i );
expect( containsPhpDiagnostic( await response.text() ) ).toBe( false );
await expect( page.locator( 'body' ) ).toHaveClass( /single-post/ );
await expect( page.getByRole( 'heading', { level: 1 } ) ).toBeVisible();
}