-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist-command.test.ts
More file actions
130 lines (123 loc) · 3.41 KB
/
Copy pathlist-command.test.ts
File metadata and controls
130 lines (123 loc) · 3.41 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import test from 'node:test';
import assert from 'node:assert/strict';
import {
formatDeploymentLogEntries,
formatDeploymentsTable,
parseDeploymentListArgs,
parseDeploymentLogsArgs,
tailLogEntriesFromNewestFiles
} from './list-command.js';
test('parseDeploymentListArgs accepts deployment list filters', () => {
assert.deepEqual(
parseDeploymentListArgs([
'--workspace',
'ws-1',
'--status=active',
'--persona',
'weekly-digest',
'--cloud-url',
'https://cloud.example.test',
'--json',
'--no-prompt'
]),
{
workspace: 'ws-1',
status: 'active',
persona: 'weekly-digest',
cloudUrl: 'https://cloud.example.test',
json: true,
noPrompt: true
}
);
});
test('formatDeploymentsTable renders agent rows', () => {
const out = formatDeploymentsTable([
{
agentId: 'b2f111111111111111111111e8c2',
personaId: '7133e815-8c84-5d05-a08b-e434006b11ac',
personaSlug: 'weekly-digest',
deployedName: 'Weekly Digest',
status: 'active',
createdAt: '2026-05-13T09:11:00.000Z',
updatedAt: '2026-07-17T08:45:00.000Z',
lastUsedAt: null,
scheduleIds: ['sched-1'],
deployedByUserId: 'user-1'
}
]);
assert.match(out, /name\s+status\s+deployed\s+lastUsed\s+agentId/);
assert.match(out, /b2f1\.\.\.e8c2/);
assert.match(out, /Weekly Digest/);
assert.doesNotMatch(out, /7133e815/);
assert.match(out, /2026-07-17 08:45 UTC/);
assert.doesNotMatch(out, /2026-05-13 09:11 UTC/);
});
test('formatDeploymentsTable falls back to createdAt when updatedAt is absent', () => {
const out = formatDeploymentsTable([
{
agentId: 'agent-1',
personaId: 'persona-1',
personaSlug: 'demo',
deployedName: 'Demo',
status: 'active',
createdAt: '2026-05-13T09:11:00.000Z',
lastUsedAt: null,
scheduleIds: [],
deployedByUserId: 'user-1'
}
]);
assert.match(out, /2026-05-13 09:11 UTC/);
});
test('parseDeploymentLogsArgs accepts selector and log flags', () => {
assert.deepEqual(
parseDeploymentLogsArgs([
'Weekly Digest',
'--workspace=ws-1',
'--path',
'/_logs/ws-1/2026-05-19.jsonl',
'--tail',
'25',
'--cloud-url',
'https://cloud.example.test',
'--json',
'--no-prompt'
]),
{
selector: 'Weekly Digest',
workspace: 'ws-1',
path: '/_logs/ws-1/2026-05-19.jsonl',
tail: 25,
cloudUrl: 'https://cloud.example.test',
json: true,
noPrompt: true
}
);
});
test('formatDeploymentLogEntries renders structured log rows', () => {
const out = formatDeploymentLogEntries([
{
ts: '2026-05-19T13:00:00.000Z',
level: 'info',
agentId: 'agent-1',
msg: 'handled event'
}
]);
assert.match(out, /2026-05-19T13:00:00.000Z\s+INFO\s+agent-1\s+handled event/);
});
test('tailLogEntriesFromNewestFiles keeps the newest entries across files', () => {
const entries = tailLogEntriesFromNewestFiles(
[
[
{ ts: '2026-05-19T13:00:00.000Z', msg: 'newer-a' },
{ ts: '2026-05-19T14:00:00.000Z', msg: 'newer-b' },
{ ts: '2026-05-19T15:00:00.000Z', msg: 'newer-c' }
],
[
{ ts: '2026-05-18T10:00:00.000Z', msg: 'older-a' },
{ ts: '2026-05-18T11:00:00.000Z', msg: 'older-b' }
]
],
3
);
assert.deepEqual(entries.map((entry) => entry.msg), ['newer-a', 'newer-b', 'newer-c']);
});