|
| 1 | +import { expect, test } from '@nuxt/test-utils/playwright' |
| 2 | + |
| 3 | +test.describe('Package Page', () => { |
| 4 | + test('/vue → package manager tabs use roving tabindex', async ({ page, goto }) => { |
| 5 | + await goto('/vue', { waitUntil: 'domcontentloaded' }) |
| 6 | + |
| 7 | + const tablist = page.locator('[role="tablist"]').first() |
| 8 | + await expect(tablist).toBeVisible() |
| 9 | + |
| 10 | + const tabs = tablist.locator('[role="tab"]') |
| 11 | + const tabCount = await tabs.count() |
| 12 | + expect(tabCount).toBeGreaterThan(1) |
| 13 | + |
| 14 | + const firstTab = tabs.first() |
| 15 | + await firstTab.focus() |
| 16 | + await expect(firstTab).toBeFocused() |
| 17 | + |
| 18 | + await page.keyboard.press('ArrowRight') |
| 19 | + |
| 20 | + const secondTab = tabs.nth(1) |
| 21 | + await expect(secondTab).toBeFocused() |
| 22 | + await expect(secondTab).toHaveAttribute('aria-selected', 'true') |
| 23 | + await expect(secondTab).toHaveAttribute('tabindex', '0') |
| 24 | + await expect(firstTab).toHaveAttribute('tabindex', '-1') |
| 25 | + |
| 26 | + const tabpanel = page.locator('[role="tabpanel"]').first() |
| 27 | + const controls = await secondTab.getAttribute('aria-controls') |
| 28 | + const panelId = await tabpanel.getAttribute('id') |
| 29 | + expect(controls).toBe(panelId) |
| 30 | + |
| 31 | + const labelledBy = await tabpanel.getAttribute('aria-labelledby') |
| 32 | + const tabId = await secondTab.getAttribute('id') |
| 33 | + expect(labelledBy).toBe(tabId) |
| 34 | + }) |
| 35 | +}) |
0 commit comments