fix(ci): remove undeclared dependency and handle PTY chunks

This commit is contained in:
morluto committed 2026-11-03 01:10:56 +08:00
1 parent 2cb29693c3
commit 3c05b4d3fe
3 files changed
+19 -15

No files matched your search

+1 -1
View File
@@ -111,7 +111,7 @@
+ existingSha = data.sha; + existingSha = data.sha;
+ } + }
+ catch (error) { + catch (error) {
+ if (!(error instanceof request_error_1.RequestError && error.status === 404)) { + if (!(error && error.status === 404)) {
+ throw error; + throw error;
+ } + }
+ } + }
@@ -10,7 +10,6 @@ import { createRequire } from "node:module";
import { dirname, join } from "node:path"; import { dirname, join } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url"; import { fileURLToPath, pathToFileURL } from "node:url";
import { promisify } from "node:util"; import { promisify } from "node:util";
import { RequestError } from "@octokit/request-error";
import { afterEach, beforeAll, expect, it, vi } from "vitest"; import { afterEach, beforeAll, expect, it, vi } from "vitest";
import { z } from "zod"; import { z } from "zod";
@@ -106,15 +105,11 @@ it("creates overflow notes on a new branch without requiring an existing file",
createNewBranch, createNewBranch,
octokit: { octokit: {
repos: { repos: {
getContent: vi.fn().mockRejectedValue( getContent: vi
new RequestError("missing", 404, { .fn()
request: { .mockRejectedValue(
method: "GET", Object.assign(new Error("missing"), { status: 404 }),
url: "https://example.test/notes", ),
headers: {},
},
}),
),
createOrUpdateFileContents: write, createOrUpdateFileContents: write,
}, },
}, },
@@ -115,11 +115,20 @@ itWithCaptureCapability(
}; };
const expanded = await capture("x".repeat(500)); const expanded = await capture("x".repeat(500));
expect(expanded.frames).toHaveLength(0);
expect(expanded.truncated).toBe(true); expect(expanded.truncated).toBe(true);
const retainedNormalized = expanded.frames.map(({ data }) => data).join("");
const retainedRaw = expanded.frames
.map(({ raw_data, data }) => raw_data ?? data)
.join("");
// PTY read boundaries need not match the child's write. A small chunk can
// fit even after another chunk was omitted for exceeding the budget.
expect(retainedNormalized).toBe(
retainedRaw.replaceAll("a", "x".repeat(500)),
);
expect(Buffer.byteLength(retainedNormalized)).toBeLessThanOrEqual(1_000);
expect(expanded.truncation_details.normalized_terminal).toMatchObject({ expect(expanded.truncation_details.normalized_terminal).toMatchObject({
budget_bytes: 1_000, budget_bytes: 1_000,
retained_bytes: 0, retained_bytes: Buffer.byteLength(retainedNormalized),
omitted_frames: expect.any(Number), omitted_frames: expect.any(Number),
}); });
expect( expect(
@@ -128,9 +137,9 @@ itWithCaptureCapability(
expect(expanded.truncation_details.raw_terminal).toMatchObject({ expect(expanded.truncation_details.raw_terminal).toMatchObject({
budget_bytes: 1_000, budget_bytes: 1_000,
observed_bytes: expect.any(Number), observed_bytes: expect.any(Number),
retained_bytes: 0, retained_bytes: Buffer.byteLength(retainedRaw),
observed_frames: expect.any(Number), observed_frames: expect.any(Number),
retained_frames: 0, retained_frames: expanded.frames.length,
}); });
expect( expect(
expanded.limitations.some((limitation) => expanded.limitations.some((limitation) =>