Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/components/form/NameNsDescription.vue
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export default {
namespace.value = toRef(props.forceNamespace);
updateNamespace(namespace);
} else if (props.namespaceKey) {
namespace.value = get(v, props.namespaceKey);
namespace.value = get(v.value, props.namespaceKey);
} else {
namespace.value = metadata?.namespace;
}
Expand Down
42 changes: 42 additions & 0 deletions shell/components/form/__tests__/NameNsDescription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,48 @@ describe('component: NameNsDescription', () => {
expect(wrapper.emitted().isNamespaceNew?.[0][0]).toBe(true);
});

it('should set the namespace using the namespaceKey prop', () => {
const namespaceName = 'custom-namespace';
const store = createStore({
getters: {
allowedNamespaces: () => () => ({ [namespaceName]: true }),
currentStore: () => () => 'cluster',
'cluster/schemaFor': () => jest.fn()
}
});

const wrapper = mount(NameNsDescription, {
props: {
value: {
setAnnotation: jest.fn(),
metadata: {},
value: { metadata: { namespace: namespaceName } }
},
mode: 'create',
namespaceKey: 'value.metadata.namespace',
},
global: {
provide: { store },
mocks: {
$store: {
dispatch: jest.fn(),
getters: {
namespaces: jest.fn(),
'customizations/getPreviewCluster': {
ready: true,
isLocal: false,
badge: {},
},
'i18n/t': jest.fn(),
},
},
},
},
});

expect((wrapper.vm as any).namespace).toBe(namespaceName);
});

it('renders the name input with the expected value', () => {
const namespaceName = 'test';
const store = createStore({
Expand Down
Loading