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:
chrnxandClaude Opus 5 committed 2026-08-15 15:34:37 -05:00
1 parent 77dc2ee33b
commit 6f418f1a51
9 files changed
+80 -23

No files matched your search

+49
View File
@@ -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.
*/