From 5c56796403fb3c0467a8d75f14329b7ba16c2142 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Tue, 25 Mar 2025 14:01:54 +0000 Subject: [PATCH] update error message on os settings error details on host details (#27441) For #27440 Updates showing the profile error message in os settings error cell to show on a different error message from the API. - [x] Added/updated automated tests - [x] Manual QA for all new/changed functionality --- .../OSSettingsErrorCell.tests.tsx | 29 +++++++++++++++--- .../OSSettingsErrorCell.tsx | 30 +++++++++++-------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tests.tsx b/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tests.tsx index 83f0190c14..ccd7e5d29c 100644 --- a/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tests.tsx +++ b/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tests.tsx @@ -108,7 +108,7 @@ describe("OSSettingsErrorCell", () => { hostId={1} profile={createMockHostMdmProfile({ status: "failed", - detail: `Fleet couldn’t populate $FLEET_VAR_CUSTOM_SCEP_URL_SCEP_WIFI because SCEP_WIFI certificate authority doesn’t exist.`, + detail: `Fleet couldn't populate $FLEET_VAR_CUSTOM_SCEP_URL_SCEP_WIFI because SCEP_WIFI certificate authority doesn't exist.`, })} /> ); @@ -121,14 +121,14 @@ describe("OSSettingsErrorCell", () => { ).toBeInTheDocument(); }); - it("renders a formatted tooltip when the error message matches digicert guid patern", () => { + it("renders a formatted tooltip when the error message matches digicert profile id error", () => { render( ); @@ -137,7 +137,28 @@ describe("OSSettingsErrorCell", () => { screen.getByText("Settings > Integrations > Certificates") ).toBeInTheDocument(); expect(screen.getByText(/correct it and resend/)).toBeInTheDocument(); - expect(screen.getByText("DIGICERT_WIFI")).toBeInTheDocument(); + expect(screen.getByText("WIFI_CERTIFICATE")).toBeInTheDocument(); + expect(screen.getByText("Profile GUID")).toBeInTheDocument(); + }); + + it("renders a formatted tooltip when the error message matches digicert deleted profile error", () => { + render( + + ); + + expect( + screen.getByText("Settings > Integrations > Certificates") + ).toBeInTheDocument(); + expect(screen.getByText(/correct it and resend/)).toBeInTheDocument(); + expect(screen.getByText("WIFI_CERTIFICATE")).toBeInTheDocument(); expect(screen.getByText("Profile GUID")).toBeInTheDocument(); }); diff --git a/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tsx b/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tsx index da2b905323..a3b30bd7cf 100644 --- a/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tsx +++ b/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsErrorCell/OSSettingsErrorCell.tsx @@ -50,6 +50,12 @@ const RefetchButton = ({ isFetching, onClick }: IRefetchButtonProps) => { * the detail does not match any of the expected patterns. */ const formatDetailCertificateError = (detail: IHostMdmProfile["detail"]) => { + const formattedCertificatesPath = ( + + Settings {">"} Integrations {">"} Certificates + + ); + const matchTokenErr = detail.match( /get certificate from (?:DigiCert|Digicert|digicert).*token configured in (?.*) certificate authority is invalid/ ); @@ -58,28 +64,28 @@ const formatDetailCertificateError = (detail: IHostMdmProfile["detail"]) => { <> Couldn't get certificate from DigiCert. The API token{" "} configured in {matchTokenErr.groups.ca} certificate authority is - invalid. Please go to{" "} - - Settings {">"} Integrations {">"} Certificates - - , correct it and resend. + invalid. Please go to {formattedCertificatesPath}, correct it and + resend. ); } const matchProfileIdErr = detail.match( - /get certificate from (?:DigiCert|Digicert|digicert).*profile_id.*configured in (?.*) certificate authority does(?:n.t| not) exist/ + /get certificate from (?:DigiCert|Digicert|digicert) for (?.*)\..*POST request: 410.*Profile with id.*was deleted/ ); - if (matchProfileIdErr?.groups) { + const matchDeletedProfileErr = detail.match( + /get certificate from (?:DigiCert|Digicert|digicert) for (?.*)\..*POST request: 400.*deleted or suspended Profile/ + ); + if (matchProfileIdErr?.groups || matchDeletedProfileErr?.groups) { return ( <> Couldn't get certificate from DigiCert. The Profile GUID{" "} - configured in {matchProfileIdErr.groups.ca} certificate authority - doesn't exist. Please go to{" "} + configured in{" "} - Settings {">"} Integrations {">"} Certificates - - , correct it and resend. + {matchProfileIdErr?.groups?.ca || matchDeletedProfileErr?.groups?.ca} + {" "} + certificate authority doesn't exist. Please go to{" "} + {formattedCertificatesPath}, correct it and resend. ); }