-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoke.test.js
More file actions
55 lines (49 loc) · 2.04 KB
/
Copy pathsmoke.test.js
File metadata and controls
55 lines (49 loc) · 2.04 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
import test from 'node:test';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
function run(args) {
return spawnSync(process.execPath, ['./bin/xterm.js', ...args], { encoding: 'utf8' });
}
test('xterm help exits successfully', () => {
const result = run(['--help']);
assert.equal(result.status, 0);
assert.match(result.stdout, /xCloud Terminal/);
assert.match(result.stdout, /--ai/);
});
test('xterm ai mode reports provider configuration without a prompt', () => {
const result = run(['--ai']);
assert.equal(result.status, 0);
assert.match(result.stdout, /xCloud Terminal AI mode/);
assert.match(result.stdout, /Provider: openrouter/);
assert.match(result.stdout, /OPENROUTER_API_URL=https:\/\/openrouter\.ai\/api\/v1/);
});
test('xterm ai prompt without key gives setup guidance', () => {
const result = run(['--ai', 'why', 'is', 'my', 'site', 'down?']);
assert.equal(result.status, 0);
assert.match(result.stdout, /AI provider is not configured/);
assert.match(result.stdout, /OPENROUTER_API_KEY/);
});
test('doctor reports redacted OpenRouter-compatible config', () => {
const result = spawnSync(process.execPath, ['./bin/xterm.js', 'doctor'], {
encoding: 'utf8',
env: {
...process.env,
OPENROUTER_API_KEY: 'sk-or-test-secret',
OPENROUTER_API_URL: 'https://openrouter.ai/api/v1',
XCLOUD_AI_MODEL: 'anthropic/claude-sonnet-4.5',
},
});
assert.equal(result.status, 0);
const payload = JSON.parse(result.stdout);
assert.equal(payload.ai.provider, 'openrouter');
assert.equal(payload.ai.baseURL, 'https://openrouter.ai/api/v1');
assert.equal(payload.ai.model, 'anthropic/claude-sonnet-4.5');
assert.equal(payload.ai.configured, true);
assert.notEqual(payload.ai.apiKey, 'sk-or-test-secret');
});
test('hosted agent points to xcloud-agent-skills', () => {
const result = run(['--ai', '--agent', 'hosted']);
assert.equal(result.status, 0);
assert.match(result.stdout, /Agent mode: hosted/);
assert.match(result.stdout, /xCloudDev\/xcloud-agent-skills/);
});