@app-vitals/agent-admin 1.48.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 +421 -0
- 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 +269 -119
- package/src/admin-ui-pages.unit.test.ts +166 -225
- package/src/admin-ui-styles.ts +8 -65
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +325 -86
- package/src/agent-envs.ts +5 -1
- package/src/agents.ts +3 -0
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
|
+
});
|