Intelligence, Advanced Charting & Trading Platform
test(ui): prevent embedded Worker history chart drift
davoodmehraban89 committed
Oct 11, 2026 at 23:54 UTC
7a2ef9a360cd0a0f33b4eec4f20f29ae79677c4f
1 file changed
+20
deploy/chartnova/history-ui-sync.test.mjs
new
+20
@@ -0,0 +1,20 @@
1
+import test from "node:test";
2
+import assert from "node:assert/strict";
3
+import fs from "node:fs";
4
+const worker=fs.readFileSync(new URL("./worker.mjs",import.meta.url),"utf8");
5
+const ui=fs.readFileSync(new URL("./history-ui.js",import.meta.url),"utf8").trimEnd();
6
+test("historical chart implementation and embedded Worker UI remain in sync",()=>{
7
+ const at=worker.lastIndexOf("return new Response(")+"return new Response(".length;
8
+ assert(at>=20);
9
+ const match=worker.slice(at).match(/^("(?:\\.|[^"\\])*")/);
10
+ assert(match,"HTML response must have a string literal");
11
+ const html=JSON.parse(match[1]);
12
+ assert(html.includes(ui),"Worker's embedded HTML must contain exactly the maintained history UI");
13
+ assert(html.includes("id=\"historyChart\""));
14
+ assert(html.includes("id=\"historyProvenance\""));
15
+});
16
+test("chart provenance distinguishes direct Neon reads from historical KV fallback",()=>{
17
+ assert.match(ui,/data\.storage/);
18
+ assert(!ui.includes("نسخه خوانش: Cloudflare KV"));
19
+ assert.match(ui,/daily_reference_point_not_ohlc/);
20
+});