Skip to content

Commit 4ac68e7

Browse files
clubandersonCopilot
andcommitted
🐛 fix: deduplicate settings-title testid for Playwright strict mode
The Settings component renders both a desktop sidebar and mobile header, each with data-testid='settings-title'. Playwright strict mode rejects queries that resolve to multiple elements. Update the settings e2e tests to accept the renamed mobile instance 'settings-title-mobile'. Fixes #19338 Signed-off-by: Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ca5cfd1 commit 4ac68e7

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

web/e2e/Settings.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ test.describe('Settings Page', () => {
7474
await expect(page.getByTestId('settings-page')).toBeVisible({ timeout: 10000 })
7575

7676
// Should have Settings heading
77-
await expect(page.getByTestId('settings-title')).toBeVisible()
78-
await expect(page.getByTestId('settings-title')).toHaveText('Settings')
77+
const settingsTitle = page.getByTestId('settings-title')
78+
.or(page.getByTestId('settings-title-mobile'))
79+
await expect(settingsTitle.first()).toBeVisible()
80+
await expect(settingsTitle.first()).toHaveText('Settings')
7981
})
8082

8183
test('has sidebar navigation', async ({ page }) => {

web/e2e/user-flows/settings-configuration.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ test.describe('Settings Configuration — "Change my preferences"', () => {
1515
const settingsPage = page.getByTestId('settings-page')
1616
await expect(settingsPage).toBeVisible({ timeout: ELEMENT_VISIBLE_TIMEOUT_MS })
1717
const title = page.getByTestId('settings-title')
18-
await expect(title).toBeVisible()
18+
.or(page.getByTestId('settings-title-mobile'))
19+
await expect(title.first()).toBeVisible()
1920
})
2021

2122
test('settings page shows configuration groups', async ({ page }) => {
@@ -117,9 +118,11 @@ test.describe('Settings Configuration — "Change my preferences"', () => {
117118
test('mobile: settings layout at 375px', async ({ page }) => {
118119
await page.setViewportSize({ width: MOBILE_WIDTH, height: MOBILE_HEIGHT })
119120
await setupDemoAndNavigate(page, '/settings')
120-
// Now that both desktop and mobile titles use the same testid,
121-
// .filter({visible: true}) ensures we get the actually-visible one
121+
// At mobile width, the desktop sidebar nav (hidden lg:block) is CSS-hidden, so
122+
// settings-title is not visible even though it exists in the DOM.
123+
// Use .filter({visible:true}) to pick whichever title variant is actually rendered.
122124
const title = page.getByTestId('settings-title')
125+
.or(page.getByTestId('settings-title-mobile'))
123126
.filter({ visible: true })
124127
.first()
125128
await expect(title).toBeVisible({ timeout: ELEMENT_VISIBLE_TIMEOUT_MS })

0 commit comments

Comments
 (0)