71 lines
4.3 KiB
TypeScript
71 lines
4.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
import { assembleReportFactTables } from "../src/lib/report-fact-tables";
|
|
import { reportFactTablesSchema } from "../src/lib/report-fact-table-schema";
|
|
import { assembleLongformCharts } from "../src/lib/personal-report-generation";
|
|
import { buildLongformCoverDocument } from "../src/lib/personal-report-longform-cover";
|
|
import { CHART_IDS, reportDocumentV2Schema } from "../src/lib/personal-report-contract";
|
|
import { projectOrdinaryReportMarkdown } from "../src/lib/report-public-projection";
|
|
|
|
|
|
|
|
const packet = JSON.parse(readFileSync(new URL("./fixtures/report-density-fictional-engine.json", import.meta.url), "utf8"));
|
|
const resolve = (path: string) => path.replace(/\[(\d+)\]/g, ".$1").split(".").reduce((value, key) => value?.[key], packet);
|
|
|
|
test("density golden: sixteen real charts have complete houses and nine occupants", () => {
|
|
const charts = assembleLongformCharts(packet, "ev-cover-longform");
|
|
assert.deepEqual(charts.map(chart => chart.id), [...CHART_IDS]);
|
|
assert.equal(reportDocumentV2Schema.shape.charts.safeParse(charts).success, true);
|
|
const document = buildLongformCoverDocument({
|
|
report: { id: "123e4567-e89b-12d3-a456-426614174000", reportType: "personal_full", presentationMode: "default", depth: "standard", requestedThemes: ["career"], skillName: "jyotish-vedic-astrology", skillVersion: "6.9.14", skillSourceCommit: null, skillSnapshotSha256: "ab".repeat(32) },
|
|
subject: { displayName: "虚构测试", birthTimeStatus: "reported", birthPlaceLabel: "虚构地点" },
|
|
markdown: "# 个人报告\n\n## 摘要\n\n原始计算供核对。", charts, factTables: assembleReportFactTables(packet),
|
|
});
|
|
assert.equal(document.factTables?.length, 8);
|
|
assert.equal(document.charts.length, 16);
|
|
for (const chart of charts) {
|
|
assert.equal(chart.houses.length, 12);
|
|
assert.equal(chart.houses.flatMap(h => h.occupants).length, 9);
|
|
assert.equal(chart.claimStatus, "parameter_sensitive");
|
|
}
|
|
});
|
|
|
|
test("density applicability remains outside ordinary narrative projection", () => {
|
|
const prose = "# 个人报告\n\n这是普通正文。\n";
|
|
const appendix = "\n## 辅助时间轴适用性(参数敏感)\n\n| 大运族 | 是否适用 / 原因 | 使用边界 |\n| --- | --- | --- |\n| Yogini | 已返回周期 | 第二时间轴,仅供交叉核对,不单独生成应期 |\n";
|
|
assert.equal(projectOrdinaryReportMarkdown(prose + appendix), projectOrdinaryReportMarkdown(prose + "\n## 核对(参数敏感)\n"));
|
|
assert.doesNotMatch(projectOrdinaryReportMarkdown(prose + appendix), /Yogini|第二时间轴/);
|
|
});
|
|
|
|
test("density golden: eight server groups contain only unchanged engine leaves", () => {
|
|
assert.equal(packet.fixtureProvenance.fictional, true);
|
|
const tables = assembleReportFactTables(packet);
|
|
assert.equal(tables.length, 8);
|
|
for (const table of tables) {
|
|
assert.ok(table.rows.length > 0, table.id);
|
|
for (const row of table.rows) assert.deepEqual(row.cells[1], resolve(row.sourcePath), row.sourcePath);
|
|
}
|
|
assert.equal(tables.find(t => t.id === "shadbala")?.rows.length, 42);
|
|
assert.equal(tables.find(t => t.id === "ashtakavarga")?.rows.length, 108);
|
|
assert.ok(tables.find(t => t.id === "annual")?.rows.some(row => row.sourcePath.includes("advanced_systems.sahams")));
|
|
});
|
|
|
|
test("density golden: Sade Sati reports missing cycle dates without inventing them", () => {
|
|
const table = assembleReportFactTables(packet).find(t => t.id === "sade_sati")!;
|
|
assert.match(table.note, /尚无三轮起止日期/);
|
|
assert.equal(table.rows.length, 6);
|
|
assert.equal(table.claimStatus, "parameter_sensitive");
|
|
assert.ok(table.rows.every(row => !/start|end|date/.test(row.sourcePath)));
|
|
});
|
|
|
|
test("density facts preserve declared limitations and reject malformed provenance", () => {
|
|
const altered = structuredClone(packet);
|
|
altered.worksheets.advanced_systems.yogas_doshas.sade_sati.claimStatus = "user_history_verification_required";
|
|
assert.equal(assembleReportFactTables(altered).find(t => t.id === "sade_sati")?.claimStatus, "user_history_verification_required");
|
|
const tables = assembleReportFactTables(packet);
|
|
tables[0].rows[0].sourcePath = tables[0].sourcePath + "_wrong.lord";
|
|
assert.equal(reportFactTablesSchema.safeParse(tables).success, false);
|
|
assert.deepEqual(assembleReportFactTables(undefined), []);
|
|
});
|