Repository navigation
Expand file tree
/
Copy pathagy-cli.test.mjs
More file actions
114 lines (105 loc) · 4.02 KB
/
Copy pathagy-cli.test.mjs
File metadata and controls
114 lines (105 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Runs the suites in test/ (brought over from gitxm/yce-magpie-agy, MIT), each
// in a bun process of its own: they mock node:child_process, move the clock and
// set the bridge's environment, and smoke.mjs ends with process.exit.
import { expect, test } from "bun:test"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
const dir = path.join(import.meta.dir, "test")
const hook = path.join(dir, "cp-hook.mjs")
function run(args, timeout, env = {}) {
const result = Bun.spawnSync({ cmd: [process.execPath, ...args], cwd: dir, env: { ...process.env, AGY_BRIDGE_STORED_SIGNIN: "skip", ...env }, stdout: "pipe", stderr: "pipe", timeout })
const output = result.stdout.toString() + result.stderr.toString()
if (result.exitCode !== 0) console.error(output)
return { code: result.exitCode, output }
}
for (const [name, mocks] of [
["platform.mjs", true],
["compat.mjs", true],
["prefill.mjs", false],
["images.mjs", false],
["usage.mjs", true],
["signin.mjs", false],
["catalog.mjs", false],
["step-usage.mjs", false],
["tool-schema.mjs", false],
["tool-summary.mjs", false],
["call-mcp-tool.mjs", false],
["usage-settlement.mjs", false],
["steer-in-session.mjs", false],
["dropped-call.mjs", false],
["dropped-step.mjs", false],
["rebase-resume.mjs", false],
["repeat-batch.mjs", false],
["unmatched-results.mjs", false],
["conversation-key.mjs", false],
["windows-nc.mjs", false],
["spare.mjs", false],
["account-scope.mjs", false],
["stateless-reuse.mjs", false],
["tools-listed.mjs", false],
["bridge-heal.mjs", false],
["slash-commands.mjs", false],
["concurrent-convs.mjs", false],
["masking-drift.mjs", false],
["spilled-output.mjs", false],
["web-search.mjs", false],
["tool-result-prefill.mjs", false],
["tool-step-retry.mjs", false],
["image-bytes.mjs", false],
["dsh-replay-state.mjs", false],
["duplicate-result-notice.mjs", false],
["image-slim.mjs", false],
["transient-history.mjs", false],
["prompt-suggestion.mjs", false],
["agent-summary.mjs", false],
["seed-replay.mjs", false],
["session-continuity.mjs", false],
["park-reread.mjs", false],
["same-opening.mjs", false],
["claude-code-sessions.mjs", false],
["media-input.mjs", false],
["default-agent.mjs", false],
["workspace-handoff.mjs", false],
]) {
test(`test/${name}`, () => {
// bun's 5s default per test is a fixed wait these process-spawning tests
// overrun on a loaded machine; the 240s run bounds a real hang.
const { code, output } = run(["test", "--timeout", "120000", ...(mocks ? ["--preload", hook] : []), `./${name}`], 240_000)
expect(output).toMatch(/\b[1-9]\d* pass\b/)
expect(code).toBe(0)
}, 250_000)
}
test("test/re2-pattern-unit.mjs", () => {
const { code, output } = run([path.join(dir, "re2-pattern-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)
test("test/image-signature-unit.mjs", () => {
const { code, output } = run([path.join(dir, "image-signature-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)
test("test/smoke.mjs against a fake agy", () => {
// Bun reads the home at startup. Keep host gateway settings and saved
// accounts out of this subprocess's fake account tests.
const home = fs.mkdtempSync(path.join(os.tmpdir(), "agy-smoke-home-"))
try {
const env = { HOME: home, USERPROFILE: home, XDG_STATE_HOME: path.join(home, "state") }
const { code, output } = run([path.join(dir, "smoke.mjs")], 240_000, env)
expect(output).toMatch(/ALL OK \(\d+ checks\)/)
expect(code).toBe(0)
} finally {
fs.rmSync(home, { recursive: true, force: true })
}
}, 250_000)
test("test/array-items-unit.mjs", () => {
const { code, output } = run([path.join(dir, "array-items-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)
test("test/documents-unit.mjs", () => {
const { code, output } = run([path.join(dir, "documents-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)