Skip to content

test(dashboard): Paste and pick mentions like a person in composer e2e - #3976

Merged
dcramer merged 1 commit into
mainfrom
fix/composer-typeahead-e2e-flakes
Nov 21, 2026
Merged

dcramer merged 1 commit into
mainfrom
fix/composer-typeahead-e2e-flakes

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Fixes two flaky dashboard e2e tests in composer-typeahead.spec.ts. Only the tests were racy. The composer has no race that a person can hit.

"a pasted Slack mention becomes a mention"

The paste sometimes landed one character late ("ask @U456!first"). Lexical moves its own selection to the DOM caret only on selectionchange, beforeinput, or a selection key press. The test sent a scripted paste event right after six ArrowLeft presses. When Chromium had not yet delivered the last ArrowLeft's selectionchange, Lexical still had the earlier caret, and a scripted paste has no key press to make it read the DOM again. A real Ctrl/Cmd+V does.

  • New e2e/paste-text.ts: pasteText(page, text) writes the clipboard and presses ControlOrMeta+V. Both text-paste tests use it.
  • New ast-grep rule e2e-text-paste-through-paste-text flags setData("text/plain", …) in dashboard e2e files. File pastes are not affected.

Mention-card tests ("a archived conversation's mention card has no Invite" and others)

These pressed Enter or Tab as soon as the person's row was visible. That row can come from the search for the earlier text while the search for the full text loads, and the menu ignores Enter and Tab on it by design. So no mention was inserted.

  • New typeMention helper in the spec waits for the row and for the Mentions list to stop being aria-busy before the key press.

via @dcramer.

--

View Session [Sentry]

"a pasted Slack mention becomes a mention" dispatched a scripted paste
event after six ArrowLeft presses. Lexical moves its own selection to
the DOM caret only on selectionchange, beforeinput, or a selection key
press. A scripted paste has none of these, so when the last ArrowLeft's
selectionchange had not run yet, the paste landed one character late
("ask  @U456!first"). The poll on the DOM caret did not prove that the
editor saw the move.

pasteText now pastes with the clipboard and the paste shortcut, whose
key press makes Lexical read the DOM caret. An ast-grep rule keeps
dashboard e2e tests from scripting text pastes again.

The mention card tests pressed Enter or Tab once the person's row was
visible. That row can come from the search for the earlier text while
the search for the full text loads, and the menu then inserts nothing
by design. typeMention also waits until the menu is not busy.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 21, 2026 10:18pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 21, 2026
@dcramer
dcramer merged commit cedf6c2 into main Nov 21, 2026
55 checks passed
@dcramer
dcramer deleted the fix/composer-typeahead-e2e-flakes branch November 21, 2026 22:40
dcramer added a commit that referenced this pull request Nov 22, 2026
…ertions (#4025)

Dashboard E2E specs get around the existing geometry and sleep bans with
page script, synthetic events, raw selectors, and timeout overrides.
Synthetic input also flakes, as in #3976. This adds four
rules to `test-architecture:check` for
`packages/junior-dashboard/e2e/**/*.spec.ts`. Shared helpers such as
`harness.ts`, `screenshot.ts`, and `pick-option.ts` are not specs and
stay allowed.

| Rule | Matches | Baseline |
| --- | --- | --- |
| `dashboard-spec-page-script` | `evaluate(`, `evaluateHandle(` | 298 in
55 specs |
| `dashboard-spec-synthetic-event` | `dispatchEvent(` | 57 in 20 specs |
| `dashboard-spec-selector` | `locator(` with a string selector | 426 in
59 specs |
| `dashboard-spec-timing` | `timeout:` overrides | 38 in 17 specs |

Each error message says what to use instead: a named helper outside the
spec, real input, `getByRole`/`getByLabel`/`getByText`, or `page.clock`.

The counts are per file in `scripts/test-architecture-baseline.json`,
under new rule keys. That uses the existing per-file shrink logic: a
spec that goes above its count fails, and one that drops below it must
lower the entry. `baseline-growth:check` skips a rule key that is not on
the base branch, since that adopts a new check (the same way
`kind-behavior` was added in #3059). After this merges,
the totals are compared to main like every other rule.

Matches are not filtered by comments. Glob strings such as
`"**/api/conversations/*/messages"` break the shared comment stripper,
and the existing dashboard rules do not filter comments either.

Not covered, so open for a follow-up decision: `waitForFunction`,
`$eval`/`evaluateAll`, `getByTestId`, `locator(CONSTANT)`,
`test.setTimeout`, and `new Promise((r) => setTimeout(r, 250))` sleeps,
which the `waitForTimeout` ban misses.

This PR does not fix existing violations.

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Aea4dab6709a7b92a1029c38bbe76b72e -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Aea4dab6709a7b92a1029c38bbe76b72e)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aea4dab6709a7b92a1029c38bbe76b72e/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — b58d3122 Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant