Files
Jyotisha/frontend/tests/chart-request-skip-contract.test.ts
T
jesse-uxGrok (agent loop)Cursor
336286e428 fix(chart): skip unused synastry overview and doomed report subprocesses
Synastry charts now skip the unused external overview and run together. Reports skip PyJHora subprocesses when that library is missing, and a full heavy-compute slot logs which paths hold it. Splitting quotas stays a simulation.

Gate, growth, and report pytest passed, as did the frontend route tests, tsc, lint, and the A/B script.

Co-Authored-By: Grok (agent loop)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-15 08:02:39 +08:00

45 lines
1.9 KiB
TypeScript

import assert from "node:assert/strict";
import { readdirSync, readFileSync, statSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";
const frontendRoot = fileURLToPath(new URL("../", import.meta.url));
const roots = ["src/app/api", "src/lib"];
// Empty on purpose. A call site that cannot send skip must be listed here with a reason.
const allowlist: string[] = [];
function walk(dir: string): string[] {
const found: string[] = [];
for (const name of readdirSync(dir)) {
const full = path.join(dir, name);
if (statSync(full).isDirectory()) found.push(...walk(full));
else if (name.endsWith(".ts") || name.endsWith(".tsx")) found.push(full);
}
return found;
}
test("python /api/chart bodies from app/api and lib send skip", () => {
const failures: string[] = [];
for (const root of roots) {
for (const file of walk(path.join(frontendRoot, root))) {
const rel = path.relative(frontendRoot, file).replaceAll("\\", "/");
if (allowlist.includes(rel)) continue;
const text = readFileSync(file, "utf8");
const re = /["']\/api\/chart["']/g;
let match: RegExpExecArray | null;
while ((match = re.exec(text))) {
const idx = match.index;
const before = text.slice(Math.max(0, idx - 120), idx);
if (!/postPython\s*\(|callEngine\s*\(|fetchEngine\s*\(|fetch\s*\(/.test(before)) continue;
const window = text.slice(Math.max(0, idx - 40), idx + 420);
const sendsSkip = window.includes("skip_vedastro_main_entry_overview: true")
|| window.includes("transitChartBody(")
|| (/["']\/api\/chart["']\s*,\s*payload/.test(window) && text.includes("skip_vedastro_main_entry_overview: true"));
if (!sendsSkip) failures.push(`${rel}:${text.slice(0, idx).split("\n").length}`);
}
}
}
assert.deepEqual(failures, []);
});