560856cf22
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 210h26m26s
CI/CD Pipeline / Frontend Lint (push) Failing after 210h27m0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 210h27m7s
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { normalizeUser } from "./auth";
|
|
|
|
describe("normalizeUser", () => {
|
|
it("normalizes canonical API current-user fields", () => {
|
|
expect(
|
|
normalizeUser({
|
|
user_id: "user-1",
|
|
email: "user@example.com",
|
|
username: "user",
|
|
display_name: "User",
|
|
email_verified: true,
|
|
}),
|
|
).toEqual({
|
|
id: "user-1",
|
|
user_id: "user-1",
|
|
email: "user@example.com",
|
|
username: "user",
|
|
display_name: "User",
|
|
is_email_verified: true,
|
|
email_verified: true,
|
|
created_at: undefined,
|
|
});
|
|
});
|
|
|
|
it("keeps compatibility with legacy UI-shaped user fields", () => {
|
|
expect(
|
|
normalizeUser({
|
|
id: "user-2",
|
|
email: "legacy@example.com",
|
|
username: "legacy",
|
|
display_name: "Legacy",
|
|
is_email_verified: false,
|
|
created_at: "2026-06-22T00:00:00Z",
|
|
}),
|
|
).toEqual({
|
|
id: "user-2",
|
|
user_id: "user-2",
|
|
email: "legacy@example.com",
|
|
username: "legacy",
|
|
display_name: "Legacy",
|
|
is_email_verified: false,
|
|
email_verified: false,
|
|
created_at: "2026-06-22T00:00:00Z",
|
|
});
|
|
});
|
|
});
|