Skip to content

Commit 7787049

Browse files
test(desktop): load the annotation preload at collection, not inside each test
A cold transform of the preload under heavy load exceeded the 15s test timeout when it ran inside the test body. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f0d8dfd commit 7787049

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎apps/desktop/src/preview/PickPreload.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, it, vi } from "vite-plus/test";
22

33
import { START_PICK_CHANNEL } from "./GuestProtocol.ts";
4+
import "./PickPreload.ts";
45

56
const ipcListeners = vi.hoisted(() => new Map<string, Array<(...args: unknown[]) => void>>());
67

@@ -17,24 +18,23 @@ vi.mock("electron", () => ({
1718

1819
vi.mock("react-grab/primitives", () => ({ getElementContext: async () => null }));
1920

20-
const startAnnotation = async (): Promise<ShadowRoot> => {
21+
const startAnnotation = (): ShadowRoot => {
2122
vi.stubGlobal(
2223
"ResizeObserver",
2324
class {
2425
observe() {}
2526
disconnect() {}
2627
},
2728
);
28-
await import("./PickPreload.ts");
2929
using attachShadow = vi.spyOn(Element.prototype, "attachShadow");
3030
for (const listener of ipcListeners.get(START_PICK_CHANNEL) ?? []) listener({}, undefined, false);
3131
const shadowRoot = attachShadow.mock.results[0]?.value;
3232
if (!(shadowRoot instanceof ShadowRoot)) throw new Error("annotation overlay did not start");
3333
return shadowRoot;
3434
};
3535

36-
it("switches tools from the keyboard after a toolbar button is clicked", async () => {
37-
const shadowRoot = await startAnnotation();
36+
it("switches tools from the keyboard after a toolbar button is clicked", () => {
37+
const shadowRoot = startAnnotation();
3838
const region = Array.from(shadowRoot.querySelectorAll("button")).find(
3939
(button) => button.textContent === "Region",
4040
);
@@ -52,8 +52,8 @@ it("switches tools from the keyboard after a toolbar button is clicked", async (
5252
).toBe("select");
5353
});
5454

55-
it("keeps the tool while typing a tool key in the comment", async () => {
56-
const shadowRoot = await startAnnotation();
55+
it("keeps the tool while typing a tool key in the comment", () => {
56+
const shadowRoot = startAnnotation();
5757
const comment = shadowRoot.querySelector("textarea");
5858
if (!comment) throw new Error("comment textarea not found");
5959

0 commit comments

Comments
 (0)