Skip to content

Commit 1929ed4

Browse files
test: more accessibility.
1 parent 8c44fad commit 1929ed4

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

playwright/helpers/app-test-helpers.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,13 @@ export const reorderWorkspaceTabBefore = async (
143143
page: Page,
144144
{ from, to }: { from: string; to: string },
145145
) => {
146-
const source = page
147-
.getByRole('button', { name: new RegExp(`^Open tab ${escapeRegex(from)}$`) })
148-
.locator('..')
149-
const target = page
150-
.getByRole('button', { name: new RegExp(`^Open tab ${escapeRegex(to)}$`) })
151-
.locator('..')
146+
const tabList = page.getByRole('list', { name: 'Workspace editor tabs' })
147+
const source = tabList.getByRole('listitem', {
148+
name: new RegExp(`^Workspace tab ${escapeRegex(from)}$`),
149+
})
150+
const target = tabList.getByRole('listitem', {
151+
name: new RegExp(`^Workspace tab ${escapeRegex(to)}$`),
152+
})
152153

153154
await source.dragTo(target)
154155
}

playwright/workspace-tabs.spec.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,20 @@ test('workspace tab drag reorder persists across reload', async ({ page }) => {
180180
to: 'App.tsx',
181181
})
182182

183-
const orderedTabs = page.locator('#workspace-tabs-strip .workspace-tab__select')
184-
await expect(orderedTabs.nth(0)).toHaveAttribute('aria-label', 'Open tab module-2.tsx')
185-
await expect(orderedTabs.nth(1)).toHaveAttribute('aria-label', 'Open tab App.tsx')
183+
const orderedTabs = page
184+
.getByRole('list', { name: 'Workspace editor tabs' })
185+
.getByRole('listitem')
186+
await expect(orderedTabs.nth(0)).toHaveAccessibleName('Workspace tab module-2.tsx')
187+
await expect(orderedTabs.nth(1)).toHaveAccessibleName('Workspace tab App.tsx')
186188

187189
await page.reload()
188190
await waitForInitialRender(page)
189191

190-
const restoredTabs = page.locator('#workspace-tabs-strip .workspace-tab__select')
191-
await expect(restoredTabs.nth(0)).toHaveAttribute('aria-label', 'Open tab module-2.tsx')
192-
await expect(restoredTabs.nth(1)).toHaveAttribute('aria-label', 'Open tab App.tsx')
192+
const restoredTabs = page
193+
.getByRole('list', { name: 'Workspace editor tabs' })
194+
.getByRole('listitem')
195+
await expect(restoredTabs.nth(0)).toHaveAccessibleName('Workspace tab module-2.tsx')
196+
await expect(restoredTabs.nth(1)).toHaveAccessibleName('Workspace tab App.tsx')
193197
})
194198

195199
test('workspace tab drag onto itself keeps order unchanged', async ({ page }) => {
@@ -199,7 +203,8 @@ test('workspace tab drag onto itself keeps order unchanged', async ({ page }) =>
199203
await addWorkspaceTab(page)
200204

201205
const labelsBefore = await page
202-
.locator('#workspace-tabs-strip .workspace-tab__select')
206+
.getByRole('list', { name: 'Workspace editor tabs' })
207+
.getByRole('listitem')
203208
.evaluateAll(nodes =>
204209
nodes
205210
.map(node => node.getAttribute('aria-label'))
@@ -212,7 +217,8 @@ test('workspace tab drag onto itself keeps order unchanged', async ({ page }) =>
212217
})
213218

214219
const labelsAfter = await page
215-
.locator('#workspace-tabs-strip .workspace-tab__select')
220+
.getByRole('list', { name: 'Workspace editor tabs' })
221+
.getByRole('listitem')
216222
.evaluateAll(nodes =>
217223
nodes
218224
.map(node => node.getAttribute('aria-label'))

src/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,7 @@ const renderWorkspaceTabs = () => {
16551655
tabContainer.className = 'workspace-tab'
16561656
tabContainer.dataset.active = isActive ? 'true' : 'false'
16571657
tabContainer.dataset.tabId = tab.id
1658+
tabContainer.setAttribute('aria-label', `Workspace tab ${tab.name}`)
16581659
tabContainer.draggable = true
16591660
tabContainer.dataset.dragOver =
16601661
dragOverWorkspaceTabId && dragOverWorkspaceTabId === tab.id ? 'true' : 'false'

0 commit comments

Comments
 (0)