test: simplify browser download path checks

This commit is contained in:
Peter Steinberger
2026-04-10 23:48:21 +01:00
parent 81fbe129c9
commit f01469358f

View File

@@ -130,6 +130,9 @@ describe("pw-tools-core", () => {
const res = await p;
const outPath = (vi.mocked(saveAs).mock.calls as unknown as Array<[string]>)[0]?.[0];
if (typeof outPath !== "string") {
throw new Error("download save path was not captured");
}
return { res, outPath };
}
@@ -284,8 +287,8 @@ describe("pw-tools-core", () => {
path.join(path.sep, "tmp", "openclaw-preferred", "downloads"),
);
const expectedDownloadsTail = `${path.join("tmp", "openclaw-preferred", "downloads")}${path.sep}`;
expect(path.dirname(String(outPath))).toBe(expectedRootedDownloadsDir);
expect(path.basename(String(outPath))).toMatch(/-file\.bin$/);
expect(path.dirname(outPath)).toBe(expectedRootedDownloadsDir);
expect(path.basename(outPath)).toMatch(/-file\.bin$/);
expect(path.normalize(res.path)).toContain(path.normalize(expectedDownloadsTail));
expect(tmpDirMocks.resolvePreferredOpenClawTmpDir).toHaveBeenCalled();
});
@@ -297,10 +300,10 @@ describe("pw-tools-core", () => {
suggestedFilename: "../../../../etc/passwd",
});
expect(typeof outPath).toBe("string");
expect(path.dirname(String(outPath))).toBe(
expect(path.dirname(outPath)).toBe(
path.resolve(path.join(path.sep, "tmp", "openclaw-preferred", "downloads")),
);
expect(path.basename(String(outPath))).toMatch(/-passwd$/);
expect(path.basename(outPath)).toMatch(/-passwd$/);
expect(path.normalize(res.path)).toContain(
path.normalize(`${path.join("tmp", "openclaw-preferred", "downloads")}${path.sep}`),
);