fix: complete CHRNX responsive edge states

This commit is contained in:
chrnx committed 2026-08-12 09:02:34 -05:00
1 parent 5073178492
commit 1e9386ac13
15 files changed
+384 -35

No files matched your search

+14 -1
View File
@@ -460,7 +460,8 @@ class BlockRenderingTest extends WP_UnitTestCase {
$this->assertStringContainsString( 'alt=""', $output );
$this->assertStringContainsString( 'width="1122"', $output );
$this->assertStringContainsString( 'height="1402"', $output );
$this->assertStringContainsString( 'loading="lazy"', $output );
$this->assertStringContainsString( 'loading="eager"', $output );
$this->assertStringContainsString( 'fetchpriority="high"', $output );
$this->assertStringContainsString( 'decoding="async"', $output );
$unsafe = render_block(
@@ -635,6 +636,18 @@ class BlockRenderingTest extends WP_UnitTestCase {
$this->assertStringNotContainsString( '<img', $output );
}
/** Topic heroes are the section surface and prioritize their approved portrait. */
public function test_topic_hero_portrait_is_eager_and_high_priority() {
$output = render_block(
array(
'blockName' => 'chrnx/topic-hero',
'attrs' => array( 'topic' => 'code' ),
)
);
$this->assertStringContainsString( 'loading="eager"', $output );
$this->assertStringContainsString( 'fetchpriority="high"', $output );
}
/** Journal pagination preserves only validated filters in actual rendered links. */
public function test_journal_pagination_links_preserve_only_valid_bounded_filters() {
$raw_search = 'needle' . str_repeat( 'x', 150 ) . '<b>unsafe</b>';
+9
View File
@@ -27,4 +27,13 @@ class ResponsiveMediaTest extends WP_UnitTestCase {
public function test_unknown_topic_portrait_returns_empty_markup() {
$this->assertSame( '', chrnx_get_topic_portrait_markup( '../../private', '', '' ) );
}
/** Above-fold art opts into eager high-priority loading while defaults remain lazy. */
public function test_topic_portrait_loading_is_explicitly_allowlisted() {
$eager = chrnx_get_topic_portrait_markup( 'code', '', '', 'eager' );
$this->assertStringContainsString( 'loading="eager"', $eager );
$this->assertStringContainsString( 'fetchpriority="high"', $eager );
$this->assertStringContainsString( 'loading="lazy"', chrnx_get_topic_portrait_markup( 'code' ) );
$this->assertStringNotContainsString( 'fetchpriority="high"', chrnx_get_topic_portrait_markup( 'code', '', '', 'invalid' ) );
}
}
+13
View File
@@ -87,6 +87,19 @@ class SettingsTest extends WP_UnitTestCase {
$this->assertSame( '', chrnx_get_subscribe_url() );
}
/** An unavailable setting cannot fall through to the current global page. */
public function test_subscribe_url_rejects_zero_even_with_a_global_page() {
$page = self::factory()->post->create_and_get(
array(
'post_type' => 'page',
'post_status' => 'publish',
)
);
$GLOBALS['post'] = $page;
update_option( 'chrnx_subscribe_page_id', 0 );
$this->assertSame( '', chrnx_get_subscribe_url() );
}
/** Field callback uses the core page dropdown and escaped description. */
public function test_subscribe_field_renders_a_core_page_dropdown() {
self::factory()->post->create(