fix: isolate CHRNX local integration state

This commit is contained in:
chrnx committed 2026-08-12 09:48:12 -05:00
1 parent 21da6da227
commit 6e93c0ad20
16 files changed
+536 -65

No files matched your search

+29 -1
View File
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { readFile, readdir } from 'node:fs/promises';
import test from 'node:test';
test( 'Playwright seeds deterministic local fixtures once outside browser workers', async () => {
@@ -14,3 +14,31 @@ test( 'Playwright seeds deterministic local fixtures once outside browser worker
assert.equal( seed.match( /chrnx_seed_editorial_terms\(\);/g )?.length, 1 );
assert.doesNotMatch( spec, /wp-env|execFileSync|beforeAll/ );
} );
test( 'database scenarios run only in a serial Chromium project after all read-only browsers', async () => {
const config = await readFile( 'playwright.config.mjs', 'utf8' );
const files = await readdir( 'tests/e2e' );
const scenario = await readFile( 'tests/e2e/visual-scenarios.spec.mjs', 'utf8' );
for ( const file of files.filter( ( name ) => name.endsWith( '.spec.mjs' ) && name !== 'visual-scenarios.spec.mjs' ) ) {
const source = await readFile( `tests/e2e/${ file }`, 'utf8' );
assert.doesNotMatch( source, /seed-test-content|wp-env|execFileSync/, `${ file } must be DB read-only` );
}
assert.match( config, /name:\s*['"]scenarios['"]/ );
assert.match( config, /testMatch:\s*['"]visual-scenarios\.spec\.mjs['"]/ );
assert.match( config, /dependencies:\s*\[\s*['"]chromium['"],\s*['"]firefox['"],\s*['"]webkit['"]\s*\]/s );
assert.match( config, /fullyParallel:\s*false/ );
assert.match( config, /workers:\s*1/ );
assert.match( scenario, /test\.describe\.configure\(\s*\{\s*mode:\s*['"]serial['"]/s );
assert.match( scenario, /test\.afterAll[\s\S]*seedScenario\(\s*['"]default['"]\s*\)/ );
} );
test( 'the npm integration chain finishes PHP and seed-state checks before browser workers', async () => {
const manifest = JSON.parse( await readFile( 'package.json', 'utf8' ) );
assert.match( manifest.scripts[ 'test:integration' ], /tests\/integration\/seed-state\.sh/ );
assert.match(
manifest.scripts.test,
/npm run test:php && npm run test:integration && npm run test:e2e/,
);
} );
+13 -2
View File
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs';
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
@@ -77,10 +77,19 @@ test( 'the visual layer is separately enqueued and covers responsive accessible
} );
test( 'all approved portraits rebuild byte-identically within payload bounds', () => {
const output = mkdtempSync( join( tmpdir(), 'chrnx-image-test-' ) );
const readme = read( 'README.md' );
const documentedCommand = 'mktemp -d "${TMPDIR:-/tmp}/chrnx-responsive.XXXXXX"';
assert.ok( readme.includes( documentedCommand ) );
const output = execFileSync( 'sh', [ '-c', documentedCommand ], { encoding: 'utf8' } ).trim();
const unsafeOutput = join( output, 'unsafe-output' );
const external = mkdtempSync( join( tmpdir(), 'chrnx-external-' ) );
const symlink = join( tmpdir(), `chrnx-symlink-${ process.pid }` );
try {
assert.throws( () => execFileSync( './scripts/build-responsive-images.sh', [ unsafeOutput ], { cwd: new URL( '../..', import.meta.url ) } ) );
writeFileSync( join( external, 'sentinel' ), 'unchanged' );
symlinkSync( external, symlink );
assert.throws( () => execFileSync( './scripts/build-responsive-images.sh', [ symlink ], { cwd: new URL( '../..', import.meta.url ) } ) );
assert.deepEqual( readdirSync( external ), [ 'sentinel' ] );
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: new URL( '../..', import.meta.url ) } );
const names = readdirSync( output ).sort();
assert.equal( names.length, 35 );
@@ -107,6 +116,8 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
assert.ok( total <= 1.7 * 1024 * 1024, `derivatives exceed 1.7 MiB: ${ total }` );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( external, { recursive: true, force: true } );
rmSync( symlink, { force: true } );
}
} );