|
1 | 1 | import React, {useEffect} from 'react'
|
2 |
| -import {Meta} from '@storybook/react' |
| 2 | +import type {Meta, StoryFn} from '@storybook/react' |
3 | 3 | import {INITIAL_VIEWPORTS} from '@storybook/addon-viewport'
|
4 | 4 | import {linkTo} from '@storybook/addon-links'
|
5 | 5 |
|
@@ -250,7 +250,7 @@ const AnchorNavVariantData = {
|
250 | 250 | ['Reliability']: 'reliability',
|
251 | 251 | }
|
252 | 252 |
|
253 |
| -export const AnchorNavVariant = args => ( |
| 253 | +export const AnchorNavVariantTemplate: StoryFn<typeof SubNav> = args => ( |
254 | 254 | <main>
|
255 | 255 | <Box paddingBlockStart={64} backgroundColor="subtle" style={{position: 'relative', zIndex: 32}}></Box>
|
256 | 256 | <SubNav {...args}>
|
@@ -290,6 +290,9 @@ export const AnchorNavVariant = args => (
|
290 | 290 | </Box>
|
291 | 291 | </main>
|
292 | 292 | )
|
| 293 | + |
| 294 | +const AnchorNavVariant = AnchorNavVariantTemplate.bind({}) |
| 295 | + |
293 | 296 | AnchorNavVariant.parameters = {
|
294 | 297 | layout: 'fullscreen',
|
295 | 298 | }
|
@@ -454,3 +457,54 @@ KeyboardNavigation.play = async ({canvasElement}) => {
|
454 | 457 | await userEvent.tab({shift: true})
|
455 | 458 | expect(getByRole('link', {name: 'Discussions'})).toHaveFocus()
|
456 | 459 | }
|
| 460 | + |
| 461 | +export const AnchorNavVariantKeyboardNavigation = AnchorNavVariant.bind({}) |
| 462 | + |
| 463 | +AnchorNavVariantKeyboardNavigation.play = async ({canvasElement}) => { |
| 464 | + const {getByRole, getAllByRole} = within(canvasElement) |
| 465 | + |
| 466 | + await userEvent.tab() |
| 467 | + expect(getByRole('link', {name: 'Enterprise'})).toHaveFocus() |
| 468 | + |
| 469 | + await userEvent.tab() |
| 470 | + expect(getByRole('link', {name: 'Overview'})).toHaveFocus() |
| 471 | + |
| 472 | + await userEvent.tab() |
| 473 | + expect(getByRole('link', {name: 'Advanced Security'})).toHaveFocus() |
| 474 | + |
| 475 | + await userEvent.tab() |
| 476 | + expect(getByRole('link', {name: 'Copilot Enterprise'})).toHaveFocus() |
| 477 | + |
| 478 | + await userEvent.tab() |
| 479 | + expect(getByRole('link', {name: 'Premium Support'})).toHaveFocus() |
| 480 | + |
| 481 | + await userEvent.tab() |
| 482 | + expect(getByRole('link', {name: 'Scale'})).toHaveFocus() |
| 483 | + |
| 484 | + await userEvent.tab() |
| 485 | + expect(getByRole('link', {name: 'AI'})).toHaveFocus() |
| 486 | + |
| 487 | + await userEvent.tab() |
| 488 | + expect(getByRole('link', {name: 'Security'})).toHaveFocus() |
| 489 | + |
| 490 | + await userEvent.tab() |
| 491 | + expect(getByRole('link', {name: 'Reliability'})).toHaveFocus() |
| 492 | + |
| 493 | + await userEvent.tab() |
| 494 | + expect(getAllByRole('button', {name: 'Learn more'})[0]).toHaveFocus() |
| 495 | + |
| 496 | + await userEvent.tab({shift: true}) |
| 497 | + expect(getByRole('link', {name: 'Reliability'})).toHaveFocus() |
| 498 | + |
| 499 | + await userEvent.tab({shift: true}) |
| 500 | + expect(getByRole('link', {name: 'Security'})).toHaveFocus() |
| 501 | + |
| 502 | + await userEvent.tab({shift: true}) |
| 503 | + expect(getByRole('link', {name: 'AI'})).toHaveFocus() |
| 504 | + |
| 505 | + await userEvent.tab({shift: true}) |
| 506 | + expect(getByRole('link', {name: 'Scale'})).toHaveFocus() |
| 507 | + |
| 508 | + await userEvent.tab({shift: true}) |
| 509 | + expect(getByRole('link', {name: 'Premium Support'})).toHaveFocus() |
| 510 | +} |
0 commit comments