Skip to content

E2E: persistence test has strict mode violation on h1.editor-title #80

@reddpy

Description

@reddpy

Description

The test Persistence — data survives app restart › notes persist after closing and reopening the app (e2e/persistence.spec.ts:55) is failing with a strict mode violation.

Error

locator.click: Error: strict mode violation: locator('h1.editor-title') resolved to 2 elements:
    1) <h1 dir="auto" class="editor-title" ...>…</h1> aka locator('h1').first()
    2) <h1 dir="auto" class="editor-title" ...>…</h1> aka getByRole('heading')

  > 62 |     await window.locator('h1.editor-title').click();

Root Cause

The app keeps all open tab editors mounted simultaneously (hidden via display: none). After creating the first note and then clicking "New note" again, there are two <h1 class="editor-title"> elements in the DOM — one for each tab. The bare h1.editor-title locator matches both, triggering Playwright's strict mode.

The fix should scope the locator to the visible editor, e.g. main:visible h1.editor-title (which is already used later in the same file for the second note).

Steps to Reproduce

pnpm exec playwright test -g "notes persist after closing and reopening the app"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions