mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
fix(ui): OCI revision metadata never renders due to conflicting guard clause (#26948) (cherry-pick #27097 for 3.2) (#27364)
Signed-off-by: Karim Zakzouk <karimzakzouk69@gmail.com> Signed-off-by: Karim Farid <karimzakzouk69@gmail.com> Co-authored-by: Karim Farid <147805022+karimzakzouk@users.noreply.github.com> Co-authored-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
parent
a39f06d602
commit
d76e1bdc58
2 changed files with 65 additions and 1 deletions
|
|
@ -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(<RevisionMetadataPanel {...defaultProps} type='helm' />);
|
||||
expect(component.toJSON()).toBeNull();
|
||||
});
|
||||
|
||||
it('does NOT return null for oci type', () => {
|
||||
const component = renderer.create(<RevisionMetadataPanel {...defaultProps} type='oci' />);
|
||||
// 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(<RevisionMetadataPanel {...defaultProps} type='git' />);
|
||||
expect(component.toJSON()).not.toBeNull();
|
||||
});
|
||||
|
||||
it('calls ociMetadata service for oci type', () => {
|
||||
const {services} = require('../../../shared/services');
|
||||
renderer.create(<RevisionMetadataPanel {...defaultProps} type='oci' />);
|
||||
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(<RevisionMetadataPanel {...defaultProps} type='git' />);
|
||||
expect(services.applications.revisionMetadata).toHaveBeenCalledWith('test-app', 'default', 'abc123', 0, 1);
|
||||
});
|
||||
});
|
||||
|
|
@ -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') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue