peppa/packages/testkit/test/ui-mode.test.ts
2026-11-15 17:34:59 +05:00

26 lines
1.4 KiB
TypeScript

// PEP-119: «Продакт» is what everyone sees by default; «Инженер» is a personal, remembered choice.
import assert from "node:assert/strict";
import { after, describe, test } from "node:test";
import { core, db, teardown } from "./helpers.ts";
process.env.PEPPA_SECRET = "mock-secret-for-tests";
after(teardown);
describe("PEP-119: UI mode", () => {
test("default is «Продакт»; the choice is per user and remembered; garbage falls back to «Продакт»", async () => {
const a = await core.upsertUserFromGitea(db, { id: 1191, login: "mock-mode-a" }, { access_token: "x" });
const b = await core.upsertUserFromGitea(db, { id: 1192, login: "mock-mode-b" }, { access_token: "y" });
assert.equal(await core.getUiMode(db, a.id), "product");
assert.equal(await core.setUiMode(db, a.id, "engineer"), "engineer");
assert.equal(await core.getUiMode(db, a.id), "engineer");
assert.equal(await core.getUiMode(db, b.id), "product", "another user is not affected");
assert.equal(await core.setUiMode(db, a.id, "root"), "product");
assert.equal(await core.getUiMode(db, a.id), "product");
});
test("a product manager's project tabs: board, epics, bugs", () => {
assert.deepEqual([...core.PRODUCT_PROJECT_TABS], ["board", "epics", "bugs"]);
assert.deepEqual(core.UI_MODE_NAMES, { product: "Продакт", engineer: "Инженер" });
});
});