fix(e2e): scope heading locators to main content area#50
fix(e2e): scope heading locators to main content area#50privilegedescalation-engineer[bot] wants to merge 1 commit intomainfrom
Conversation
Replace bare getByRole("heading", { name: /Intel GPU — .../i }) calls
with page.locator('main').getByRole('heading', { name: '...' }) so that
each locator matches exactly one element and Playwright strict mode is
satisfied.
The main element is the appropriate scoping container for plugin page
content. Exact name matching (without regex) is used to be precise about
which heading is being targeted.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
| Filename | Overview |
|---|---|
| e2e/intel-gpu.spec.ts | All heading locators scoped to main; regex matching replaced with exact strings. One pre-existing omission: heading assertion after sidebar click has no timeout. |
Sequence Diagram
sequenceDiagram
participant PW as Playwright Test
participant P as Page DOM
participant Sidebar as sidebar (nav)
participant Main as main (content)
note over PW,Main: Before fix — bare getByRole may match multiple elements
PW->>P: getByRole('heading', {name: /Intel GPU — Overview/i})
P-->>Sidebar: heading match?
P-->>Main: heading match?
P-->>PW: ❌ StrictModeViolation (2+ matches)
note over PW,Main: After fix — locator scoped to main
PW->>Main: locator('main').getByRole('heading', {name: 'Intel GPU — Overview'})
Main-->>PW: ✅ single heading match
Prompt To Fix All With AI
This is a comment left during a code review.
Path: e2e/intel-gpu.spec.ts
Line: 22-24
Comment:
**Missing timeout after navigation**
All other heading assertions in this file pass `{ timeout: 15_000 }`, but this one does not. After `gpuEntry.click()` triggers a client-side navigation, the heading may not be immediately present in the DOM. Without an explicit timeout, Playwright falls back to the global `expect` timeout configured in `playwright.config.ts`. Adding the same `15_000` ms timeout used elsewhere makes the behaviour consistent and less fragile in slow CI environments.
```suggestion
await expect(
page.locator('main').getByRole('heading', { name: 'Intel GPU — Overview' })
).toBeVisible({ timeout: 15_000 });
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(e2e): scope heading locators to main..." | Re-trigger Greptile
| await expect( | ||
| page.locator('main').getByRole('heading', { name: 'Intel GPU — Overview' }) | ||
| ).toBeVisible(); |
There was a problem hiding this comment.
Missing timeout after navigation
All other heading assertions in this file pass { timeout: 15_000 }, but this one does not. After gpuEntry.click() triggers a client-side navigation, the heading may not be immediately present in the DOM. Without an explicit timeout, Playwright falls back to the global expect timeout configured in playwright.config.ts. Adding the same 15_000 ms timeout used elsewhere makes the behaviour consistent and less fragile in slow CI environments.
| await expect( | |
| page.locator('main').getByRole('heading', { name: 'Intel GPU — Overview' }) | |
| ).toBeVisible(); | |
| await expect( | |
| page.locator('main').getByRole('heading', { name: 'Intel GPU — Overview' }) | |
| ).toBeVisible({ timeout: 15_000 }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: e2e/intel-gpu.spec.ts
Line: 22-24
Comment:
**Missing timeout after navigation**
All other heading assertions in this file pass `{ timeout: 15_000 }`, but this one does not. After `gpuEntry.click()` triggers a client-side navigation, the heading may not be immediately present in the DOM. Without an explicit timeout, Playwright falls back to the global `expect` timeout configured in `playwright.config.ts`. Adding the same `15_000` ms timeout used elsewhere makes the behaviour consistent and less fragile in slow CI environments.
```suggestion
await expect(
page.locator('main').getByRole('heading', { name: 'Intel GPU — Overview' })
).toBeVisible({ timeout: 15_000 });
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Replace bare
getByRole('heading', { name: /Intel GPU — .../i })selectors withpage.locator('main').getByRole('heading', { name: '...' })in the E2E smoke tests.The bare selectors may match multiple elements (e.g., a heading inside the sidebar
and the page heading) causing Playwright strict-mode violations. Scoping to the
mainelement ensures each locator targets exactly one element.Changes
page.locator('main').getByRole('heading', ...)Test plan
npx playwright testpasses in CInpx playwright test --headedpasses locally🤖 Generated with Claude Code