summaryrefslogtreecommitdiff
path: root/web/test
diff options
context:
space:
mode:
Diffstat (limited to 'web/test')
-rw-r--r--web/test/start-next-task.test.mjs21
1 files changed, 19 insertions, 2 deletions
diff --git a/web/test/start-next-task.test.mjs b/web/test/start-next-task.test.mjs
index 6863f7e..eaf3087 100644
--- a/web/test/start-next-task.test.mjs
+++ b/web/test/start-next-task.test.mjs
@@ -9,8 +9,11 @@ import assert from 'node:assert/strict';
// Returns {output, exit_code} on HTTP 2xx
// Throws on HTTP error
-async function startNextTask(basePath, fetchFn) {
- const res = await fetchFn(`${basePath}/api/scripts/start-next-task`, { method: 'POST' });
+async function startNextTask(basePath, fetchFn, agent) {
+ const url = agent && agent !== 'auto'
+ ? `${basePath}/api/scripts/start-next-task?agent=${agent}`
+ : `${basePath}/api/scripts/start-next-task`;
+ const res = await fetchFn(url, { method: 'POST' });
if (!res.ok) {
let msg = `HTTP ${res.status}`;
try { const body = await res.json(); msg = body.error || msg; } catch {}
@@ -35,6 +38,20 @@ describe('startNextTask', () => {
assert.equal(captured.opts.method, 'POST');
});
+ it('appends agent as query parameter when provided', async () => {
+ let captured = null;
+ const mockFetch = (url, opts) => {
+ captured = { url, opts };
+ return Promise.resolve({
+ ok: true,
+ json: () => Promise.resolve({ output: 'claudomator start --agent claude abc-123\n', exit_code: 0 }),
+ });
+ };
+
+ await startNextTask('http://localhost:8484', mockFetch, 'claude');
+ assert.equal(captured.url, 'http://localhost:8484/api/scripts/start-next-task?agent=claude');
+ });
+
it('returns output and exit_code on success', async () => {
const mockFetch = () => Promise.resolve({
ok: true,