diff --git a/packages/admin-portal/src/services/UserService.test.ts b/packages/admin-portal/src/services/UserService.test.ts index 518eea8c2c8..2a036a8add0 100644 --- a/packages/admin-portal/src/services/UserService.test.ts +++ b/packages/admin-portal/src/services/UserService.test.ts @@ -81,12 +81,14 @@ describe("resolveOptionLabel", () => { }) describe("getSelectOptionLabel", () => { - it("shows the stored option next to its description", () => { - expect(getSelectOptionLabel({M: "Male"}, "M", translate())).toBe("M - Male") + it("shows the configured label without prepending the stored option", () => { + expect(getSelectOptionLabel({"0": "0 - Non Resident"}, "0", translate())).toBe( + "0 - Non Resident" + ) }) - it("keeps the stored option visible when the option itself is overridden", () => { - expect(getSelectOptionLabel(undefined, "M", translate({M: "Male"}))).toBe("M - Male") + it("shows the translated label without prepending the stored option", () => { + expect(getSelectOptionLabel(undefined, "M", translate({M: "Male"}))).toBe("Male") }) it("shows the option alone when nothing describes it", () => { diff --git a/packages/admin-portal/src/services/UserService.ts b/packages/admin-portal/src/services/UserService.ts index 623c037078e..819901c6be9 100644 --- a/packages/admin-portal/src/services/UserService.ts +++ b/packages/admin-portal/src/services/UserService.ts @@ -141,9 +141,9 @@ const getSelectOptionDescription = ( } /** - * Label shown for one option of a `select` user profile attribute. The stored - * option stays visible, so the admin still sees what is written to the voter, - * and its description is appended when the attribute configures one. + * Label shown for one option of a `select` user profile attribute. A configured + * description replaces the stored value; the value is the fallback when the + * option has no description. */ export const getSelectOptionLabel = ( optionLabels: Record | undefined, @@ -152,7 +152,7 @@ export const getSelectOptionLabel = ( ): string => { const description = getSelectOptionDescription(optionLabels, option, t) - return description && description !== option ? `${option} - ${description}` : option + return description ?? option } const toPositiveInteger = (value: unknown): number | undefined => {