summaryrefslogtreecommitdiff
path: root/integration-tests/list_directory.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests/list_directory.test.js')
-rw-r--r--integration-tests/list_directory.test.js52
1 files changed, 45 insertions, 7 deletions
diff --git a/integration-tests/list_directory.test.js b/integration-tests/list_directory.test.js
index af7aae78..16f49f4b 100644
--- a/integration-tests/list_directory.test.js
+++ b/integration-tests/list_directory.test.js
@@ -6,19 +6,57 @@
import { test } from 'node:test';
import { strict as assert } from 'assert';
-import { TestRig } from './test-helper.js';
+import { TestRig, printDebugInfo, validateModelOutput } from './test-helper.js';
+import { existsSync } from 'fs';
+import { join } from 'path';
-test('should be able to list a directory', async (t) => {
+test('should be able to list a directory', async () => {
const rig = new TestRig();
- rig.setup(t.name);
+ await rig.setup('should be able to list a directory');
rig.createFile('file1.txt', 'file 1 content');
rig.mkdir('subdir');
rig.sync();
+ // Poll for filesystem changes to propagate in containers
+ await rig.poll(
+ () => {
+ // Check if the files exist in the test directory
+ const file1Path = join(rig.testDir, 'file1.txt');
+ const subdirPath = join(rig.testDir, 'subdir');
+ return existsSync(file1Path) && existsSync(subdirPath);
+ },
+ 1000, // 1 second max wait
+ 50, // check every 50ms
+ );
+
const prompt = `Can you list the files in the current directory. Display them in the style of 'ls'`;
- const result = rig.run(prompt);
- const lines = result.split('\n').filter((line) => line.trim() !== '');
- assert.ok(lines.some((line) => line.includes('file1.txt')));
- assert.ok(lines.some((line) => line.includes('subdir')));
+ const result = await rig.run(prompt);
+
+ const foundToolCall = await rig.waitForToolCall('list_directory');
+
+ // Add debugging information
+ if (
+ !foundToolCall ||
+ !result.includes('file1.txt') ||
+ !result.includes('subdir')
+ ) {
+ const allTools = printDebugInfo(rig, result, {
+ 'Found tool call': foundToolCall,
+ 'Contains file1.txt': result.includes('file1.txt'),
+ 'Contains subdir': result.includes('subdir'),
+ });
+
+ console.error(
+ 'List directory calls:',
+ allTools
+ .filter((t) => t.toolRequest.name === 'list_directory')
+ .map((t) => t.toolRequest.args),
+ );
+ }
+
+ assert.ok(foundToolCall, 'Expected to find a list_directory tool call');
+
+ // Validate model output - will throw if no output, warn if missing expected content
+ validateModelOutput(result, ['file1.txt', 'subdir'], 'List directory test');
});