Skip to content

bug: E2E editor tests flaky — strict mode violations from leftover content #140

@zacharias-ona

Description

@zacharias-ona

Description

5 E2E editor tests fail against production due to Playwright strict mode violations. Tests find multiple matching elements because content from previous test runs persists on the page. Detected during post-merge verification of PR #135, but unrelated to that PR's changes (search empty state fix).

Failures

1. e2e/editor-drag.spec.ts:5 — "drag handle appears when hovering a block"

Typed text not found in editor — locator('p').filter({ hasText: 'DragTest ...' }) finds no elements.

2. e2e/editor-drag.spec.ts:76 — "drag handle is draggable and positioned near the hovered block"

Same pattern — locator('p').filter({ hasText: 'Block one' }) finds no elements.

3. e2e/editor-slash-commands.spec.ts:46 — "selecting a heading option inserts a heading block"

editor.locator('h1') resolves to 2 elements (an existing "Imported Heading" h1 and the newly inserted one), causing a strict mode violation.

4. e2e/editor-toolbar.spec.ts:34 — "bold button toggles bold formatting"

editor.locator('strong') resolves to 2 elements (a pre-existing bold element and the newly bolded text), causing a strict mode violation.

5. e2e/editor-toolbar.spec.ts:94 — "keyboard shortcut Cmd+B applies bold"

Same as above — editor.locator('strong') matches 2 elements.

Root Cause

These tests create content on existing pages but don't clean up. When the page already has content from prior runs (bold text, headings), the locators match multiple elements. The drag tests may also be affected by editor content not rendering in time.

Acceptance Criteria

  • All 5 failing editor E2E tests pass reliably against production
  • Tests use specific locators (e.g., .first(), .filter({ hasText }), or nth()) to avoid strict mode violations
  • Tests either create fresh pages or scope locators to newly inserted content
  • pnpm lint && pnpm typecheck && pnpm test pass

Technical Notes

  • Affected files: e2e/editor-drag.spec.ts, e2e/editor-slash-commands.spec.ts, e2e/editor-toolbar.spec.ts
  • The fix is to make locators more specific so they don't match leftover content from previous runs
  • PR fix: search empty state never renders for no-match queries (#126) #135 (search empty state fix) did not modify any editor code
  • 37 of 42 E2E tests pass; all ad-hoc smoke tests pass

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions