|
1 | | -import { describe, expect, test } from "bun:test"; |
| 1 | +import { describe, expect, spyOn, test } from "bun:test"; |
| 2 | +import * as patchEnvelope from "../../src/responses/apply-patch-envelope"; |
2 | 3 | import { |
3 | 4 | createRoutedCustomToolRestoreBlockRewrite, |
4 | 5 | RoutedCustomToolProgressError, |
@@ -191,7 +192,17 @@ describe("routed Responses custom-tool stream consistency", () => { |
191 | 192 | const body = `+${"x".repeat(65_536)}\n+last line\n`; |
192 | 193 | const wrapped = JSON.stringify({ input: `${opening}${body}*** End Patch ***\n` }); |
193 | 194 | const normalized = `${opening}${body}*** End Patch\n`; |
194 | | - const result = restoreExecStream(wrapped, wrapped.match(/[\s\S]{1,37}/g)!, "apply_patch"); |
| 195 | + const original = patchEnvelope.stableCanonicalPatchPrefix; |
| 196 | + let longChecks = 0; |
| 197 | + const spy = spyOn(patchEnvelope, "stableCanonicalPatchPrefix").mockImplementation((...args) => { |
| 198 | + expect(args[1]).toBe(args[0].slice(-64)); |
| 199 | + if (args[0].length > 64) longChecks++; |
| 200 | + return original(...args); |
| 201 | + }); |
| 202 | + let result: ReturnType<typeof restoreExecStream>; |
| 203 | + try { result = restoreExecStream(wrapped, wrapped.match(/[\s\S]{1,37}/g)!, "apply_patch"); } |
| 204 | + finally { spy.mockRestore(); } |
| 205 | + expect(longChecks).toBeGreaterThan(0); |
195 | 206 | for (const preview of result.previews) expect(normalized.startsWith(preview)).toBe(true); |
196 | 207 | expect(result.preview).toBe(normalized.slice(0, -1)); |
197 | 208 | expect(result.doneInput).toBe(normalized); |
|
0 commit comments