Skip to content

Commit

Permalink
include gke zone in list of extra locations (rancher#12289)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis-toboggan-md authored Oct 21, 2024
1 parent 69c1080 commit 83e250b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
7 changes: 5 additions & 2 deletions pkg/gke/components/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default defineComponent({
this.$emit('update:region', this.defaultRegion);
} else {
this.$emit('update:region', null);
this.$emit('update:zone', this.defaultZone);
this.setZone({ name: this.defaultZone });
}
}
},
Expand Down Expand Up @@ -389,6 +389,8 @@ export default defineComponent({
setZone(neu: {name: string}) {
this.selectedZone = neu;
this.$emit('update:zone', neu.name);
this.$emit('update:locations', [neu.name]);
},
setExtraZone(add: boolean, zone: string) {
Expand Down Expand Up @@ -443,6 +445,7 @@ export default defineComponent({
:value="zone"
:disabled="!isNewOrUnprovisioned"
:loading="loadingZones"
data-testid="gke-zone-select"
@selecting="setZone"
/>
</div>
Expand All @@ -462,7 +465,7 @@ export default defineComponent({
:label="zoneOpt.name"
:value="locations.includes(zoneOpt.name)"
:data-testid="`gke-extra-zones-${zoneOpt.name}`"
:disabled="!isNewOrUnprovisioned"
:disabled="isView"
class="extra-zone-checkbox"
@update:value="e=>setExtraZone(e, zoneOpt.name)"
/>
Expand Down
2 changes: 1 addition & 1 deletion pkg/gke/components/CruGKE.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const defaultGkeConfig = {
},
kubernetesVersion: '',
labels: {},
locations: [],
locations: [DEFAULT_GCP_ZONE],
loggingService: 'logging.googleapis.com/kubernetes',
maintenanceWindow: '',
masterAuthorizedNetworks: { enabled: false, cidrBlocks: [] },
Expand Down
34 changes: 25 additions & 9 deletions pkg/gke/components/__tests__/Config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ import flushPromises from 'flush-promises';
import Config from '@pkg/gke/components/Config.vue';
import Checkbox from '@components/Form/Checkbox/Checkbox.vue';

// const mockedValidationMixin = {
// computed: {
// fvFormIsValid: jest.fn(),
// type: jest.fn(),
// fvUnreportedValidationErrors: jest.fn(),
// },
// methods: { fvGetAndReportPathRules: jest.fn() }
// };

const mockedStore = (versionSetting: any) => {
return {
getters: {
Expand Down Expand Up @@ -208,4 +199,29 @@ describe('gke Config', () => {

expect(Object.keys(checkedNotInLocations)).toHaveLength(0);
});

it('should add newly selected zone to the list of extra zones (gkeConfig.locations) and remove old extra zones', async() => {
const setup = requiredSetup();

const wrapper = shallowMount(Config, {
propsData: {
zone: 'us-east1-b',
region: '',
cloudCredentialId: '',
projectId: 'test-project',
locations: ['us-east1-a']
},
...setup
});

wrapper.setProps({ cloudCredentialId: 'abc' });
await flushPromises();

const zoneSelect = wrapper.getComponent('[data-testid="gke-zone-select"]');

zoneSelect.vm.$emit('selecting', { name: 'us-east4-b' });

await flushPromises();
expect(wrapper.emitted('update:locations')[0][0]).toStrictEqual(['us-east4-b']);
});
});

0 comments on commit 83e250b

Please sign in to comment.