fix: make pw download tests platform-safe

This commit is contained in:
Peter Steinberger
2026-01-12 22:27:19 +00:00
parent f19d37c7bb
commit 7ba72aeb6c
2 changed files with 20 additions and 20 deletions

View File

@@ -669,12 +669,9 @@ export async function runReplyAgent(params: {
runId, runId,
blockReplyBreak: resolvedBlockStreamingBreak, blockReplyBreak: resolvedBlockStreamingBreak,
blockReplyChunking, blockReplyChunking,
onPartialReply: onPartialReply: allowPartialStream
allowPartialStream
? async (payload) => { ? async (payload) => {
const textForTyping = await handlePartialForTyping( const textForTyping = await handlePartialForTyping(payload);
payload,
);
if (!opts?.onPartialReply || textForTyping === undefined) if (!opts?.onPartialReply || textForTyping === undefined)
return; return;
await opts.onPartialReply({ await opts.onPartialReply({

View File

@@ -1,3 +1,4 @@
import path from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest"; import { beforeEach, describe, expect, it, vi } from "vitest";
let currentPage: Record<string, unknown> | null = null; let currentPage: Record<string, unknown> | null = null;
@@ -306,10 +307,11 @@ describe("pw-tools-core", () => {
currentPage = { on, off }; currentPage = { on, off };
const mod = await importModule(); const mod = await importModule();
const targetPath = path.resolve("/tmp/file.bin");
const p = mod.waitForDownloadViaPlaywright({ const p = mod.waitForDownloadViaPlaywright({
cdpUrl: "http://127.0.0.1:18792", cdpUrl: "http://127.0.0.1:18792",
targetId: "T1", targetId: "T1",
path: "/tmp/file.bin", path: targetPath,
timeoutMs: 1000, timeoutMs: 1000,
}); });
@@ -318,8 +320,8 @@ describe("pw-tools-core", () => {
downloadHandler?.(download); downloadHandler?.(download);
const res = await p; const res = await p;
expect(saveAs).toHaveBeenCalledWith("/tmp/file.bin"); expect(saveAs).toHaveBeenCalledWith(targetPath);
expect(res.path).toBe("/tmp/file.bin"); expect(res.path).toBe(targetPath);
}); });
it("clicks a ref and saves the resulting download", async () => { it("clicks a ref and saves the resulting download", async () => {
@@ -342,11 +344,12 @@ describe("pw-tools-core", () => {
currentPage = { on, off }; currentPage = { on, off };
const mod = await importModule(); const mod = await importModule();
const targetPath = path.resolve("/tmp/report.pdf");
const p = mod.downloadViaPlaywright({ const p = mod.downloadViaPlaywright({
cdpUrl: "http://127.0.0.1:18792", cdpUrl: "http://127.0.0.1:18792",
targetId: "T1", targetId: "T1",
ref: "e12", ref: "e12",
path: "/tmp/report.pdf", path: targetPath,
timeoutMs: 1000, timeoutMs: 1000,
}); });
@@ -357,8 +360,8 @@ describe("pw-tools-core", () => {
downloadHandler?.(download); downloadHandler?.(download);
const res = await p; const res = await p;
expect(saveAs).toHaveBeenCalledWith("/tmp/report.pdf"); expect(saveAs).toHaveBeenCalledWith(targetPath);
expect(res.path).toBe("/tmp/report.pdf"); expect(res.path).toBe(targetPath);
}); });
it("waits for a matching response and returns its body", async () => { it("waits for a matching response and returns its body", async () => {