Merge branch 'feature/character-led-sections' into feature/music-podcast-grunge-stages
This commit is contained in:
20 files changed
+1313
-76
No files matched your search
@@ -367,7 +367,7 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
'music' => 'the-no-names-musician-cutout.png',
|
||||
'podcasts' => 'alter-ego-podcasts.png',
|
||||
'life' => 'alter-ego-life.png',
|
||||
'gaming' => 'alter-ego-gaming.png',
|
||||
'gaming' => 'alter-ego-gaming-half-body.png',
|
||||
);
|
||||
foreach ( $expected as $slug => $filename ) {
|
||||
$this->assertSame( 'assets/images/' . $filename, chrnx_get_topic_art_asset( $slug ) );
|
||||
@@ -628,6 +628,9 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
$this->assertStringContainsString( 'loading="eager"', $output );
|
||||
$this->assertStringContainsString( 'fetchpriority="high"', $output );
|
||||
$this->assertStringContainsString( 'decoding="async"', $output );
|
||||
$this->assertStringContainsString( 'type="image/avif"', $output );
|
||||
$this->assertStringContainsString( 'type="image/webp"', $output );
|
||||
$this->assertStringContainsString( 'srcset="', $output );
|
||||
|
||||
$unsafe = render_block(
|
||||
array(
|
||||
@@ -651,6 +654,59 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
);
|
||||
$this->assertStringContainsString( 'width="1024"', $gaming );
|
||||
$this->assertStringContainsString( 'height="1536"', $gaming );
|
||||
$this->assertStringContainsString( 'alter-ego-gaming-half-body', $gaming );
|
||||
}
|
||||
|
||||
/** Topic heroes share the three-layer stage and unknown topics retain a safe labeled fallback. */
|
||||
public function test_topic_hero_uses_shared_stage_and_labels_unknown_fallbacks() {
|
||||
$attributes = array(
|
||||
'topic' => 'future-topic',
|
||||
'headingLevel' => 2,
|
||||
);
|
||||
ob_start();
|
||||
include get_theme_file_path( 'blocks/topic-hero/render.php' );
|
||||
$output = (string) ob_get_clean();
|
||||
|
||||
$this->assertStringContainsString( 'chrnx-topic-hero', $output );
|
||||
$this->assertStringContainsString( 'chrnx-character-stage', $output );
|
||||
$this->assertStringContainsString( '>Future Topic</h2>', $output );
|
||||
$this->assertMatchesRegularExpression( '/class="chrnx-topic-hero__fallback" aria-hidden="true"/', $output );
|
||||
$this->assertStringNotContainsString( '<img', $output );
|
||||
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML( '<?xml encoding="utf-8" ?>' . $output, LIBXML_NOERROR | LIBXML_NOWARNING );
|
||||
$xpath = new DOMXPath( $dom );
|
||||
$stage = $xpath->query( '//*[contains(concat(" ", normalize-space(@class), " "), " chrnx-character-stage ")]' )->item( 0 );
|
||||
$children = array();
|
||||
foreach ( $stage->childNodes as $child ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property.
|
||||
if ( XML_ELEMENT_NODE === $child->nodeType ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property.
|
||||
$children[] = $child;
|
||||
}
|
||||
}
|
||||
$this->assertCount( 3, $children );
|
||||
$this->assertStringContainsString( 'chrnx-character-stage__atmosphere', $children[0]->getAttribute( 'class' ) );
|
||||
$this->assertSame( 'true', $children[0]->getAttribute( 'aria-hidden' ) );
|
||||
$this->assertStringContainsString( 'chrnx-character-stage__content', $children[1]->getAttribute( 'class' ) );
|
||||
$this->assertStringContainsString( 'chrnx-character-stage__art', $children[2]->getAttribute( 'class' ) );
|
||||
}
|
||||
|
||||
/** Show archives use podcast art without replacing the visible show name. */
|
||||
public function test_show_archive_uses_podcasts_art_and_keeps_silicon_ranch_title() {
|
||||
$show = get_term_by( 'slug', 'silicon-ranch', 'chrnx_show' );
|
||||
$this->assertInstanceOf( WP_Term::class, $show );
|
||||
$this->go_to( get_term_link( $show ) );
|
||||
|
||||
$output = render_block(
|
||||
array(
|
||||
'blockName' => 'chrnx/topic-hero',
|
||||
'attrs' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertStringContainsString( '>Silicon Ranch</h2>', $output );
|
||||
$this->assertStringContainsString( 'alter-ego-podcasts.png', $output );
|
||||
$this->assertStringNotContainsString( '>Podcasts</h2>', $output );
|
||||
$this->assertSame( 1, substr_count( $output, 'class="chrnx-character-stage"' ) );
|
||||
}
|
||||
|
||||
/** Subscribe CTA is exactly empty until a published Page is configured. */
|
||||
|
||||
Reference in new issue
Block a user