Files
chrnx-dev-wp/tests/smoke/related-stories-browser-acceptance.test.mjs
T

49 lines
1.9 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import test from 'node:test';
import { containsPhpDiagnostic } from '../e2e/response-diagnostics.mjs';
test( 'response diagnostics catch plain and display_errors PHP failures without normal prose', () => {
for ( const diagnostic of [
'PHP Warning: Undefined variable $story',
'Warning: Undefined variable $story',
'<b>Warning</b>: Undefined variable $story<br />',
'PHP Notice: Undefined index: story',
'Notice: Undefined index: story',
'<b>Notice</b>: Undefined index: story<br />',
'PHP Fatal error: Uncaught Error',
'Fatal error: Uncaught Error',
'<b>Fatal error</b>: Uncaught Error<br />',
'PHP Parse error: unexpected token',
'Parse error: unexpected token',
'<b>Parse error</b>: unexpected token<br />',
'PHP Deprecated: Optional parameter',
'Deprecated: Optional parameter',
'<b>Deprecated</b>: Optional parameter<br />',
] ) {
assert.equal( containsPhpDiagnostic( diagnostic ), true, diagnostic );
}
for ( const prose of [
'Warning signs can make a story more useful.',
'A notice board hangs beside the door.',
'The album Deprecated Futures is available now.',
'Fatal Error is the title of a fictional game.',
'Parse errors carefully when reviewing a compiler.',
] ) {
assert.equal( containsPhpDiagnostic( prose ), false, prose );
}
} );
test( 'WebKit native scroll uses a focused rail and a real keyboard gesture', async () => {
const source = await readFile( 'tests/e2e/related-stories.spec.mjs', 'utf8' );
const helper = source.match(
/async function scrollRailNatively[\s\S]*?\n}\n\ntest\.describe\.serial/,
)?.[ 0 ];
assert.ok( helper, 'native scroll helper must remain inspectable' );
assert.doesNotMatch( helper, /track\.evaluate|\.scrollBy\s*\(/ );
assert.match( helper, /track\.focus\(\)[\s\S]*keyboard\.press\(\s*['"]ArrowRight['"]\s*\)/ );
} );