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 "";
}
/** 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 {
const firstName = readOptionalString(item, "firstName", "FirstName");
const lastName = readOptionalString(item, "lastName", "LastName");

View file

@ -204,10 +204,7 @@ const GET_USER_SERIALIZED_DIRECTORY = {
data: [
{
Id: "s1",
Name: "Alex",
FirstName: "Alex",
LastName: "Smith",
UserName: "alex.smith",
Name: "Alex Smith",
},
],
};
@ -217,7 +214,7 @@ describe("workOrdersApi.fetchUsers", () => {
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);
const users = await workOrdersApi.fetchUsers();