Skip to content

Commit 41f9711

Browse files
test(integration): make the utf-bom defaultFileEncoding test deterministic (#13196)
The 'should create new file with BOM when defaultFileEncoding is utf-8-bom' integration test was the only case in utf-bom-encoding.test.ts that drove a real model round-trip (rig.run + waitForToolCall, up to 300s per attempt). On the loaded Docker self-hosted runner that round-trip can exceed the vitest timeout, which blocked the v0.24.8-preview.0 release (#13066). Convert it to runForcedToolCallScenario with a fake write_file call, the same deterministic pattern as the sibling tests in this file. The real write_file tool still executes, so the BOM assertions are unchanged. Also unstub the env vars the scenario stubs, matching the first describe block. Closes #13066 Co-authored-by: F415643 <[email protected]> Co-authored-by: doudouOUC <[email protected]>
1 parent dd82140 commit 41f9711

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎integration-tests/cli/utf-bom-encoding.test.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ d('BOM end-to-end integration', () => {
202202
});
203203

204204
describe('BOM with defaultFileEncoding configuration', () => {
205+
afterEach(() => {
206+
vi.unstubAllEnvs();
207+
});
208+
205209
it('should create new file with BOM when defaultFileEncoding is utf-8-bom', async () => {
206210
const rigWithBOM = new TestRig();
207211
await rigWithBOM.setup('bom-default-encoding', {
@@ -213,14 +217,19 @@ describe('BOM with defaultFileEncoding configuration', () => {
213217
});
214218

215219
const filename = 'new-file-with-bom.js';
220+
const filePath = join(rigWithBOM.testDir!, filename);
216221

217-
// Ask Qwen Code to create a new file
218-
const prompt = `create a new file called ${filename} with content: const greeting = "hello";`;
219-
await rigWithBOM.run(prompt);
220-
await rigWithBOM.waitForToolCall('write_file');
222+
await runForcedToolCallScenario({
223+
rig: rigWithBOM,
224+
toolCall: fakeToolCall('write_file', {
225+
file_path: filePath,
226+
content: 'const greeting = "hello";',
227+
}),
228+
prompt: `create a new file called ${filename} with content: const greeting = "hello";`,
229+
finalResponse: 'Done.',
230+
});
221231

222232
// Read the created file as raw bytes
223-
const filePath = join(rigWithBOM.testDir!, filename);
224233
const fileBuffer = readFileSync(filePath);
225234

226235
// Verify BOM is present (first 3 bytes should be EF BB BF)

0 commit comments

Comments
 (0)