diff --git a/src/gitops/components/shared/MetadataLabels/MetadataLabels.test.tsx b/src/gitops/components/shared/MetadataLabels/MetadataLabels.test.tsx
index c8fb44f03..45a62e6ce 100644
--- a/src/gitops/components/shared/MetadataLabels/MetadataLabels.test.tsx
+++ b/src/gitops/components/shared/MetadataLabels/MetadataLabels.test.tsx
@@ -42,4 +42,14 @@ describe('MetadataLabels', () => {
`"
no-value-label
"`,
);
});
+
+ it('renders with a custom numLabels', () => {
+ expect(
+ renderToStaticMarkup(
+ ,
+ ),
+ ).toMatchInlineSnapshot(
+ `"app=frontend
"`,
+ );
+ });
});
diff --git a/src/gitops/topology/actions/creators.test.ts b/src/gitops/topology/actions/creators.test.ts
index 3d16d2d80..976f457bb 100644
--- a/src/gitops/topology/actions/creators.test.ts
+++ b/src/gitops/topology/actions/creators.test.ts
@@ -1,7 +1,7 @@
import { getDeleteRolloutAction, editRollout } from './creators';
describe('topology action creators', () => {
- it('getDeleteRolloutAction', () => {
+ it('returns the delete action id and label', () => {
const action = getDeleteRolloutAction(() => {});
expect({ id: action.id, label: action.label }).toMatchInlineSnapshot(`
{
@@ -11,7 +11,15 @@ describe('topology action creators', () => {
`);
});
- it('editRollout', () => {
+ it('calls the delete modal from the action', () => {
+ const deleteModal = jest.fn();
+ const action = getDeleteRolloutAction(deleteModal);
+ expect(typeof action.cta).toBe('function');
+ (action.cta as () => void)();
+ expect(deleteModal).toHaveBeenCalledTimes(1);
+ });
+
+ it('returns the edit action with a yaml href', () => {
const action = editRollout({
apiVersion: 'argoproj.io/v1alpha1',
kind: 'Rollout',
@@ -27,4 +35,30 @@ describe('topology action creators', () => {
}
`);
});
+
+ it('builds the edit href when namespace is missing', () => {
+ const action = editRollout({
+ apiVersion: 'argoproj.io/v1alpha1',
+ kind: 'Rollout',
+ metadata: { name: 'my-rollout' },
+ } as any);
+ expect(action.cta).toMatchInlineSnapshot(`
+ {
+ "href": "/ns/undefined/argoproj.io~v1alpha1~Rollout/my-rollout/yaml",
+ }
+ `);
+ });
+
+ it('builds the edit href when name is missing', () => {
+ const action = editRollout({
+ apiVersion: 'argoproj.io/v1alpha1',
+ kind: 'Rollout',
+ metadata: { namespace: 'default' },
+ } as any);
+ expect(action.cta).toMatchInlineSnapshot(`
+ {
+ "href": "/ns/default/argoproj.io~v1alpha1~Rollout/undefined/yaml",
+ }
+ `);
+ });
});
diff --git a/src/gitops/utils/components/ExternalLink/ExternalLink.test.tsx b/src/gitops/utils/components/ExternalLink/ExternalLink.test.tsx
index 6a28ca367..264f631e1 100644
--- a/src/gitops/utils/components/ExternalLink/ExternalLink.test.tsx
+++ b/src/gitops/utils/components/ExternalLink/ExternalLink.test.tsx
@@ -41,4 +41,30 @@ describe('ExternalLink', () => {
`"Link"`,
);
});
+
+ it('renders href and target without text', () => {
+ expect(renderToStaticMarkup()).toMatchInlineSnapshot(
+ `""`,
+ );
+ });
+
+ it('uses children instead of text when both are set', () => {
+ expect(
+ renderToStaticMarkup(
+
+ Visible
+ ,
+ ),
+ ).toMatchInlineSnapshot(
+ `"Visible"`,
+ );
+ });
+
+ it('renders an empty link when children are empty', () => {
+ expect(
+ renderToStaticMarkup({''}),
+ ).toMatchInlineSnapshot(
+ `""`,
+ );
+ });
});