fix: make pw download tests platform-safe
This commit is contained in:
@@ -669,20 +669,17 @@ 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(payload);
|
||||||
const textForTyping = await handlePartialForTyping(
|
if (!opts?.onPartialReply || textForTyping === undefined)
|
||||||
payload,
|
return;
|
||||||
);
|
await opts.onPartialReply({
|
||||||
if (!opts?.onPartialReply || textForTyping === undefined)
|
text: textForTyping,
|
||||||
return;
|
mediaUrls: payload.mediaUrls,
|
||||||
await opts.onPartialReply({
|
});
|
||||||
text: textForTyping,
|
}
|
||||||
mediaUrls: payload.mediaUrls,
|
: undefined,
|
||||||
});
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
onReasoningStream:
|
onReasoningStream:
|
||||||
typingSignals.shouldStartOnReasoning || opts?.onReasoningStream
|
typingSignals.shouldStartOnReasoning || opts?.onReasoningStream
|
||||||
? async (payload) => {
|
? async (payload) => {
|
||||||
|
|||||||
@@ -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 () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user