Skip to content

Commit bfc701c

Browse files
committed
test(ui): type sidebar clipboard lifecycle fixtures correctly
1 parent 926aaf2 commit bfc701c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎ui/src/pages/chat/components/chat-sidebar.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ describe("file sidebar clipboard feedback", () => {
225225
{ label: "Copy file contents", value: "const answer = 42;" },
226226
];
227227

228-
type FilePanel = HTMLElement & { content: unknown; updateComplete: Promise<unknown> };
228+
type FilePanel = HTMLElement & {
229+
content: unknown;
230+
ensureFileEditor: () => Promise<void>;
231+
updateComplete: Promise<unknown>;
232+
};
229233

230234
async function mountFilePanel(): Promise<FilePanel> {
231235
const panel = document.createElement("openclaw-chat-detail-panel") as FilePanel;
@@ -235,10 +239,7 @@ describe("file sidebar clipboard feedback", () => {
235239
name: "example.ts",
236240
content: "const answer = 42;",
237241
};
238-
vi.spyOn(
239-
panel as HTMLElement & { ensureFileEditor: () => Promise<void> },
240-
"ensureFileEditor",
241-
).mockResolvedValue();
242+
vi.spyOn(panel, "ensureFileEditor").mockResolvedValue();
242243
document.body.append(panel);
243244
await panel.updateComplete;
244245
return panel;
@@ -270,6 +271,9 @@ describe("file sidebar clipboard feedback", () => {
270271
const timerIndex = schedule.mock.calls
271272
.map(([, timeout], callIndex) => (timeout === delay ? callIndex : -1))
272273
.filter((callIndex) => callIndex >= 0)[index];
274+
if (timerIndex === undefined) {
275+
throw new Error(`Missing sidebar clipboard reset timer after ${delay}ms`);
276+
}
273277
const reset = schedule.mock.calls[timerIndex]?.[0];
274278
if (typeof reset !== "function") {
275279
throw new Error(`Expected sidebar clipboard reset timer after ${delay}ms`);

0 commit comments

Comments
 (0)