Skip to content

test(dashboard-e2e): strict-mode locator collision on 'Recently Closed' when a backlog item title contains the phrase #828

Closed

Description

@amrmelsayed

Symptom

Scheduled Dashboard E2E Tests workflow on main is failing (run 26328466816, 2026-05-23 08:46 UTC). All retries failed.

Single failing test:

packages/codev/src/agent-farm/__tests__/e2e/work-view-backlog.test.ts:153
  > recently closed section renders when items exist

Error:

Error: strict mode violation: locator('.work-section:has-text("Recently Closed")')
       resolved to 2 elements:
  1) <section class="work-section">…</section>  aka getByText('Backlog#819projectcore:')
  2) <section class="work-section">…</section>  aka getByText('Recently Closed✓#')

Root cause

The test uses an over-loose locator:

const closedSection = page.locator('.work-section:has-text("Recently Closed")');
await expect(closedSection).toBeVisible({ timeout: 5_000 });

:has-text(...) matches anywhere in the element subtree. Issue #813 ("vscode: migrate Recently Closed view from sidebar to Codev panel tab") is currently open with the project label, so it renders inside the Backlog section's item list — its title contains the substring "Recently Closed", causing the selector to match the Backlog section and the Recently Closed section.

This is a test-only bug. Product code is fine — the Backlog and Recently Closed sections render correctly.

Why it surfaced now

The test is data-coupled to live GitHub Issues. It happened to pass while no open backlog issue contained the substring "Recently Closed". Issue #813 was filed and the title contains the literal phrase, so the test started failing on the next scheduled run.

The flakiness is latent: any future issue whose title contains "Recently Closed" (or similar header text) will break the test again.

Fix

Scope the locator to the section heading, not the section subtree. Each section renders <h3 class=\"work-section-title\">{name}</h3> (see `packages/dashboard/src/components/WorkView.tsx:122-134`), so:

const closedSection = page.locator('.work-section', {
  has: page.locator('h3.work-section-title', { hasText: /^Recently Closed$/ }),
});

or equivalently:

const closedSection = page.locator('.work-section:has(h3.work-section-title:text-is(\"Recently Closed\"))');

Apply the same scoping to both occurrences in the test (lines 152 and 173). Sweep the rest of the file (and any other dashboard e2e tests) for the same .work-section:has-text(\"…\") pattern — Builders / Needs Attention / Backlog headings are all vulnerable to the same collision.

Acceptance criteria

  • packages/codev/src/agent-farm/__tests__/e2e/work-view-backlog.test.ts no longer uses :has-text(...) to identify work sections; matches the heading element directly.
  • Any sibling dashboard e2e tests using the same loose pattern are hardened the same way.
  • Scheduled Dashboard E2E workflow on main is green for two consecutive runs.

Out of scope

  • Decoupling the test from live GitHub state (the test deliberately exercises real data via /api/overview — keep that, just don't trip on issue-title content).

Activity

  1. self-assigned this
    on May 23, 2026
  2. added
    bug
    area/tower
    on May 23, 2026
  3. amrmelsayed commented on May 28, 2026

    @amrmelsayed
    CollaboratorAuthor

    Same flake reproduced on main today — Dashboard E2E run 26566196472 failed with the identical locator collision:

    strict mode violation: locator('.work-section:has-text("Recently Closed")') resolved to 2 elements:
      1) <section class="work-section">…</section> aka getByText('Backlog#913projectvscode:')
      2) <section class="work-section">…</section> aka getByText('Recently Closed✓#')
    

    Test: src/agent-farm/__tests__/e2e/work-view-backlog.test.ts:153 — "recently closed section renders when items exist". All 3 retries hit the same collision.

    Today's offending backlog item was #913 (filed earlier in the same session). Doesn't matter which specific issue triggers it — the .work-section:has-text("Recently Closed") locator will collide with whichever backlog item happens to render at fixture-injection time if its textContent (or the section's combined textContent) contains the substring "Recently Closed."

    This continues to surface with regular cadence — any session that files an issue with backlog churn shortly before a push can knock CI red. Recommending bumping priority on the fix (anchor the locator to the section's h2/header element, or filter to .work-section:not(.work-section--backlog), or anything else that breaks the substring-match path).

  4. amrmelsayed commented on May 28, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  5. amrmelsayed commented on May 28, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  6. added 2 commits that reference this issue on May 28, 2026
  7. added a commit that references this issue on May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/towerbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions