Skip to content

Commit 0e25639

Browse files
authored
Merge pull request #151 from ToolboxAid/pr/26175-CHARLIE-007-system-health-environment-identity
PR_26175_CHARLIE_007-system-health-environment-identity
2 parents 9f76a94 + 930daf6 commit 0e25639

8 files changed

Lines changed: 313 additions & 37 deletions

File tree

admin/system-health.html

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ <h2>Admin</h2>
3838
<details class="vertical-accordion" open>
3939
<summary>Health Sections</summary>
4040
<div class="accordion-body content-stack">
41-
<p>Environment Summary</p>
41+
<p>Environment Identity</p>
42+
<p>Environment Map</p>
4243
<p>Local API Startup</p>
4344
<p>Database Health</p>
4445
<p>Storage Health</p>
@@ -57,21 +58,43 @@ <h2>Admin</h2>
5758
<h2 id="admin-system-health-title">System Health Tables</h2>
5859
</div>
5960
<div class="table-wrapper">
60-
<table class="data-table" aria-label="Environment summary">
61-
<caption>Environment Summary</caption>
61+
<table class="data-table" aria-label="Environment identity">
62+
<caption>Environment Identity</caption>
6263
<thead>
6364
<tr>
64-
<th scope="col">Environment</th>
65-
<th scope="col">Purpose</th>
66-
<th scope="col">Promotion Gate</th>
65+
<th scope="col">Field</th>
66+
<th scope="col">Current Deployment</th>
6767
<th scope="col">Status</th>
6868
</tr>
6969
</thead>
7070
<tbody>
71-
<tr><td>DEV</td><td>Local implementation and diagnostics</td><td>Developer validation</td><td data-health-status="PASS">PASS</td></tr>
72-
<tr><td>IST</td><td>Integrated system testing</td><td>Cross-feature validation</td><td data-health-status="PASS">PASS</td></tr>
73-
<tr><td>UAT</td><td>User acceptance testing</td><td>Owner review</td><td data-health-status="PASS">PASS</td></tr>
74-
<tr><td>PRD</td><td>Production runtime</td><td>EOD approval</td><td data-health-status="PASS">PASS</td></tr>
71+
<tr><td>Environment name</td><td data-admin-system-health-environment-value="name">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="name" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
72+
<tr><td>Hosting model</td><td data-admin-system-health-environment-value="hostingModel">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="hostingModel" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
73+
<tr><td>Site URL</td><td data-admin-system-health-environment-value="siteUrl">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="siteUrl" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
74+
<tr><td>API URL</td><td data-admin-system-health-environment-value="apiUrl">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="apiUrl" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
75+
<tr><td>Database model</td><td data-admin-system-health-environment-value="databaseModel">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="databaseModel" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
76+
<tr><td>Storage folder</td><td data-admin-system-health-environment-value="storageFolder">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="storageFolder" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
77+
<tr><td>Last health check</td><td data-admin-system-health-environment-value="lastHealthCheck">Loading</td><td data-health-status="PENDING" data-admin-system-health-environment-status="lastHealthCheck" title="Reason: current environment identity has not loaded yet." aria-label="PENDING: current environment identity has not loaded yet.">PENDING</td></tr>
78+
</tbody>
79+
</table>
80+
</div>
81+
<div class="table-wrapper">
82+
<table class="data-table" aria-label="Environment map">
83+
<caption>Environment Map</caption>
84+
<thead>
85+
<tr>
86+
<th scope="col">Environment</th>
87+
<th scope="col">Hosting model</th>
88+
<th scope="col">Database model</th>
89+
<th scope="col">Storage folder</th>
90+
</tr>
91+
</thead>
92+
<tbody>
93+
<tr><td>Local</td><td>VS Code + Local API</td><td>Local Docker PostgreSQL</td><td>/local</td></tr>
94+
<tr><td>DEV</td><td>Local Docker</td><td>Local Docker PostgreSQL</td><td>/dev</td></tr>
95+
<tr><td>IST</td><td>Local Docker</td><td>Local Docker PostgreSQL</td><td>/ist</td></tr>
96+
<tr><td>UAT</td><td>Cloudflare</td><td>Supabase PostgreSQL</td><td>/uat</td></tr>
97+
<tr><td>PRD</td><td>Cloudflare</td><td>Supabase PostgreSQL</td><td>/prd</td></tr>
7598
</tbody>
7699
</table>
77100
</div>

