From 23860766352590dcd8099a66db98c9f395012464 Mon Sep 17 00:00:00 2001 From: Nancy <42977925+mantis-toboggan-md@users.noreply.github.com> Date: Thu, 15 Aug 2024 09:33:39 -0700 Subject: [PATCH] fix default aks pool name and add unit test (#11644) --- pkg/aks/components/CruAks.vue | 2 +- pkg/aks/components/__tests__/CruAks.test.ts | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/aks/components/CruAks.vue b/pkg/aks/components/CruAks.vue index 9db30a7e851..910abbde659 100644 --- a/pkg/aks/components/CruAks.vue +++ b/pkg/aks/components/CruAks.vue @@ -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; } diff --git a/pkg/aks/components/__tests__/CruAks.test.ts b/pkg/aks/components/__tests__/CruAks.test.ts index 44e9d02aad8..953218a1d32 100644 --- a/pkg/aks/components/__tests__/CruAks.test.ts +++ b/pkg/aks/components/__tests__/CruAks.test.ts @@ -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: { @@ -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(); + }); });