Skip to content

Commit

Permalink
fix default aks pool name and add unit test (rancher#11644)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis-toboggan-md authored Aug 15, 2024
1 parent 5ee4809 commit 2386076
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/aks/components/CruAks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ export default defineComponent({
const _id = randomStr();
if (!this.nodePools.length) {
poolName = 'agentPool';
poolName = 'agentpool';
// there must be at least one System pool so if it's the first pool, default to that
mode = 'System' as AKSPoolMode;
}
Expand Down
20 changes: 19 additions & 1 deletion pkg/aks/components/__tests__/CruAks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import flushPromises from 'flush-promises';
import { shallowMount, Wrapper } from '@vue/test-utils';
import CruAks from '@pkg/aks/components/CruAks.vue';
// eslint-disable-next-line jest/no-mocks-import
import { mockRegions, mockVersionsSorted } from '@pkg/aks/util/__mocks__/aks';
import { mockRegions, mockVersionsSorted } from '../../util/__mocks__/aks';
import { AKSNodePool } from 'types';
import { _EDIT, _CREATE } from '@shell/config/query-params';
import { nodePoolNames } from '../../util/validators';

const mockedValidationMixin = {
computed: {
Expand Down Expand Up @@ -476,4 +477,21 @@ describe('aks provisioning form', () => {
expect(wrapper.vm.$data.config.logAnalyticsWorkspaceGroup).toBeNull();
expect(wrapper.vm.$data.config.logAnalyticsWorkspaceName).toBeNull();
});

it('should use a valid value for the default pool name', async() => {
const wrapper = shallowMount(CruAks, {
propsData: { value: {}, mode: _CREATE },
...requiredSetup()
});

await setCredential(wrapper);

wrapper.vm.addPool();
await wrapper.vm.$nextTick();

expect(wrapper.vm.nodePools).toHaveLength(1);
const nodeName = wrapper.vm.nodePools[0].name;

expect(nodePoolNames({ t: (str:string) => str })(nodeName)).toBeUndefined();
});
});

0 comments on commit 2386076

Please sign in to comment.