assets/theme-v2/js/admin-system-health.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ function asText(value, fallback = "not available") {
2222
class AdminSystemHealthController {
2323
constructor(root) {
2424
this.root = root;
25+
this.environmentValues = new Map(Array.from(root.querySelectorAll("[data-admin-system-health-environment-value]")).map((node) => [
26+
node.dataset.adminSystemHealthEnvironmentValue,
27+
node,
28+
]));
29+
this.environmentStatuses = new Map(Array.from(root.querySelectorAll("[data-admin-system-health-environment-status]")).map((node) => [
30+
node.dataset.adminSystemHealthEnvironmentStatus,
31+
node,
32+
]));
2533
this.dbValues = new Map(Array.from(root.querySelectorAll("[data-admin-system-health-db-value]")).map((node) => [
2634
node.dataset.adminSystemHealthDbValue,
2735
node,
@@ -43,7 +51,7 @@ class AdminSystemHealthController {
4351
}
4452

4553
init() {
46-
if ((!this.dbValues.size && !this.storageValues.size) || document.querySelector("[data-session-access-blocked='admin']") || window.GameFoundrySessionGuard?.blocked === true) {
54+
if ((!this.environmentValues.size && !this.dbValues.size && !this.storageValues.size) || document.querySelector("[data-session-access-blocked='admin']") || window.GameFoundrySessionGuard?.blocked === true) {
4755
return;
4856
}
4957
this.load();
@@ -56,6 +64,18 @@ class AdminSystemHealthController {
5664
}
5765
}
5866

67+
setEnvironmentValue(key, value, fallback) {
68+
const node = this.environmentValues.get(key);
69+
if (node) {
70+
node.textContent = asText(value, fallback);
71+
}
72+
}
73+
74+
setEnvironmentStatus(key, status, reason = "") {
75+
const node = this.environmentStatuses.get(key);
76+
this.setStatusNode(node, status, reason);
77+
}
78+
5979
setStorageValue(key, value, fallback) {
6080
const node = this.storageValues.get(key);
6181
if (node) {
@@ -78,13 +98,34 @@ class AdminSystemHealthController {
7898
}
7999

80100
renderPending(reason) {
101+
["name", "hostingModel", "siteUrl", "apiUrl", "databaseModel", "storageFolder", "lastHealthCheck"].forEach((key) => {
102+
this.setEnvironmentStatus(key, "PENDING", reason);
103+
});
81104
["host", "database", "migration", "connection"].forEach((key) => {
82105
this.setStatus(key, "PENDING", reason);
83106
});
84107
this.renderStartupPending(reason);
85108
this.renderStoragePending(reason);
86109
}
87110

111+
renderEnvironmentIdentity(environmentIdentity = {}) {
112+
const reason = environmentIdentity.message || "Current deployment environment identity returned by the safe Admin System Health API.";
113+
this.setEnvironmentValue("name", environmentIdentity.name, "Unknown");
114+
this.setEnvironmentStatus("name", environmentIdentity.status, reason);
115+
this.setEnvironmentValue("hostingModel", environmentIdentity.hostingModel, "not configured");
116+
this.setEnvironmentStatus("hostingModel", environmentIdentity.hostingModel ? "PASS" : "WARN", reason);
117+
this.setEnvironmentValue("siteUrl", environmentIdentity.siteUrl, "not configured");
118+
this.setEnvironmentStatus("siteUrl", environmentIdentity.siteUrlStatus, reason);
119+
this.setEnvironmentValue("apiUrl", environmentIdentity.apiUrl, "not configured");
120+
this.setEnvironmentStatus("apiUrl", environmentIdentity.apiUrlStatus, reason);
121+
this.setEnvironmentValue("databaseModel", environmentIdentity.databaseModel, "not configured");
122+
this.setEnvironmentStatus("databaseModel", environmentIdentity.databaseModel ? "PASS" : "WARN", reason);
123+
this.setEnvironmentValue("storageFolder", environmentIdentity.storageFolder, "not configured");
124+
this.setEnvironmentStatus("storageFolder", environmentIdentity.storageFolderStatus, reason);
125+
this.setEnvironmentValue("lastHealthCheck", environmentIdentity.lastHealthCheck, "not available");
126+
this.setEnvironmentStatus("lastHealthCheck", environmentIdentity.lastHealthCheck ? "PASS" : "WARN", reason);
127+
}
128+
88129
renderStoragePending(reason) {
89130
["bucket", "list", "read", "write", "delete"].forEach((key) => {
90131
this.setStorageStatus(key, "PENDING", reason);
@@ -250,6 +291,7 @@ class AdminSystemHealthController {
250291
this.renderPending("Safe Admin System Health API refused to render because the response exposed secret controls.");
251292
return;
252293
}
294+
this.renderEnvironmentIdentity(data?.environmentIdentity || {});
253295
this.renderPostgresStatus(data?.databaseStatus || {});
254296
this.renderStartupDiagnostics(data?.localApiStartup || {});
255297
this.renderStorageStatus(data?.storageStatus || {});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# PR_26175_CHARLIE_007 System Health Environment Identity
2+
3+
## Scope
4+
5+
Team: Charlie
6+
7+
Purpose: Add current deployment environment identity to Admin System Health and keep the all-environment map as static reference only.
8+
9+
## Changes
10+
11+
- Added a server-owned current environment identity model for Local, DEV, IST, UAT, and PRD.
12+
- Added current deployment fields for environment name, hosting model, site URL, API URL, database model, storage folder, and last health check.
13+
- Replaced the active multi-environment summary table with a current deployment identity table.
14+
- Added a static Environment Map for Local, DEV, IST, UAT, and PRD without health status fields.
15+
- Updated focused API and Playwright tests.
16+
17+
## Architecture Constraint
18+
19+
PASS. System Health displays the current deployment environment only. The Environment Map is static reference content and does not actively health-check other environments.
20+
21+
## Validation
22+
23+
- PASS: `node --check src/dev-runtime/server/local-api-router.mjs`
24+
- PASS: `node --check assets/theme-v2/js/admin-system-health.js`
25+
- PASS: `git diff --check`
26+
- PASS: `node --test tests/dev-runtime/AdminHealthOperations.test.mjs`
27+
- PASS: `npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line`
28+
29+
## Notes
30+
31+
GitHub CLI is unavailable in this workspace. Branch push uses local `git`; draft PR creation uses the GitHub connector when available, otherwise the manual compare URL is reported.

docs_build/dev/reports/coverage_changed_js_guardrail.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Missing changed runtime JS files are WARN, not FAIL.
66
Source: Playwright/Chromium built-in V8 coverage from the active Playwright run.
77

88
Changed runtime JS files considered:
9-
(100%) none changed - no changed runtime JS files
9+
(0%) src/dev-runtime/server/local-api-router.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
10+
(89%) assets/theme-v2/js/admin-system-health.js - executed lines 288/288; executed functions 33/37
1011

1112
Guardrail warnings:
12-
(100%) none changed - no changed runtime JS files
13+
(0%) src/dev-runtime/server/local-api-router.mjs - WARNING: changed runtime JS file missing from coverage; advisory only

docs_build/dev/reports/playwright_v8_coverage_report.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,31 @@ Note: entry percentages use function coverage when available, otherwise line cov
1212
Note: coverage entries are aggregated across every page/tool where coverageReporter.start(page) and coverageReporter.stop(page) ran.
1313

1414
Exercised tool entry points detected:
15-
(69%) Toolbox Index - exercised 3 runtime JS files
15+
(46%) Toolbox Index - exercised 1 runtime JS files
1616
(0%) Tool Template V2 - not exercised by this Playwright run
17-
(74%) Theme V2 Shared JS - exercised 3 runtime JS files
17+
(78%) Theme V2 Shared JS - exercised 4 runtime JS files
1818

1919
Changed runtime JS files covered:
20-
(100%) none changed - no changed runtime JS files
20+
(0%) src/dev-runtime/server/local-api-router.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
21+
(89%) assets/theme-v2/js/admin-system-health.js - executed lines 288/288; executed functions 33/37
2122

2223
Files with executed line/function counts where available:
23-
(8%) src/api/session-api-client.js - executed lines 68/68; executed functions 1/12
24-
(17%) src/api/toolbox-votes-api-client.js - executed lines 46/46; executed functions 1/6
25-
(25%) toolbox/game-hub/game-hub-api-client.js - executed lines 26/26; executed functions 1/4
26-
(36%) src/shared/toolbox/tool-metadata-inventory.js - executed lines 2041/2041; executed functions 12/33
27-
(50%) toolbox/tools-page-accordions.js - executed lines 1156/1156; executed functions 1/2
28-
(59%) assets/toolbox/colors/js/index.js - executed lines 1859/1859; executed functions 122/207
29-
(63%) src/api/server-api-client.js - executed lines 167/167; executed functions 12/19
24+
(36%) src/api/server-api-client.js - executed lines 167/167; executed functions 5/14
25+
(46%) toolbox/tool-registry-api-client.js - executed lines 155/155; executed functions 12/26
3026
(64%) assets/theme-v2/js/tool-display-mode.js - executed lines 204/204; executed functions 9/14
31-
(65%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 1001/1001; executed functions 58/89
3227
(65%) src/api/public-config-client.js - executed lines 209/209; executed functions 17/26
33-
(67%) src/api/game-journey-completion-api-client.js - executed lines 15/15; executed functions 2/3
34-
(76%) toolbox/tool-registry-api-client.js - executed lines 155/155; executed functions 22/29
35-
(100%) assets/theme-v2/js/toolbox-status-bar.js - executed lines 398/398; executed functions 35/35
28+
(74%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 1001/1001; executed functions 69/93
29+
(80%) src/api/admin-owner-navigation.js - executed lines 42/42; executed functions 4/5
30+
(83%) assets/js/shared/status.js - executed lines 37/37; executed functions 5/6
31+
(89%) assets/theme-v2/js/admin-system-health.js - executed lines 288/288; executed functions 33/37
32+
(91%) assets/theme-v2/js/admin-owner-navigation.js - executed lines 58/58; executed functions 10/11
33+
(100%) src/api/admin-system-health-api-client.js - executed lines 19/19; executed functions 3/3
3634

3735
Uncovered or low-coverage changed JS files:
38-
(100%) none changed - no changed runtime JS files
36+
(0%) src/dev-runtime/server/local-api-router.mjs - WARNING: uncovered changed runtime JS file; advisory only
3937

4038
Changed JS files considered:
41-
(0%) assets/toolbox/idea-board/js/index.js - changed JS file not collected as browser runtime coverage
42-
(0%) tests/playwright/tools/IdeaBoardTableNotes.spec.mjs - changed JS file not collected as browser runtime coverage
43-
(0%) tests/playwright/tools/ToolboxRoutePages.spec.mjs - changed JS file not collected as browser runtime coverage
39+
(0%) src/dev-runtime/server/local-api-router.mjs - changed JS file not collected as browser runtime coverage
40+
(0%) tests/dev-runtime/AdminHealthOperations.test.mjs - changed JS file not collected as browser runtime coverage
41+
(0%) tests/playwright/tools/AdminHealthOperationsPage.spec.mjs - changed JS file not collected as browser runtime coverage
42+
(89%) assets/theme-v2/js/admin-system-health.js - changed JS file with browser V8 coverage

0 commit comments

Comments
 (0)