Files
co-lite/solvway-admin-portal/app/api/password-rules/route.test.ts
T
ngqileandClaude Opus 5.5 8ce9fcf471 feat: portal password hints, company hint, interest and role delete, dashboard notes
- Login: company-code hint after an invalid-credentials failure with an empty company.
- Password forms show the active rules (label-first, count-safe) and tie hint and refusal to the input.
- Interests and roles: soft delete with confirm dialogs; deactivate now confirms too.
- Dashboard figure explanations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-02 02:59:44 +08:00

27 lines
1.1 KiB
TypeScript

import { describe, it, expect, vi, beforeEach } from "vitest";
const mocks = vi.hoisted(() => ({ callMobileApi: vi.fn(), getToken: vi.fn() }));
vi.mock("@/app/lib/server/mobileApi", () => ({ callMobileApi: mocks.callMobileApi }));
vi.mock("@/app/lib/server/session", () => ({ getToken: mocks.getToken }));
import { GET } from "./route";
beforeEach(() => {
mocks.callMobileApi.mockReset().mockResolvedValue({ ok: true, data: [{ param: "NO_OTHER_LANGUAGE", value: null }] });
mocks.getToken.mockReset().mockResolvedValue("tok");
});
describe("GET /api/password-rules", () => {
it("is 401 without a session", async () => {
mocks.getToken.mockResolvedValue(null);
expect((await GET()).status).toBe(401);
expect(mocks.callMobileApi).not.toHaveBeenCalled();
});
it("returns the active rules from the admin endpoint", async () => {
const res = await GET();
expect(await res.json()).toEqual([{ param: "NO_OTHER_LANGUAGE", value: null }]);
expect(mocks.callMobileApi).toHaveBeenCalledWith("/api/admin/password-rules/active", { token: "tok" });
});
});