test: verify Related Stories workflows

This commit is contained in:
chrnx committed 2026-08-12 21:54:50 -05:00
1 parent d8ad3d388f
commit 3a34a9990f
8 files changed
+702 -110

No files matched your search

+21
View File
@@ -298,11 +298,32 @@ describe( 'Related Stories progressive controllers', () => {
media.change( false );
expect( focusAtHide ).toBe( fixture.heading );
expect( document.activeElement ).toBe( fixture.heading );
expect( fixture.heading.getAttribute( 'tabindex' ) ).toBe( '-1' );
document.querySelector( '[data-unrelated]' ).focus();
expect( fixture.heading.hasAttribute( 'tabindex' ) ).toBe( false );
expect( fixture.controls.hidden ).toBe( true );
},
);
test( 'resize repairs focused controls before the media change event arrives', () => {
const { initialize } = require( modulePath );
const media = createMedia( true );
const fixture = installFixture().get( 'one' );
initialize( options( media ) );
fixture.next.focus();
media.matches = false;
fixture.geometry.clientWidth = fixture.geometry.scrollWidth;
window.dispatchEvent( new Event( 'resize' ) );
expect( document.activeElement ).toBe( fixture.heading );
expect( fixture.controls.hidden ).toBe( true );
expect( fixture.next.disabled ).toBe( false );
expect( fixture.heading.getAttribute( 'tabindex' ) ).toBe( '-1' );
document.querySelector( '[data-unrelated]' ).focus();
expect( fixture.heading.hasAttribute( 'tabindex' ) ).toBe( false );
} );
test( 'unrelated focus remains unchanged when adaptive controls hide', () => {
const { initialize } = require( modulePath );
const media = createMedia( true );