@app-vitals/agent-admin 1.49.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/agents-page.e2e.ts +61 -21
- package/e2e/marketplaces-section.e2e.ts +5 -24
- package/e2e/plugins-section.e2e.ts +6 -27
- package/package.json +2 -2
- package/src/admin-ui-agent-sections.unit.test.ts +95 -0
- package/src/admin-ui-agent-template.smoke.test.ts +22 -16
- package/src/admin-ui-github-identity-pages.unit.test.ts +22 -1
- package/src/admin-ui-github-identity.smoke.test.ts +1 -1
- package/src/admin-ui-installation-repos.smoke.test.ts +7 -7
- package/src/admin-ui-pages.ts +137 -110
- package/src/admin-ui-pages.unit.test.ts +166 -225
- package/src/admin-ui-styles.ts +0 -65
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +184 -96
package/e2e/agents-page.e2e.ts
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Admin UI — Agents Page E2E Tests (ADM-3.2)
|
|
4
4
|
*
|
|
5
5
|
* Tests the agent detail page at GET /admin/agents/:id, covering:
|
|
6
|
+
* Sections (SGL-1.2): general = /:id, automation, configuration, access,
|
|
7
|
+
* extensions = /:id/<section>. Each check loads the section owning the element.
|
|
8
|
+
*
|
|
6
9
|
* 1. Unauthenticated GET /admin/agents → redirects to /admin/login
|
|
7
10
|
* 2. Authenticated → page title contains agent name
|
|
8
11
|
* 3. Authenticated → h1 contains agent name
|
|
@@ -26,7 +29,7 @@
|
|
|
26
29
|
import { type ChildProcess, spawn } from "node:child_process";
|
|
27
30
|
import { dirname, resolve } from "node:path";
|
|
28
31
|
import { fileURLToPath } from "node:url";
|
|
29
|
-
import { type BrowserContext, type Page,
|
|
32
|
+
import { type BrowserContext, expect, type Page, test } from "@playwright/test";
|
|
30
33
|
import { sign } from "hono/jwt";
|
|
31
34
|
|
|
32
35
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
@@ -109,6 +112,7 @@ async function mintSession(
|
|
|
109
112
|
async function loadAgentDetailPage(
|
|
110
113
|
page: Page,
|
|
111
114
|
context: BrowserContext,
|
|
115
|
+
section: "" | "automation" | "configuration" | "access" | "extensions" = "",
|
|
112
116
|
): Promise<void> {
|
|
113
117
|
const token = await mintSession();
|
|
114
118
|
await context.addCookies([
|
|
@@ -121,7 +125,9 @@ async function loadAgentDetailPage(
|
|
|
121
125
|
sameSite: "Lax",
|
|
122
126
|
},
|
|
123
127
|
]);
|
|
124
|
-
await page.goto(
|
|
128
|
+
await page.goto(
|
|
129
|
+
`${BASE_URL}/admin/agents/${AGENT_ID}${section ? `/${section}` : ""}`,
|
|
130
|
+
);
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
// ─── 1. Unauthenticated redirect ──────────────────────────────────────────────
|
|
@@ -158,7 +164,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
158
164
|
page,
|
|
159
165
|
context,
|
|
160
166
|
}) => {
|
|
161
|
-
await loadAgentDetailPage(page, context);
|
|
167
|
+
await loadAgentDetailPage(page, context, "configuration");
|
|
162
168
|
await expect(page.locator("body")).toContainText("SLACK_BOT_TOKEN");
|
|
163
169
|
});
|
|
164
170
|
|
|
@@ -166,7 +172,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
166
172
|
page,
|
|
167
173
|
context,
|
|
168
174
|
}) => {
|
|
169
|
-
await loadAgentDetailPage(page, context);
|
|
175
|
+
await loadAgentDetailPage(page, context, "configuration");
|
|
170
176
|
const body = await page.locator("body").textContent();
|
|
171
177
|
expect(body).toContain("••••••••");
|
|
172
178
|
expect(body).not.toContain("xoxb-secret-value");
|
|
@@ -176,12 +182,12 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
176
182
|
page,
|
|
177
183
|
context,
|
|
178
184
|
}) => {
|
|
179
|
-
await loadAgentDetailPage(page, context);
|
|
185
|
+
await loadAgentDetailPage(page, context, "automation");
|
|
180
186
|
await expect(page.locator("body")).toContainText("0 9 * * 1");
|
|
181
187
|
});
|
|
182
188
|
|
|
183
189
|
test("cron job prompt is visible", async ({ page, context }) => {
|
|
184
|
-
await loadAgentDetailPage(page, context);
|
|
190
|
+
await loadAgentDetailPage(page, context, "automation");
|
|
185
191
|
await expect(page.locator("body")).toContainText("Send the weekly standup");
|
|
186
192
|
});
|
|
187
193
|
|
|
@@ -189,7 +195,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
189
195
|
page,
|
|
190
196
|
context,
|
|
191
197
|
}) => {
|
|
192
|
-
await loadAgentDetailPage(page, context);
|
|
198
|
+
await loadAgentDetailPage(page, context, "access");
|
|
193
199
|
await expect(page.locator("body")).toContainText("Production token");
|
|
194
200
|
});
|
|
195
201
|
|
|
@@ -197,7 +203,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
197
203
|
page,
|
|
198
204
|
context,
|
|
199
205
|
}) => {
|
|
200
|
-
await loadAgentDetailPage(page, context);
|
|
206
|
+
await loadAgentDetailPage(page, context, "configuration");
|
|
201
207
|
const envForm = page.locator('form[action*="/envs"]').first();
|
|
202
208
|
await expect(envForm).toBeAttached();
|
|
203
209
|
});
|
|
@@ -206,7 +212,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
206
212
|
page,
|
|
207
213
|
context,
|
|
208
214
|
}) => {
|
|
209
|
-
await loadAgentDetailPage(page, context);
|
|
215
|
+
await loadAgentDetailPage(page, context, "automation");
|
|
210
216
|
const cronForm = page.locator('form[action*="/crons"]').first();
|
|
211
217
|
await expect(cronForm).toBeAttached();
|
|
212
218
|
});
|
|
@@ -215,7 +221,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
215
221
|
page,
|
|
216
222
|
context,
|
|
217
223
|
}) => {
|
|
218
|
-
await loadAgentDetailPage(page, context);
|
|
224
|
+
await loadAgentDetailPage(page, context, "access");
|
|
219
225
|
const tokenForm = page.locator('form[action*="/tokens"]').first();
|
|
220
226
|
await expect(tokenForm).toBeAttached();
|
|
221
227
|
});
|
|
@@ -251,17 +257,7 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
251
257
|
context,
|
|
252
258
|
}) => {
|
|
253
259
|
await page.setViewportSize({ width: 375, height: 812 });
|
|
254
|
-
await loadAgentDetailPage(page, context);
|
|
255
|
-
|
|
256
|
-
// Env Vars now lives inside a collapsed accordion group (AGA-1.1) —
|
|
257
|
-
// expand it before asserting on the visibility of anything inside.
|
|
258
|
-
await page
|
|
259
|
-
.locator("#env-vars")
|
|
260
|
-
.locator("xpath=ancestor::details[contains(@class, 'group')]")
|
|
261
|
-
.first()
|
|
262
|
-
.evaluate((details) => {
|
|
263
|
-
(details as HTMLDetailsElement).open = true;
|
|
264
|
-
});
|
|
260
|
+
await loadAgentDetailPage(page, context, "configuration");
|
|
265
261
|
|
|
266
262
|
const deleteBtn = page
|
|
267
263
|
.locator("#env-vars .data-table .btn", { hasText: "Delete" })
|
|
@@ -276,6 +272,50 @@ test.describe("GET /admin/agents/:id — authenticated", () => {
|
|
|
276
272
|
});
|
|
277
273
|
});
|
|
278
274
|
|
|
275
|
+
// ─── Section sidebar navigation (SGL-1.2) ────────────────────────────────────
|
|
276
|
+
|
|
277
|
+
test.describe("agent section sidebar", () => {
|
|
278
|
+
test("lists all five sections and marks General current on /:id", async ({
|
|
279
|
+
page,
|
|
280
|
+
context,
|
|
281
|
+
}) => {
|
|
282
|
+
await loadAgentDetailPage(page, context);
|
|
283
|
+
const nav = page.locator("nav.settings-sidebar");
|
|
284
|
+
for (const label of [
|
|
285
|
+
"General",
|
|
286
|
+
"Automation",
|
|
287
|
+
"Configuration",
|
|
288
|
+
"Access",
|
|
289
|
+
"Extensions",
|
|
290
|
+
]) {
|
|
291
|
+
await expect(nav.getByRole("link", { name: label })).toBeVisible();
|
|
292
|
+
}
|
|
293
|
+
await expect(nav.locator('a[aria-current="page"]')).toHaveText("General");
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test("clicking a sidebar link navigates to that section", async ({
|
|
297
|
+
page,
|
|
298
|
+
context,
|
|
299
|
+
}) => {
|
|
300
|
+
await loadAgentDetailPage(page, context);
|
|
301
|
+
const nav = page.locator("nav.settings-sidebar");
|
|
302
|
+
|
|
303
|
+
await nav.getByRole("link", { name: "Automation" }).click();
|
|
304
|
+
await expect(page).toHaveURL(
|
|
305
|
+
`${BASE_URL}/admin/agents/${AGENT_ID}/automation`,
|
|
306
|
+
);
|
|
307
|
+
await expect(page.locator("body")).toContainText("0 9 * * 1");
|
|
308
|
+
|
|
309
|
+
await nav.getByRole("link", { name: "Extensions" }).click();
|
|
310
|
+
await expect(page).toHaveURL(
|
|
311
|
+
`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`,
|
|
312
|
+
);
|
|
313
|
+
await expect(nav.locator('a[aria-current="page"]')).toHaveText(
|
|
314
|
+
"Extensions",
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
279
319
|
// ─── New-specialty picker (ATS-4.1) ──────────────────────────────────────────
|
|
280
320
|
|
|
281
321
|
async function loadNewAgentPage(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* admin/e2e/marketplaces-section.e2e.ts
|
|
3
|
-
* Admin UI — Marketplaces section on the agent
|
|
3
|
+
* Admin UI — Marketplaces section on the agent Extensions section (/admin/agents/:id/extensions) (PMK-1.5)
|
|
4
4
|
*
|
|
5
5
|
* Covers: remote rows listed, add and remove of a remote row, and baked rows
|
|
6
6
|
* (reported by the runtime) rendered read-only with no controls.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { type ChildProcess, spawn } from "node:child_process";
|
|
13
13
|
import { dirname, resolve } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
|
-
import { type BrowserContext, type Page,
|
|
15
|
+
import { type BrowserContext, expect, type Page, test } from "@playwright/test";
|
|
16
16
|
import { sign } from "hono/jwt";
|
|
17
17
|
|
|
18
18
|
const PORT = 3496;
|
|
@@ -87,24 +87,7 @@ async function loadAgentPage(page: Page, context: BrowserContext) {
|
|
|
87
87
|
sameSite: "Lax",
|
|
88
88
|
},
|
|
89
89
|
]);
|
|
90
|
-
await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
91
|
-
await openGroup(page);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// The section lives in the "Plugins & Tools" accordion group, collapsed on
|
|
95
|
-
// every page load (including the redirect after each add/remove).
|
|
96
|
-
async function openGroup(page: Page) {
|
|
97
|
-
// Set `open` rather than clicking the summary, so a still-old (already
|
|
98
|
-
// open) page can't be toggled shut; the table locator retries across the
|
|
99
|
-
// navigation.
|
|
100
|
-
await expect(async () => {
|
|
101
|
-
await page
|
|
102
|
-
.locator("details", { has: page.locator("#marketplaces-table") })
|
|
103
|
-
.evaluate((el) => {
|
|
104
|
-
(el as HTMLDetailsElement).open = true;
|
|
105
|
-
});
|
|
106
|
-
await expect(table(page)).toBeVisible({ timeout: 1000 });
|
|
107
|
-
}).toPass();
|
|
90
|
+
await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
108
91
|
}
|
|
109
92
|
|
|
110
93
|
test("lists the remote row with source and ref, and the baked row", async ({
|
|
@@ -135,16 +118,14 @@ test("adds a remote row and then removes it", async ({ page, context }) => {
|
|
|
135
118
|
await form.locator('input[name="source"]').fill("owner/added");
|
|
136
119
|
await form.locator('input[name="ref"]').fill("main");
|
|
137
120
|
await form.getByRole("button", { name: "Add marketplace" }).click();
|
|
138
|
-
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
139
|
-
await openGroup(page);
|
|
121
|
+
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
140
122
|
|
|
141
123
|
const added = table(page).locator("tbody tr", { hasText: "added-remote" });
|
|
142
124
|
await expect(added).toContainText("owner/added");
|
|
143
125
|
await expect(added).toContainText("main");
|
|
144
126
|
|
|
145
127
|
await added.getByRole("button", { name: "Remove" }).click();
|
|
146
|
-
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
147
|
-
await openGroup(page);
|
|
128
|
+
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
148
129
|
await expect(
|
|
149
130
|
table(page).locator("tbody tr", { hasText: "added-remote" }),
|
|
150
131
|
).toHaveCount(0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* admin/e2e/plugins-section.e2e.ts
|
|
3
|
-
* Admin UI — Plugins card add/remove on the agent
|
|
3
|
+
* Admin UI — Plugins card add/remove on the agent Extensions section (/admin/agents/:id/extensions) (PUI-1.2)
|
|
4
4
|
*
|
|
5
5
|
* Covers: seeded row listed, add by spec (explicit and bare), malformed spec
|
|
6
6
|
* error, and remove.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { type ChildProcess, spawn } from "node:child_process";
|
|
13
13
|
import { dirname, resolve } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
|
-
import { type BrowserContext, type Page,
|
|
15
|
+
import { type BrowserContext, expect, type Page, test } from "@playwright/test";
|
|
16
16
|
import { sign } from "hono/jwt";
|
|
17
17
|
|
|
18
18
|
const PORT = 3497;
|
|
@@ -87,24 +87,7 @@ async function loadAgentPage(page: Page, context: BrowserContext) {
|
|
|
87
87
|
sameSite: "Lax",
|
|
88
88
|
},
|
|
89
89
|
]);
|
|
90
|
-
await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
91
|
-
await openGroup(page);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// The section lives in the "Plugins & Tools" accordion group, collapsed on
|
|
95
|
-
// every page load (including the redirect after each add/remove).
|
|
96
|
-
async function openGroup(page: Page) {
|
|
97
|
-
// Set `open` rather than clicking the summary, so a still-old (already
|
|
98
|
-
// open) page can't be toggled shut; the table locator retries across the
|
|
99
|
-
// navigation.
|
|
100
|
-
await expect(async () => {
|
|
101
|
-
await page
|
|
102
|
-
.locator("details", { has: page.locator("#plugins-table") })
|
|
103
|
-
.evaluate((el) => {
|
|
104
|
-
(el as HTMLDetailsElement).open = true;
|
|
105
|
-
});
|
|
106
|
-
await expect(table(page)).toBeVisible({ timeout: 1000 });
|
|
107
|
-
}).toPass();
|
|
90
|
+
await page.goto(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
108
91
|
}
|
|
109
92
|
|
|
110
93
|
test("lists the seeded plugin", async ({ page, context }) => {
|
|
@@ -119,8 +102,7 @@ test("adds a plugin by spec and then removes it", async ({ page, context }) => {
|
|
|
119
102
|
const form = page.locator("#add-plugin-form");
|
|
120
103
|
await form.locator('input[name="spec"]').fill("added@seeded-remote");
|
|
121
104
|
await form.getByRole("button", { name: "Add plugin" }).click();
|
|
122
|
-
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
123
|
-
await openGroup(page);
|
|
105
|
+
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
124
106
|
|
|
125
107
|
const added = table(page).locator("tbody tr", {
|
|
126
108
|
hasText: "added@seeded-remote",
|
|
@@ -128,8 +110,7 @@ test("adds a plugin by spec and then removes it", async ({ page, context }) => {
|
|
|
128
110
|
await expect(added).toHaveCount(1);
|
|
129
111
|
|
|
130
112
|
await added.getByRole("button", { name: "Remove" }).click();
|
|
131
|
-
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
132
|
-
await openGroup(page);
|
|
113
|
+
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
133
114
|
await expect(
|
|
134
115
|
table(page).locator("tbody tr", { hasText: "added@seeded-remote" }),
|
|
135
116
|
).toHaveCount(0);
|
|
@@ -146,8 +127,7 @@ test("a bare name defaults to the shipwright marketplace", async ({
|
|
|
146
127
|
const form = page.locator("#add-plugin-form");
|
|
147
128
|
await form.locator('input[name="spec"]').fill("barename");
|
|
148
129
|
await form.getByRole("button", { name: "Add plugin" }).click();
|
|
149
|
-
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}`);
|
|
150
|
-
await openGroup(page);
|
|
130
|
+
await page.waitForURL(`${BASE_URL}/admin/agents/${AGENT_ID}/extensions`);
|
|
151
131
|
await expect(
|
|
152
132
|
table(page).locator("tbody tr", { hasText: "barename@shipwright" }),
|
|
153
133
|
).toHaveCount(1);
|
|
@@ -163,6 +143,5 @@ test("a malformed spec redirects with an error and adds nothing", async ({
|
|
|
163
143
|
await form.locator('input[name="spec"]').fill("a@b@c");
|
|
164
144
|
await form.getByRole("button", { name: "Add plugin" }).click();
|
|
165
145
|
await page.waitForURL(/\?error=/);
|
|
166
|
-
await openGroup(page);
|
|
167
146
|
await expect(table(page).locator("tbody tr")).toHaveCount(before);
|
|
168
147
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "0.135.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.
|
|
45
|
+
"@app-vitals/agent-lib": "1.50.0",
|
|
46
46
|
"@hono/zod-openapi": "^1.0.0",
|
|
47
47
|
"@prisma/adapter-pg": "^7.10.0",
|
|
48
48
|
"@prisma/client": "^7.10.0",
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import {
|
|
4
|
+
AGENT_POST_SECTIONS,
|
|
5
|
+
AGENT_SECTIONS,
|
|
6
|
+
agentSectionPath,
|
|
7
|
+
} from "./admin-ui-pages.ts";
|
|
8
|
+
|
|
9
|
+
const source = readFileSync(new URL("./admin-ui.ts", import.meta.url), "utf8");
|
|
10
|
+
|
|
11
|
+
interface Handler {
|
|
12
|
+
route: string;
|
|
13
|
+
suffix: string;
|
|
14
|
+
body: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Every `app.<method>("/admin/agents/:id/...")` registration with its body. */
|
|
18
|
+
function agentHandlers(method: "post" | "get"): Handler[] {
|
|
19
|
+
const re = /app\.(get|post)\(\s*"(\/admin\/agents\/:id(\/[^"]*)?)"/g;
|
|
20
|
+
const hits = [...source.matchAll(re)];
|
|
21
|
+
const all = [...source.matchAll(/\n {2}app\.(get|post|put|delete)\(/g)];
|
|
22
|
+
return hits
|
|
23
|
+
.filter((m) => m[1] === method)
|
|
24
|
+
.map((m) => {
|
|
25
|
+
const start = m.index ?? 0;
|
|
26
|
+
const next = all.find((a) => (a.index ?? 0) > start);
|
|
27
|
+
return {
|
|
28
|
+
route: m[2] as string,
|
|
29
|
+
suffix: (m[3] ?? "") as string,
|
|
30
|
+
body: source.slice(start, next?.index ?? source.length),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe("agent POST handler to section table (SGL-1.3)", () => {
|
|
36
|
+
const posts = agentHandlers("post");
|
|
37
|
+
|
|
38
|
+
test("scan finds the registered handlers", () => {
|
|
39
|
+
expect(posts.length).toBeGreaterThan(25);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("every POST /admin/agents/:id/* handler has a section entry", () => {
|
|
43
|
+
const missing = posts
|
|
44
|
+
.map((h) => h.suffix)
|
|
45
|
+
.filter((s) => s !== "" && !(s in AGENT_POST_SECTIONS));
|
|
46
|
+
expect(missing).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("the table has no stale entries", () => {
|
|
50
|
+
const registered = new Set(posts.map((h) => h.suffix));
|
|
51
|
+
const stale = Object.keys(AGENT_POST_SECTIONS).filter(
|
|
52
|
+
(k) => !registered.has(k),
|
|
53
|
+
);
|
|
54
|
+
expect(stale).toEqual([]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("table values are real sections", () => {
|
|
58
|
+
for (const s of Object.values(AGENT_POST_SECTIONS)) {
|
|
59
|
+
expect(AGENT_SECTIONS).toContain(s);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("no handler redirects to a bare /admin/agents/:id path", () => {
|
|
64
|
+
expect(source).not.toMatch(
|
|
65
|
+
/`\/admin\/agents\/\$\{(agentId|result\.agentId)\}(\?|`)/,
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("each handler's redirects use the section its card lives in", () => {
|
|
70
|
+
const bad: string[] = [];
|
|
71
|
+
for (const h of posts) {
|
|
72
|
+
const expected = AGENT_POST_SECTIONS[h.suffix];
|
|
73
|
+
if (!expected || h.suffix === "/settings") continue;
|
|
74
|
+
for (const m of h.body.matchAll(
|
|
75
|
+
/agentSectionPath\(\s*[\w.]+,\s*"(\w+)"/g,
|
|
76
|
+
)) {
|
|
77
|
+
if (m[1] !== expected) bad.push(`${h.suffix}: ${m[1]} != ${expected}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
expect(bad).toEqual([]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("error/success/warning params survive on every section", () => {
|
|
84
|
+
for (const section of AGENT_SECTIONS) {
|
|
85
|
+
const p = agentSectionPath("a1", section, {
|
|
86
|
+
error: "bad thing",
|
|
87
|
+
success: "ok",
|
|
88
|
+
});
|
|
89
|
+
const url = new URL(p, "http://x");
|
|
90
|
+
expect(url.searchParams.get("error")).toBe("bad thing");
|
|
91
|
+
expect(url.searchParams.get("success")).toBe("ok");
|
|
92
|
+
expect(url.pathname).toBe(agentSectionPath("a1", section));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -139,15 +139,24 @@ const post = (
|
|
|
139
139
|
},
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
/** Concatenated HTML of every agent section page (the template UI is spread across them). */
|
|
143
|
+
async function allSectionsHtml(
|
|
144
|
+
app: ReturnType<typeof createAdminUIApp>,
|
|
145
|
+
): Promise<string> {
|
|
146
|
+
const pages = await Promise.all(
|
|
147
|
+
["", "/automation", "/configuration", "/extensions"].map(async (s) =>
|
|
148
|
+
(await get(app, `/admin/agents/${AGENT_ID}${s}`)).text(),
|
|
149
|
+
),
|
|
150
|
+
);
|
|
151
|
+
return pages.join("\n");
|
|
152
|
+
}
|
|
153
|
+
|
|
142
154
|
describe("agent page template badges (ATP-2.4)", () => {
|
|
143
155
|
it("marks every env, tool, plugin and cron as inherited or custom", async () => {
|
|
144
156
|
const { api } = fakeAgentsApi();
|
|
145
|
-
const html = await (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
`/admin/agents/${AGENT_ID}`,
|
|
149
|
-
)
|
|
150
|
-
).text();
|
|
157
|
+
const html = await allSectionsHtml(
|
|
158
|
+
createAdminUIApp(detailDeps({ agentsApi: api })),
|
|
159
|
+
);
|
|
151
160
|
// 1 env + 1 tool + 1 plugin + 1 cron inherited; 1 env + 1 tool custom.
|
|
152
161
|
expect(html.match(/data-source="template"/g)).toHaveLength(4);
|
|
153
162
|
expect(html.match(/data-source="custom"/g)).toHaveLength(2);
|
|
@@ -184,13 +193,13 @@ describe("agent page template badges (ATP-2.4)", () => {
|
|
|
184
193
|
},
|
|
185
194
|
}),
|
|
186
195
|
);
|
|
187
|
-
const before = await (
|
|
196
|
+
const before = await allSectionsHtml(app);
|
|
188
197
|
expect(before).toContain('data-source="template"');
|
|
189
198
|
await post(app, `/admin/agents/${AGENT_ID}/envs`, {
|
|
190
199
|
key: "TPL_KEY",
|
|
191
200
|
value: "mine",
|
|
192
201
|
});
|
|
193
|
-
const after = await (
|
|
202
|
+
const after = await allSectionsHtml(app);
|
|
194
203
|
expect(after).not.toContain('data-source="template"');
|
|
195
204
|
expect(after).toContain('data-source="custom"');
|
|
196
205
|
});
|
|
@@ -200,7 +209,7 @@ describe("detach / reattach (ATP-2.4)", () => {
|
|
|
200
209
|
it("attached agent offers Detach; POST calls the detach endpoint", async () => {
|
|
201
210
|
const { api, calls } = fakeAgentsApi();
|
|
202
211
|
const app = createAdminUIApp(detailDeps({ agentsApi: api }));
|
|
203
|
-
const html = await (
|
|
212
|
+
const html = await allSectionsHtml(app);
|
|
204
213
|
expect(html).toContain(`/admin/agents/${AGENT_ID}/template/detach`);
|
|
205
214
|
expect(html).not.toContain(`/template/reattach`);
|
|
206
215
|
|
|
@@ -221,7 +230,7 @@ describe("detach / reattach (ATP-2.4)", () => {
|
|
|
221
230
|
const app = createAdminUIApp(
|
|
222
231
|
detailDeps({ agentsApi: api, detached: true }),
|
|
223
232
|
);
|
|
224
|
-
const html = await (
|
|
233
|
+
const html = await allSectionsHtml(app);
|
|
225
234
|
expect(html).toContain("Detached from template");
|
|
226
235
|
expect(html).toContain(`/admin/agents/${AGENT_ID}/template/reattach`);
|
|
227
236
|
expect(html).not.toContain(`/template/detach`);
|
|
@@ -257,12 +266,9 @@ describe("detach / reattach (ATP-2.4)", () => {
|
|
|
257
266
|
describe("reset to template (ATP-2.4)", () => {
|
|
258
267
|
it("custom rows get a per-item reset; template rows do not", async () => {
|
|
259
268
|
const { api } = fakeAgentsApi();
|
|
260
|
-
const html = await (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
`/admin/agents/${AGENT_ID}`,
|
|
264
|
-
)
|
|
265
|
-
).text();
|
|
269
|
+
const html = await allSectionsHtml(
|
|
270
|
+
createAdminUIApp(detailDeps({ agentsApi: api })),
|
|
271
|
+
);
|
|
266
272
|
// custom env MINE and custom tool Bash(ls:*) -> 2 per-item resets, plus
|
|
267
273
|
// the agent-wide reset.
|
|
268
274
|
expect(html.match(/name="kind" value="(env|tool)"/g)).toHaveLength(2);
|
|
@@ -11,7 +11,28 @@ import {
|
|
|
11
11
|
renderGithubAccessResult,
|
|
12
12
|
renderGithubUsernameRow,
|
|
13
13
|
} from "./admin-ui-github-identity-pages.ts";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
AGENT_SECTIONS,
|
|
16
|
+
type AgentDetail,
|
|
17
|
+
renderAgentDetailPage as renderAgentDetailSection,
|
|
18
|
+
} from "./admin-ui-pages.ts";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Renders every agent detail section (SGL-1.2) concatenated, so card-level
|
|
22
|
+
* assertions don't depend on which section a card lives in. Pass
|
|
23
|
+
* `opts.section` to render a single section instead.
|
|
24
|
+
*/
|
|
25
|
+
function renderAgentDetailPage(
|
|
26
|
+
...args: Parameters<typeof renderAgentDetailSection>
|
|
27
|
+
): string {
|
|
28
|
+
const opts = args[9];
|
|
29
|
+
if (opts?.section) return renderAgentDetailSection(...args);
|
|
30
|
+
return AGENT_SECTIONS.map((section) => {
|
|
31
|
+
const a = [...args] as typeof args;
|
|
32
|
+
a[9] = { ...opts, section };
|
|
33
|
+
return renderAgentDetailSection(...a);
|
|
34
|
+
}).join("\n");
|
|
35
|
+
}
|
|
15
36
|
|
|
16
37
|
const AGENT: AgentDetail = {
|
|
17
38
|
id: "agent-123",
|
|
@@ -82,7 +82,7 @@ describe("admin UI — GitHub identity (GHE-2.5)", () => {
|
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
const get = (app: ReturnType<typeof setup>["app"], cookie: string) =>
|
|
85
|
-
app.request(`/admin/agents/${AGENT_ID}`, {
|
|
85
|
+
app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
86
86
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
87
87
|
});
|
|
88
88
|
const post = (
|
|
@@ -118,7 +118,7 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
118
118
|
describe("card presence", () => {
|
|
119
119
|
it("shows the Sync button and no input when both Apps are configured", async () => {
|
|
120
120
|
const { app } = setup({ agentsApi: () => json(INSTALLED) });
|
|
121
|
-
const html = await (await get(app, "")).text();
|
|
121
|
+
const html = await (await get(app, "/access")).text();
|
|
122
122
|
expect(html).toContain('id="github-installation-card"');
|
|
123
123
|
expect(html).toContain('id="github-sync-btn"');
|
|
124
124
|
const card = html.slice(html.indexOf('id="github-installation-card"'));
|
|
@@ -134,7 +134,7 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
134
134
|
lookup: null,
|
|
135
135
|
},
|
|
136
136
|
});
|
|
137
|
-
const html = await (await get(app, "")).text();
|
|
137
|
+
const html = await (await get(app, "/access")).text();
|
|
138
138
|
expect(html).not.toContain("github-installation-card");
|
|
139
139
|
});
|
|
140
140
|
|
|
@@ -146,7 +146,7 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
146
146
|
lookup: { role: "lookup" },
|
|
147
147
|
},
|
|
148
148
|
});
|
|
149
|
-
const html = await (await get(app, "")).text();
|
|
149
|
+
const html = await (await get(app, "/access")).text();
|
|
150
150
|
expect(html).not.toContain("github-installation-card");
|
|
151
151
|
});
|
|
152
152
|
|
|
@@ -154,20 +154,20 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
154
154
|
const { app } = setup({
|
|
155
155
|
enterprise: { configured: false, installer: null, lookup: null },
|
|
156
156
|
});
|
|
157
|
-
const html = await (await get(app, "")).text();
|
|
157
|
+
const html = await (await get(app, "/access")).text();
|
|
158
158
|
expect(html).not.toContain("github-installation-card");
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
it("shows the missing-App-id reason, not the button, with no GH_APP_ID", async () => {
|
|
162
162
|
const { app } = setup({ env: { FOO: "bar" } });
|
|
163
|
-
const html = await (await get(app, "")).text();
|
|
163
|
+
const html = await (await get(app, "/access")).text();
|
|
164
164
|
expect(html).toContain('data-reason="missing-app-id"');
|
|
165
165
|
expect(html).not.toContain('id="github-sync-btn"');
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
it("shows the no-username reason, not the button, with no bound user", async () => {
|
|
169
169
|
const { app } = setup({ username: null });
|
|
170
|
-
const html = await (await get(app, "")).text();
|
|
170
|
+
const html = await (await get(app, "/access")).text();
|
|
171
171
|
expect(html).toContain('data-reason="no-username"');
|
|
172
172
|
expect(html).not.toContain('id="github-sync-btn"');
|
|
173
173
|
});
|
|
@@ -409,7 +409,7 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
409
409
|
repos: ["acme/api", "ACME/Web", "other/gone"],
|
|
410
410
|
agentsApi: api,
|
|
411
411
|
});
|
|
412
|
-
const html = await (await get(app, "")).text();
|
|
412
|
+
const html = await (await get(app, "/configuration")).text();
|
|
413
413
|
expect(html).toContain('id="repos-uncovered-warning"');
|
|
414
414
|
expect(html).toContain("other/gone");
|
|
415
415
|
expect(html.match(/data-uncovered="1"/g)?.length).toBe(1);
|