fix: harden CHRNX shell accessibility
This commit is contained in:
14 files changed
+520
-54
No files matched your search
@@ -15,9 +15,9 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
delete_option( 'chrnx_subscribe_page_id' );
|
||||
}
|
||||
|
||||
/** All nine block types register from metadata. */
|
||||
/** All eleven block types register from metadata. */
|
||||
public function test_all_editorial_blocks_are_registered() {
|
||||
$names = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand' );
|
||||
$names = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content' );
|
||||
foreach ( $names as $name ) {
|
||||
$type = WP_Block_Type_Registry::get_instance()->get_registered( 'chrnx/' . $name );
|
||||
$this->assertInstanceOf( WP_Block_Type::class, $type, $name );
|
||||
@@ -25,6 +25,48 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/** Mobile menu control is localized, initially hidden, and targets the one primary navigation. */
|
||||
public function test_mobile_menu_toggle_renders_progressive_control() {
|
||||
$output = render_block(
|
||||
array(
|
||||
'blockName' => 'chrnx/mobile-menu-toggle',
|
||||
'attrs' => array(),
|
||||
'innerBlocks' => array(),
|
||||
'innerHTML' => '',
|
||||
'innerContent' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertStringContainsString( 'data-chrnx-menu-toggle', $output );
|
||||
$this->assertStringContainsString( 'aria-controls="chrnx-primary-navigation"', $output );
|
||||
$this->assertStringContainsString( 'aria-expanded="false"', $output );
|
||||
$this->assertStringContainsString( 'hidden', $output );
|
||||
$this->assertStringContainsString( 'Open primary navigation', $output );
|
||||
$this->assertStringContainsString( 'Close primary navigation', $output );
|
||||
}
|
||||
|
||||
/** Footer destinations and personal copy render through escaped translation functions. */
|
||||
public function test_footer_content_renders_local_internal_navigation() {
|
||||
$output = render_block(
|
||||
array(
|
||||
'blockName' => 'chrnx/footer-content',
|
||||
'attrs' => array(),
|
||||
'innerBlocks' => array(),
|
||||
'innerHTML' => '',
|
||||
'innerContent' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertStringContainsString( 'aria-label="Footer navigation"', $output );
|
||||
foreach ( array( 'journal', 'projects', 'music', 'podcasts', 'about' ) as $path ) {
|
||||
$this->assertStringContainsString( 'href="' . esc_url( home_url( '/' . $path . '/' ) ) . '"', $output );
|
||||
}
|
||||
$this->assertStringContainsString( 'Made in Sinaloa, shared from home.', $output );
|
||||
$this->assertStringContainsString( esc_html( get_bloginfo( 'name' ) ), $output );
|
||||
$this->assertStringNotContainsString( 'facebook', strtolower( $output ) );
|
||||
$this->assertStringNotContainsString( '<form', $output );
|
||||
}
|
||||
|
||||
/** The approved local wordmark links to the portable site home URL. */
|
||||
public function test_site_brand_renders_escaped_local_home_and_wordmark_urls() {
|
||||
$output = render_block(
|
||||
|
||||
Reference in new issue
Block a user