diff --git a/assets/images/podcast-frequency-grunge.png b/assets/images/podcast-frequency-grunge.png new file mode 100644 index 0000000..9697071 Binary files /dev/null and b/assets/images/podcast-frequency-grunge.png differ diff --git a/tests/assets/test_alter_ego_assets.py b/tests/assets/test_alter_ego_assets.py index 6bd6514..69f1267 100644 --- a/tests/assets/test_alter_ego_assets.py +++ b/tests/assets/test_alter_ego_assets.py @@ -17,6 +17,7 @@ ALTER_EGO_ASSETS = ( "alter-ego-gaming.png", ) ALTER_EGO_SOURCE_ASSETS = (*ALTER_EGO_ASSETS, "alter-ego-gaming-half-body.png") +BACKGROUND_ASSETS = ("podcast-frequency-grunge.png",) CONTACT_SHEET_SCRIPT = PROJECT_ROOT / "scripts" / "build-alter-ego-contact-sheet.py" @@ -93,6 +94,42 @@ def test_alter_ego_asset_inventory_and_image_contract() -> None: ) +def test_background_asset_inventory_and_image_contract() -> None: + assert BACKGROUND_ASSETS == ("podcast-frequency-grunge.png",) + + missing = [ + name for name in BACKGROUND_ASSETS if not (ASSET_DIRECTORY / name).is_file() + ] + assert not missing, "Background asset inventory mismatch:\n" + "\n".join( + f"- missing assets/images/{name}" for name in missing + ) + + violations: list[str] = [] + for name in BACKGROUND_ASSETS: + path = ASSET_DIRECTORY / name + with Image.open(path) as image: + if image.format != "PNG": + violations.append(f"{name}: expected PNG, got {image.format!r}") + if image.mode not in {"RGB", "RGBA"}: + violations.append(f"{name}: expected RGB or RGBA, got {image.mode!r}") + + width, height = image.size + if width < 1536 or height < 960: + violations.append( + f"{name}: expected at least 1536x960, got {width}x{height}" + ) + + aspect_ratio = width / height + if not 1.35 <= aspect_ratio <= 1.7: + violations.append( + f"{name}: aspect ratio {aspect_ratio:.4f} outside 1.35..1.7" + ) + + assert not violations, "Background asset contract violations:\n" + "\n".join( + f"- {violation}" for violation in violations + ) + + def test_gaming_half_body_preserves_original_and_has_prominent_visible_alpha() -> None: original = ASSET_DIRECTORY / "alter-ego-gaming.png" half_body = ASSET_DIRECTORY / "alter-ego-gaming-half-body.png" diff --git a/tests/smoke/visual-integration.test.mjs b/tests/smoke/visual-integration.test.mjs index 16b7fc6..b739a39 100644 --- a/tests/smoke/visual-integration.test.mjs +++ b/tests/smoke/visual-integration.test.mjs @@ -1,11 +1,12 @@ import assert from 'node:assert/strict'; -import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs'; +import { existsSync, 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'; import { test } from 'node:test'; const read = ( path ) => readFileSync( new URL( `../../${ path }`, import.meta.url ), 'utf8' ); +const PODCAST_BACKGROUND_SOURCE = 'assets/images/podcast-frequency-grunge.png'; test( 'local visual fixtures define stable pages and representative editorial states', () => { const pages = JSON.parse( read( 'tests/fixtures/pages.json' ) ); @@ -242,6 +243,30 @@ test( 'post-card CSS fallbacks never reuse approved section portraits', () => { assert.doesNotMatch( components, /url\([^)]*(?:alter-ego-|the-no-names-musician-cutout)/ ); } ); +test( 'podcast background source stays separate from portrait and card fallbacks', () => { + assert.ok( + existsSync( new URL( `../../${ PODCAST_BACKGROUND_SOURCE }`, import.meta.url ) ), + `missing ${ PODCAST_BACKGROUND_SOURCE }`, + ); + + const portraitAllowlist = read( 'inc/queries.php' ); + assert.doesNotMatch( portraitAllowlist, /podcast-frequency-grunge\.png/ ); + + for ( const path of [ + 'assets/css/components.css', + 'blocks/featured-stories/style.css', + 'blocks/journal-stream/style.css', + 'blocks/latest-podcast/style.css', + 'blocks/related-posts/style.css', + ] ) { + assert.doesNotMatch( + read( path ), + /podcast-frequency-grunge\.png/, + `${ PODCAST_BACKGROUND_SOURCE } must not become a card fallback in ${ path }`, + ); + } +} ); + test( 'front page and section pages connect the real editorial patterns', () => { const front = read( 'templates/front-page.html' ); assert.match( front, /chrnx\/home-intro/ );