mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
test(desktop): fix flaky forum empty-draft replacement e2e (#7981)
## Summary
The `replacement=` cases (`add` and `publish`) of `forum source visit …:
A→B→A retains source draft` in `forum-agent-invitation.spec.ts` are
flaky. They fail at line 449 because the source draft still reads
`@RemoteScout hello`.
Cause: Playwright's `fill("")` on a contenteditable sets a DOM selection
and then presses `Delete`. ProseMirror handles `Delete` with its own
selection, which sometimes hasn't synced from the DOM yet. When that
happens the key press does nothing, `onUpdate` never fires, and the
clear is never recorded. I confirmed this with temporary logging:
failing runs have no authored-content update after the fill. Non-empty
`fill` uses `insertText`, which goes through ProseMirror's DOM input
path, so it isn't affected.
Fix (test only):
- Clear the draft with `ControlOrMeta+a` followed by `Delete`, so
ProseMirror owns the selection.
- Assert the replacement text before navigating away.
### Related issue
None found. The spec hasn't changed since #7125. This test failed in 10
of the last 40 CI runs of `Desktop Smoke E2E (2)`, for example #3700.
### Testing
- `--repeat-each=100 --retries=0 --workers=4` on the two affected cases:
- Before the fix: 14 of 200 runs failed at `:449`.
- After the fix: 200 of 200 passed.
- Full `forum-agent-invitation.spec.ts`: 19 passed.
- Pre-push hooks passed (desktop typecheck and desktop tests).
Signed-off-by: Fizz <6be7be23ec5bba868f3e1db5ec86013d76bd1a293dce5b435a192158fec13641@buzz.block.builderlab.xyz>
Co-authored-by: Fizz <6be7be23ec5bba868f3e1db5ec86013d76bd1a293dce5b435a192158fec13641@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -430,8 +430,17 @@ for (const stage of ["add", "publish"] as const) {
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Remove attachment" }),
|
||||
).toBeVisible();
|
||||
if (replacement !== null)
|
||||
if (replacement === "") {
|
||||
// fill("") presses Delete over a DOM selection ProseMirror may not
|
||||
// have synced yet; select through the editor's own keymap instead.
|
||||
await page.getByTestId("message-input").click();
|
||||
await page.keyboard.press("ControlOrMeta+a");
|
||||
await page.keyboard.press("Delete");
|
||||
} else if (replacement !== null) {
|
||||
await page.getByTestId("message-input").fill(replacement);
|
||||
}
|
||||
if (replacement !== null)
|
||||
await expect(page.getByTestId("message-input")).toHaveText(replacement);
|
||||
await navigate(1);
|
||||
await releaseForumGate(page);
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user