mirror of
https://github.com/block/buzz.git
synced 2026-10-30 05:51:46 +00:00
## Summary Test-side fixes for the two largest desktop E2E flake clusters in the 21–28 Oct 2026 CI audit: - **Composer `fill()` races the app's deferred focus-to-end** (§1). Text was appended to the old draft, or a clear did nothing. - **Clicks on the hover-only message action bar while the timeline re-pins** (§3/§8/§18). Reply and more-actions clicks timed out or were intercepted. Two shared helpers replace the per-spec workarounds, and §9 rides along because its spec now imports them. The PR changes test code only. It is one of seven PRs split out of the `flakey-tests` branch (siblings below). ### Related issue None found. #8559, #8622 and #8613 touch these specs or helpers, but had no coverage for these clusters. Draft #8661 edits `empty-edit-delete.spec.ts`'s `submitEmptyEdit` and `beforeEach`, the same lines as this PR. ### New helpers - `tests/helpers/composer.ts`: - `clearComposer` waits for the app's focus, then repeats select-all + Delete through the editor keymap until the editor is empty (250 ms per try, 5 s overall). - `replaceComposerText` clears, then fills. On an empty document, a late collapse to the end is a no-op. - `tests/helpers/channelHeadReady.ts`: - `GENERAL_CHANNEL_ID`. - `openGeneral` clicks `#general`, then calls `waitForMockChannelHeadReady`. - `pressRowAction(button)` does focus + Enter. The action bar also shows on focus-within, and more-actions is a Radix trigger that opens on Enter. ### Flaky tests fixed | Test | Failing runs | Cause | Change | |---|---|---|---| | §1 `inbox-edit.spec.ts:525` | 39641311877, 39821769576, 40333705511, 40348069929, 40388246283 | **Append:** entering edit mode, or closing the non-member mention dialog, focuses the end of the draft in deferred steps: RAF, a nested RAF, then ProseMirror's 20 ms selection resync. `fill()` selects and inserts in separate protocol steps, so a step that lands in between collapses the selection and the text is appended. **Clear does nothing:** `fill("")` presses Delete before ProseMirror handles `selectionchange`, so the editor blocks it. | `clearComposer` / `replaceComposerText` | | §1 `inbox-edit.spec.ts:560` | 39538411386, 39821769576 | Same as above. | Same | | §1 `mention-recipients.spec.ts:591` (both variants) | 39799090750, 40374286094, 39641311877 | Same | Same | | §1 `mention-recipients.spec.ts:691` (both variants) | 40348069929, 40556019361, 39601763602 | Same | Same | | §1 `messaging.spec.ts:3799` | 39827234118, 40445481983 | Same, plus a bare `#general` click and a `force: true` Reply | Same, plus `openGeneral` and `pressRowAction` | | §1 `messaging.spec.ts:4022` | 40389392495 | Same | Same | | §1 `messaging.spec.ts:4289` | 39822883395, 40557808800, 40566841699 | Same | Same | | §1 `messaging.spec.ts:4368` | 40574058918 | Same | Same | | §1 `remote-owned-mentions.spec.ts:463` (both variants) | 39618692657, 40374286094, 40382726903, 40389392495, 40582387515 | Same, after the Invite dialog closes | Same | | §3 `messaging.spec.ts` :3531, :3647, :4122, :4208, :4450 (root and reply) and :4633 (keyboard and button) | :3531 40583830861, 40595483966. :3647 40566841699, 40597484657. :4122 39641311877, 40368315739, 40368363357. :4208 39525092486, 39796569342, 40367495044. :4450 39796569342, 40348069929, 40373404267. :4633 39530486096, 40348069929, 40368315739, 40582387515, 40368363357 | The action bar is `pointer-events-none` until its row is hovered. Opening `#general` refreshes the head after the live subscription lands, and the timeline re-pins, so the row moves out from under the pointer. `force: true` only hid this. | `openGeneral`, then `pressRowAction` on Reply or more-actions. Six more messaging tests that used hover + `click({ force: true })` get the same change, and each first waits for its last row to contain the sent root. | | §18 `thread-follow.spec.ts:350` | 39529963092, 40348069929, 40583830861 (all 3), 40595483966; PR 39541263507 (all 3) | Same; the composer overlay intercepts the more-actions click. | Same | | §8 `thread-head-stale-edit.spec.ts:55` | 39525092486, 39618692657, 39796569342, 39822883395, 40011714848, 40281448810, 40368363357, 40389392495, 40445481983, 40574058918; PR 40031299575 (all 3) | Same (used `force: true`) | Same | | `file-attachment.spec.ts:165` | 1–2 CI failures (audit long tail) | A more-actions click on a moving timeline | Same | | `empty-edit-delete.spec.ts` (`openMoreActionsMenu`, `submitEmptyEdit`, the non-empty edit, `beforeEach`) | Covered under §11 in the desktop-races sibling | The same hover and `fill` races | The head-ready wait before emitting, `pressRowAction`, `clearComposer` and `replaceComposerText`. The autocomplete table rows keep their back-to-back keys, which is what they test. | | §9 `file-attachment.spec.ts:419` "upload progress floats above the dock and lifts Jump to latest" | 10 of 50 main jobs, including 40583830861, 40597484657, 40608383847 | A programmatic `scrollTop` keeps the bottom intent armed. The upload card resizes the content, the timeline re-pins, and the pill unmounts under `boundingBox()`. The fixed 250 ms wait read the card mid-slide. | `scrollTimelineUp()` leaves the bottom with a real wheel, and one `expect.poll` checks all three layout relations. | Local before/after counts are from the original `flakey-tests` commits (e286a6ae0, 816c7c35e, c66f411f3, 67185df6a), running `main`'s copy and the changed copy side by side under forcings: - **§1 at 4× CPU throttle:** 130/130 after; `main`'s copies ranged from 5/10 to 10/10. - **§1 with `selectionchange` delayed, a stretched resync, or a gap inside `fill()`:** `main`'s copies 0/5 to 4/5 and 0/20; after 65/65 and 20/20. - **§3 at 4× throttle:** `main` had 3 Reply-click timeouts at :4208 and 3 at :4633 (keyboard); after 120/120. - **`file-attachment:165`:** 0/3 before, 3/3 after. - **§9 unforced:** 4/5 before, 5/5 after. These were measured with the helper's first version, which waited two frames plus the 20 ms resync. The final state-based helper ran unforced only: 157/157 and then 196/196 over the touched specs. Its retry was not checked under a forced late collapse. :3531, :3647, :4122, :4450 root, :4633 button, `thread-head-stale-edit:55` and the six force-click tests were not force-reproduced; they get the fix that matches their CI signatures and reproduced siblings. Dropped: - `mention-recipients.spec.ts:933` (40608383847) fails on `flavors.handled`, which is unrelated. - `persistent-agent-audience.spec.ts:828` (`@Mor@Morg`) did not reproduce in 79 forced runs. ### Verification This branch was pushed without local re-verification, by the user's choice: local test runs were overloading the machine and failing for that reason. **Hosted CI is the check.** It was pushed with `git push --no-verify`, because the pre-push hook runs typecheck and the unit suites. #8613's flake-check lane will also repeat the changed specs. - Every file except `empty-edit-delete.spec.ts` is byte-identical to its final version on `flakey-tests` (67185df6a). That file carries only this PR's hunks; see "Merge order". - Checked for this PR: `git diff --check`, biome on the partial spec (no changes, the same as on `main`), and a conflict-free merge with all six siblings onto `main`. ### Readiness Test-only change. AGENTS.md's readiness steps (agent review, then human confirmation) are still outstanding, so `buzz-review-completed` is not set. ### Merge order No required order. `desktop/tests/e2e/empty-edit-delete.spec.ts` is also edited by **flakey-tests-desktop-races**, which adds the autocomplete table after line 158. This PR changes imports, helpers, `beforeEach` and line 143. The hunks don't touch, so the two merge cleanly in either order, as checked with `git merge-tree`. Draft #8661 edits the same `submitEmptyEdit`/`beforeEach` lines; whichever lands second will need a rebase. ### Sibling PRs Split from `flakey-tests` (one PR per area): #8676 (PostgreSQL lease + lane), #8677 (relay E2E helper + Windows shell), #8678 (mobile), #8679 (Tauri apt cache + Windows Rust cap), #8680 (desktop product races), #8681 (desktop E2E state gates). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
154 lines
6.0 KiB
TypeScript
154 lines
6.0 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { installMockBridge } from "../helpers/bridge";
|
|
import { openGeneral, pressRowAction } from "../helpers/channelHeadReady";
|
|
import { clearComposer, replaceComposerText } from "../helpers/composer";
|
|
|
|
// A message the mock identity authors in #general. Editing/deleting one's own
|
|
// message is exactly Sam's workflow: "delete a message by clearing its edit."
|
|
// It is emitted per test rather than reusing the seeded `mock-general-welcome`:
|
|
// edits and deletions only overlay a target with a real 64-hex event id, so
|
|
// that seed keeps its edit only until the post-subscribe window refetch.
|
|
const ORIGINAL_CONTENT = "Ship notes for #general";
|
|
const RENDERED_ORIGINAL_CONTENT = "Ship notes for general";
|
|
let OWN_MESSAGE_ID: string;
|
|
|
|
// Open the more-actions menu for a message row and wait for the menu to mount.
|
|
async function openMoreActionsMenu(
|
|
page: import("@playwright/test").Page,
|
|
messageId: string,
|
|
) {
|
|
await pressRowAction(page.getByTestId(`more-actions-${messageId}`));
|
|
await expect(page.locator('[role="menuitem"]').first()).toBeVisible({
|
|
timeout: 5_000,
|
|
});
|
|
}
|
|
|
|
// Enter edit mode for a message, clear it to empty, and submit — the gesture
|
|
// that triggers the empty-edit delete confirmation.
|
|
async function submitEmptyEdit(
|
|
page: import("@playwright/test").Page,
|
|
messageId: string,
|
|
) {
|
|
await openMoreActionsMenu(page, messageId);
|
|
await page.getByTestId(`edit-message-${messageId}`).click();
|
|
await expect(page.getByTestId("edit-target")).toBeVisible({ timeout: 5_000 });
|
|
// Edit mode sets the editor content via Tiptap's async transaction pipeline;
|
|
// wait for it to populate before we clear it.
|
|
const input = page.getByTestId("message-input");
|
|
await expect(input).not.toBeEmpty({ timeout: 5_000 });
|
|
await clearComposer(input);
|
|
await page.keyboard.press("Enter");
|
|
}
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await installMockBridge(page);
|
|
await page.goto("/");
|
|
await openGeneral(page);
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(
|
|
() =>
|
|
(
|
|
window as Window & {
|
|
__BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__?: (input: {
|
|
channelName: string;
|
|
kind: number;
|
|
exactChannel: boolean;
|
|
}) => boolean;
|
|
}
|
|
).__BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__?.({
|
|
channelName: "general",
|
|
kind: 9,
|
|
exactChannel: true,
|
|
}) ?? false,
|
|
),
|
|
)
|
|
.toBe(true);
|
|
const emitted = await page.evaluate(
|
|
(content) =>
|
|
(
|
|
window as Window & {
|
|
__BUZZ_E2E_EMIT_MOCK_MESSAGE__?: (input: {
|
|
channelName: string;
|
|
content: string;
|
|
}) => { id: string } | undefined;
|
|
}
|
|
).__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({ channelName: "general", content }),
|
|
ORIGINAL_CONTENT,
|
|
);
|
|
if (!emitted?.id) throw new Error("mock message emit did not return an id");
|
|
OWN_MESSAGE_ID = emitted.id;
|
|
});
|
|
|
|
test("clearing an edit to empty prompts to delete, then deletes on confirm", async ({
|
|
page,
|
|
}) => {
|
|
const row = page.locator(`[data-message-id="${OWN_MESSAGE_ID}"]`);
|
|
await expect(row).toBeVisible({ timeout: 10_000 });
|
|
|
|
await submitEmptyEdit(page, OWN_MESSAGE_ID);
|
|
|
|
// The same "Delete message?" confirmation the Delete menu action shows — an
|
|
// empty edit is routed through it, not silently deleted.
|
|
const dialog = page.getByRole("alertdialog");
|
|
await expect(dialog).toBeVisible({ timeout: 10_000 });
|
|
await expect(dialog).toContainText("Delete message?");
|
|
// Edit mode stays active while the dialog is open — it exits only on confirm.
|
|
await expect(page.getByTestId("edit-target")).toBeVisible();
|
|
|
|
// Confirm → the message row is removed and edit mode has exited.
|
|
await dialog.getByRole("button", { name: "Delete" }).click();
|
|
await expect(dialog).toBeHidden({ timeout: 5_000 });
|
|
await expect(page.getByTestId("edit-target")).toBeHidden();
|
|
await expect(row).toBeHidden({ timeout: 5_000 });
|
|
});
|
|
|
|
test("cancelling the empty-edit delete keeps the message", async ({ page }) => {
|
|
const row = page.locator(`[data-message-id="${OWN_MESSAGE_ID}"]`);
|
|
await expect(row).toBeVisible({ timeout: 10_000 });
|
|
|
|
await submitEmptyEdit(page, OWN_MESSAGE_ID);
|
|
|
|
const dialog = page.getByRole("alertdialog");
|
|
await expect(dialog).toBeVisible({ timeout: 10_000 });
|
|
|
|
// Cancel → nothing is deleted, the original message survives, and the user is
|
|
// left in edit mode (the editing session is preserved, not discarded).
|
|
await dialog.getByRole("button", { name: "Cancel" }).click();
|
|
await expect(dialog).toBeHidden({ timeout: 5_000 });
|
|
await expect(page.getByTestId("edit-target")).toBeVisible();
|
|
await expect(row).toBeVisible();
|
|
await expect(page.getByTestId("message-timeline")).toContainText(
|
|
RENDERED_ORIGINAL_CONTENT,
|
|
);
|
|
await expect(row.getByLabel("Open channel general")).toBeVisible();
|
|
});
|
|
|
|
test("a non-empty edit still edits and never deletes", async ({ page }) => {
|
|
const row = page.locator(`[data-message-id="${OWN_MESSAGE_ID}"]`);
|
|
await expect(row).toBeVisible({ timeout: 10_000 });
|
|
|
|
await openMoreActionsMenu(page, OWN_MESSAGE_ID);
|
|
await page.getByTestId(`edit-message-${OWN_MESSAGE_ID}`).click();
|
|
await expect(page.getByTestId("edit-target")).toBeVisible({ timeout: 5_000 });
|
|
const input = page.getByTestId("message-input");
|
|
await expect(input).not.toBeEmpty({ timeout: 5_000 });
|
|
const editedContent = `Edited, not deleted ${Date.now()}`;
|
|
|
|
await replaceComposerText(input, editedContent);
|
|
await page.keyboard.press("Enter");
|
|
|
|
// No delete confirmation, edit mode exits, the row survives with new text.
|
|
await expect(page.getByRole("alertdialog")).toHaveCount(0);
|
|
await expect(page.getByTestId("edit-target")).toBeHidden({ timeout: 10_000 });
|
|
await expect(row).toBeVisible();
|
|
await expect(page.getByTestId("message-timeline")).toContainText(
|
|
editedContent,
|
|
);
|
|
await expect(page.getByTestId("message-timeline")).not.toContainText(
|
|
RENDERED_ORIGINAL_CONTENT,
|
|
);
|
|
});
|