5610ef9f1a
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (push) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 1m8s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m31s
CI/CD Pipeline / Frontend Lint (push) Successful in 2m26s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m46s
CI/CD Pipeline / Unit Tests (push) Successful in 3m49s
CI/CD Pipeline / Integration Tests (push) Successful in 1m52s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 6m29s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 8m32s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 50s
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 1m21s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m11s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
import { normalizeUser } from "@/api/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",
|
|
})
|
|
})
|
|
})
|