fix: fall back to placeholder art when a cover attachment is gone
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
9 files changed
+80
-23
No files matched your search
@@ -559,9 +559,9 @@ const immutableSurfaces = [
|
||||
],
|
||||
// Project names come from the project list query: 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' ],
|
||||
headings: [ 'Proyectos', 'Ailed', 'Expressive Tea', 'Published research' ],
|
||||
paragraphs: [],
|
||||
contentText: 'Selected work Ailed Expressive Tea Published research',
|
||||
contentText: 'Proyectos Ailed Expressive Tea Published research',
|
||||
},
|
||||
{
|
||||
name: 'About',
|
||||
|
||||
@@ -193,7 +193,7 @@ test( 'home remains coherent at all approved review viewports', async ( { page }
|
||||
await expect( page.locator( 'main#chrnx-main' ) ).toBeVisible();
|
||||
await expect( page.getByRole( 'contentinfo' ) ).toBeVisible();
|
||||
await expect( page.getByRole( 'heading', { level: 1 } ) ).toHaveCount( 1 );
|
||||
await expect( page.getByText( 'Selected work', { exact: true } ) ).toBeVisible();
|
||||
await expect( page.getByText( 'Proyectos', { exact: true } ) ).toBeVisible();
|
||||
await expect( page.getByText( 'The No Names', { exact: true } ).first() ).toBeVisible();
|
||||
await expect( page.locator( 'picture source[type="image/avif"]' ).first() ).toHaveAttribute(
|
||||
'srcset',
|
||||
|
||||
@@ -205,9 +205,9 @@ class PatternsTest extends WP_UnitTestCase {
|
||||
public function test_character_led_patterns_use_the_exact_shared_stage_api() {
|
||||
$contracts = array(
|
||||
'home-projects' => array(
|
||||
'heading' => 'Selected work',
|
||||
'heading' => 'Proyectos',
|
||||
// The project names come from the project list query now, not the pattern.
|
||||
'order' => array( 'Selected work' ),
|
||||
'order' => array( 'Proyectos' ),
|
||||
'art' => 'alter-ego-code-768.webp',
|
||||
'art_alt' => '',
|
||||
'atmosphere' => 'chrnx-character-stage__secondary-art',
|
||||
|
||||
@@ -107,6 +107,55 @@ class ProjectBlocksTest extends WP_UnitTestCase {
|
||||
$this->assertSame( '', trim( do_blocks( '<!-- wp:chrnx/project-detail /-->' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure a list card falls back to placeholder art when the stored cover
|
||||
* attachment no longer exists, instead of rendering a blank art column.
|
||||
*/
|
||||
public function test_project_list_with_deleted_cover_uses_placeholder_art() {
|
||||
$term_id = self::factory()->term->create(
|
||||
array(
|
||||
'taxonomy' => 'chrnx_project',
|
||||
'slug' => 'deleted-cover-list-test',
|
||||
)
|
||||
);
|
||||
update_term_meta( $term_id, 'chrnx_project_cover', 999999 );
|
||||
|
||||
$markup = do_blocks( '<!-- wp:chrnx/project-list /-->' );
|
||||
|
||||
// Scope the assertion to this term's own card: the taxonomy query is
|
||||
// unfiltered, so other projects' cards must not mask a broken one.
|
||||
$needle = 'chrnx_project=deleted-cover-list-test';
|
||||
$link_offset = strpos( $markup, $needle );
|
||||
$this->assertNotFalse( $link_offset, 'Expected a card linking to the test project.' );
|
||||
$card_start = strrpos( substr( $markup, 0, $link_offset ), '<article' );
|
||||
$card_end = strpos( $markup, '</article>', $link_offset );
|
||||
$card = substr( $markup, $card_start, $card_end - $card_start );
|
||||
|
||||
$this->assertStringContainsString( 'chrnx-project-card__fallback', $card );
|
||||
$this->assertStringNotContainsString( 'chrnx-project-card__cover', $card );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the detail block falls back to placeholder art when the stored
|
||||
* cover attachment no longer exists, instead of rendering a blank art column.
|
||||
*/
|
||||
public function test_project_detail_with_deleted_cover_uses_placeholder_art() {
|
||||
$term_id = self::factory()->term->create(
|
||||
array(
|
||||
'taxonomy' => 'chrnx_project',
|
||||
'slug' => 'deleted-cover-detail-test',
|
||||
)
|
||||
);
|
||||
update_term_meta( $term_id, 'chrnx_project_cover', 999999 );
|
||||
|
||||
$this->go_to( get_term_link( $term_id ) );
|
||||
|
||||
$markup = do_blocks( '<!-- wp:chrnx/project-detail /-->' );
|
||||
|
||||
$this->assertStringContainsString( 'chrnx-project-detail__fallback', $markup );
|
||||
$this->assertStringNotContainsString( 'chrnx-project-detail__cover', $markup );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure a project archive filters the journal to that project.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user