Skip to content

fix(e2e): scope heading locators to main content area#50

Open
privilegedescalation-engineer[bot] wants to merge 1 commit intomainfrom
fix/heading-selectors
Open

fix(e2e): scope heading locators to main content area#50
privilegedescalation-engineer[bot] wants to merge 1 commit intomainfrom
fix/heading-selectors

Conversation

@privilegedescalation-engineer
Copy link
Copy Markdown
Contributor

Summary

Replace bare getByRole('heading', { name: /Intel GPU — .../i }) selectors with
page.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
main element ensures each locator targets exactly one element.

Changes

  • All page heading assertions now use page.locator('main').getByRole('heading', ...)
  • Regex name matching replaced with exact string matching for precision

Test plan

  • npx playwright test passes in CI
  • npx playwright test --headed passes locally

🤖 Generated with Claude Code

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>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR scopes all heading locators in the E2E smoke tests to the main content element (page.locator('main').getByRole('heading', ...)) to prevent Playwright strict-mode violations that occur when a heading is present in both the sidebar and the page body. It also switches from case-insensitive regex name matching to exact string matching.

  • All six heading assertions now use page.locator('main').getByRole('heading', ...) instead of the bare page.getByRole('heading', ...)
  • Regex patterns (e.g., /Intel GPU — Overview/i) replaced with exact string literals (e.g., 'Intel GPU — Overview')
  • No functional logic is changed outside the test file
  • The first navigation test ('sidebar intel-gpu entry is clickable and navigates to overview') still has no timeout on the scoped heading assertion — this is pre-existing and not introduced by this PR, but worth noting since after a click+navigation the heading may not be immediately available

Confidence Score: 5/5

Safe to merge — targeted fix to a single test file with no production code changes.

The change is narrowly scoped to E2E test helpers: it correctly addresses Playwright strict-mode violations by anchoring locators to main, and switches to exact string matching for precision. The only note is a pre-existing missing timeout on one assertion, which is a non-blocking style suggestion.

No files require special attention.

Important Files Changed

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
Loading
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

Comment thread e2e/intel-gpu.spec.ts
Comment on lines +22 to +24
await expect(
page.locator('main').getByRole('heading', { name: 'Intel GPU — Overview' })
).toBeVisible();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants