Intelligence, Advanced Charting & Trading Platform

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").replace(/\r\n/g,"\n").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 });