fix: isolate CHRNX local integration state
This commit is contained in:
16 files changed
+536
-65
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const projectRoot = fileURLToPath( new URL( '../..', import.meta.url ) );
|
||||
const seedScenario = ( scenario ) =>
|
||||
execFileSync( './scripts/seed-test-content.sh', [ scenario ], {
|
||||
cwd: projectRoot,
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: `/opt/homebrew/opt/docker/bin:${ process.env.PATH ?? '' }`,
|
||||
},
|
||||
stdio: 'pipe',
|
||||
} );
|
||||
|
||||
test.describe.configure( { mode: 'serial' } );
|
||||
|
||||
test.afterAll( () => {
|
||||
seedScenario( 'default' );
|
||||
} );
|
||||
|
||||
test( 'local featured and subscribe scenarios restore the default dataset', async ( { page } ) => {
|
||||
try {
|
||||
for ( const count of [ 1, 2 ] ) {
|
||||
seedScenario( `featured-${ count }` );
|
||||
await page.goto( `/?fixtureScenario=featured-${ count }` );
|
||||
await expect( page.locator( '.chrnx-featured-stories article' ) ).toHaveCount( count );
|
||||
const hrefs = await page
|
||||
.locator( '.chrnx-featured-stories article a' )
|
||||
.evaluateAll( ( links ) => links.map( ( link ) => link.href ) );
|
||||
expect( new Set( hrefs ).size ).toBe( hrefs.length );
|
||||
}
|
||||
for ( const scenario of [ 'subscribe-unpublished', 'subscribe-unavailable' ] ) {
|
||||
seedScenario( scenario );
|
||||
await page.goto( `/?fixtureScenario=${ scenario }` );
|
||||
await expect( page.locator( '.chrnx-subscribe-cta' ) ).toHaveCount( 0 );
|
||||
}
|
||||
} finally {
|
||||
seedScenario( 'default' );
|
||||
}
|
||||
await page.goto( '/' );
|
||||
await expect( page.locator( '.chrnx-featured-stories article' ) ).toHaveCount( 3 );
|
||||
await expect(
|
||||
page.getByRole( 'link', { name: 'Subscribe', exact: true } ).first(),
|
||||
).toBeVisible();
|
||||
} );
|
||||
@@ -1,18 +1,5 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { injectAxe } from 'axe-playwright';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const projectRoot = fileURLToPath( new URL( '../..', import.meta.url ) );
|
||||
const seedScenario = ( scenario ) =>
|
||||
execFileSync( './scripts/seed-test-content.sh', [ scenario ], {
|
||||
cwd: projectRoot,
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: `/opt/homebrew/opt/docker/bin:${ process.env.PATH ?? '' }`,
|
||||
},
|
||||
stdio: 'pipe',
|
||||
} );
|
||||
|
||||
const viewports = [
|
||||
{ width: 375, height: 812 },
|
||||
@@ -151,35 +138,6 @@ test( 'cards without featured media use CSS-only topic treatments', async ( { pa
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'local featured and subscribe scenarios restore the default dataset', async ( {
|
||||
page,
|
||||
}, testInfo ) => {
|
||||
test.skip( testInfo.project.name !== 'chromium', 'Database scenarios run once in Chromium.' );
|
||||
try {
|
||||
for ( const count of [ 1, 2 ] ) {
|
||||
seedScenario( `featured-${ count }` );
|
||||
await page.goto( `/?fixtureScenario=featured-${ count }` );
|
||||
await expect( page.locator( '.chrnx-featured-stories article' ) ).toHaveCount( count );
|
||||
const hrefs = await page
|
||||
.locator( '.chrnx-featured-stories article a' )
|
||||
.evaluateAll( ( links ) => links.map( ( link ) => link.href ) );
|
||||
expect( new Set( hrefs ).size ).toBe( hrefs.length );
|
||||
}
|
||||
for ( const scenario of [ 'subscribe-unpublished', 'subscribe-unavailable' ] ) {
|
||||
seedScenario( scenario );
|
||||
await page.goto( `/?fixtureScenario=${ scenario }` );
|
||||
await expect( page.locator( '.chrnx-subscribe-cta' ) ).toHaveCount( 0 );
|
||||
}
|
||||
} finally {
|
||||
seedScenario( 'default' );
|
||||
}
|
||||
await page.goto( '/' );
|
||||
await expect( page.locator( '.chrnx-featured-stories article' ) ).toHaveCount( 3 );
|
||||
await expect(
|
||||
page.getByRole( 'link', { name: 'Subscribe', exact: true } ).first(),
|
||||
).toBeVisible();
|
||||
} );
|
||||
|
||||
test( 'podcast canonical metadata is safe and missing metadata never invents a player or link', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Adversarial assertions for the local fixture environment lifecycle.
|
||||
*
|
||||
* @package CHRNX
|
||||
*/
|
||||
|
||||
$chrnx_test_host = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
|
||||
if ( ! in_array( $chrnx_test_host, array( 'localhost', '127.0.0.1' ), true ) ) {
|
||||
WP_CLI::error( 'Refusing fixture-state tests outside local wp-env.' );
|
||||
}
|
||||
|
||||
$chrnx_test_mode = isset( $args[0] ) && is_string( $args[0] ) ? $args[0] : '';
|
||||
$chrnx_test_option_names = array(
|
||||
'sticky_posts',
|
||||
'blogname',
|
||||
'blogdescription',
|
||||
'show_on_front',
|
||||
'page_on_front',
|
||||
'page_for_posts',
|
||||
'permalink_structure',
|
||||
'chrnx_subscribe_page_id',
|
||||
);
|
||||
|
||||
/** Return exact option existence and serialized value. */
|
||||
function chrnx_test_option_state( string $name ): array {
|
||||
global $wpdb;
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Test asserts exact persisted option bytes.
|
||||
$raw = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s", $name ) );
|
||||
return array(
|
||||
'exists' => null !== $raw,
|
||||
'raw' => $raw,
|
||||
);
|
||||
}
|
||||
|
||||
/** Return IDs for fixture-owned sticky posts. */
|
||||
function chrnx_test_fixture_stickies(): array {
|
||||
$sticky = array_map( 'absint', (array) get_option( 'sticky_posts', array() ) );
|
||||
return array_values(
|
||||
array_filter(
|
||||
$sticky,
|
||||
static function ( int $post_id ): bool {
|
||||
return '' !== (string) get_post_meta( $post_id, '_chrnx_fixture_key', true );
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** Find one local fixture-owned post. */
|
||||
function chrnx_test_find_fixture( string $key, string $post_type ): int {
|
||||
$ids = get_posts(
|
||||
array(
|
||||
'post_type' => $post_type,
|
||||
'post_status' => 'any',
|
||||
'posts_per_page' => 1,
|
||||
'fields' => 'ids',
|
||||
'meta_key' => '_chrnx_fixture_key',
|
||||
'meta_value' => $key,
|
||||
)
|
||||
);
|
||||
return empty( $ids ) ? 0 : absint( $ids[0] );
|
||||
}
|
||||
|
||||
/** Fail with a precise integration assertion. */
|
||||
function chrnx_test_assert( bool $condition, string $message ): void {
|
||||
if ( ! $condition ) {
|
||||
WP_CLI::error( $message );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'setup' === $chrnx_test_mode ) {
|
||||
$chrnx_test_created_id = wp_insert_post(
|
||||
array(
|
||||
'post_status' => 'publish',
|
||||
'post_title' => 'Unrelated sticky sentinel',
|
||||
'post_type' => 'post',
|
||||
),
|
||||
true
|
||||
);
|
||||
if ( is_wp_error( $chrnx_test_created_id ) ) {
|
||||
WP_CLI::error( 'Could not create unrelated sticky sentinel.' );
|
||||
}
|
||||
update_option( 'sticky_posts', array( absint( $chrnx_test_created_id ) ) );
|
||||
update_option( 'blogname', 'Pre-existing local title' );
|
||||
update_option( 'blogdescription', 'Pre-existing local description' );
|
||||
update_option( 'show_on_front', 'posts' );
|
||||
update_option( 'page_on_front', 0 );
|
||||
update_option( 'page_for_posts', 0 );
|
||||
update_option( 'permalink_structure', '' );
|
||||
update_option( 'chrnx_subscribe_page_id', 424242 );
|
||||
$chrnx_test_subscribe_id = chrnx_test_find_fixture( 'page-subscribe', 'page' );
|
||||
if ( $chrnx_test_subscribe_id > 0 ) {
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $chrnx_test_subscribe_id,
|
||||
'post_status' => 'private',
|
||||
)
|
||||
);
|
||||
}
|
||||
$chrnx_test_expected = array();
|
||||
foreach ( $chrnx_test_option_names as $chrnx_test_option_name ) {
|
||||
$chrnx_test_expected[ $chrnx_test_option_name ] = chrnx_test_option_state( $chrnx_test_option_name );
|
||||
}
|
||||
$chrnx_test_expected['subscribe'] = array(
|
||||
'exists' => $chrnx_test_subscribe_id > 0,
|
||||
'id' => $chrnx_test_subscribe_id,
|
||||
'status' => $chrnx_test_subscribe_id > 0 ? get_post_status( $chrnx_test_subscribe_id ) : null,
|
||||
);
|
||||
update_option( '_chrnx_seed_test_expected', $chrnx_test_expected, false );
|
||||
update_option( '_chrnx_seed_test_unrelated_id', absint( $chrnx_test_created_id ), false );
|
||||
WP_CLI::success( 'Adversarial fixture environment prepared.' );
|
||||
return;
|
||||
}
|
||||
|
||||
$chrnx_test_unrelated_id = absint( get_option( '_chrnx_seed_test_unrelated_id', 0 ) );
|
||||
if ( 'check-default' === $chrnx_test_mode || 'check-featured-1' === $chrnx_test_mode ) {
|
||||
$chrnx_test_sticky = array_map( 'absint', (array) get_option( 'sticky_posts', array() ) );
|
||||
chrnx_test_assert( in_array( $chrnx_test_unrelated_id, $chrnx_test_sticky, true ), 'Seeder removed an unrelated sticky post.' );
|
||||
$chrnx_test_expected_count = 'check-featured-1' === $chrnx_test_mode ? 1 : 3;
|
||||
chrnx_test_assert( count( chrnx_test_fixture_stickies() ) === $chrnx_test_expected_count, 'Fixture sticky scenario count is wrong.' );
|
||||
if ( 'check-default' === $chrnx_test_mode ) {
|
||||
chrnx_test_assert( 'CHRNX' === get_option( 'blogname' ), 'Default visual title was not applied.' );
|
||||
chrnx_test_assert( '/%postname%/' === get_option( 'permalink_structure' ), 'Default visual permalinks were not applied.' );
|
||||
}
|
||||
WP_CLI::success( 'Fixture sticky ownership is isolated.' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'check-subscribe-unpublished' === $chrnx_test_mode ) {
|
||||
$chrnx_test_subscribe_id = chrnx_test_find_fixture( 'page-subscribe', 'page' );
|
||||
chrnx_test_assert( 'draft' === get_post_status( $chrnx_test_subscribe_id ), 'Subscribe unpublished scenario did not draft the fixture page.' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'check-subscribe-unavailable' === $chrnx_test_mode ) {
|
||||
chrnx_test_assert( 0 === absint( get_option( 'chrnx_subscribe_page_id' ) ), 'Subscribe unavailable scenario did not clear its fixture pointer.' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'check-restore' === $chrnx_test_mode ) {
|
||||
$chrnx_test_expected = get_option( '_chrnx_seed_test_expected', array() );
|
||||
foreach ( $chrnx_test_option_names as $chrnx_test_option_name ) {
|
||||
chrnx_test_assert( chrnx_test_option_state( $chrnx_test_option_name ) === $chrnx_test_expected[ $chrnx_test_option_name ], 'Restore mismatch for ' . $chrnx_test_option_name . '.' );
|
||||
}
|
||||
if ( ! empty( $chrnx_test_expected['subscribe']['exists'] ) ) {
|
||||
chrnx_test_assert( get_post_status( $chrnx_test_expected['subscribe']['id'] ) === $chrnx_test_expected['subscribe']['status'], 'Subscribe fixture status was not restored.' );
|
||||
}
|
||||
chrnx_test_assert( false === get_option( '_chrnx_fixture_environment_snapshot_v1', false ), 'Snapshot was not removed after restore.' );
|
||||
WP_CLI::success( 'Original local configuration restored exactly.' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'cleanup' === $chrnx_test_mode ) {
|
||||
if ( $chrnx_test_unrelated_id > 0 ) {
|
||||
wp_delete_post( $chrnx_test_unrelated_id, true );
|
||||
}
|
||||
delete_option( '_chrnx_seed_test_expected' );
|
||||
delete_option( '_chrnx_seed_test_unrelated_id' );
|
||||
return;
|
||||
}
|
||||
|
||||
WP_CLI::error( 'Unknown fixture-state test mode.' );
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
chrnx_test_root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
|
||||
chrnx_test_docker=${CHRNX_DOCKER_CLI_DIR:-/opt/homebrew/opt/docker/bin}
|
||||
chrnx_test_wp() {
|
||||
PATH="$chrnx_test_docker:$PATH" npm exec -- wp-env run cli wp eval-file wp-content/themes/chrnx/tests/integration/seed-state.php "$1"
|
||||
}
|
||||
chrnx_test_seed() {
|
||||
PATH="$chrnx_test_docker:$PATH" "$chrnx_test_root/scripts/seed-test-content.sh" "$1"
|
||||
}
|
||||
chrnx_test_cleanup() {
|
||||
chrnx_test_seed restore >/dev/null 2>&1 || true
|
||||
chrnx_test_wp cleanup >/dev/null 2>&1 || true
|
||||
chrnx_test_seed default >/dev/null 2>&1 || true
|
||||
}
|
||||
trap chrnx_test_cleanup EXIT HUP INT TERM
|
||||
|
||||
cd -- "$chrnx_test_root"
|
||||
chrnx_test_seed restore
|
||||
chrnx_test_wp setup
|
||||
chrnx_test_seed default
|
||||
chrnx_test_wp check-default
|
||||
chrnx_test_seed featured-1
|
||||
chrnx_test_wp check-featured-1
|
||||
chrnx_test_seed subscribe-unpublished
|
||||
chrnx_test_wp check-subscribe-unpublished
|
||||
chrnx_test_seed subscribe-unavailable
|
||||
chrnx_test_wp check-subscribe-unavailable
|
||||
chrnx_test_seed restore
|
||||
chrnx_test_wp check-restore
|
||||
chrnx_test_wp cleanup
|
||||
chrnx_test_seed default
|
||||
trap - EXIT HUP INT TERM
|
||||
@@ -712,6 +712,57 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/** Show archive pagination keeps canonical archive routing and rejects raw show filters. */
|
||||
public function test_show_archive_pagination_preserves_internal_routing_only() {
|
||||
global $wp_rewrite;
|
||||
$previous_structure = get_option( 'permalink_structure' );
|
||||
$term = get_term_by( 'slug', 'silicon-ranch', 'chrnx_show' );
|
||||
for ( $index = 1; $index <= 12; ++$index ) {
|
||||
$post_id = self::factory()->post->create( array( 'post_title' => 'Show archive result ' . $index ) );
|
||||
wp_set_object_terms( $post_id, 'podcasts', 'chrnx_topic' );
|
||||
wp_set_object_terms( $post_id, 'silicon-ranch', 'chrnx_show' );
|
||||
}
|
||||
$previous_get = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Synthetic read-only request.
|
||||
$pretty_link = static function ( $url, $term_object, $taxonomy ) {
|
||||
if ( 'chrnx_show' === $taxonomy && 'silicon-ranch' === $term_object->slug ) {
|
||||
return 'https://example.test/subdirectory/show/silicon-ranch/';
|
||||
}
|
||||
return $url;
|
||||
};
|
||||
try {
|
||||
$wp_rewrite->set_permalink_structure( '/%postname%/' );
|
||||
$this->go_to( get_term_link( $term ) );
|
||||
add_filter( 'term_link', $pretty_link, 10, 3 );
|
||||
$_GET = array( // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Synthetic read-only request.
|
||||
'chrnx_show' => 'invented-show',
|
||||
'evil' => 'drop-me',
|
||||
);
|
||||
$output = $this->render_journal_stream();
|
||||
preg_match( '/chrnx-journal-stream__pagination.*?href="([^"]+)".*?<\/nav>/s', $output, $pretty_match );
|
||||
$pretty_href = html_entity_decode( $pretty_match[1] ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8' );
|
||||
$this->assertSame( '/subdirectory/show/silicon-ranch/', wp_parse_url( $pretty_href, PHP_URL_PATH ) );
|
||||
parse_str( (string) wp_parse_url( $pretty_href, PHP_URL_QUERY ), $pretty_query );
|
||||
$this->assertSame( 'silicon-ranch', $pretty_query['chrnx_show'] ?? '' );
|
||||
$this->assertArrayNotHasKey( 'evil', $pretty_query );
|
||||
|
||||
remove_filter( 'term_link', $pretty_link, 10 );
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
$this->go_to( get_term_link( $term ) );
|
||||
$output = $this->render_journal_stream();
|
||||
preg_match( '/chrnx-journal-stream__pagination.*?href="([^"]+)".*?<\/nav>/s', $output, $plain_match );
|
||||
$plain_href = html_entity_decode( $plain_match[1] ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8' );
|
||||
parse_str( (string) wp_parse_url( $plain_href, PHP_URL_QUERY ), $plain_query );
|
||||
$this->assertSame( 'silicon-ranch', $plain_query['chrnx_show'] ?? '' );
|
||||
$this->assertSame( '2', (string) ( $plain_query['paged'] ?? '' ) );
|
||||
$this->assertArrayNotHasKey( 'evil', $plain_query );
|
||||
} finally {
|
||||
remove_filter( 'term_link', $pretty_link, 10 );
|
||||
$_GET = $previous_get;
|
||||
$wp_rewrite->set_permalink_structure( $previous_structure );
|
||||
$this->go_to( '/' );
|
||||
}
|
||||
}
|
||||
|
||||
/** Plain-permalink Journal links preserve Page routing and only validated public filters. */
|
||||
public function test_journal_pagination_preserves_plain_page_routing() {
|
||||
global $wp_rewrite;
|
||||
|
||||
@@ -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/,
|
||||
);
|
||||
} );
|
||||
@@ -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 } );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
Reference in new issue
Block a user