Files
Jyotisha/frontend/tests/settings-url.test.ts
T
Jesse_Chen dc6598d7e4 fix(web): keep the settings dialog one size and move billing into it (BUG-554)
The four account panes now share a fixed frame, chart profiles open as list then detail, and membership lives in the homepage dialog instead of a separate page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-06 18:29:51 +08:00

39 lines
1.3 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { parseSettingsQuery, stripSettingsQuery } from "../src/lib/settings-url.ts";
test("parses a billing settings query with source, plan and tab", () => {
const query = parseSettingsQuery("?settings=billing&source=legacy&plan=monthly&tab=orders");
assert.deepEqual(query, {
pane: "billing",
source: "legacy",
plan: "monthly",
tab: "orders",
});
});
test("returns null when the settings pane is absent or not billing", () => {
assert.equal(parseSettingsQuery(""), null);
assert.equal(parseSettingsQuery("?c=11111111-1111-4111-8111-111111111111"), null);
assert.equal(parseSettingsQuery("?settings=profile"), null);
});
test("ignores unknown plan and tab aliases", () => {
const query = parseSettingsQuery("?settings=billing&plan=weekly&tab=invoices&source=credits");
assert.deepEqual(query, {
pane: "billing",
source: "credits",
plan: null,
tab: null,
});
});
test("strips settings fields and keeps the session query", () => {
assert.equal(
stripSettingsQuery("?settings=billing&source=legacy&c=11111111-1111-4111-8111-111111111111"),
"/?c=11111111-1111-4111-8111-111111111111",
);
assert.equal(stripSettingsQuery("?settings=billing&source=legacy&plan=yearly&tab=redeem"), "/");
});