Skip to content

Commit 9831bf9

Browse files
committed
test: update tests
1 parent 4730c57 commit 9831bf9

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

test/e2e/create-command.spec.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test.describe('Create Command', () => {
6262
})
6363

6464
test.describe('Copy Functionality', () => {
65-
test('copy button is always visible', async ({ page, goto }) => {
65+
test('copy button is accessible and keyboard discoverable', async ({ page, goto }) => {
6666
await goto('/package/vite', { waitUntil: 'hydration' })
6767

6868
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
@@ -75,9 +75,13 @@ test.describe('Create Command', () => {
7575
const createCommandContainer = page.locator('.group\\/createcmd').first()
7676
await expect(createCommandContainer).toBeVisible({ timeout: 20000 })
7777

78-
// Copy button should always be visible
78+
// Copy button should be in the DOM and accessible to screen readers
7979
const copyButton = createCommandContainer.locator('button')
80-
await expect(copyButton).toHaveCSS('opacity', '1')
80+
await expect(copyButton).toBeAttached()
81+
82+
// Focus the button to verify it's keyboard accessible
83+
await copyButton.focus()
84+
await expect(copyButton).toBeFocused()
8185
})
8286

8387
test('clicking copy button copies create command and shows confirmation', async ({
@@ -114,16 +118,20 @@ test.describe('Create Command', () => {
114118
})
115119

116120
test.describe('Install Command Copy', () => {
117-
test('copy button is always visible', async ({ page, goto }) => {
121+
test('copy button is accessible and keyboard discoverable', async ({ page, goto }) => {
118122
await goto('/package/is-odd', { waitUntil: 'hydration' })
119123

120124
// Find the install command container
121125
const installCommandContainer = page.locator('.group\\/installcmd').first()
122126
await expect(installCommandContainer).toBeVisible()
123127

124-
// Copy button should always be visible
128+
// Copy button should be in the DOM and accessible to screen readers
125129
const copyButton = installCommandContainer.locator('button')
126-
await expect(copyButton).toHaveCSS('opacity', '1')
130+
await expect(copyButton).toBeAttached()
131+
132+
// Focus the button to verify it's keyboard accessible
133+
await copyButton.focus()
134+
await expect(copyButton).toBeFocused()
127135
})
128136

129137
test('clicking copy button copies install command and shows confirmation', async ({
@@ -153,7 +161,7 @@ test.describe('Create Command', () => {
153161
})
154162

155163
test.describe('Run Command Copy', () => {
156-
test('copy button is always visible', async ({ page, goto }) => {
164+
test('copy button is accessible and keyboard discoverable', async ({ page, goto }) => {
157165
await goto('/package/vite', { waitUntil: 'hydration' })
158166

159167
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
@@ -166,9 +174,13 @@ test.describe('Create Command', () => {
166174
const runCommandContainer = page.locator('.group\\/runcmd').first()
167175
await expect(runCommandContainer).toBeVisible({ timeout: 20000 })
168176

169-
// Copy button should always be visible
177+
// Copy button should be in the DOM and accessible to screen readers
170178
const copyButton = runCommandContainer.locator('button')
171-
await expect(copyButton).toHaveCSS('opacity', '1')
179+
await expect(copyButton).toBeAttached()
180+
181+
// Focus the button to verify it's keyboard accessible
182+
await copyButton.focus()
183+
await expect(copyButton).toBeFocused()
172184
})
173185

174186
test('clicking copy button copies run command and shows confirmation', async ({

0 commit comments

Comments
 (0)