fix: isolate CHRNX seed lifecycle tests

This commit is contained in:
chrnx committed 2026-08-12 10:25:49 -05:00
1 parent 6e93c0ad20
commit 57e7e9aaf3
10 files changed
+277 -316

No files matched your search

+25 -6
View File
@@ -34,11 +34,30 @@ test( 'database scenarios run only in a serial Chromium project after all read-o
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 () => {
test( 'the npm integration chain finishes isolated PHP 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/,
);
assert.equal( manifest.scripts[ 'test:integration' ], undefined );
assert.match( manifest.scripts.test, /npm run test:php && npm run test:e2e/ );
assert.doesNotMatch( JSON.stringify( manifest.scripts ), /seed-state\.sh/ );
} );
test( 'restore lifecycle runs only in isolated PHPUnit and never in shared DB scripts', async () => {
const manifest = JSON.parse( await readFile( 'package.json', 'utf8' ) );
const phpTest = await readFile( 'tests/php/FixtureEnvironmentTest.php', 'utf8' );
const library = await readFile( 'scripts/lib/fixture-environment.php', 'utf8' );
const files = await readdir( 'tests/integration' ).catch( () => [] );
assert.deepEqual( files.filter( ( name ) => /seed-state|harness-preservation/.test( name ) ), [] );
assert.doesNotMatch( JSON.stringify( manifest.scripts ), /tests\/integration|seed-state/ );
assert.match( phpTest, /WP_UnitTestCase/ );
assert.match( phpTest, /chrnx_fixture_environment_snapshot/ );
assert.match( phpTest, /chrnx_fixture_environment_restore/ );
assert.match( library, /raw_base64/ );
} );
test( 'PHPUnit is pinned to the isolated tests-cli database', async () => {
const manifest = JSON.parse( await readFile( 'package.json', 'utf8' ) );
assert.match( manifest.scripts[ 'test:php' ], /wp-env run tests-cli/ );
assert.doesNotMatch( manifest.scripts[ 'test:php' ], /wp-env run cli/ );
assert.doesNotMatch( JSON.stringify( manifest.scripts ), /wp-env run cli[^\n"]*phpunit/ );
} );