diff --git a/changes/39082-setup-logo-light-background b/changes/39082-setup-logo-light-background new file mode 100644 index 0000000000..bb3a4362df --- /dev/null +++ b/changes/39082-setup-logo-light-background @@ -0,0 +1 @@ +* Fixed a bug where the organization logo URL entered during setup was only saved for dark backgrounds and not for light backgrounds. diff --git a/frontend/utilities/helpers.tests.tsx b/frontend/utilities/helpers.tests.tsx index f7acfa7944..27e9ceb7d1 100644 --- a/frontend/utilities/helpers.tests.tsx +++ b/frontend/utilities/helpers.tests.tsx @@ -1,5 +1,6 @@ import { getPastDate, getFutureDate } from "test/test-utils"; -import { +import type { IRegistrationFormData } from "interfaces/registration_form_data"; +import helpers, { removeOSPrefix, compareVersions, willExpireWithinXDays, @@ -77,4 +78,48 @@ describe("helpers utilities", () => { expect(willExpireWithinXDays(fiftyDaysAgo, 30)).toEqual(false); }); }); + + describe("setupData function", () => { + it("sets org_logo_url_light_background to the same value as org_logo_url", () => { + const formData: IRegistrationFormData = { + email: "admin@example.com", + name: "Admin", + password: "password123", + password_confirmation: "password123", + org_name: "Fleet", + org_web_url: "", + org_logo_url: "https://example.com/logo.png", + fleet_web_address: "", + server_url: "https://fleet.example.com", + }; + + const result = helpers.setupData(formData); + + expect(result.org_info.org_logo_url).toEqual( + "https://example.com/logo.png" + ); + expect(result.org_info.org_logo_url_light_background).toEqual( + "https://example.com/logo.png" + ); + }); + + it("sets org_logo_url_light_background to empty string when org_logo_url is not provided", () => { + const formData: IRegistrationFormData = { + email: "admin@example.com", + name: "Admin", + password: "password123", + password_confirmation: "password123", + org_name: "Fleet", + org_web_url: "", + org_logo_url: "", + fleet_web_address: "", + server_url: "https://fleet.example.com", + }; + + const result = helpers.setupData(formData); + + expect(result.org_info.org_logo_url).toEqual(""); + expect(result.org_info.org_logo_url_light_background).toEqual(""); + }); + }); }); diff --git a/frontend/utilities/helpers.tsx b/frontend/utilities/helpers.tsx index 3c7044d399..8207cd558b 100644 --- a/frontend/utilities/helpers.tsx +++ b/frontend/utilities/helpers.tsx @@ -56,6 +56,7 @@ import { isPlatformLabelNameFromAPI, } from "utilities/constants"; import { IDropdownOption } from "interfaces/dropdownOption"; +import type { IRegistrationFormData } from "interfaces/registration_form_data"; import CustomLink from "components/CustomLink"; const ORG_INFO_ATTRS = ["org_name", "org_logo_url"]; @@ -517,7 +518,7 @@ export const greyCell = (roleOrTeamText: string): boolean => { ); }; -const setupData = (formData: any) => { +const setupData = (formData: IRegistrationFormData) => { const orgInfo = pick(formData, ORG_INFO_ATTRS); const adminInfo = pick(formData, ADMIN_ATTRS); @@ -525,6 +526,7 @@ const setupData = (formData: any) => { server_url: formData.server_url, org_info: { ...orgInfo, + org_logo_url_light_background: orgInfo.org_logo_url || "", }, admin: { admin: true,