From c40ffd60b55ca1ad14287dd9e9da6ca81db4ac43 Mon Sep 17 00:00:00 2001 From: trdoyle Date: Tue, 1 Sep 2026 18:05:38 +0100 Subject: [PATCH 1/2] Add unit tests for health & application set status Signed-off-by: trdoyle --- .../Statuses/ApplicationSetStatus.test.tsx | 29 ++++++++++++++++ src/gitops/Statuses/ApplicationSetStatus.tsx | 34 +++++++++++++++++++ src/gitops/Statuses/HealthStatus.test.tsx | 26 ++++++++++++++ src/gitops/Statuses/SyncStatus.test.tsx | 6 ++++ .../components/shared/ApplicationSetList.tsx | 28 +-------------- 5 files changed, 96 insertions(+), 27 deletions(-) create mode 100644 src/gitops/Statuses/ApplicationSetStatus.test.tsx create mode 100644 src/gitops/Statuses/ApplicationSetStatus.tsx diff --git a/src/gitops/Statuses/ApplicationSetStatus.test.tsx b/src/gitops/Statuses/ApplicationSetStatus.test.tsx new file mode 100644 index 000000000..1e55de4b0 --- /dev/null +++ b/src/gitops/Statuses/ApplicationSetStatus.test.tsx @@ -0,0 +1,29 @@ +import { renderToStaticMarkup } from 'react-dom/server'; + +import ApplicationSetStatus from './ApplicationSetStatus'; + +describe('ApplicationSetStatus', () => { + it('renders Healthy', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `" Healthy"`, + ); + }); + + it('renders Error', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `" Error"`, + ); + }); + + it('renders Unknown for unrecognised status', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `" Unknown"`, + ); + }); + + it('renders Unknown icon for empty status', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `" "`, + ); + }); +}); diff --git a/src/gitops/Statuses/ApplicationSetStatus.tsx b/src/gitops/Statuses/ApplicationSetStatus.tsx new file mode 100644 index 000000000..077512365 --- /dev/null +++ b/src/gitops/Statuses/ApplicationSetStatus.tsx @@ -0,0 +1,34 @@ +import * as React from 'react'; +import { + HealthDegradedIcon, + HealthHealthyIcon, + HealthUnknownIcon, +} from 'src/gitops/utils/components/Icons/Icons'; +import { ApplicationSetStatus as AppSetStatus } from 'src/gitops/utils/constants'; + +interface ApplicationSetStatusProps { + status: string; +} + +const ApplicationSetStatus: React.FC = ({ status }) => { + let targetIcon: React.ReactNode; + + switch (status) { + case AppSetStatus.HEALTHY: + targetIcon = ; + break; + case AppSetStatus.ERROR: + targetIcon = ; + break; + default: + targetIcon = ; + } + + return ( + + {targetIcon} {status} + + ); +}; + +export default ApplicationSetStatus; diff --git a/src/gitops/Statuses/HealthStatus.test.tsx b/src/gitops/Statuses/HealthStatus.test.tsx index 28051d55a..182cf01fa 100644 --- a/src/gitops/Statuses/HealthStatus.test.tsx +++ b/src/gitops/Statuses/HealthStatus.test.tsx @@ -20,12 +20,30 @@ describe('HealthStatus', () => { ); }); + it('renders Suspended', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `"
Suspended
"`, + ); + }); + + it('renders Missing', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `"
Missing
"`, + ); + }); + it('renders Unknown for unrecognized status', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( `"
SomethingElse
"`, ); }); + it('renders Unknown for undefined status', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `"
"`, + ); + }); + it('renders popover when message is provided', () => { expect( renderToStaticMarkup(), @@ -65,4 +83,12 @@ describe('HealthStatusIcon', () => { `""`, ); }); + + it('renders Unknown icon for unrecognised status', () => { + expect( + renderToStaticMarkup(), + ).toMatchInlineSnapshot( + `""`, + ); + }); }); diff --git a/src/gitops/Statuses/SyncStatus.test.tsx b/src/gitops/Statuses/SyncStatus.test.tsx index 1796a6c8a..bb417b365 100644 --- a/src/gitops/Statuses/SyncStatus.test.tsx +++ b/src/gitops/Statuses/SyncStatus.test.tsx @@ -25,4 +25,10 @@ describe('SyncStatus', () => { `" "`, ); }); + + it('renders Unknown icon for undefined status', () => { + expect(renderToStaticMarkup()).toMatchInlineSnapshot( + `" "`, + ); + }); }); diff --git a/src/gitops/components/shared/ApplicationSetList.tsx b/src/gitops/components/shared/ApplicationSetList.tsx index 49edec67d..d025d9447 100644 --- a/src/gitops/components/shared/ApplicationSetList.tsx +++ b/src/gitops/components/shared/ApplicationSetList.tsx @@ -26,13 +26,8 @@ import { Tbody, Td, ThProps, Tr } from '@patternfly/react-table'; import { useApplicationSetActionsProvider } from '../../hooks/useApplicationSetActionsProvider'; import { ApplicationSetKind, ApplicationSetModel } from '../../models/ApplicationSetModel'; +import ApplicationSetStatusFragment from '../../Statuses/ApplicationSetStatus'; import ActionsDropdown from '../../utils/components/ActionDropDown/ActionDropDown'; -// Import status icons for consistency with ApplicationList -import { - HealthDegradedIcon, - HealthHealthyIcon, - HealthUnknownIcon, -} from '../../utils/components/Icons/Icons'; import { ApplicationSetStatus } from '../../utils/constants'; import { getAppSetGeneratorCount, getAppSetStatus } from '../../utils/gitops'; import { modelToGroupVersionKind, modelToRef } from '../../utils/utils'; @@ -90,27 +85,6 @@ const getGeneratedAppsCount = ( }).length; }; -const ApplicationSetStatusFragment: React.FC<{ status: string }> = ({ status }) => { - let targetIcon: React.ReactNode; - - switch (status) { - case ApplicationSetStatus.HEALTHY: - targetIcon = ; - break; - case ApplicationSetStatus.ERROR: - targetIcon = ; - break; - default: - targetIcon = ; - } - - return ( - - {targetIcon} {status} - - ); -}; - interface ApplicationSetProps { namespace: string; hideNameLabelFilters?: boolean; From 88031ca31a4e4ad35b0897f6c2122dc3d9dfd02f Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 2 Sep 2026 13:27:24 -0400 Subject: [PATCH 2/2] fix: update status snapshots for PatternFly v5 tokens on 4.18 Cherry-picked tests from main used PF6 CSS variables; release-4.18 still renders PF5 tokens. Signed-off-by: Atif Ali --- src/gitops/Statuses/ApplicationSetStatus.test.tsx | 8 ++++---- src/gitops/Statuses/HealthStatus.test.tsx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gitops/Statuses/ApplicationSetStatus.test.tsx b/src/gitops/Statuses/ApplicationSetStatus.test.tsx index 1e55de4b0..21c13076c 100644 --- a/src/gitops/Statuses/ApplicationSetStatus.test.tsx +++ b/src/gitops/Statuses/ApplicationSetStatus.test.tsx @@ -5,25 +5,25 @@ import ApplicationSetStatus from './ApplicationSetStatus'; describe('ApplicationSetStatus', () => { it('renders Healthy', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `" Healthy"`, + `" Healthy"`, ); }); it('renders Error', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `" Error"`, + `" Error"`, ); }); it('renders Unknown for unrecognised status', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `" Unknown"`, + `" Unknown"`, ); }); it('renders Unknown icon for empty status', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `" "`, + `" "`, ); }); }); diff --git a/src/gitops/Statuses/HealthStatus.test.tsx b/src/gitops/Statuses/HealthStatus.test.tsx index 182cf01fa..9ff85b36d 100644 --- a/src/gitops/Statuses/HealthStatus.test.tsx +++ b/src/gitops/Statuses/HealthStatus.test.tsx @@ -22,13 +22,13 @@ describe('HealthStatus', () => { it('renders Suspended', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `"
Suspended
"`, + `"
Suspended
"`, ); }); it('renders Missing', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `"
Missing
"`, + `"
Missing
"`, ); }); @@ -40,7 +40,7 @@ describe('HealthStatus', () => { it('renders Unknown for undefined status', () => { expect(renderToStaticMarkup()).toMatchInlineSnapshot( - `"
"`, + `"
"`, ); });