@app-vitals/agent-admin 1.49.0 → 1.51.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-account-nav.ts +3 -14
- package/src/admin-ui-account-nav.unit.test.ts +5 -14
- package/src/admin-ui-account-pages.ts +21 -10
- package/src/admin-ui-account-pages.unit.test.ts +12 -12
- package/src/admin-ui-account.smoke.test.ts +4 -0
- package/src/admin-ui-account.ts +5 -0
- package/src/admin-ui-accounts-pages.ts +36 -16
- package/src/admin-ui-accounts-pages.unit.test.ts +29 -0
- package/src/admin-ui-accounts.smoke.test.ts +2 -0
- package/src/admin-ui-accounts.ts +10 -1
- 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-settings-layout.ts +24 -6
- package/src/admin-ui-settings.smoke.test.ts +28 -0
- package/src/admin-ui-styles.ts +1 -70
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +211 -131
|
@@ -9,14 +9,17 @@
|
|
|
9
9
|
import { afterEach, describe, expect, test } from "bun:test";
|
|
10
10
|
import { renderZeroQuotaNotice } from "./admin-ui-account-pages.ts";
|
|
11
11
|
import {
|
|
12
|
+
AGENT_SECTIONS,
|
|
12
13
|
type AgentDetail,
|
|
13
14
|
type AgentListItem,
|
|
15
|
+
agentSectionPath,
|
|
16
|
+
settingsRedirectSection,
|
|
14
17
|
type CronJobItem,
|
|
15
18
|
ERROR_KIND_LABELS,
|
|
16
19
|
type MemberItem,
|
|
17
20
|
type PluginItem,
|
|
18
21
|
renderAddAnotherOrgAction,
|
|
19
|
-
renderAgentDetailPage,
|
|
22
|
+
renderAgentDetailPage as renderAgentDetailSection,
|
|
20
23
|
renderAgentsPage,
|
|
21
24
|
renderChatMessageBubble,
|
|
22
25
|
renderChatPage,
|
|
@@ -34,6 +37,23 @@ import {
|
|
|
34
37
|
import { baseStyles, renderAdminToolbar } from "./admin-ui-styles.ts";
|
|
35
38
|
import type { ChatMessage, ChatThread } from "./http-chat-client.ts";
|
|
36
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Renders every agent detail section (SGL-1.2) concatenated, so card-level
|
|
42
|
+
* assertions don't depend on which section a card lives in. Pass
|
|
43
|
+
* `opts.section` to render a single section instead.
|
|
44
|
+
*/
|
|
45
|
+
function renderAgentDetailPage(
|
|
46
|
+
...args: Parameters<typeof renderAgentDetailSection>
|
|
47
|
+
): string {
|
|
48
|
+
const opts = args[9];
|
|
49
|
+
if (opts?.section) return renderAgentDetailSection(...args);
|
|
50
|
+
return AGENT_SECTIONS.map((section) => {
|
|
51
|
+
const a = [...args] as typeof args;
|
|
52
|
+
a[9] = { ...opts, section };
|
|
53
|
+
return renderAgentDetailSection(...a);
|
|
54
|
+
}).join("\n");
|
|
55
|
+
}
|
|
56
|
+
|
|
37
57
|
// ─── Shared fixtures ──────────────────────────────────────────────────────────
|
|
38
58
|
|
|
39
59
|
const AGENT: AgentDetail = {
|
|
@@ -2150,47 +2170,15 @@ describe("renderAgentDetailPage — patch author allowlist", () => {
|
|
|
2150
2170
|
});
|
|
2151
2171
|
});
|
|
2152
2172
|
|
|
2153
|
-
// ─── renderAgentDetailPage —
|
|
2154
|
-
|
|
2155
|
-
describe("renderAgentDetailPage — accordion groups", () => {
|
|
2156
|
-
/**
|
|
2157
|
-
* All 4 group `<details class="group">` blocks, in document order.
|
|
2158
|
-
* A naive non-greedy `[\s\S]*?<\/details>` regex breaks here because
|
|
2159
|
-
* several cards (e.g. Slack access's "Connect Slack" popover) nest their
|
|
2160
|
-
* own unrelated `<details>` inside a group's body — this walks nesting
|
|
2161
|
-
* depth so each group's true closing tag is found.
|
|
2162
|
-
*/
|
|
2163
|
-
function extractGroups(html: string): string[] {
|
|
2164
|
-
const groups: string[] = [];
|
|
2165
|
-
const openTagRe = /<details class="group">/g;
|
|
2166
|
-
let match: RegExpExecArray | null;
|
|
2167
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: standard regex-loop idiom
|
|
2168
|
-
while ((match = openTagRe.exec(html)) !== null) {
|
|
2169
|
-
const start = match.index;
|
|
2170
|
-
let depth = 1;
|
|
2171
|
-
let cursor = start + match[0].length;
|
|
2172
|
-
const tagRe = /<details\b[^>]*>|<\/details>/g;
|
|
2173
|
-
tagRe.lastIndex = cursor;
|
|
2174
|
-
let tagMatch: RegExpExecArray | null;
|
|
2175
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: standard regex-loop idiom
|
|
2176
|
-
while ((tagMatch = tagRe.exec(html)) !== null) {
|
|
2177
|
-
if (tagMatch[0] === "</details>") {
|
|
2178
|
-
depth--;
|
|
2179
|
-
} else {
|
|
2180
|
-
depth++;
|
|
2181
|
-
}
|
|
2182
|
-
if (depth === 0) {
|
|
2183
|
-
cursor = tagRe.lastIndex;
|
|
2184
|
-
break;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
groups.push(html.slice(start, cursor));
|
|
2188
|
-
}
|
|
2189
|
-
return groups;
|
|
2190
|
-
}
|
|
2173
|
+
// ─── renderAgentDetailPage — per-section pages (SGL-1.2) ─────────────────────
|
|
2191
2174
|
|
|
2192
|
-
|
|
2193
|
-
|
|
2175
|
+
describe("renderAgentDetailPage — sections", () => {
|
|
2176
|
+
function render(
|
|
2177
|
+
section: (typeof AGENT_SECTIONS)[number] | undefined,
|
|
2178
|
+
opts?: Parameters<typeof renderAgentDetailPage>[9],
|
|
2179
|
+
isAdmin = true,
|
|
2180
|
+
): string {
|
|
2181
|
+
return renderAgentDetailSection(
|
|
2194
2182
|
AGENT,
|
|
2195
2183
|
{},
|
|
2196
2184
|
[SYSTEM_CRON, CUSTOM_CRON],
|
|
@@ -2205,199 +2193,163 @@ describe("renderAgentDetailPage — accordion groups", () => {
|
|
|
2205
2193
|
},
|
|
2206
2194
|
],
|
|
2207
2195
|
USER_NAME,
|
|
2208
|
-
|
|
2209
|
-
{
|
|
2196
|
+
isAdmin,
|
|
2197
|
+
{
|
|
2198
|
+
timezone: "UTC",
|
|
2199
|
+
extensionCardsHtml: ['<div id="ext-header">H</div>'],
|
|
2200
|
+
configurationCardsHtml: ['<div id="ext-config">C</div>'],
|
|
2201
|
+
...(section ? { section } : {}),
|
|
2202
|
+
...opts,
|
|
2203
|
+
},
|
|
2210
2204
|
);
|
|
2211
2205
|
}
|
|
2212
2206
|
|
|
2213
|
-
test(
|
|
2214
|
-
|
|
2215
|
-
expect(
|
|
2207
|
+
test("agentSectionPath: general is the bare agent path, others append the section", () => {
|
|
2208
|
+
expect(agentSectionPath("a b")).toBe("/admin/agents/a%20b");
|
|
2209
|
+
expect(agentSectionPath("a1", "general")).toBe("/admin/agents/a1");
|
|
2210
|
+
expect(agentSectionPath("a1", "automation")).toBe(
|
|
2211
|
+
"/admin/agents/a1/automation",
|
|
2212
|
+
);
|
|
2216
2213
|
});
|
|
2217
2214
|
|
|
2218
|
-
test("
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
expect(groups[0]).toContain('<span class="group-title">Automation</span>');
|
|
2222
|
-
expect(groups[1]).toContain(
|
|
2223
|
-
'<span class="group-title">Configuration</span>',
|
|
2215
|
+
test("agentSectionPath: appends encoded query params and skips undefined", () => {
|
|
2216
|
+
expect(agentSectionPath("a1", "general", { error: "x y" })).toBe(
|
|
2217
|
+
"/admin/agents/a1?error=x%20y",
|
|
2224
2218
|
);
|
|
2225
|
-
expect(
|
|
2226
|
-
|
|
2227
|
-
|
|
2219
|
+
expect(
|
|
2220
|
+
agentSectionPath("a1", "access", { success: "ok", warning: "a&b=c" }),
|
|
2221
|
+
).toBe("/admin/agents/a1/access?success=ok&warning=a%26b%3Dc");
|
|
2222
|
+
expect(agentSectionPath("a1", "extensions", { error: undefined })).toBe(
|
|
2223
|
+
"/admin/agents/a1/extensions",
|
|
2228
2224
|
);
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
test("all 4 groups render collapsed (no `open` attribute) by default", () => {
|
|
2232
|
-
const html = render();
|
|
2233
|
-
const groupTags = html.match(/<details class="group"[^>]*>/g) ?? [];
|
|
2234
|
-
expect(groupTags).toHaveLength(4);
|
|
2235
|
-
for (const tag of groupTags) {
|
|
2236
|
-
expect(tag).not.toContain("open");
|
|
2237
|
-
}
|
|
2238
|
-
});
|
|
2239
|
-
|
|
2240
|
-
test("groups stay collapsed even when agent.missingRequiredEnv is non-empty", () => {
|
|
2241
|
-
const agent: AgentDetail = { ...AGENT, missingRequiredEnv: ["GH_TOKEN"] };
|
|
2242
|
-
const html = renderAgentDetailPage(
|
|
2243
|
-
agent,
|
|
2244
|
-
{},
|
|
2245
|
-
[SYSTEM_CRON],
|
|
2246
|
-
[],
|
|
2247
|
-
[],
|
|
2248
|
-
[],
|
|
2249
|
-
[],
|
|
2250
|
-
USER_NAME,
|
|
2251
|
-
true,
|
|
2252
|
-
{ timezone: "UTC" },
|
|
2225
|
+
expect(agentSectionPath("a1", "automation", {})).toBe(
|
|
2226
|
+
"/admin/agents/a1/automation",
|
|
2253
2227
|
);
|
|
2254
|
-
const groupTags = html.match(/<details class="group"[^>]*>/g) ?? [];
|
|
2255
|
-
expect(groupTags).toHaveLength(4);
|
|
2256
|
-
for (const tag of groupTags) {
|
|
2257
|
-
expect(tag).not.toContain("open");
|
|
2258
|
-
}
|
|
2259
|
-
});
|
|
2260
|
-
|
|
2261
|
-
test("Automation group contains the Cron Jobs card", () => {
|
|
2262
|
-
const html = render();
|
|
2263
|
-
const groups = extractGroups(html);
|
|
2264
|
-
expect(groups[0]).toContain('<div class="card-title">Cron Jobs</div>');
|
|
2265
|
-
expect(groups[0]).not.toContain("Env Vars");
|
|
2266
2228
|
});
|
|
2267
2229
|
|
|
2268
|
-
test("
|
|
2269
|
-
const
|
|
2270
|
-
|
|
2271
|
-
expect(
|
|
2272
|
-
|
|
2273
|
-
|
|
2230
|
+
test("settingsRedirectSection: Slack access form goes to access, policy form to configuration", () => {
|
|
2231
|
+
const slack = new FormData();
|
|
2232
|
+
slack.set("restrictSlackToMembers", "false");
|
|
2233
|
+
expect(settingsRedirectSection(slack)).toBe("access");
|
|
2234
|
+
const policy = new FormData();
|
|
2235
|
+
policy.set("minConfidence", "70");
|
|
2236
|
+
expect(settingsRedirectSection(policy)).toBe("configuration");
|
|
2274
2237
|
});
|
|
2275
2238
|
|
|
2276
|
-
test("
|
|
2277
|
-
|
|
2278
|
-
const groups = extractGroups(html);
|
|
2279
|
-
expect(groups[2]).toContain("member@example.com");
|
|
2280
|
-
expect(groups[2]).toContain(
|
|
2281
|
-
'<div class="card-title">Author allowlist (review)</div>',
|
|
2282
|
-
);
|
|
2283
|
-
expect(groups[2]).toContain(
|
|
2284
|
-
'<div class="card-title">Author allowlist (patch)</div>',
|
|
2285
|
-
);
|
|
2286
|
-
expect(groups[2]).toContain('<div class="card-title">Slack access</div>');
|
|
2287
|
-
expect(groups[2]).toContain(
|
|
2288
|
-
'<div class="card-title">Task Store Tokens</div>',
|
|
2289
|
-
);
|
|
2239
|
+
test("defaults to General", () => {
|
|
2240
|
+
expect(render(undefined)).toBe(render("general"));
|
|
2290
2241
|
});
|
|
2291
2242
|
|
|
2292
|
-
test("
|
|
2293
|
-
const html = render();
|
|
2294
|
-
|
|
2295
|
-
expect(
|
|
2296
|
-
expect(
|
|
2243
|
+
test("General: header info, Sync Manifest, stat strip, header extension cards, Danger zone", () => {
|
|
2244
|
+
const html = render("general");
|
|
2245
|
+
expect(html).toContain("Sync Manifest");
|
|
2246
|
+
expect(html).toContain('class="stat-strip"');
|
|
2247
|
+
expect(html).toContain('id="ext-header"');
|
|
2248
|
+
expect(html).toContain('class="settings-danger-zone"');
|
|
2249
|
+
expect(html).toContain("Danger Zone");
|
|
2250
|
+
expect(html).not.toContain("Cron Jobs");
|
|
2251
|
+
expect(html).not.toContain('id="env-vars"');
|
|
2252
|
+
expect(html).not.toContain('id="ext-config"');
|
|
2253
|
+
expect(html).not.toContain("Agent Policy");
|
|
2297
2254
|
});
|
|
2298
2255
|
|
|
2299
|
-
test("Danger
|
|
2300
|
-
const html = render();
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
expect(dangerZoneIndex).toBeGreaterThan(lastGroupEnd);
|
|
2304
|
-
// Sits in its own .card, not nested in a .group-body.
|
|
2305
|
-
const dangerZoneCardIndex = html.indexOf(
|
|
2306
|
-
'<div class="card" style="border:1px solid #fca5a5">',
|
|
2256
|
+
test("General: Danger zone is last, after the stat strip", () => {
|
|
2257
|
+
const html = render("general");
|
|
2258
|
+
expect(html.indexOf("Danger Zone")).toBeGreaterThan(
|
|
2259
|
+
html.indexOf('class="stat-strip"'),
|
|
2307
2260
|
);
|
|
2308
|
-
expect(dangerZoneCardIndex).toBeGreaterThan(lastGroupEnd);
|
|
2309
2261
|
});
|
|
2310
2262
|
|
|
2311
|
-
test("Danger
|
|
2312
|
-
const html =
|
|
2313
|
-
AGENT,
|
|
2314
|
-
{},
|
|
2315
|
-
[],
|
|
2316
|
-
[],
|
|
2317
|
-
[],
|
|
2318
|
-
[],
|
|
2319
|
-
[],
|
|
2320
|
-
USER_NAME,
|
|
2321
|
-
false,
|
|
2322
|
-
{ timezone: "UTC" },
|
|
2323
|
-
);
|
|
2263
|
+
test("General: Danger zone hidden when canManage is false", () => {
|
|
2264
|
+
const html = render("general", { canManage: false }, false);
|
|
2324
2265
|
expect(html).not.toContain("Danger Zone");
|
|
2325
|
-
expect(extractGroups(html)).toHaveLength(4);
|
|
2326
2266
|
});
|
|
2327
2267
|
|
|
2328
|
-
test("
|
|
2329
|
-
const html = render();
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2268
|
+
test("Automation renders only the cron jobs card", () => {
|
|
2269
|
+
const html = render("automation");
|
|
2270
|
+
expect(html).toContain('<div class="card-title">Cron Jobs</div>');
|
|
2271
|
+
expect(html).toContain('action="/admin/agents/agent-123/crons"');
|
|
2272
|
+
expect(html).not.toContain('class="stat-strip"');
|
|
2273
|
+
expect(html).not.toContain("Danger Zone");
|
|
2274
|
+
expect(html).not.toContain('id="env-vars"');
|
|
2275
|
+
expect(html).not.toContain("Agent Policy");
|
|
2276
|
+
});
|
|
2277
|
+
|
|
2278
|
+
test("Configuration renders env vars, repos, config extension cards, policy in order", () => {
|
|
2279
|
+
const html = render("configuration");
|
|
2280
|
+
const idx = [
|
|
2281
|
+
'id="env-vars"',
|
|
2282
|
+
'<div class="card-title">Repos</div>',
|
|
2283
|
+
'id="ext-config"',
|
|
2284
|
+
'<div class="card-title">Agent Policy</div>',
|
|
2285
|
+
].map((m) => html.indexOf(m));
|
|
2286
|
+
expect(idx.every((i) => i > -1)).toBe(true);
|
|
2287
|
+
expect([...idx].sort((x, y) => x - y)).toEqual(idx);
|
|
2288
|
+
expect(html).not.toContain("Cron Jobs");
|
|
2289
|
+
expect(html).not.toContain('class="stat-strip"');
|
|
2290
|
+
expect(html).not.toContain("Danger Zone");
|
|
2291
|
+
expect(html).not.toContain('id="ext-header"');
|
|
2338
2292
|
});
|
|
2339
2293
|
|
|
2340
|
-
test("
|
|
2341
|
-
const html = render();
|
|
2342
|
-
|
|
2343
|
-
expect(
|
|
2344
|
-
|
|
2294
|
+
test("Access renders identity, members, allowlists, slack access and tokens", () => {
|
|
2295
|
+
const html = render("access");
|
|
2296
|
+
expect(html).toContain("Owner & identities");
|
|
2297
|
+
expect(html).toContain("member@example.com");
|
|
2298
|
+
expect(html).toContain('action="/admin/agents/agent-123/members"');
|
|
2299
|
+
expect(html).toContain(
|
|
2300
|
+
'action="/admin/agents/agent-123/review-author-allowlist/add"',
|
|
2345
2301
|
);
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
test("Plugins & Tools group's stat string reflects tool/plugin counts", () => {
|
|
2349
|
-
const html = render();
|
|
2350
|
-
const groups = extractGroups(html);
|
|
2351
|
-
expect(groups[3]).toContain(
|
|
2352
|
-
'<span class="group-sub">2 tools · 2 plugins</span>',
|
|
2302
|
+
expect(html).toContain(
|
|
2303
|
+
'action="/admin/agents/agent-123/patch-author-allowlist/add"',
|
|
2353
2304
|
);
|
|
2305
|
+
expect(html).toContain('<div class="card-title">Slack access</div>');
|
|
2306
|
+
expect(html).toContain("Task Store Tokens");
|
|
2307
|
+
expect(html).toContain('action="/admin/agents/agent-123/tokens"');
|
|
2308
|
+
expect(html).not.toContain('<div class="card-title">Tools</div>');
|
|
2309
|
+
expect(html).not.toContain("Cron Jobs");
|
|
2354
2310
|
});
|
|
2355
2311
|
|
|
2356
|
-
test("
|
|
2357
|
-
const
|
|
2358
|
-
expect(
|
|
2359
|
-
expect(
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
const
|
|
2365
|
-
expect(
|
|
2366
|
-
expect(
|
|
2367
|
-
expect(
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
expect(html).toContain("querySelectorAll");
|
|
2392
|
-
expect(html).toContain(".group");
|
|
2393
|
-
expect(html).toContain("el.open = true");
|
|
2312
|
+
test("Access hides members and Slack access when canManage is false", () => {
|
|
2313
|
+
const html = render("access", { canManage: false }, false);
|
|
2314
|
+
expect(html).not.toContain('action="/admin/agents/agent-123/members"');
|
|
2315
|
+
expect(html).not.toContain('<div class="card-title">Slack access</div>');
|
|
2316
|
+
expect(html).toContain("Task Store Tokens");
|
|
2317
|
+
});
|
|
2318
|
+
|
|
2319
|
+
test("Extensions renders tools, plugins, marketplaces", () => {
|
|
2320
|
+
const html = render("extensions");
|
|
2321
|
+
expect(html).toContain('action="/admin/agents/agent-123/tools"');
|
|
2322
|
+
expect(html).toContain('action="/admin/agents/agent-123/plugins"');
|
|
2323
|
+
expect(html).toContain('action="/admin/agents/agent-123/marketplaces"');
|
|
2324
|
+
expect(html).toContain('<div class="card-title">Tools</div>');
|
|
2325
|
+
expect(html).toContain('<div class="card-title">Plugins</div>');
|
|
2326
|
+
expect(html).toContain('<div class="card-title">Marketplaces</div>');
|
|
2327
|
+
expect(html).not.toContain("Task Store Tokens");
|
|
2328
|
+
});
|
|
2329
|
+
|
|
2330
|
+
test("sidebar lists all five sections with the current one active", () => {
|
|
2331
|
+
for (const section of AGENT_SECTIONS) {
|
|
2332
|
+
const html = render(section);
|
|
2333
|
+
for (const label of [
|
|
2334
|
+
"General",
|
|
2335
|
+
"Automation",
|
|
2336
|
+
"Configuration",
|
|
2337
|
+
"Access",
|
|
2338
|
+
"Extensions",
|
|
2339
|
+
]) {
|
|
2340
|
+
expect(html).toContain(`>${label}</a>`);
|
|
2341
|
+
}
|
|
2342
|
+
const active = html.match(
|
|
2343
|
+
/<a class="settings-nav-link" href="([^"]*)" aria-current="page"/,
|
|
2344
|
+
);
|
|
2345
|
+
expect(active?.[1]).toBe(agentSectionPath("agent-123", section));
|
|
2346
|
+
}
|
|
2394
2347
|
});
|
|
2395
2348
|
|
|
2396
|
-
test("
|
|
2397
|
-
const
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
expect(html).toContain("el.open = false");
|
|
2349
|
+
test("alerts render on every section", () => {
|
|
2350
|
+
for (const section of AGENT_SECTIONS) {
|
|
2351
|
+
expect(render(section, { error: "boom" })).toContain("boom");
|
|
2352
|
+
}
|
|
2401
2353
|
});
|
|
2402
2354
|
});
|
|
2403
2355
|
|
|
@@ -2585,18 +2537,6 @@ describe("renderAgentDetailPage — stat strip", () => {
|
|
|
2585
2537
|
expect(tileSection).not.toContain("stat-tile-warning");
|
|
2586
2538
|
});
|
|
2587
2539
|
|
|
2588
|
-
test("stat strip renders before accordion groups", () => {
|
|
2589
|
-
const html = render();
|
|
2590
|
-
const statStripIndex = html.indexOf('class="stat-strip"');
|
|
2591
|
-
const automationGroupIndex = html.indexOf(
|
|
2592
|
-
'<span class="group-title">Automation</span>',
|
|
2593
|
-
);
|
|
2594
|
-
|
|
2595
|
-
expect(statStripIndex).toBeGreaterThan(-1);
|
|
2596
|
-
expect(automationGroupIndex).toBeGreaterThan(-1);
|
|
2597
|
-
expect(statStripIndex < automationGroupIndex).toBe(true);
|
|
2598
|
-
});
|
|
2599
|
-
|
|
2600
2540
|
test("CSS: .stat-strip and .stat-tile classes exist in baseStyles", () => {
|
|
2601
2541
|
const styles = baseStyles();
|
|
2602
2542
|
expect(styles).toContain(".stat-strip");
|
|
@@ -4026,6 +3966,7 @@ describe("all page renderers — single DOCTYPE and viewport meta (CFB-1.2)", ()
|
|
|
4026
3966
|
() =>
|
|
4027
3967
|
renderAgentDetailPage(AGENT, {}, [], [], [], [], [], USER_NAME, true, {
|
|
4028
3968
|
timezone: "UTC",
|
|
3969
|
+
section: "general",
|
|
4029
3970
|
}),
|
|
4030
3971
|
],
|
|
4031
3972
|
[
|
|
@@ -4387,14 +4328,15 @@ describe("renderAgentDetailPage — platform-only page (no extension cards)", ()
|
|
|
4387
4328
|
expect(html).not.toContain("Recent Verification Activity");
|
|
4388
4329
|
});
|
|
4389
4330
|
|
|
4390
|
-
test("still renders every platform
|
|
4331
|
+
test("still renders every platform section nav entry", () => {
|
|
4391
4332
|
for (const group of [
|
|
4333
|
+
"General",
|
|
4392
4334
|
"Automation",
|
|
4393
4335
|
"Configuration",
|
|
4394
4336
|
"Access",
|
|
4395
|
-
"
|
|
4337
|
+
"Extensions",
|
|
4396
4338
|
]) {
|
|
4397
|
-
expect(html).toContain(
|
|
4339
|
+
expect(html).toContain(`>${group}</a>`);
|
|
4398
4340
|
}
|
|
4399
4341
|
});
|
|
4400
4342
|
});
|
|
@@ -4426,8 +4368,8 @@ describe("renderAgentDetailPage — configuration card slots", () => {
|
|
|
4426
4368
|
expect(two).toBeLessThan(policy);
|
|
4427
4369
|
});
|
|
4428
4370
|
|
|
4429
|
-
test("header cards render above the stat strip, configuration cards
|
|
4430
|
-
const html =
|
|
4371
|
+
test("header cards render above the stat strip, configuration cards only on the Configuration section", () => {
|
|
4372
|
+
const html = renderAgentDetailSection(
|
|
4431
4373
|
AGENT,
|
|
4432
4374
|
{},
|
|
4433
4375
|
[],
|
|
@@ -4443,12 +4385,11 @@ describe("renderAgentDetailPage — configuration card slots", () => {
|
|
|
4443
4385
|
configurationCardsHtml: ['<div class="card">cfg</div>'],
|
|
4444
4386
|
},
|
|
4445
4387
|
);
|
|
4388
|
+
// Header cards live on General; config cards render only on Configuration.
|
|
4446
4389
|
const statStrip = html.indexOf('<div class="stat-strip">');
|
|
4447
|
-
|
|
4448
|
-
'<span class="group-title">Configuration</span>',
|
|
4449
|
-
);
|
|
4390
|
+
expect(html.indexOf("hdr")).toBeGreaterThan(-1);
|
|
4450
4391
|
expect(html.indexOf("hdr")).toBeLessThan(statStrip);
|
|
4451
|
-
expect(html.
|
|
4392
|
+
expect(html).not.toContain(">cfg<");
|
|
4452
4393
|
});
|
|
4453
4394
|
});
|
|
4454
4395
|
|
|
@@ -101,11 +101,15 @@ export function mergeSettingsNavItems(
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export const SETTINGS_GHE_PATH = "/admin/settings/github-enterprise";
|
|
104
|
+
export const SETTINGS_ACCOUNT_PATH = "/admin/account";
|
|
105
|
+
export const SETTINGS_ACCOUNTS_PATH = "/admin/accounts";
|
|
104
106
|
export const SETTINGS_TEMPLATES_PATH = "/admin/settings/templates";
|
|
105
107
|
|
|
106
108
|
export interface BuildSettingsNavOptions {
|
|
107
109
|
/** Include the GitHub Enterprise item (its routes are registered). */
|
|
108
110
|
githubEnterprise?: boolean;
|
|
111
|
+
/** Include Account (members) and, admin-only, Accounts (SGL-2.3). */
|
|
112
|
+
accounts?: boolean;
|
|
109
113
|
/** Include the Templates item (its routes are registered). */
|
|
110
114
|
templates?: boolean;
|
|
111
115
|
/** Extension-contributed items (SGL-2.1). */
|
|
@@ -113,8 +117,9 @@ export interface BuildSettingsNavOptions {
|
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
/**
|
|
116
|
-
* Base settings nav (SGL-2.
|
|
117
|
-
*
|
|
120
|
+
* Base settings nav: Account section (SGL-2.3), Platform section (GitHub
|
|
121
|
+
* Enterprise, Templates, admin-only Accounts) plus extension items. Empty
|
|
122
|
+
* sections are dropped.
|
|
118
123
|
*/
|
|
119
124
|
export function buildSettingsNav(
|
|
120
125
|
opts: BuildSettingsNavOptions = {},
|
|
@@ -130,10 +135,23 @@ export function buildSettingsNav(
|
|
|
130
135
|
if (opts.templates) {
|
|
131
136
|
platform.push({ label: "Templates", path: SETTINGS_TEMPLATES_PATH });
|
|
132
137
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
if (opts.accounts) {
|
|
139
|
+
platform.push({
|
|
140
|
+
label: "Accounts",
|
|
141
|
+
path: SETTINGS_ACCOUNTS_PATH,
|
|
142
|
+
adminOnly: true,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const sections: SettingsNavSection[] = [];
|
|
146
|
+
if (opts.accounts) {
|
|
147
|
+
sections.push({
|
|
148
|
+
label: "Account",
|
|
149
|
+
items: [{ label: "Account", path: SETTINGS_ACCOUNT_PATH }],
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (platform.length > 0)
|
|
153
|
+
sections.push({ label: "Platform", items: platform });
|
|
154
|
+
const base: SettingsNav = { sections };
|
|
137
155
|
return mergeSettingsNavItems(base, [...(opts.extraItems ?? [])]);
|
|
138
156
|
}
|
|
139
157
|
|
|
@@ -191,3 +191,31 @@ describe("toolbar Settings entry", () => {
|
|
|
191
191
|
);
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
|
+
|
|
195
|
+
describe("GET /admin/settings with accounts (SGL-2.3)", () => {
|
|
196
|
+
const selfServe = { enabled: true, contactEmail: "c@x.com" };
|
|
197
|
+
const build = (member: string | null) =>
|
|
198
|
+
createAdminUIApp(
|
|
199
|
+
makeMockDeps({
|
|
200
|
+
templateService,
|
|
201
|
+
selfServe,
|
|
202
|
+
accountServices: memberAccounts(member),
|
|
203
|
+
} as never),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
it("lands an account member on Account", async () => {
|
|
207
|
+
const res = await build("m@acme.com").request("/admin/settings", {
|
|
208
|
+
headers: { cookie: await userCookie("m@acme.com") },
|
|
209
|
+
});
|
|
210
|
+
expect(res.status).toBe(302);
|
|
211
|
+
expect(res.headers.get("location")).toBe("/admin/account");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("skips Account for an admin without an account", async () => {
|
|
215
|
+
const res = await build(null).request("/admin/settings", {
|
|
216
|
+
headers: { cookie: await adminCookie() },
|
|
217
|
+
});
|
|
218
|
+
expect(res.status).toBe(302);
|
|
219
|
+
expect(res.headers.get("location")).toBe("/admin/settings/templates");
|
|
220
|
+
});
|
|
221
|
+
});
|