@@ -12,63 +12,60 @@ test.beforeEach(async ({ page }) => {
1212
1313test . describe ( "SkipLink:" , function ( ) {
1414 test ( "skip link is present in DOM but initially hidden" , async ( { page } ) => {
15- // Skip link should be in the DOM but not visible
1615 const skipLink = page . locator ( ".widget-skip-link" ) . first ( ) ;
1716 await expect ( skipLink ) . toBeAttached ( ) ;
18-
19- // Check initial styling (hidden)
20- const transform = await skipLink . evaluate ( el => getComputedStyle ( el ) . transform ) ;
21- expect ( transform ) . toContain ( "matrix(1, 0, 0, 1, 0, -48)" ) ;
17+
18+ // Element is translated above the viewport — its bottom edge should be at or above y=0
19+ const rect = await skipLink . evaluate ( el => el . getBoundingClientRect ( ) . toJSON ( ) ) ;
20+ expect ( rect . bottom ) . toBeLessThanOrEqual ( 0 ) ;
2221 } ) ;
2322
2423 test ( "skip link becomes visible when focused via keyboard" , async ( { page } ) => {
25- // Tab to focus the skip link (should be first focusable element)
2624 const skipLink = page . locator ( ".widget-skip-link" ) . first ( ) ;
2725 await page . keyboard . press ( "Tab" ) ;
28-
26+
2927 await expect ( skipLink ) . toBeFocused ( ) ;
30- await page . waitForTimeout ( 1000 ) ;
31- // Check that it becomes visible when focused
32- const transform = await skipLink . evaluate ( el => getComputedStyle ( el ) . transform ) ;
33- expect ( transform ) . toContain ( "matrix(1, 0, 0, 1, 0, 0)" )
28+ // Element should now be within the viewport
29+ const rect = await skipLink . evaluate ( el => el . getBoundingClientRect ( ) . toJSON ( ) ) ;
30+ expect ( rect . top ) . toBeGreaterThanOrEqual ( 0 ) ;
3431 } ) ;
3532
3633 test ( "skip link navigates to main content when activated" , async ( { page } ) => {
3734 // Tab to focus the skip link
3835 await page . keyboard . press ( "Tab" ) ;
39-
36+
4037 const skipLink = page . locator ( ".widget-skip-link" ) . first ( ) ;
4138 await expect ( skipLink ) . toBeFocused ( ) ;
42-
39+
4340 // Activate the skip link
4441 await page . keyboard . press ( "Enter" ) ;
45-
42+
4643 // Check that main content is now focused
4744 const mainContent = page . locator ( "main" ) ;
4845 await expect ( mainContent ) . toBeFocused ( ) ;
4946 } ) ;
5047
5148 test ( "skip link has correct attributes and text" , async ( { page } ) => {
5249 const skipLink = page . locator ( ".widget-skip-link" ) . first ( ) ;
53-
50+
5451 // Check default text
5552 await expect ( skipLink ) . toHaveText ( "Skip to main content" ) ;
56-
53+
5754 // Check href attribute
5855 await expect ( skipLink ) . toHaveAttribute ( "href" , "#" ) ;
59-
56+
6057 // Check CSS class
6158 await expect ( skipLink ) . toHaveClass ( "widget-skip-link mx-name-skipLink1" ) ;
6259 } ) ;
6360
6461 test ( "visual comparison" , async ( { page } ) => {
6562 // Tab to make skip link visible for screenshot
6663 await page . keyboard . press ( "Tab" ) ;
67-
64+
6865 const skipLink = page . locator ( ".widget-skip-link" ) . first ( ) ;
6966 await expect ( skipLink ) . toBeFocused ( ) ;
70-
67+
7168 // Visual comparison of focused skip link
7269 await expect ( skipLink ) . toHaveScreenshot ( "skiplink-focused.png" ) ;
7370 } ) ;
74- } ) ;
71+ } ) ;
0 commit comments