Files
Jyotisha/frontend/tests/settings-mvp-contract.test.ts
T
Jesse_Chen 54269fcfcc
Independent Staging Quality Gate / validate (push) Has been cancelled
Independent Staging Quality Gate / publish (push) Has been cancelled
refactor(chat): extract home helpers, chart library, and starter surfaces
page.tsx still owns the chat main chain, but the first product surfaces now
live in their own modules so later splits can land without editing the 4k-line
Home. Source-lock tests follow the moved tokens; the orphan user-data contract
is aligned and added to the quick gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-01 22:58:02 +08:00

48 lines
2.2 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");
assert.match(charts, /编辑本人资料/);
assert.match(charts, /onSubmit=\{saveProfile\}/);
assert.match(charts, /onSubmit=\{saveOtherChart\}/);
assert.match(charts, /setEditingSelfChart\(true\)/);
});
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 \/>;/);
});