fix(work-orders): assert GET User full display name

This commit is contained in:
Arthur Bassi 2026-08-31 10:22:27 -03:00
parent e9e17dadec
commit 8031357dfa
2 changed files with 3 additions and 6 deletions

View file

@ -120,7 +120,7 @@ function readOptionalString(item: Record<string, unknown>, ...keys: string[]): s
return ""; return "";
} }
/** GET User exposes `Name` as first name only; prefer FirstName + LastName when present. */ /** GET User serializes `Name` as FirstName + LastName; compose those fields if present. */
function mapUserDisplayName(item: Record<string, unknown>): string { function mapUserDisplayName(item: Record<string, unknown>): string {
const firstName = readOptionalString(item, "firstName", "FirstName"); const firstName = readOptionalString(item, "firstName", "FirstName");
const lastName = readOptionalString(item, "lastName", "LastName"); const lastName = readOptionalString(item, "lastName", "LastName");

View file

@ -204,10 +204,7 @@ const GET_USER_SERIALIZED_DIRECTORY = {
data: [ data: [
{ {
Id: "s1", Id: "s1",
Name: "Alex", Name: "Alex Smith",
FirstName: "Alex",
LastName: "Smith",
UserName: "alex.smith",
}, },
], ],
}; };
@ -217,7 +214,7 @@ describe("workOrdersApi.fetchUsers", () => {
apiGet.mockReset(); apiGet.mockReset();
}); });
it("composes a full display name from the serialized GET User shape", async () => { it("maps the serialized GET User Name as the full display name", async () => {
apiGet.mockResolvedValue(GET_USER_SERIALIZED_DIRECTORY); apiGet.mockResolvedValue(GET_USER_SERIALIZED_DIRECTORY);
const users = await workOrdersApi.fetchUsers(); const users = await workOrdersApi.fetchUsers();