mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 20:20:22 +00:00
test: simplify browser download path checks
This commit is contained in:
@@ -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}`),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user