From 30efe53bf2dfb055ecf17e8b2f6bbe3741bd03e8 Mon Sep 17 00:00:00 2001 From: Karim Farid <147805022+karimzakzouk@users.noreply.github.com> Date: Wed, 15 Apr 2026 22:51:21 +0200 Subject: [PATCH] fix(ui): OCI revision metadata never renders due to conflicting guard clause (#26948) (#27097) Signed-off-by: Karim Zakzouk Signed-off-by: Karim Farid Co-authored-by: Blake Pettersson --- .../revision-metadata-panel.test.tsx | 64 +++++++++++++++++++ .../revision-metadata-panel.tsx | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 ui/src/app/applications/components/application-status-panel/revision-metadata-panel.test.tsx diff --git a/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.test.tsx b/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.test.tsx new file mode 100644 index 0000000000..fca164c77c --- /dev/null +++ b/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.test.tsx @@ -0,0 +1,64 @@ +import * as React from 'react'; +import * as renderer from 'react-test-renderer'; +import {RevisionMetadataPanel} from './revision-metadata-panel'; + +jest.mock('../../../shared/services', () => ({ + services: { + applications: { + revisionMetadata: jest.fn(() => + Promise.resolve({ + author: 'Test Author', + date: '2026-01-01T00:00:00Z', + message: 'Test commit message', + tags: ['v1.0.0'], + signatureInfo: '' + }) + ), + ociMetadata: jest.fn(() => + Promise.resolve({ + authors: 'OCI Author', + createdAt: '2026-01-01T00:00:00Z', + description: 'Test OCI description', + version: '1.0.0' + }) + ) + } + } +})); + +describe('RevisionMetadataPanel', () => { + const defaultProps = { + appName: 'test-app', + appNamespace: 'default', + revision: 'abc123', + versionId: 1 + }; + + it('returns null for helm type', () => { + const component = renderer.create(); + expect(component.toJSON()).toBeNull(); + }); + + it('does NOT return null for oci type', () => { + const component = renderer.create(); + // The component should render (not null) - this is the bug fix + expect(component.toJSON()).not.toBeNull(); + }); + + it('does NOT return null for git type', () => { + const component = renderer.create(); + expect(component.toJSON()).not.toBeNull(); + }); + + it('calls ociMetadata service for oci type', () => { + const {services} = require('../../../shared/services'); + renderer.create(); + expect(services.applications.ociMetadata).toHaveBeenCalledWith('test-app', 'default', 'abc123', 0, 1); + }); + + it('calls revisionMetadata service for git type', () => { + const {services} = require('../../../shared/services'); + renderer.create(); + expect(services.applications.revisionMetadata).toHaveBeenCalledWith('test-app', 'default', 'abc123', 0, 1); + }); +}); diff --git a/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.tsx b/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.tsx index 4f81214e1c..620cbef53d 100644 --- a/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.tsx +++ b/ui/src/app/applications/components/application-status-panel/revision-metadata-panel.tsx @@ -4,7 +4,7 @@ import {Timestamp} from '../../../shared/components/timestamp'; import {services} from '../../../shared/services'; export const RevisionMetadataPanel = (props: {appName: string; appNamespace: string; type: string; revision: string; versionId: number}) => { - if (props.type === 'helm' || props.type === 'oci') { + if (props.type === 'helm') { return null; } if (props.type === 'oci') {