Skip to content

Commit 74e9308

Browse files
committed
test: tighten media outside-workspace error assertion
1 parent 3cf5b8f commit 74e9308

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎src/media/store.outside-workspace.test.ts‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,26 @@ vi.mock("./store.runtime.js", () => {
1919

2020
type StoreModule = typeof import("./store.js");
2121

22+
let SaveMediaSourceError: StoreModule["SaveMediaSourceError"];
2223
let saveMediaSource: StoreModule["saveMediaSource"];
2324

2425
async function expectOutsideWorkspaceStoreFailure(sourcePath: string) {
25-
await expect(saveMediaSource(sourcePath)).rejects.toMatchObject({
26-
code: "invalid-path",
27-
message: "Media path is outside workspace root",
26+
let storeError: unknown;
27+
try {
28+
await saveMediaSource(sourcePath);
29+
} catch (error) {
30+
storeError = error;
31+
}
32+
expect(storeError).toBeInstanceOf(SaveMediaSourceError);
33+
if (!(storeError instanceof SaveMediaSourceError)) {
34+
throw new Error("expected SaveMediaSourceError");
35+
}
36+
expect(storeError.name).toBe("SaveMediaSourceError");
37+
expect(storeError.code).toBe("invalid-path");
38+
expect(storeError.message).toBe("Media path is outside workspace root");
39+
expect(storeError.cause).toStrictEqual({
40+
code: "outside-workspace",
41+
message: "file is outside workspace root",
2842
});
2943
}
3044

@@ -33,7 +47,7 @@ describe("media store outside-workspace mapping", () => {
3347
let home = "";
3448

3549
beforeAll(async () => {
36-
({ saveMediaSource } = await import("./store.js"));
50+
({ SaveMediaSourceError, saveMediaSource } = await import("./store.js"));
3751
tempHome = await createTempHomeEnv("openclaw-media-store-test-home-");
3852
home = tempHome.home;
3953
});

0 commit comments

Comments
 (0)