pi-mega-compact 0.11.4 → 0.11.5
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/dist/extensions/dashboard-server/api-contracts/endpoints.js +19 -0
- package/dist/extensions/dashboard-server/api-contracts/memory.js +8 -0
- package/dist/extensions/dashboard-server/api-contracts/provider-cache.js +1 -0
- package/dist/extensions/dashboard-server/api-contracts/setup.js +10 -0
- package/dist/extensions/dashboard-server/index-reader.js +6 -2
- package/dist/extensions/dashboard-server/routes-cache.js +115 -55
- package/dist/extensions/dashboard-server/routes-memory.js +51 -0
- package/dist/extensions/dashboard-server/routes-repo.js +2 -2
- package/dist/extensions/dashboard-server/routes-setup.js +162 -0
- package/dist/extensions/dashboard-server/routes.js +2 -0
- package/dist/extensions/dashboard-server/server.js +7 -1
- package/dist/extensions/mega-commands.js +189 -1
- package/dist/extensions/mega-config.js +2 -0
- package/dist/extensions/mega-events/agent-handlers.js +19 -4
- package/dist/extensions/mega-events/compact-handlers.js +1 -0
- package/dist/extensions/mega-events/context-handler.js +37 -92
- package/dist/extensions/mega-events/context-hwm.js +51 -0
- package/dist/extensions/mega-events/error-classifier.js +16 -5
- package/dist/extensions/mega-events/mirror-append.js +107 -0
- package/dist/extensions/mega-events/outage-advisor.js +7 -1
- package/dist/extensions/mega-events/perf-handler.js +51 -1
- package/dist/extensions/mega-events/recall-tail.js +59 -0
- package/dist/extensions/mega-events/session-handlers.js +15 -8
- package/dist/extensions/mega-runtime/reset-runtime.js +5 -0
- package/dist/extensions/mega-runtime/runtime.js +6 -0
- package/dist/src/embedder.js +41 -2
- package/dist/src/memoryStats.js +75 -0
- package/dist/src/prefix-break.js +43 -0
- package/dist/src/pricing.js +1 -1
- package/dist/src/store/sqlite/perf-samples.js +144 -16
- package/dist/src/store/turns/memory-store.js +8 -0
- package/dist/src/store/turns/sqlite-store.js +14 -3
- package/dist/src/store/turns/types.js +18 -1
- package/dist/src/store/vectorIndex.js +26 -5
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js → AchievementTiles-BoL7qBOJ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js.map → AchievementTiles-BoL7qBOJ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/AchievementsTab-BFDE3HYc.js +2 -0
- package/extensions/dashboard-client/dist/assets/{AchievementsTab-DjxfYrDc.js.map → AchievementsTab-BFDE3HYc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js +2 -0
- package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js → ConfigTab-DDFE-ckA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js.map → ConfigTab-DDFE-ckA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js → EventsTab-B6UxZ7PM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js.map → EventsTab-B6UxZ7PM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js → GameTab-DehUX-KE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js.map → GameTab-DehUX-KE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js → MaintenanceTab-0GWRt4wn.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js.map → MaintenanceTab-0GWRt4wn.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js → MetricsTab-C3rwMVsN.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js.map → MetricsTab-C3rwMVsN.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-39O9_x5j.js +2 -0
- package/extensions/dashboard-client/dist/assets/{OverviewTab-D4kGvsiQ.js.map → OverviewTab-39O9_x5j.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js +2 -0
- package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js → SessionsTab-DXDTCi3r.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js.map → SessionsTab-DXDTCi3r.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js +2 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js +2 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js → TopicsTab-BAw972BV.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js.map → TopicsTab-BAw972BV.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js → TurnsTab-Cf5mGIdl.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js.map → TurnsTab-Cf5mGIdl.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js +2 -0
- package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{index-BX0bcgLu.js → index-4gQ7auad.js} +10 -10
- package/extensions/dashboard-client/dist/assets/index-4gQ7auad.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js +2 -0
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js → useSSE-DNgMuyP6.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js.map → useSSE-DNgMuyP6.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/App.tsx +4 -0
- package/extensions/dashboard-client/src/api/client.ts +14 -0
- package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +21 -12
- package/extensions/dashboard-client/src/components/ProviderCacheCard.tsx +56 -0
- package/extensions/dashboard-client/src/components/SavingsByModelTable.tsx +38 -57
- package/extensions/dashboard-client/src/tabs/CacheTab.tsx +1 -0
- package/extensions/dashboard-client/src/tabs/SetupTab.tsx +355 -0
- package/extensions/dashboard-client/tsconfig.json +3 -2
- package/extensions/dashboard-client/vite.config.ts +2 -0
- package/extensions/dashboard-server/api-contracts/endpoints.ts +36 -3
- package/extensions/dashboard-server/api-contracts/index.ts +7 -0
- package/extensions/dashboard-server/api-contracts/memory.ts +27 -0
- package/extensions/dashboard-server/api-contracts/multi-repo.ts +231 -231
- package/extensions/dashboard-server/api-contracts/provider-cache.ts +37 -0
- package/extensions/dashboard-server/api-contracts/setup.ts +58 -0
- package/extensions/dashboard-server/index-reader.ts +138 -121
- package/extensions/dashboard-server/routes-cache.ts +161 -85
- package/extensions/dashboard-server/routes-memory.ts +63 -0
- package/extensions/dashboard-server/routes-repo.ts +36 -36
- package/extensions/dashboard-server/routes-setup.ts +181 -0
- package/extensions/dashboard-server/routes.ts +2 -0
- package/extensions/dashboard-server/server.ts +6 -0
- package/extensions/mega-commands.ts +211 -1
- package/extensions/mega-config.ts +10 -0
- package/extensions/mega-events/agent-handlers.ts +20 -4
- package/extensions/mega-events/compact-handlers.ts +1 -0
- package/extensions/mega-events/context-handler.ts +45 -110
- package/extensions/mega-events/context-hwm.ts +85 -0
- package/extensions/mega-events/error-classifier.ts +15 -4
- package/extensions/mega-events/mirror-append.ts +155 -0
- package/extensions/mega-events/outage-advisor.ts +11 -5
- package/extensions/mega-events/perf-handler.ts +79 -5
- package/extensions/mega-events/recall-tail.ts +88 -0
- package/extensions/mega-events/session-handlers.ts +14 -7
- package/extensions/mega-runtime/helpers.ts +12 -0
- package/extensions/mega-runtime/reset-runtime.ts +5 -0
- package/extensions/mega-runtime/runtime.ts +6 -0
- package/package.json +5 -2
- package/src/embedder.ts +42 -2
- package/src/memoryStats.ts +107 -0
- package/src/prefix-break.ts +83 -0
- package/src/pricing.ts +2 -2
- package/src/store/sqlite/perf-samples.ts +215 -22
- package/src/store/turns/memory-store.ts +10 -1
- package/src/store/turns/sqlite-store.ts +27 -15
- package/src/store/turns/types.ts +21 -0
- package/src/store/vectorIndex.ts +33 -4
- package/dist/extensions/conflict-scan.test.js +0 -115
- package/dist/extensions/dashboard-server/api-contracts.test.js +0 -884
- package/dist/extensions/dashboard-server/html.test.js +0 -52
- package/dist/extensions/dashboard-server/perf-server.test.js +0 -80
- package/dist/extensions/dashboard-server/routes-cache.test.js +0 -248
- package/dist/extensions/dashboard-server/server.test.js +0 -120
- package/dist/extensions/dashboard-server-s32.test.js +0 -181
- package/dist/extensions/dashboard-server.test.js +0 -339
- package/dist/extensions/mega-cache-replay.test.js +0 -400
- package/dist/extensions/mega-compact-s38.test.js +0 -1383
- package/dist/extensions/mega-compact.test.js +0 -1112
- package/dist/extensions/mega-events.test.js +0 -47
- package/dist/extensions/mega-game-cmds.test.js +0 -163
- package/dist/extensions/mega-runtime/snapshot.test.js +0 -127
- package/dist/extensions/mega-runtime/state.test.js +0 -266
- package/dist/extensions/mega-runtime/widget.test.js +0 -343
- package/dist/extensions/mega-shutdown-widget.test.js +0 -121
- package/dist/extensions/mega-teamrun.test.js +0 -156
- package/dist/extensions/mega-trim.test.js +0 -58
- package/dist/extensions/mega-turn-store.test.js +0 -68
- package/dist/src/boundary.test.js +0 -170
- package/dist/src/compact.test.js +0 -78
- package/dist/src/config/themes.test.js +0 -94
- package/dist/src/dedup/dedup.test.js +0 -41
- package/dist/src/dedup/l1.test.js +0 -50
- package/dist/src/dedup/raptor/buildHistory.test.js +0 -292
- package/dist/src/dedup/raptor/multilevel-serve.test.js +0 -229
- package/dist/src/dedup/raptor/multilevel.test.js +0 -238
- package/dist/src/dedup/raptor/promote.test.js +0 -69
- package/dist/src/dedup/raptor/raptor.test.js +0 -248
- package/dist/src/dedup/raptor/retrieval.test.js +0 -95
- package/dist/src/dedup/raptor/serve-gate.test.js +0 -298
- package/dist/src/dedup/sprint12.test.js +0 -219
- package/dist/src/dedup-engine.test.js +0 -472
- package/dist/src/driftDetection.test.js +0 -87
- package/dist/src/e2e.test.js +0 -698
- package/dist/src/engine.test.js +0 -111
- package/dist/src/extractive.test.js +0 -147
- package/dist/src/fork.test.js +0 -81
- package/dist/src/game/scoring.test.js +0 -98
- package/dist/src/httpEmbedder.test.js +0 -277
- package/dist/src/importance.test.js +0 -372
- package/dist/src/intent.test.js +0 -78
- package/dist/src/log.test.js +0 -42
- package/dist/src/mechanical-fix.test.js +0 -65
- package/dist/src/memory.test.js +0 -70
- package/dist/src/memoryConsolidate.test.js +0 -38
- package/dist/src/memoryOps.test.js +0 -129
- package/dist/src/memoryRecall.test.js +0 -171
- package/dist/src/memoryRoundtrip.test.js +0 -137
- package/dist/src/metrics/turns.test.js +0 -152
- package/dist/src/mirror/mirror.test.js +0 -185
- package/dist/src/raptor-inject-summaries.test.js +0 -162
- package/dist/src/ratio.bench.test.js +0 -897
- package/dist/src/recall.integration.test.js +0 -77
- package/dist/src/recall.test.js +0 -379
- package/dist/src/sprint14.test.js +0 -219
- package/dist/src/sprint4x-rag-verification.test.js +0 -93
- package/dist/src/store/compression.test.js +0 -139
- package/dist/src/store/memoryIndex.test.js +0 -51
- package/dist/src/store/migrate.test.js +0 -139
- package/dist/src/store/pgOpenGuard.test.js +0 -74
- package/dist/src/store/phase01.test.js +0 -81
- package/dist/src/store/phase04.test.js +0 -54
- package/dist/src/store/sprint10.test.js +0 -186
- package/dist/src/store/sqlite/game-achievements.test.js +0 -67
- package/dist/src/store/sqlite/game-scores.test.js +0 -106
- package/dist/src/store/sqlite/game-state.test.js +0 -76
- package/dist/src/store/sqlite/global-index.test.js +0 -136
- package/dist/src/store/sqlite/mechanical-fix.test.js +0 -146
- package/dist/src/store/sqlite/perf-samples.test.js +0 -146
- package/dist/src/store/sqlite/raptor.test.js +0 -106
- package/dist/src/store/sqlite/turns.test.js +0 -183
- package/dist/src/store/sqlite.cachehit.test.js +0 -55
- package/dist/src/store/sqlite.dbmaint.test.js +0 -158
- package/dist/src/store/sqlite.dbmirror.test.js +0 -184
- package/dist/src/store/turns/contract-compliance.test.js +0 -428
- package/dist/src/store/turns/memory-store.test.js +0 -9
- package/dist/src/store/turns/migrations.test.js +0 -138
- package/dist/src/store/turns/sqlite-store.test.js +0 -144
- package/dist/src/store/vectorIndex.test.js +0 -123
- package/dist/src/store.test.js +0 -161
- package/dist/src/supersede.test.js +0 -36
- package/dist/src/topics/cluster.test.js +0 -150
- package/dist/src/topics/store.test.js +0 -117
- package/dist/src/types.test.js +0 -9
- package/dist/src/vector-search-cache.test.js +0 -157
- package/dist/src/vectorStore.test.js +0 -479
- package/dist/src/wiki.test.js +0 -171
- package/extensions/conflict-scan.test.ts +0 -129
- package/extensions/dashboard-client/dist/assets/AchievementsTab-DjxfYrDc.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-D4kGvsiQ.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js +0 -2
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js.map +0 -1
- package/extensions/dashboard-server/api-contracts.test.ts +0 -1065
- package/extensions/dashboard-server/html.test.ts +0 -62
- package/extensions/dashboard-server/perf-server.test.ts +0 -101
- package/extensions/dashboard-server/routes-cache.test.ts +0 -302
- package/extensions/dashboard-server/server.test.ts +0 -131
- package/extensions/dashboard-server-s32.test.ts +0 -195
- package/extensions/dashboard-server.test.ts +0 -382
- package/extensions/mega-cache-replay.test.ts +0 -526
- package/extensions/mega-compact-s38.test.ts +0 -1433
- package/extensions/mega-compact.test.ts +0 -1509
- package/extensions/mega-events.test.ts +0 -55
- package/extensions/mega-game-cmds.test.ts +0 -197
- package/extensions/mega-runtime/snapshot.test.ts +0 -139
- package/extensions/mega-runtime/state.test.ts +0 -262
- package/extensions/mega-runtime/widget.test.ts +0 -468
- package/extensions/mega-shutdown-widget.test.ts +0 -141
- package/extensions/mega-teamrun.test.ts +0 -176
- package/extensions/mega-trim.test.ts +0 -64
- package/extensions/mega-turn-store.test.ts +0 -108
- package/src/boundary.test.ts +0 -187
- package/src/compact.test.ts +0 -99
- package/src/config/themes.test.ts +0 -116
- package/src/dedup/dedup.test.ts +0 -46
- package/src/dedup/l1.test.ts +0 -57
- package/src/dedup/raptor/buildHistory.test.ts +0 -353
- package/src/dedup/raptor/multilevel-serve.test.ts +0 -273
- package/src/dedup/raptor/multilevel.test.ts +0 -325
- package/src/dedup/raptor/promote.test.ts +0 -82
- package/src/dedup/raptor/raptor.test.ts +0 -297
- package/src/dedup/raptor/retrieval.test.ts +0 -118
- package/src/dedup/raptor/serve-gate.test.ts +0 -348
- package/src/dedup/sprint12.test.ts +0 -242
- package/src/dedup-engine.test.ts +0 -670
- package/src/driftDetection.test.ts +0 -100
- package/src/e2e.test.ts +0 -843
- package/src/engine.test.ts +0 -123
- package/src/extractive.test.ts +0 -174
- package/src/fork.test.ts +0 -94
- package/src/game/scoring.test.ts +0 -103
- package/src/httpEmbedder.test.ts +0 -286
- package/src/importance.test.ts +0 -538
- package/src/intent.test.ts +0 -87
- package/src/log.test.ts +0 -47
- package/src/mechanical-fix.test.ts +0 -70
- package/src/memory.test.ts +0 -92
- package/src/memoryConsolidate.test.ts +0 -47
- package/src/memoryOps.test.ts +0 -148
- package/src/memoryRecall.test.ts +0 -194
- package/src/memoryRoundtrip.test.ts +0 -155
- package/src/metrics/turns.test.ts +0 -165
- package/src/mirror/mirror.test.ts +0 -240
- package/src/raptor-inject-summaries.test.ts +0 -228
- package/src/ratio.bench.test.ts +0 -1316
- package/src/recall.integration.test.ts +0 -96
- package/src/recall.test.ts +0 -467
- package/src/sprint14.test.ts +0 -245
- package/src/sprint4x-rag-verification.test.ts +0 -119
- package/src/store/compression.test.ts +0 -168
- package/src/store/memoryIndex.test.ts +0 -61
- package/src/store/migrate.test.ts +0 -158
- package/src/store/pgOpenGuard.test.ts +0 -89
- package/src/store/phase01.test.ts +0 -88
- package/src/store/phase04.test.ts +0 -58
- package/src/store/sprint10.test.ts +0 -214
- package/src/store/sqlite/game-achievements.test.ts +0 -80
- package/src/store/sqlite/game-scores.test.ts +0 -132
- package/src/store/sqlite/game-state.test.ts +0 -89
- package/src/store/sqlite/global-index.test.ts +0 -222
- package/src/store/sqlite/mechanical-fix.test.ts +0 -162
- package/src/store/sqlite/perf-samples.test.ts +0 -169
- package/src/store/sqlite/raptor.test.ts +0 -139
- package/src/store/sqlite/turns.test.ts +0 -218
- package/src/store/sqlite.cachehit.test.ts +0 -68
- package/src/store/sqlite.dbmaint.test.ts +0 -193
- package/src/store/sqlite.dbmirror.test.ts +0 -229
- package/src/store/turns/contract-compliance.test.ts +0 -562
- package/src/store/turns/memory-store.test.ts +0 -15
- package/src/store/turns/migrations.test.ts +0 -161
- package/src/store/turns/sqlite-store.test.ts +0 -161
- package/src/store/vectorIndex.test.ts +0 -140
- package/src/store.test.ts +0 -191
- package/src/supersede.test.ts +0 -42
- package/src/topics/cluster.test.ts +0 -176
- package/src/topics/store.test.ts +0 -132
- package/src/types.test.ts +0 -10
- package/src/vector-search-cache.test.ts +0 -190
- package/src/vectorStore.test.ts +0 -533
- package/src/wiki.test.ts +0 -217
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* html.test.ts — S34 Game Mode tab presence in the dashboard HTML template.
|
|
3
|
-
*/
|
|
4
|
-
import { test, describe } from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { dashboardHtml } from "./html.js";
|
|
7
|
-
describe("S34 dashboard HTML Game Mode", () => {
|
|
8
|
-
const html = dashboardHtml("custom");
|
|
9
|
-
test("Game Mode tab button + panel-game exist", () => {
|
|
10
|
-
assert.ok(html.includes('<button class="tab" data-tab="game">Game Mode</button>'), "game tab button present");
|
|
11
|
-
assert.ok(html.includes('<div class="tab-panel" id="panel-game">'), "panel-game present");
|
|
12
|
-
});
|
|
13
|
-
test("level-up-pulse + mega-flash keyframes present", () => {
|
|
14
|
-
assert.ok(html.includes("@keyframes level-up-pulse"), "level-up-pulse keyframe present");
|
|
15
|
-
assert.ok(html.includes("@keyframes mega-flash"), "mega-flash keyframe present");
|
|
16
|
-
});
|
|
17
|
-
test("empty-state string present", () => {
|
|
18
|
-
assert.ok(html.includes("No scores yet — run a session with game mode on."), "empty-state string present");
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe("S35 dashboard HTML achievements", () => {
|
|
22
|
-
const html = dashboardHtml("custom");
|
|
23
|
-
test("Achievements heading + ach-tiles/ach-toast containers present", () => {
|
|
24
|
-
assert.ok(html.includes(">Achievements</h3>"), "Achievements heading present");
|
|
25
|
-
assert.ok(html.includes('id="ach-tiles"'), "ach-tiles container present");
|
|
26
|
-
assert.ok(html.includes('id="ach-toast"'), "ach-toast element present");
|
|
27
|
-
});
|
|
28
|
-
test("ach-unlock-pulse keyframe + ach-tile classes present", () => {
|
|
29
|
-
assert.ok(html.includes("@keyframes ach-unlock-pulse"), "ach-unlock-pulse keyframe present");
|
|
30
|
-
assert.ok(html.includes(".ach-tile"), "ach-tile class present");
|
|
31
|
-
assert.ok(html.includes(".ach-tile.unlocked"), "unlocked class present");
|
|
32
|
-
assert.ok(html.includes(".ach-tile.locked"), "locked class present");
|
|
33
|
-
});
|
|
34
|
-
test("renderAchievements fn + GET /api/achievements fetch present", () => {
|
|
35
|
-
assert.ok(html.includes("function renderAchievements"), "renderAchievements fn present");
|
|
36
|
-
assert.ok(html.includes("fetch('/api/achievements')"), "achievements fetch present");
|
|
37
|
-
});
|
|
38
|
-
test("visible-but-locked teaser string present", () => {
|
|
39
|
-
assert.ok(html.includes("??? "), "??? teaser present");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe("S35 dashboard HTML achievements escaping (v0.8.4 fix)", () => {
|
|
43
|
-
const html = dashboardHtml("custom");
|
|
44
|
-
test("Opie's Wild Ride JS string is backslash-escaped (no bare apostrophe)", () => {
|
|
45
|
-
// The served <script> uses single-quoted JS strings: '🏆 Opie\'s Wild Ride...'.
|
|
46
|
-
// A bare apostrophe (Opie's) would terminate the string and halt the script,
|
|
47
|
-
// breaking .tab click bindings. The served HTML MUST contain the escaped
|
|
48
|
-
// form Opie\'s and MUST NOT contain the bare form '🏆 Opie's'.
|
|
49
|
-
assert.ok(html.includes("🏆 Opie\\'s Wild Ride"), "served JS contains Opie\\'s (escaped)");
|
|
50
|
-
assert.ok(!html.includes("🏆 Opie's Wild Ride"), "no bare Opie's in served JS");
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* perf-server.test.ts — v0.8.8 /api/perf endpoint (GET aggregates + 405).
|
|
3
|
-
* Mirrors the server.test.ts spawn-and-fetch harness (self-contained so the
|
|
4
|
-
* dashboard HTTP-port lane stays isolated).
|
|
5
|
-
*/
|
|
6
|
-
import { test, describe } from "node:test";
|
|
7
|
-
import assert from "node:assert/strict";
|
|
8
|
-
import { mkdtempSync, rmSync, readFileSync } from "node:fs";
|
|
9
|
-
import { tmpdir } from "node:os";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import { spawn } from "node:child_process";
|
|
12
|
-
import { recordPerfSample } from "../../src/store/sqlite.js";
|
|
13
|
-
const SERVER_ENTRY = new URL("./server.js", import.meta.url).pathname;
|
|
14
|
-
function waitFor(cond, timeoutMs = 6000) {
|
|
15
|
-
const start = Date.now();
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
const tick = async () => {
|
|
18
|
-
if (await cond())
|
|
19
|
-
return resolve();
|
|
20
|
-
if (Date.now() - start > timeoutMs)
|
|
21
|
-
return reject(new Error("timeout"));
|
|
22
|
-
setTimeout(tick, 50);
|
|
23
|
-
};
|
|
24
|
-
tick();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function freshDir(prefix) {
|
|
28
|
-
return mkdtempSync(join(tmpdir(), prefix));
|
|
29
|
-
}
|
|
30
|
-
async function withServer(port, dir, fn) {
|
|
31
|
-
process.env.MEGACOMPACT_DASHBOARD_PORT = port;
|
|
32
|
-
const child = spawn(process.execPath, [SERVER_ENTRY, dir], { stdio: "ignore" });
|
|
33
|
-
try {
|
|
34
|
-
await waitFor(async () => {
|
|
35
|
-
try {
|
|
36
|
-
const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
|
|
37
|
-
const res = await fetch(`http://localhost:${raw.port}/api/version`);
|
|
38
|
-
return res.ok;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
|
|
45
|
-
return await fn(raw.port);
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
child.kill("SIGTERM");
|
|
49
|
-
delete process.env.MEGACOMPACT_DASHBOARD_PORT;
|
|
50
|
-
rmSync(dir, { recursive: true, force: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
describe("v0.8.8 /api/perf", () => {
|
|
54
|
-
test("GET returns aggregates over recorded perf_samples", async () => {
|
|
55
|
-
const dir = freshDir("dash-perf-agg-");
|
|
56
|
-
recordPerfSample(dir, "turn_latency_ms", 100, { turnIndex: 1 });
|
|
57
|
-
recordPerfSample(dir, "turn_latency_ms", 200);
|
|
58
|
-
recordPerfSample(dir, "tps", 50);
|
|
59
|
-
recordPerfSample(dir, "rss_mb", 256);
|
|
60
|
-
await withServer("19440", dir, async (port) => {
|
|
61
|
-
const res = await fetch(`http://localhost:${port}/api/perf?minutes=30`);
|
|
62
|
-
assert.equal(res.status, 200);
|
|
63
|
-
const d = (await res.json());
|
|
64
|
-
assert.equal(d.sampleCount, 4);
|
|
65
|
-
assert.equal(d.turn_latency_ms.n, 2);
|
|
66
|
-
assert.equal(d.turn_latency_ms.p50, 100); // nearest-rank p50 of [100,200]
|
|
67
|
-
assert.equal(d.turn_latency_ms.p95, 200); // nearest-rank p95 of [100,200]
|
|
68
|
-
assert.equal(d.tps.avg, 50);
|
|
69
|
-
assert.equal(d.rss_mb.latest, 256);
|
|
70
|
-
assert.equal(d.diag, null); // no runtime wrote dashboard.json in this dir
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
test("non-GET (POST) -> 405", async () => {
|
|
74
|
-
const dir = freshDir("dash-perf-meth-");
|
|
75
|
-
await withServer("19441", dir, async (port) => {
|
|
76
|
-
const res = await fetch(`http://localhost:${port}/api/perf`, { method: "POST" });
|
|
77
|
-
assert.equal(res.status, 405);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* routes-cache.test.ts — Sprint A /api/provider-cache endpoint tests.
|
|
3
|
-
*
|
|
4
|
-
* Covers the A.4 spec:
|
|
5
|
-
* - GET 200 → shape matches ProviderCacheResponse
|
|
6
|
-
* - POST → 405
|
|
7
|
-
* - empty perf_samples → zeros/nulls
|
|
8
|
-
* - no model snapshot → savings: null
|
|
9
|
-
* - with model snapshot → priced savings fields
|
|
10
|
-
*
|
|
11
|
-
* Uses the same spawn-and-fetch harness as perf-server.test.ts.
|
|
12
|
-
*/
|
|
13
|
-
import { test, describe } from "node:test";
|
|
14
|
-
import assert from "node:assert/strict";
|
|
15
|
-
import { mkdtempSync, rmSync, readFileSync } from "node:fs";
|
|
16
|
-
import { tmpdir } from "node:os";
|
|
17
|
-
import { join } from "node:path";
|
|
18
|
-
import { spawn } from "node:child_process";
|
|
19
|
-
import { recordPerfSample, recordModelSnapshot, } from "../../src/store/sqlite.js";
|
|
20
|
-
const SERVER_ENTRY = new URL("./server.js", import.meta.url).pathname;
|
|
21
|
-
function waitFor(cond, timeoutMs = 6000) {
|
|
22
|
-
const start = Date.now();
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
const tick = async () => {
|
|
25
|
-
if (await cond())
|
|
26
|
-
return resolve();
|
|
27
|
-
if (Date.now() - start > timeoutMs)
|
|
28
|
-
return reject(new Error("timeout"));
|
|
29
|
-
setTimeout(tick, 50);
|
|
30
|
-
};
|
|
31
|
-
tick();
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function freshDir(prefix) {
|
|
35
|
-
return mkdtempSync(join(tmpdir(), prefix));
|
|
36
|
-
}
|
|
37
|
-
async function withServer(port, dir, fn) {
|
|
38
|
-
process.env.MEGACOMPACT_DASHBOARD_PORT = port;
|
|
39
|
-
const child = spawn(process.execPath, [SERVER_ENTRY, dir], {
|
|
40
|
-
stdio: "ignore",
|
|
41
|
-
});
|
|
42
|
-
try {
|
|
43
|
-
await waitFor(async () => {
|
|
44
|
-
try {
|
|
45
|
-
const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
|
|
46
|
-
const res = await fetch(`http://localhost:${raw.port}/api/version`);
|
|
47
|
-
return res.ok;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
|
|
54
|
-
return await fn(raw.port);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
child.kill("SIGTERM");
|
|
58
|
-
delete process.env.MEGACOMPACT_DASHBOARD_PORT;
|
|
59
|
-
rmSync(dir, { recursive: true, force: true });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
describe("/api/provider-cache", () => {
|
|
63
|
-
test("GET 200 — shape matches ProviderCacheResponse", async () => {
|
|
64
|
-
const dir = freshDir("dash-pcache-agg-");
|
|
65
|
-
// Seed one cache_hit_pct sample with full meta.
|
|
66
|
-
recordPerfSample(dir, "cache_hit_pct", 42, {
|
|
67
|
-
cacheRead: 100,
|
|
68
|
-
cacheWrite: 20,
|
|
69
|
-
input: 500,
|
|
70
|
-
});
|
|
71
|
-
await withServer("19450", dir, async (port) => {
|
|
72
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
73
|
-
assert.equal(res.status, 200);
|
|
74
|
-
const body = (await res.json());
|
|
75
|
-
// Shape assertions
|
|
76
|
-
assert.ok("cache" in body, "should have cache");
|
|
77
|
-
assert.ok("savings" in body, "should have savings");
|
|
78
|
-
assert.ok("updatedAt" in body, "should have updatedAt");
|
|
79
|
-
assert.equal(body.cache.turnCount, 1);
|
|
80
|
-
assert.equal(body.cache.totalCacheRead, 100);
|
|
81
|
-
assert.equal(body.cache.totalCacheWrite, 20);
|
|
82
|
-
assert.equal(body.cache.totalInput, 500);
|
|
83
|
-
assert.ok(typeof body.cache.firstTurnAt === "string");
|
|
84
|
-
assert.ok(typeof body.cache.latestTurnAt === "string");
|
|
85
|
-
assert.ok(typeof body.updatedAt === "string");
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
test("GET 200 — empty perf_samples returns zeros/nulls", async () => {
|
|
89
|
-
const dir = freshDir("dash-pcache-empty-");
|
|
90
|
-
await withServer("19451", dir, async (port) => {
|
|
91
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
92
|
-
assert.equal(res.status, 200);
|
|
93
|
-
const body = (await res.json());
|
|
94
|
-
assert.equal(body.cache.turnCount, 0);
|
|
95
|
-
assert.equal(body.cache.avgHitPct, 0);
|
|
96
|
-
assert.equal(body.cache.totalCacheRead, 0);
|
|
97
|
-
assert.equal(body.cache.totalCacheWrite, 0);
|
|
98
|
-
assert.equal(body.cache.totalInput, 0);
|
|
99
|
-
assert.equal(body.cache.firstTurnAt, null);
|
|
100
|
-
assert.equal(body.cache.latestTurnAt, null);
|
|
101
|
-
assert.equal(body.savings, null);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
test("POST → 405", async () => {
|
|
105
|
-
const dir = freshDir("dash-pcache-meth-");
|
|
106
|
-
await withServer("19452", dir, async (port) => {
|
|
107
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`, {
|
|
108
|
-
method: "POST",
|
|
109
|
-
});
|
|
110
|
-
assert.equal(res.status, 405);
|
|
111
|
-
const body = (await res.json());
|
|
112
|
-
assert.equal(body.error, "method_not_allowed");
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
test("no model snapshot → savings: null", async () => {
|
|
116
|
-
const dir = freshDir("dash-pcache-nosnap-");
|
|
117
|
-
recordPerfSample(dir, "cache_hit_pct", 50, {
|
|
118
|
-
cacheRead: 200,
|
|
119
|
-
cacheWrite: 30,
|
|
120
|
-
input: 1000,
|
|
121
|
-
});
|
|
122
|
-
await withServer("19453", dir, async (port) => {
|
|
123
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
124
|
-
assert.equal(res.status, 200);
|
|
125
|
-
const body = (await res.json());
|
|
126
|
-
assert.equal(body.savings, null);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
test("with model snapshot → priced savings fields", async () => {
|
|
130
|
-
const dir = freshDir("dash-pcache-savings-");
|
|
131
|
-
recordPerfSample(dir, "cache_hit_pct", 50, {
|
|
132
|
-
cacheRead: 2000,
|
|
133
|
-
cacheWrite: 400,
|
|
134
|
-
input: 10000,
|
|
135
|
-
});
|
|
136
|
-
// Record a model snapshot with a known input rate.
|
|
137
|
-
recordModelSnapshot("/tmp/test-repo", {
|
|
138
|
-
provider: "anthropic",
|
|
139
|
-
providerName: "Anthropic",
|
|
140
|
-
modelId: "claude-sonnet-4-20250514",
|
|
141
|
-
modelName: "Claude Sonnet 4",
|
|
142
|
-
inputRate: 3e-6, // $3 / 1M tokens
|
|
143
|
-
outputRate: 15e-6,
|
|
144
|
-
contextWindow: 200000,
|
|
145
|
-
maxTokens: 32000,
|
|
146
|
-
reasoning: false,
|
|
147
|
-
}, dir);
|
|
148
|
-
await withServer("19454", dir, async (port) => {
|
|
149
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
150
|
-
assert.equal(res.status, 200);
|
|
151
|
-
const body = (await res.json());
|
|
152
|
-
assert.ok(body.savings, "savings should not be null");
|
|
153
|
-
// cacheReadSaved = 2000 * 3e-6 * 0.9 = 0.0054
|
|
154
|
-
assert.ok(body.savings.cacheReadSaved > 0, "cacheReadSaved > 0");
|
|
155
|
-
// cacheWriteCost = 400 * 3e-6 * 0.25 = 0.0003
|
|
156
|
-
assert.ok(body.savings.cacheWriteCost > 0, "cacheWriteCost > 0");
|
|
157
|
-
assert.ok(body.savings.netSaved ===
|
|
158
|
-
body.savings.cacheReadSaved - body.savings.cacheWriteCost, "netSaved = cacheReadSaved - cacheWriteCost");
|
|
159
|
-
assert.equal(body.savings.model, "Claude Sonnet 4");
|
|
160
|
-
assert.equal(body.savings.inputRate, 3e-6);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
test("partial meta (missing fields) → treated as 0", async () => {
|
|
164
|
-
const dir = freshDir("dash-pcache-partial-");
|
|
165
|
-
// Only input in meta; cacheRead/cacheWrite missing → treated as 0.
|
|
166
|
-
recordPerfSample(dir, "cache_hit_pct", 30, { input: 800 });
|
|
167
|
-
// Only cacheRead in meta; input/cacheWrite missing → treated as 0.
|
|
168
|
-
recordPerfSample(dir, "cache_hit_pct", 60, { cacheRead: 150 });
|
|
169
|
-
await withServer("19455", dir, async (port) => {
|
|
170
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
171
|
-
assert.equal(res.status, 200);
|
|
172
|
-
const body = (await res.json());
|
|
173
|
-
// First sample: input=800, cacheRead=0, cacheWrite=0
|
|
174
|
-
// Second sample: cacheRead=150, input=0, cacheWrite=0
|
|
175
|
-
assert.equal(body.cache.turnCount, 2);
|
|
176
|
-
assert.equal(body.cache.totalCacheRead, 150);
|
|
177
|
-
assert.equal(body.cache.totalCacheWrite, 0);
|
|
178
|
-
assert.equal(body.cache.totalInput, 800);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
test("NULL meta → counted in turnCount, contributes 0 tokens + 0 avg", async () => {
|
|
182
|
-
const dir = freshDir("dash-pcache-nullmeta-");
|
|
183
|
-
// avgHitPct is derived from (cacheRead / (cacheRead + input + cacheWrite)) * 100,
|
|
184
|
-
// NOT from the `value` column. NULL meta → no tokens → avg 0, not 25.
|
|
185
|
-
recordPerfSample(dir, "cache_hit_pct", 25, undefined);
|
|
186
|
-
await withServer("19456", dir, async (port) => {
|
|
187
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
188
|
-
assert.equal(res.status, 200);
|
|
189
|
-
const body = (await res.json());
|
|
190
|
-
assert.equal(body.cache.turnCount, 1);
|
|
191
|
-
assert.equal(body.cache.avgHitPct, 0);
|
|
192
|
-
assert.equal(body.cache.totalCacheRead, 0);
|
|
193
|
-
assert.equal(body.cache.totalCacheWrite, 0);
|
|
194
|
-
assert.equal(body.cache.totalInput, 0);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
test("model snapshot with modelName=null → falls back to modelId", async () => {
|
|
198
|
-
const dir = freshDir("dash-pcache-modelid-");
|
|
199
|
-
recordPerfSample(dir, "cache_hit_pct", 10, {
|
|
200
|
-
cacheRead: 100,
|
|
201
|
-
cacheWrite: 10,
|
|
202
|
-
input: 1000,
|
|
203
|
-
});
|
|
204
|
-
recordModelSnapshot("/tmp/test-repo", {
|
|
205
|
-
provider: "openai",
|
|
206
|
-
providerName: null,
|
|
207
|
-
modelId: "gpt-4o",
|
|
208
|
-
modelName: null,
|
|
209
|
-
inputRate: 2.5e-6,
|
|
210
|
-
outputRate: 10e-6,
|
|
211
|
-
contextWindow: 128000,
|
|
212
|
-
maxTokens: 16384,
|
|
213
|
-
reasoning: false,
|
|
214
|
-
}, dir);
|
|
215
|
-
await withServer("19457", dir, async (port) => {
|
|
216
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
217
|
-
assert.equal(res.status, 200);
|
|
218
|
-
const body = (await res.json());
|
|
219
|
-
assert.ok(body.savings);
|
|
220
|
-
assert.equal(body.savings.model, "gpt-4o");
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
test("model snapshot with zero inputRate → savings: null", async () => {
|
|
224
|
-
const dir = freshDir("dash-pcache-zerorate-");
|
|
225
|
-
recordPerfSample(dir, "cache_hit_pct", 10, {
|
|
226
|
-
cacheRead: 100,
|
|
227
|
-
cacheWrite: 10,
|
|
228
|
-
input: 1000,
|
|
229
|
-
});
|
|
230
|
-
recordModelSnapshot("/tmp/test-repo", {
|
|
231
|
-
provider: "local",
|
|
232
|
-
providerName: null,
|
|
233
|
-
modelId: "local-llm",
|
|
234
|
-
modelName: null,
|
|
235
|
-
inputRate: 0,
|
|
236
|
-
outputRate: 0,
|
|
237
|
-
contextWindow: 4096,
|
|
238
|
-
maxTokens: 2048,
|
|
239
|
-
reasoning: false,
|
|
240
|
-
}, dir);
|
|
241
|
-
await withServer("19458", dir, async (port) => {
|
|
242
|
-
const res = await fetch(`http://localhost:${port}/api/provider-cache`);
|
|
243
|
-
assert.equal(res.status, 200);
|
|
244
|
-
const body = (await res.json());
|
|
245
|
-
assert.equal(body.savings, null);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
});
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server.test.ts — S34 /api/game-scores endpoint (GET leaderboard, metric
|
|
3
|
-
* validation, method + limit handling). Mirrors the S32 /api/game-state
|
|
4
|
-
* spawn-and-fetch harness.
|
|
5
|
-
*/
|
|
6
|
-
import { test, describe } from "node:test";
|
|
7
|
-
import assert from "node:assert/strict";
|
|
8
|
-
import { mkdtempSync, rmSync, readFileSync } from "node:fs";
|
|
9
|
-
import { tmpdir } from "node:os";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import { spawn } from "node:child_process";
|
|
12
|
-
import { recordScore } from "../../src/store/sqlite.js";
|
|
13
|
-
const SERVER_ENTRY = new URL("./server.js", import.meta.url).pathname;
|
|
14
|
-
function waitFor(cond, timeoutMs = 6000) {
|
|
15
|
-
const start = Date.now();
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
const tick = async () => {
|
|
18
|
-
if (await cond())
|
|
19
|
-
return resolve();
|
|
20
|
-
if (Date.now() - start > timeoutMs)
|
|
21
|
-
return reject(new Error("timeout"));
|
|
22
|
-
setTimeout(tick, 50);
|
|
23
|
-
};
|
|
24
|
-
tick();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function freshDir(prefix) {
|
|
28
|
-
return mkdtempSync(join(tmpdir(), prefix));
|
|
29
|
-
}
|
|
30
|
-
async function withServer(port, dir, fn) {
|
|
31
|
-
process.env.MEGACOMPACT_DASHBOARD_PORT = port;
|
|
32
|
-
const child = spawn(process.execPath, [SERVER_ENTRY, dir], { stdio: "ignore" });
|
|
33
|
-
try {
|
|
34
|
-
await waitFor(async () => {
|
|
35
|
-
try {
|
|
36
|
-
const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
|
|
37
|
-
const res = await fetch(`http://localhost:${raw.port}/api/version`);
|
|
38
|
-
return res.ok;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
|
|
45
|
-
return await fn(raw.port);
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
child.kill("SIGTERM");
|
|
49
|
-
delete process.env.MEGACOMPACT_DASHBOARD_PORT;
|
|
50
|
-
rmSync(dir, { recursive: true, force: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
describe("S34 /api/game-scores", () => {
|
|
54
|
-
test("GET ?metric=cache returns recorded rows as JSON array", async () => {
|
|
55
|
-
const dir = freshDir("dash-gs-cache-");
|
|
56
|
-
recordScore(dir, { repo_root: "/repo/a", metric: "cache", value: 42 });
|
|
57
|
-
await withServer("19430", dir, async (port) => {
|
|
58
|
-
const res = await fetch(`http://localhost:${port}/api/game-scores?metric=cache`);
|
|
59
|
-
assert.equal(res.status, 200);
|
|
60
|
-
const rows = (await res.json());
|
|
61
|
-
assert.ok(Array.isArray(rows));
|
|
62
|
-
assert.equal(rows.length, 1);
|
|
63
|
-
assert.equal(rows[0].repo_root, "/repo/a");
|
|
64
|
-
assert.equal(rows[0].value, 42);
|
|
65
|
-
assert.ok(typeof rows[0].ts === "number");
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
test("unknown metric -> 400", async () => {
|
|
69
|
-
const dir = freshDir("dash-gs-bad-");
|
|
70
|
-
await withServer("19431", dir, async (port) => {
|
|
71
|
-
const res = await fetch(`http://localhost:${port}/api/game-scores?metric=bogus`);
|
|
72
|
-
assert.equal(res.status, 400);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
test("non-GET (POST) -> 405", async () => {
|
|
76
|
-
const dir = freshDir("dash-gs-meth-");
|
|
77
|
-
await withServer("19432", dir, async (port) => {
|
|
78
|
-
const res = await fetch(`http://localhost:${port}/api/game-scores`, { method: "POST" });
|
|
79
|
-
assert.equal(res.status, 405);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
test("limit clamp: 3 rows -> default 10 returns 3, limit=2 caps to 2, limit<=0 clamps to >=1", async () => {
|
|
83
|
-
const dir = freshDir("dash-gs-lim-");
|
|
84
|
-
recordScore(dir, { repo_root: "/repo/a", metric: "cache", value: 1 });
|
|
85
|
-
recordScore(dir, { repo_root: "/repo/b", metric: "cache", value: 2 });
|
|
86
|
-
recordScore(dir, { repo_root: "/repo/c", metric: "cache", value: 3 });
|
|
87
|
-
await withServer("19433", dir, async (port) => {
|
|
88
|
-
const all = (await fetch(`http://localhost:${port}/api/game-scores?metric=cache`).then((r) => r.json()));
|
|
89
|
-
assert.equal(all.length, 3);
|
|
90
|
-
const capped = (await fetch(`http://localhost:${port}/api/game-scores?metric=cache&limit=2`).then((r) => r.json()));
|
|
91
|
-
assert.equal(capped.length, 2);
|
|
92
|
-
const zero = (await fetch(`http://localhost:${port}/api/game-scores?metric=cache&limit=0`).then((r) => r.json()));
|
|
93
|
-
assert.ok(zero.length >= 1, "limit<=0 clamps to >=1 row");
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
describe("S35 /api/achievements", () => {
|
|
98
|
-
test("GET returns the 9 seeded achievement rows", async () => {
|
|
99
|
-
const dir = freshDir("dash-ach-");
|
|
100
|
-
await withServer("19434", dir, async (port) => {
|
|
101
|
-
const res = await fetch(`http://localhost:${port}/api/achievements`);
|
|
102
|
-
assert.equal(res.status, 200);
|
|
103
|
-
const rows = (await res.json());
|
|
104
|
-
assert.ok(Array.isArray(rows));
|
|
105
|
-
assert.equal(rows.length, 9);
|
|
106
|
-
const opie = rows.find((r) => r.id === "opie_wild_ride");
|
|
107
|
-
assert.ok(opie, "opie_wild_ride seeded");
|
|
108
|
-
assert.equal(opie.hidden, 1);
|
|
109
|
-
assert.equal(opie.unlocked_at, null);
|
|
110
|
-
assert.equal(rows.find((r) => r.id === "first_compact").title, "First Compact");
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
test("non-GET (POST) -> 405", async () => {
|
|
114
|
-
const dir = freshDir("dash-ach-meth-");
|
|
115
|
-
await withServer("19435", dir, async (port) => {
|
|
116
|
-
const res = await fetch(`http://localhost:${port}/api/achievements`, { method: "POST" });
|
|
117
|
-
assert.equal(res.status, 405);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|