Skip to content

Commit a1fb664

Browse files
baxenSmartie
andauthored
test(desktop): synchronize upload edit smoke test (#7903)
## Summary Fix the upload/edit smoke-test race observed on main at `6410e685a80d42db0645fadc9bbe710559ef911e`. - Hold the mock upload at the Tauri IPC boundary and release it explicitly after checking edit rejection, rather than assuming menu interaction finishes within one second. - Wait for the Radix menu to unmount: edit dispatch happens in `onCloseAutoFocus`, after the click. Without that wait, the negative assertion can pass before the edit callback actually runs. - Keep the existing attachment-preservation and subsequent successful-edit assertions. No production code or CI coverage is changed. ## Evidence and scope - [Main failure](https://github.com/block/buzz/actions/runs/36189213149/job/108250341388): `opening edit during an immediate photo upload preserves the draft`, including an upload-progress timeout on retry. - Investigated from #7791, which changes only `docs/nips/NIP-AR.md`. Its PostgreSQL failures and video-menu timeout are separate; PostgreSQL passed on this main run, and the video spec passed locally. This PR does not claim to fix those failures or the separate pointer-interception failure seen in the main job. - #7843 already addresses unrelated runtime suites being selected for docs-only PRs. ## Validation - Full desktop `pnpm test`: 6,676 Node tests + 92 jsdom tests passed. - Upload/edit regression repeated 5 times: passed. Holding the upload without waiting for menu teardown failed all 5 runs, demonstrating the second race. - Complete file-attachment and video-attachment Playwright specs: 30 passed. - Pre-push desktop lint, typecheck, full desktop tests, and file-size gate passed at `46e3d4392e5b56dcb74ea864aa19aa10287f27d3`. - `just ci` attempted: initial formatting issue corrected; second run exceeded the 5-minute local limit during Tauri clippy. Not claiming full repository CI green. ## Review / human verification Self-reviewed the diff against the test contract; no production behavior changes. Draft pending human verification and CI. To verify: activate Hermit, then `cd desktop && pnpm test:e2e:smoke file-attachment.spec.ts --grep "opening edit during" --repeat-each=5`. Expect all five runs to pass, retaining the upload in the draft and allowing edit only after upload release. Originating conversation: buzz://message?channel=aa7f2b48-d367-4ca1-be09-116a2eb45b99&id=1b68585ba4483a87f5a453fd7bbdd11d434e332dcb4aff8acfe1f5d2601b6561 Signed-off-by: Smartie <fb3185faacfc3760b6b4fe0085a8878d8dd537f7a7671c7d3184fe1aa1b04df4@buzz.block.builderlab.xyz> Co-authored-by: Smartie <fb3185faacfc3760b6b4fe0085a8878d8dd537f7a7671c7d3184fe1aa1b04df4@buzz.block.builderlab.xyz>
1 parent 6410e68 commit a1fb664

1 file changed

Lines changed: 31 additions & 7 deletions

File tree

‎desktop/tests/e2e/file-attachment.spec.ts‎

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,49 @@ test("opening edit during an immediate photo upload preserves the draft", async
166166
page,
167167
}) => {
168168
await page.goto("/");
169+
await page.getByTestId("channel-general").click();
170+
await expect(page.getByTestId("chat-title")).toHaveText("general");
171+
// Hold the upload at the IPC boundary until the edit assertion completes.
172+
// A fixed delay races menu interaction and CI scheduling, so it can test
173+
// an already-completed upload instead of the in-flight draft guard.
169174
await page.evaluate(() => {
170-
const e2e = (
171-
window as Window & {
172-
__BUZZ_E2E__?: { mock?: { uploadDelayMs?: number } };
173-
}
174-
).__BUZZ_E2E__;
175-
if (e2e?.mock) e2e.mock.uploadDelayMs = 1_000;
175+
const w = window as Window & {
176+
__RELEASE_PHOTO_UPLOAD__?: () => void;
177+
__TAURI_INTERNALS__: {
178+
invoke: (
179+
command: string,
180+
payload: unknown,
181+
options: unknown,
182+
) => Promise<unknown>;
183+
};
184+
};
185+
const original = w.__TAURI_INTERNALS__.invoke.bind(w.__TAURI_INTERNALS__);
186+
const gate = new Promise<void>((resolve) => {
187+
w.__RELEASE_PHOTO_UPLOAD__ = resolve;
188+
});
189+
w.__TAURI_INTERNALS__.invoke = async (command, payload, options) => {
190+
if (command === "upload_media_bytes_raw") await gate;
191+
return original(command, payload, options);
192+
};
176193
});
177-
await page.getByTestId("channel-general").click();
178194
await choosePhoto(page);
179195
await expect(page.getByTestId("upload-progress")).toBeVisible();
180196

181197
await openMoreActionsMenu(page, "mock-general-welcome");
182198
await page.getByTestId("edit-message-mock-general-welcome").click();
199+
// Edit is dispatched by onCloseAutoFocus after Radix unmounts the menu,
200+
// not by the click itself. Keep the upload held through that handoff.
201+
await expect(page.getByRole("menu")).toHaveCount(0);
183202

184203
// Edit entry is rejected while the compacted draft cannot represent the
185204
// reserved upload slot. The upload remains current and lands in the draft.
186205
await expect(page.getByTestId("edit-target")).toHaveCount(0);
187206
await expect(page.getByTestId("upload-progress")).toBeVisible();
207+
await page.evaluate(() => {
208+
(
209+
window as Window & { __RELEASE_PHOTO_UPLOAD__: () => void }
210+
).__RELEASE_PHOTO_UPLOAD__();
211+
});
188212
await expect(page.getByTestId("upload-progress")).toHaveCount(0, {
189213
timeout: 5_000,
190214
});

0 commit comments

Comments
 (0)