Files
Jyotisha/frontend/tests/synastry-display-order.test.ts
T
jesse-uxandCursor dd9efb3447 fix(synastry): keep the picker order in the report title
The pair key stays sorted for dedup, and generation now loads the two people in the order they were chosen. The report back link uses Link so the new route passes the page-link lint.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-21 18:26:26 +08:00

22 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from "node:assert/strict";
import test from "node:test";
import { readFileSync } from "node:fs";
import { synastryDisplaySubjectIds } from "../src/lib/synastry-display-order.ts";
import { synastryFollowupTitle } from "../src/lib/synastry-report-session.ts";
test("picker order outranks the sorted pair key for the title and the chat", () => {
const ids = synastryDisplaySubjectIds("person-yi", "self", { first: "self", second: "person-yi" });
assert.deepEqual(ids, ["self", "person-yi"]);
const labels: Record<string, string> = { self: "甲", "person-yi": "乙" };
const names = { a: labels[ids[0]] ?? "", b: labels[ids[1]] ?? "" };
assert.equal(`${names.a} × ${names.b} · 婚恋合盘`, "甲 × 乙 · 婚恋合盘");
assert.equal(synastryFollowupTitle(names), "甲 × 乙 · 合盘追问");
assert.deepEqual(synastryDisplaySubjectIds("person-yi", "self", null), ["person-yi", "self"]);
const wait = readFileSync(new URL("../src/components/synastry/synastry-wait.tsx", import.meta.url), "utf8");
const run = readFileSync(new URL("../src/lib/synastry-full-run.ts", import.meta.url), "utf8");
assert.match(wait, /\$\{a\} × \$\{b\}/);
assert.match(run, /synastryDisplaySubjectIds\(/);
assert.match(run, /cardSummary: `\$\{names\.a\} × \$\{names\.b\} · 婚恋合盘`/);
});