Files
Jyotisha/frontend/tests/settings-mvp-contract.test.ts
T
Jesse_Chen b6a70aa7df fix(ayanamsa): pin Lahiri on reference sets and add a user setting
Product default stays Raman. Public-case revalidation and fixture dashas now pass --ayanamsa lahiri; profiles store the four selectable values.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 16:33:46 +08:00

51 lines
2.4 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { homeSurface as page } from "./home-surface.ts";
const sidebar = readFileSync(new URL("../src/components/app-sidebar.tsx", import.meta.url), "utf8");
const overlay = readFileSync(new URL("../src/components/account-dialog-overlay.tsx", import.meta.url), "utf8");
function between(source: string, start: string, end: string) {
const startIndex = source.indexOf(start);
const endIndex = source.indexOf(end, startIndex + start.length);
assert.notEqual(startIndex, -1, `missing start marker: ${start}`);
assert.notEqual(endIndex, -1, `missing end marker: ${end}`);
return source.slice(startIndex, endIndex);
}
test("account menu exposes the four MVP settings sections", () => {
assert.match(sidebar, /<span>个人资料<\/span>/);
assert.match(sidebar, /<span>星盘资料<\/span>/);
assert.match(sidebar, /<span>通用设置<\/span>/);
assert.match(sidebar, /<span>账户与点数<\/span>/);
assert.match(sidebar, /onOpenGeneral/);
});
test("personal profile is limited to account basics and links to chart settings", () => {
const profile = between(page, " renderProfile() {", " renderChartLibrary() {");
assert.match(profile, /账户信息/);
assert.match(profile, /登录邮箱/);
assert.match(profile, /管理星盘资料/);
assert.doesNotMatch(profile, /<ProfileFields/);
assert.doesNotMatch(profile, /出生资料/);
});
test("the chart library owns self-profile editing and keeps other-chart save separate", () => {
const charts = readFileSync(new URL("../src/components/chart-library-panel.tsx", import.meta.url), "utf8");
const personalProfile = between(page, " renderProfile() {", " renderChartLibrary() {");
assert.match(charts, /编辑本人资料/);
assert.match(charts, /onSubmit=\{saveProfile\}/);
assert.match(charts, /onSubmit=\{saveOtherChart\}/);
assert.match(charts, /setEditingSelfChart\(true\)/);
assert.match(charts, /AyanamsaPreferenceField/);
assert.doesNotMatch(personalProfile, /AyanamsaPreferenceField/);
});
test("the general dialog renders the shared theme preference panel", () => {
assert.match(overlay, /dialog: "profile" \| "chart-library" \| "general" \| "logout"/);
assert.match(overlay, /renderGeneral: \(\) => ReactNode/);
assert.match(overlay, /return model\.renderGeneral\(\)/);
assert.match(page, /renderGeneral\(\) \{\s*return <ThemePreferencePanel \/>;/);
});