diff --git a/scripts/seed-test-content.php b/scripts/seed-test-content.php index 59be910..2a33069 100644 --- a/scripts/seed-test-content.php +++ b/scripts/seed-test-content.php @@ -134,9 +134,22 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_index => $chrnx_seed_post ) { wp_set_object_terms( $chrnx_seed_post_id, array(), 'chrnx_show', false ); } - foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration', 'canonical_episode_url' ) as $chrnx_seed_meta_key ) { + if ( isset( $chrnx_seed_post['release'] ) ) { + wp_set_object_terms( $chrnx_seed_post_id, sanitize_key( $chrnx_seed_post['release'] ), 'chrnx_release', false ); + } else { + wp_set_object_terms( $chrnx_seed_post_id, array(), 'chrnx_release', false ); + } + + foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration', 'canonical_episode_url', 'chrnx_project_featured' ) as $chrnx_seed_meta_key ) { delete_post_meta( $chrnx_seed_post_id, $chrnx_seed_meta_key ); } + if ( ! empty( $chrnx_seed_post['projectFeatured'] ) ) { + update_post_meta( $chrnx_seed_post_id, 'chrnx_project_featured', true ); + } + delete_post_meta( $chrnx_seed_post_id, 'chrnx_track_number' ); + if ( isset( $chrnx_seed_post['trackNumber'] ) ) { + update_post_meta( $chrnx_seed_post_id, 'chrnx_track_number', absint( $chrnx_seed_post['trackNumber'] ) ); + } if ( isset( $chrnx_seed_post['episodeNumber'] ) ) { update_post_meta( $chrnx_seed_post_id, 'chrnx_episode_number', absint( $chrnx_seed_post['episodeNumber'] ) ); } diff --git a/tests/e2e/editorial-editor.spec.mjs b/tests/e2e/editorial-editor.spec.mjs index 7dd1ae6..80e7252 100644 --- a/tests/e2e/editorial-editor.spec.mjs +++ b/tests/e2e/editorial-editor.spec.mjs @@ -42,4 +42,11 @@ test( 'editorial and podcast controls initialize in the real post editor', async await expect( page.getByLabel( 'Duration', { exact: true } ) ).toBeVisible(); await expect( page.getByLabel( 'Participants (one per line)', { exact: true } ) ).toBeVisible(); await expect( page.getByLabel( 'Canonical episode URL', { exact: true } ) ).toBeVisible(); + + // Switching topic swaps which per-topic panel is offered. + await openPanel( 'Topic' ); + await page.getByRole( 'radio', { name: 'Projects', exact: true } ).check(); + await expect( page.getByLabel( 'Episode number', { exact: true } ) ).toBeHidden(); + await openPanel( 'Project' ); + await expect( page.getByLabel( 'Show in Selected work', { exact: true } ) ).toBeVisible(); } ); diff --git a/tests/e2e/music-podcast-stages.spec.mjs b/tests/e2e/music-podcast-stages.spec.mjs index da16a4b..f129796 100644 --- a/tests/e2e/music-podcast-stages.spec.mjs +++ b/tests/e2e/music-podcast-stages.spec.mjs @@ -7,7 +7,7 @@ const landings = [ path: '/music/', root: '.chrnx-music-landing', atmosphere: '.chrnx-character-stage__collage', - art: 'img[src*="the-no-names-musician-cutout.png"]', + art: 'img[src*="the-no-names-musician-cutout-768.webp"]', internalHeadings: ':scope > h3, .chrnx-release-card h4', internalHeadingCount: 4, next: ':scope > p', @@ -17,7 +17,7 @@ const landings = [ path: '/podcasts/', root: '.chrnx-podcast-landing', atmosphere: '.chrnx-character-stage__frequency', - art: 'img[src*="alter-ego-podcasts.png"]', + art: 'img[src*="alter-ego-podcasts-768.webp"]', internalHeadings: '.chrnx-podcast-card__title', internalHeadingCount: 1, next: ':scope > .wp-block-chrnx-latest-podcast', @@ -550,24 +550,26 @@ const immutableSurfaces = [ name: 'Projects', path: '/projects/', root: '.chrnx-home-projects', - art: 'img[src*="alter-ego-code.png"]', - atmosphereCount: 1, - imageSources: [ 'alter-ego-research.png', 'alter-ego-code.png' ], - headings: [ 'Selected work', 'Expressive Tea', 'Ailed', 'Published research' ], + art: 'img[src*="alter-ego-code-768.webp"]', + atmosphereCount: 2, + imageSources: [ + 'projects-grunge-1536.webp', + 'alter-ego-research-768.webp', + 'alter-ego-code-768.webp', + ], + // Project names come from chrnx/selected-work: picked projects newest-first, + // then the most recent ones. This is the seeded order, not a frozen string. + headings: [ 'Selected work', 'Ailed', 'Expressive Tea', 'Published research' ], paragraphs: [], - contentText: 'Selected work Expressive Tea Ailed Published research', + contentText: 'Selected work Ailed Expressive Tea Published research', }, { name: 'About', path: '/about/', root: '.chrnx-about', - art: 'img[src*="alter-ego-life.png"]', - atmosphereCount: 0, - imageSources: [ - 'alter-ego-life.png', - 'alter-ego-literature.png', - 'alter-ego-gaming-half-body.png', - ], + art: 'img[src*="alter-ego-life-768.webp"]', + atmosphereCount: 1, + imageSources: [ 'about-grunge-1536.webp', 'alter-ego-life-768.webp' ], headings: [ 'About', 'Beyond the work' ], paragraphs: [ 'I work as Lead Developer @Expressive Tea, building full-stack software with JavaScript and Python. I am also an independent researcher exploring emotion modeling and game AI; my practice includes open source work and amateur data science.', diff --git a/tests/e2e/pattern-editor-validity.spec.mjs b/tests/e2e/pattern-editor-validity.spec.mjs index 48dec37..7fcc819 100644 --- a/tests/e2e/pattern-editor-validity.spec.mjs +++ b/tests/e2e/pattern-editor-validity.spec.mjs @@ -6,8 +6,8 @@ const patterns = [ patternTitle: 'Music landing', pageSlug: 'music', patternSlug: 'chrnx/music-landing', - atmosphereAsset: 'the-no-names-collage.jpeg', - artAsset: 'the-no-names-musician-cutout.png', + atmosphereAsset: 'the-no-names-collage-768.webp', + artAsset: 'the-no-names-musician-cutout-768.webp', contentCopy: 'The No Names es una banda activa', supportingCopy: 'El proceso usa generative AI', }, @@ -16,8 +16,8 @@ const patterns = [ patternTitle: 'Podcast landing', pageSlug: 'podcasts', patternSlug: 'chrnx/podcast-landing', - atmosphereAsset: 'podcast-frequency-grunge.png', - artAsset: 'alter-ego-podcasts.png', + atmosphereAsset: 'podcast-frequency-grunge-1536.webp', + artAsset: 'alter-ego-podcasts-768.webp', contentCopy: 'Conversations about the work behind software, research, music, and games.', supportingCopy: '', }, @@ -55,12 +55,15 @@ async function closeWelcomeGuide( page ) { } async function waitForEditor( page ) { + // The Site Editor boots slower than the default 5s poll under load. await expect - .poll( () => - page.evaluate( () => { - const editor = window.wp?.data?.select( 'core/block-editor' ); - return typeof editor?.getBlocks === 'function' && editor.getBlocks().length > 0; - } ), + .poll( + () => + page.evaluate( () => { + const editor = window.wp?.data?.select( 'core/block-editor' ); + return typeof editor?.getBlocks === 'function' && editor.getBlocks().length > 0; + } ), + { timeout: 20_000 }, ) .toBe( true ); } @@ -70,7 +73,12 @@ async function waitForPatternEditorState( page ) { .poll( () => page.evaluate( () => { - const store = window.wp.data.select( 'core/block-editor' ); + // The editor may still be booting on the first poll; returning an + // empty list retries instead of throwing out of expect.poll. + const store = window.wp?.data?.select( 'core/block-editor' ); + if ( typeof store?.getBlocks !== 'function' ) { + return []; + } const flatten = ( blocks ) => blocks.flatMap( ( block ) => [ block, ...flatten( block.innerBlocks || [] ) ] ); const all = flatten( store.getBlocks() ); diff --git a/tests/fixtures/pages.json b/tests/fixtures/pages.json index 026265a..45d57db 100644 --- a/tests/fixtures/pages.json +++ b/tests/fixtures/pages.json @@ -18,7 +18,7 @@ "slug": "projects", "title": "Projects", "status": "publish", - "content": "

Software · investigación · sistemas expresivos

" + "content": "

Software · investigación · sistemas expresivos

" }, { "fixtureKey": "page-music", @@ -46,6 +46,6 @@ "slug": "subscribe", "title": "Subscribe", "status": "publish", - "content": "

Stay close to the work

New notes, experiments, music, and conversations. The final subscription provider will be connected before launch.

" + "content": "

Stay close to the work

New notes, experiments, music, and conversations.

" } ] diff --git a/tests/fixtures/posts.json b/tests/fixtures/posts.json index df110de..4902112 100644 --- a/tests/fixtures/posts.json +++ b/tests/fixtures/posts.json @@ -9,6 +9,35 @@ "featured": true, "fixtureState": "unbroken-code" }, + { + "fixtureKey": "post-project-expressive-tea", + "title": "Expressive Tea", + "slug": "expressive-tea", + "excerpt": "Full-stack product work in JavaScript and Python, built with a small team and a long memory.", + "content": "

Lead development on a full-stack product built with JavaScript and Python, where the interesting constraints are organizational as often as technical.

", + "topic": "projects", + "language": "en", + "projectFeatured": true + }, + { + "fixtureKey": "post-project-ailed", + "title": "Ailed", + "slug": "ailed", + "excerpt": "An expressive agent that models hesitation instead of resolving it away.", + "content": "

An experiment in emotion modeling for game AI: the agent is allowed to be uncertain, and that uncertainty is part of its behavior rather than a defect.

", + "topic": "projects", + "language": "en", + "projectFeatured": true + }, + { + "fixtureKey": "post-project-published-research", + "title": "Published research", + "slug": "published-research", + "excerpt": "Independent research on emotion modeling and expressive systems.", + "content": "

Independent research published on arXiv, covering emotion modeling and the design of systems that can express internal state.

", + "topic": "projects", + "language": "en" + }, { "fixtureKey": "post-research-primary", "title": "What game AI can learn from the uncomfortable space between intention and action", @@ -47,6 +76,39 @@ "language": "es", "fixtureState": "missing-media" }, + { + "fixtureKey": "post-track-uno", + "title": "La primera que se rompió", + "slug": "la-primera-que-se-rompio", + "excerpt": "Fixture local de canción: letra y notas de proceso sin publicar material real.", + "content": "

Letra

Este contenido existe únicamente como fixture local del tema.

Por qué existe

Nota de proceso de ejemplo para validar la plantilla de canción.

", + "topic": "music", + "language": "es", + "release": "el-hermoso-caos", + "trackNumber": 1 + }, + { + "fixtureKey": "post-track-dos", + "title": "Cuarto sin ventanas", + "slug": "cuarto-sin-ventanas", + "excerpt": "Fixture local de canción para validar el orden de la lista de pistas.", + "content": "

Letra

Este contenido existe únicamente como fixture local del tema.

", + "topic": "music", + "language": "es", + "release": "el-hermoso-caos", + "trackNumber": 2 + }, + { + "fixtureKey": "post-track-tres", + "title": "Jerga rota", + "slug": "jerga-rota", + "excerpt": "Fixture local de canción asignada a otro disco.", + "content": "

Letra

Este contenido existe únicamente como fixture local del tema.

", + "topic": "music", + "language": "es", + "release": "aqui-se-rompio-una-jerga", + "trackNumber": 1 + }, { "fixtureKey": "post-podcast-episode", "title": "Silicon Ranch: conversaciones sin diapositivas", diff --git a/tests/php/ResponsiveMediaTest.php b/tests/php/ResponsiveMediaTest.php index b704aad..7ccc000 100644 --- a/tests/php/ResponsiveMediaTest.php +++ b/tests/php/ResponsiveMediaTest.php @@ -29,7 +29,8 @@ class ResponsiveMediaTest extends WP_UnitTestCase { $this->assertStringContainsString( 'podcast-frequency-grunge-768.webp 768w', $markup ); $this->assertStringContainsString( 'podcast-frequency-grunge-1536.webp 1536w', $markup ); $this->assertStringContainsString( 'sizes="(max-width: 780px) 100vw, 1200px"', $markup ); - $this->assertStringContainsString( 'podcast-frequency-grunge.png', $markup ); + $this->assertStringContainsString( 'src="http://', $markup ); + $this->assertDoesNotMatchRegularExpression( '#src="[^"]*/assets/images/podcast-frequency-grunge\.png"#', $markup ); $this->assertStringContainsString( 'class="chrnx-character-stage__frequency"', $markup ); $this->assertStringContainsString( 'width="1536"', $markup ); $this->assertStringContainsString( 'height="1024"', $markup ); @@ -43,14 +44,16 @@ class ResponsiveMediaTest extends WP_UnitTestCase { $this->assertSame( '', chrnx_get_atmosphere_markup( '../../private', 'unsafe class' ) ); } - /** Approved topic portraits render a compact picture element with a PNG fallback. */ + /** Approved topic portraits render a compact picture element with a WebP fallback. */ public function test_topic_portrait_picture_markup_has_modern_sources_and_dimensions() { $markup = chrnx_get_topic_portrait_markup( 'code', 'Code workshop portrait', 'chrnx-section-portrait' ); $this->assertStringContainsString( 'assertStringContainsString( 'type="image/avif"', $markup ); $this->assertStringContainsString( 'type="image/webp"', $markup ); - $this->assertStringContainsString( 'alter-ego-code.png', $markup ); + // The fallback is a generated derivative, never the design master. + $this->assertStringContainsString( 'generated/alter-ego-code-768.webp', $markup ); + $this->assertDoesNotMatchRegularExpression( '#src="[^"]*/assets/images/alter-ego-code\.png"#', $markup ); $this->assertStringContainsString( 'width="1122"', $markup ); $this->assertStringContainsString( 'height="1402"', $markup ); $this->assertStringContainsString( 'loading="lazy"', $markup );