diff --git a/inc/queries.php b/inc/queries.php index a5f8a3d..78d2a99 100644 --- a/inc/queries.php +++ b/inc/queries.php @@ -321,7 +321,7 @@ function chrnx_sanitize_journal_search( $value ) { */ function chrnx_get_journal_archive_filter( $queried_object = null ): array { $queried_object = null === $queried_object ? get_queried_object() : $queried_object; - if ( ! $queried_object instanceof WP_Term || ! in_array( $queried_object->taxonomy, array( 'chrnx_topic', 'chrnx_language' ), true ) ) { + if ( ! $queried_object instanceof WP_Term || ! in_array( $queried_object->taxonomy, array( 'chrnx_topic', 'chrnx_language', 'chrnx_show' ), true ) ) { return array(); } @@ -473,7 +473,7 @@ function chrnx_get_journal_query_args( array $request ): array { ); $tax_query = array(); - foreach ( array( 'chrnx_topic', 'chrnx_language' ) as $taxonomy ) { + foreach ( array( 'chrnx_topic', 'chrnx_language', 'chrnx_show' ) as $taxonomy ) { $value = $request[ $taxonomy ] ?? ''; $slug = chrnx_validate_editorial_term_slug( $value, $taxonomy ); if ( '' !== $slug ) { diff --git a/tests/e2e/visual-states.spec.mjs b/tests/e2e/visual-states.spec.mjs index 6c29dda..4ce9780 100644 --- a/tests/e2e/visual-states.spec.mjs +++ b/tests/e2e/visual-states.spec.mjs @@ -96,9 +96,8 @@ test( 'long, incomplete, empty, and missing states stay usable', async ( { page } ), ).toBeVisible(); await expect( page.locator( '.chrnx-podcast-meta' ) ).toHaveCount( 0 ); - await expect( page.locator( '.taxonomy-chrnx_topic, .taxonomy-chrnx_language' ) ).toHaveCount( - 0, - ); + await expect( page.locator( '.taxonomy-chrnx_topic' ) ).toContainText( 'Podcasts' ); + await expect( page.locator( '.taxonomy-chrnx_language' ) ).toContainText( 'Español' ); await expect( page.getByText( 'Estado de prueba para un episodio sin show' ) ).toHaveCount( 0 ); await page.goto( '/emotion-is-not-a-slider-designing-expressive-systems-that-can-hesitate/' ); @@ -197,6 +196,20 @@ test( 'podcast canonical metadata is safe and missing metadata never invents a p ); } ); +test( 'incomplete podcast remains journal-visible but excluded from show and latest surfaces', async ( { + page, +} ) => { + const title = 'Conversación pendiente de datos editoriales'; + await page.goto( `/?s=${ encodeURIComponent( title ) }` ); + await expect( page.locator( '.chrnx-journal-card', { hasText: title } ) ).toHaveCount( 1 ); + + await page.goto( '/podcasts/' ); + await expect( page.locator( '.chrnx-latest-podcast', { hasText: title } ) ).toHaveCount( 0 ); + + await page.goto( '/show/silicon-ranch/' ); + await expect( page.locator( 'main', { hasText: title } ) ).toHaveCount( 0 ); +} ); + test( 'site routes preserve heading order, named landmarks, and skip-link keyboard flow', async ( { page, }, testInfo ) => { diff --git a/tests/fixtures/posts.json b/tests/fixtures/posts.json index c672307..0b8b620 100644 --- a/tests/fixtures/posts.json +++ b/tests/fixtures/posts.json @@ -63,7 +63,9 @@ "fixtureKey": "post-podcast-missing-meta", "title": "Conversación pendiente de datos editoriales", "content": "
El tema debe seguir siendo claro aunque la ficha editorial todavía esté incompleta.
", - "fixtureStates": [ "missing-podcast-meta", "missing-excerpt", "missing-topic", "missing-language" ] + "topic": "podcasts", + "language": "es", + "fixtureStates": [ "missing-podcast-meta", "missing-excerpt" ] }, { "fixtureKey": "post-life-fatherhood", @@ -78,8 +80,8 @@ "title": "Small interfaces, fewer lies", "excerpt": "Why narrow APIs often produce software that is easier to trust and maintain.", "content": "A public interface is a promise. Smaller promises leave less room for accidental fiction.
", - "topic": "code", - "language": "en" + "language": "en", + "fixtureState": "missing-topic" }, { "fixtureKey": "post-research-paper", @@ -87,7 +89,7 @@ "excerpt": "Turning published research into experiments that can be felt, inspected, and challenged.", "content": "Publication is not the end of an idea. It is where other people finally get a fair chance to disagree with it.
", "topic": "research", - "language": "en" + "fixtureState": "missing-language" }, { "fixtureKey": "post-gaming-accessibility", diff --git a/tests/php/EditorialQueriesTest.php b/tests/php/EditorialQueriesTest.php index 9b80aaf..b2c27ac 100644 --- a/tests/php/EditorialQueriesTest.php +++ b/tests/php/EditorialQueriesTest.php @@ -251,6 +251,22 @@ class EditorialQueriesTest extends WP_UnitTestCase { $this->assertArrayNotHasKey( 'tax_query', chrnx_get_journal_query_args( $unsupported ) ); } + /** Show archives constrain Journal results to actual show membership. */ + public function test_show_archive_context_excludes_podcasts_without_show_membership() { + $member = $this->create_post( 'Show member', '2026-02-02 10:00:00', 'podcasts' ); + $loose = $this->create_post( 'Podcast without show', '2026-02-03 10:00:00', 'podcasts' ); + wp_set_object_terms( $member, 'silicon-ranch', 'chrnx_show' ); + $term = get_term_by( 'slug', 'silicon-ranch', 'chrnx_show' ); + $this->go_to( get_term_link( $term ) ); + + $context = chrnx_get_journal_request_context( array() ); + $this->assertSame( 'silicon-ranch', $context['chrnx_show'] ); + $ids = array_map( 'absint', wp_list_pluck( chrnx_run_eligible_query( chrnx_get_journal_query_args( $context ) )->posts, 'ID' ) ); + $this->assertContains( $member, $ids ); + $this->assertNotContains( $loose, $ids ); + $this->go_to( '/' ); + } + /** Malformed journal request values are ignored and never copied into query args. */ public function test_journal_query_ignores_malformed_filters_and_caps_search() { $args = chrnx_get_journal_query_args( diff --git a/tests/smoke/visual-integration.test.mjs b/tests/smoke/visual-integration.test.mjs index 0f2d713..70d549b 100644 --- a/tests/smoke/visual-integration.test.mjs +++ b/tests/smoke/visual-integration.test.mjs @@ -29,6 +29,13 @@ test( 'local visual fixtures define stable pages and representative editorial st assert.ok( posts.some( ( post ) => /^https:\/\//.test( post.canonicalEpisodeUrl ?? '' ) ) ); assert.ok( posts.some( ( post ) => hasState( post, 'missing-podcast-meta' ) && !( 'canonicalEpisodeUrl' in post ) ) ); assert.equal( new Set( posts.map( ( post ) => post.fixtureKey ) ).size, posts.length ); + const incompletePodcast = posts.find( ( post ) => post.fixtureKey === 'post-podcast-missing-meta' ); + assert.equal( incompletePodcast?.topic, 'podcasts' ); + assert.equal( incompletePodcast?.language, 'es' ); + assert.ok( !( 'show' in incompletePodcast ) && !( 'canonicalEpisodeUrl' in incompletePodcast ) ); + assert.ok( hasState( incompletePodcast, 'missing-excerpt' ) ); + assert.ok( posts.some( ( post ) => post.fixtureKey !== incompletePodcast.fixtureKey && hasState( post, 'missing-topic' ) && !( 'topic' in post ) ) ); + assert.ok( posts.some( ( post ) => post.fixtureKey !== incompletePodcast.fixtureKey && hasState( post, 'missing-language' ) && !( 'language' in post ) ) ); for ( const topic of [ 'code', 'research', 'gaming', 'literature', 'music', 'podcasts', 'life' ] ) { assert.ok( posts.some( ( post ) => post.topic === topic ), `missing ${ topic } fixture` ); }