@rancher/shell 3.0.7 → 3.0.8-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/vendor/githubapp.svg +13 -0
- package/assets/styles/base/_typography.scss +1 -1
- package/assets/styles/themes/_modern.scss +5 -5
- package/assets/translations/en-us.yaml +91 -11
- package/assets/translations/zh-hans.yaml +0 -4
- package/components/Inactivity.vue +222 -106
- package/components/InstallHelmCharts.vue +2 -2
- package/components/ResourceDetail/index.vue +1 -1
- package/components/SortableTable/index.vue +17 -2
- package/components/fleet/FleetConfigMapSelector.vue +117 -0
- package/components/fleet/FleetSecretSelector.vue +127 -0
- package/components/fleet/__tests__/FleetConfigMapSelector.test.ts +125 -0
- package/components/fleet/__tests__/FleetSecretSelector.test.ts +82 -0
- package/components/form/FileImageSelector.vue +13 -4
- package/components/form/FileSelector.vue +11 -2
- package/components/form/ResourceLabeledSelect.vue +1 -0
- package/components/form/__tests__/ResourceLabeledSelect.test.ts +90 -0
- package/components/nav/Header.vue +1 -0
- package/config/product/auth.js +1 -0
- package/config/query-params.js +1 -0
- package/config/settings.ts +8 -1
- package/config/types.js +2 -0
- package/dialog/AddonConfigConfirmationDialog.vue +45 -1
- package/edit/__tests__/fleet.cattle.io.helmop.test.ts +52 -11
- package/edit/auth/AuthProviderWarningBanners.vue +14 -1
- package/edit/auth/github-app-steps.vue +97 -0
- package/edit/auth/github-steps.vue +75 -0
- package/edit/auth/github.vue +94 -65
- package/edit/fleet.cattle.io.helmop.vue +51 -2
- package/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget.vue +15 -5
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +11 -9
- package/edit/provisioning.cattle.io.cluster/rke2.vue +56 -9
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +28 -2
- package/list/projectsecret.vue +1 -1
- package/machine-config/azure.vue +1 -1
- package/mixins/chart.js +1 -1
- package/models/__tests__/chart.test.ts +17 -9
- package/models/__tests__/compliance.cattle.io.clusterscanprofile.spec.js +30 -0
- package/models/catalog.cattle.io.app.js +1 -1
- package/models/chart.js +3 -1
- package/models/compliance.cattle.io.clusterscanprofile.js +1 -1
- package/models/management.cattle.io.authconfig.js +1 -0
- package/package.json +2 -2
- package/pages/auth/login.vue +5 -2
- package/pages/auth/verify.vue +1 -1
- package/pages/c/_cluster/apps/charts/AppChartCardSubHeader.vue +3 -2
- package/pages/c/_cluster/apps/charts/chart.vue +2 -2
- package/pages/c/_cluster/explorer/EventsTable.vue +89 -3
- package/pages/c/_cluster/explorer/tools/index.vue +3 -3
- package/pages/c/_cluster/settings/performance.vue +12 -25
- package/pages/home.vue +313 -12
- package/plugins/axios.js +2 -1
- package/plugins/dashboard-store/actions.js +1 -1
- package/plugins/dashboard-store/resource-class.js +17 -2
- package/plugins/steve/steve-pagination-utils.ts +2 -2
- package/scripts/extension/publish +1 -1
- package/store/auth.js +8 -3
- package/store/aws.js +8 -6
- package/store/features.js +1 -0
- package/store/index.js +9 -3
- package/store/prefs.js +6 -0
- package/types/kube/kube-api.ts +2 -1
- package/types/rancher/index.d.ts +1 -0
- package/types/resources/settings.d.ts +29 -7
- package/types/shell/index.d.ts +59 -0
- package/utils/__tests__/cluster.test.ts +379 -1
- package/utils/cluster.js +157 -3
- package/utils/dynamic-content/__tests__/config.test.ts +187 -0
- package/utils/dynamic-content/__tests__/index.test.ts +390 -0
- package/utils/dynamic-content/__tests__/info.test.ts +263 -0
- package/utils/dynamic-content/__tests__/new-release.test.ts +216 -0
- package/utils/dynamic-content/__tests__/support-notice.test.ts +262 -0
- package/utils/dynamic-content/__tests__/util.test.ts +235 -0
- package/utils/dynamic-content/config.ts +55 -0
- package/utils/dynamic-content/index.ts +273 -0
- package/utils/dynamic-content/info.ts +219 -0
- package/utils/dynamic-content/new-release.ts +126 -0
- package/utils/dynamic-content/support-notice.ts +169 -0
- package/utils/dynamic-content/types.d.ts +101 -0
- package/utils/dynamic-content/util.ts +122 -0
- package/utils/inactivity.ts +104 -0
- package/utils/pagination-utils.ts +19 -4
- package/utils/release-notes.ts +1 -1
package/utils/cluster.js
CHANGED
|
@@ -8,8 +8,8 @@ import { compare, sortable } from '@shell/utils/version';
|
|
|
8
8
|
import { sortBy } from '@shell/utils/sort';
|
|
9
9
|
import { HARVESTER_CONTAINER, SCHEDULING_CUSTOMIZATION } from '@shell/store/features';
|
|
10
10
|
import { _CREATE, _EDIT } from '@shell/config/query-params';
|
|
11
|
-
import
|
|
12
|
-
import { set } from '@shell/utils/object';
|
|
11
|
+
import isEmptyLodash from 'lodash/isEmpty';
|
|
12
|
+
import { set, diff, isEmpty, clone } from '@shell/utils/object';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Combination of paginationFilterHiddenLocalCluster and paginationFilterOnlyKubernetesClusters
|
|
@@ -323,7 +323,7 @@ export async function initSchedulingCustomization(value, features, store, mode)
|
|
|
323
323
|
errors.push(e);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
if (schedulingCustomizationFeatureEnabled && mode === _CREATE &&
|
|
326
|
+
if (schedulingCustomizationFeatureEnabled && mode === _CREATE && isEmptyLodash(value?.clusterAgentDeploymentCustomization?.schedulingCustomization)) {
|
|
327
327
|
set(value, 'clusterAgentDeploymentCustomization.schedulingCustomization', { priorityClass: clusterAgentDefaultPC, podDisruptionBudget: clusterAgentDefaultPDB });
|
|
328
328
|
}
|
|
329
329
|
|
|
@@ -335,3 +335,157 @@ export async function initSchedulingCustomization(value, features, store, mode)
|
|
|
335
335
|
clusterAgentDefaultPC, clusterAgentDefaultPDB, schedulingCustomizationFeatureEnabled, schedulingCustomizationOriginallyEnabled, errors
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Recursively filters a `diffs` object to only include differences that are relevant to the user.
|
|
341
|
+
* A difference is considered relevant if the user has provided a custom value for that specific field.
|
|
342
|
+
*
|
|
343
|
+
* @param {object} diffs - The object representing the differences between two chart versions' default values.
|
|
344
|
+
* @param {object} userVals - The object containing the user's custom values.
|
|
345
|
+
* @returns {object} A new object containing only the relevant differences.
|
|
346
|
+
*/
|
|
347
|
+
export function _addonConfigPreserveFilter(diffs, userVals) {
|
|
348
|
+
const filtered = {};
|
|
349
|
+
|
|
350
|
+
for (const key of Object.keys(diffs)) {
|
|
351
|
+
const diffVal = diffs[key];
|
|
352
|
+
const userVal = userVals?.[key];
|
|
353
|
+
|
|
354
|
+
const isDiffObject = typeof diffVal === 'object' && diffVal !== null && !Array.isArray(diffVal);
|
|
355
|
+
const isUserObject = typeof userVal === 'object' && userVal !== null && !Array.isArray(userVal);
|
|
356
|
+
|
|
357
|
+
// If both the diff and user value are objects, we need to recurse into them.
|
|
358
|
+
if (isDiffObject && isUserObject) {
|
|
359
|
+
const nestedFiltered = _addonConfigPreserveFilter(diffVal, userVal);
|
|
360
|
+
|
|
361
|
+
if (!isEmpty(nestedFiltered)) {
|
|
362
|
+
filtered[key] = nestedFiltered;
|
|
363
|
+
}
|
|
364
|
+
} else if (userVal !== undefined) {
|
|
365
|
+
// If the user has provided a value for this key, the difference is relevant.
|
|
366
|
+
filtered[key] = diffVal;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return filtered;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Processes a single add-on version change. It fetches the old and new chart information,
|
|
375
|
+
* calculates the differences in default values, and filters them based on user's customizations.
|
|
376
|
+
* If there are no significant differences, it preserves the user's custom values for the new version.
|
|
377
|
+
*
|
|
378
|
+
* @param {object} store The Vuex store.
|
|
379
|
+
* @param {object} userChartValues The user's customized chart values.
|
|
380
|
+
* @param {string} chartName The name of the chart to process.
|
|
381
|
+
* @param {object} oldAddon The addon information from the previous Kubernetes version.
|
|
382
|
+
* @param {object} newAddon The addon information from the new Kubernetes version.
|
|
383
|
+
* @returns {object|null} An object containing the diff and a preserve flag, or null on error.
|
|
384
|
+
*/
|
|
385
|
+
async function _addonConfigPreserveProcess(store, userChartValues, chartName, oldAddon, newAddon) {
|
|
386
|
+
if (chartName.includes('none')) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
const [oldVersionInfo, newVersionInfo] = await Promise.all([
|
|
392
|
+
store.dispatch('catalog/getVersionInfo', {
|
|
393
|
+
repoType: 'cluster',
|
|
394
|
+
repoName: oldAddon.repo,
|
|
395
|
+
chartName,
|
|
396
|
+
versionName: oldAddon.version,
|
|
397
|
+
}),
|
|
398
|
+
store.dispatch('catalog/getVersionInfo', {
|
|
399
|
+
repoType: 'cluster',
|
|
400
|
+
repoName: newAddon.repo,
|
|
401
|
+
chartName,
|
|
402
|
+
versionName: newAddon.version,
|
|
403
|
+
})
|
|
404
|
+
]);
|
|
405
|
+
|
|
406
|
+
const oldDefaults = oldVersionInfo.values;
|
|
407
|
+
const newDefaults = newVersionInfo.values;
|
|
408
|
+
const defaultsDifferences = diff(oldDefaults, newDefaults);
|
|
409
|
+
|
|
410
|
+
const userOldValues = userChartValues[`${ chartName }-${ oldAddon.version }`];
|
|
411
|
+
|
|
412
|
+
// We only care about differences in values that the user has actually customized.
|
|
413
|
+
// If the user hasn't touched a value, a change in its default should not be considered a breaking change.
|
|
414
|
+
const defaultsAndUserDifferences = userOldValues ? _addonConfigPreserveFilter(defaultsDifferences, userOldValues) : {};
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
diff: defaultsAndUserDifferences,
|
|
418
|
+
preserve: isEmpty(defaultsAndUserDifferences)
|
|
419
|
+
};
|
|
420
|
+
} catch (e) {
|
|
421
|
+
console.error(`Failed to get chart version info for diff for chart ${ chartName }`, e); // eslint-disable-line no-console
|
|
422
|
+
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @typedef {object} AddonPreserveContext
|
|
429
|
+
* @property {object} addonConfigDiffs - An object that stores the diffs.
|
|
430
|
+
* @property {string[]} addonNames - An array of addon names to check.
|
|
431
|
+
* @property {object} $store - The Vuex store.
|
|
432
|
+
* @property {object} userChartValues - The user's customized chart values.
|
|
433
|
+
*
|
|
434
|
+
* When the Kubernetes version is changed, this method is called to handle the add-on configurations
|
|
435
|
+
* for all enabled addons. It checks if an addon's version has changed and, if so, determines if the
|
|
436
|
+
* user's custom configurations should be preserved for the new version.
|
|
437
|
+
*
|
|
438
|
+
* The goal is to avoid showing a confirmation dialog for changes in default values that the user has not customized.
|
|
439
|
+
*
|
|
440
|
+
* @param {AddonPreserveContext} context The context object from the component.
|
|
441
|
+
* @param {object} oldCharts The charts object from the K8s release object being changed from.
|
|
442
|
+
* @param {object} newCharts The charts object from the K8s release object being changed to.
|
|
443
|
+
*/
|
|
444
|
+
export async function addonConfigPreserve(context, oldCharts, newCharts) {
|
|
445
|
+
const {
|
|
446
|
+
addonConfigDiffs,
|
|
447
|
+
addonNames,
|
|
448
|
+
$store,
|
|
449
|
+
userChartValues
|
|
450
|
+
} = context;
|
|
451
|
+
|
|
452
|
+
if (!oldCharts || !newCharts) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Clear the diffs object for the new run
|
|
457
|
+
for (const key in addonConfigDiffs) {
|
|
458
|
+
delete addonConfigDiffs[key];
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Iterate through the addons that are enabled for the cluster.
|
|
462
|
+
for (const chartName of addonNames) {
|
|
463
|
+
const oldAddon = oldCharts[chartName];
|
|
464
|
+
const newAddon = newCharts[chartName];
|
|
465
|
+
|
|
466
|
+
// If the addon didn't exist in the old K8s version, there's nothing to compare.
|
|
467
|
+
if (!oldAddon) {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Check if the add-on version has changed.
|
|
472
|
+
if (newAddon && newAddon.version !== oldAddon.version) {
|
|
473
|
+
const result = await _addonConfigPreserveProcess($store, userChartValues, chartName, oldAddon, newAddon);
|
|
474
|
+
|
|
475
|
+
if (result) {
|
|
476
|
+
addonConfigDiffs[chartName] = result.diff;
|
|
477
|
+
|
|
478
|
+
if (result.preserve) {
|
|
479
|
+
const oldKey = `${ chartName }-${ oldAddon.version }`;
|
|
480
|
+
const newKey = `${ chartName }-${ newAddon.version }`;
|
|
481
|
+
|
|
482
|
+
// If custom values exist for the old version, and none exist for the new version,
|
|
483
|
+
// copy the values to the new key to preserve them.
|
|
484
|
+
if (userChartValues[oldKey] && !userChartValues[newKey]) {
|
|
485
|
+
userChartValues[newKey] = clone(userChartValues[oldKey]);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { getConfig } from '../config';
|
|
2
|
+
import { SETTING } from '@shell/config/settings';
|
|
3
|
+
import * as version from '@shell/config/version';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_ENDPOINT = 'https://updates.rancher.io/rancher/$dist/updates';
|
|
6
|
+
|
|
7
|
+
// Mock dependencies
|
|
8
|
+
jest.mock('@shell/config/version', () => ({ getVersionData: jest.fn(), isRancherPrime: jest.fn() }));
|
|
9
|
+
|
|
10
|
+
describe('getConfig', () => {
|
|
11
|
+
let mockGetters: any;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
// Reset mocks before each test
|
|
15
|
+
(version.getVersionData as jest.Mock).mockClear();
|
|
16
|
+
(version.isRancherPrime as jest.Mock).mockClear();
|
|
17
|
+
|
|
18
|
+
// Default mock for getters
|
|
19
|
+
mockGetters = { 'management/byId': jest.fn() };
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('community distribution', () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
(version.getVersionData as jest.Mock).mockReturnValue({ RancherPrime: 'false' });
|
|
25
|
+
(version.isRancherPrime as jest.Mock).mockReturnValue(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should return default community config when no settings are present', () => {
|
|
29
|
+
mockGetters['management/byId'].mockReturnValue(null);
|
|
30
|
+
const config = getConfig(mockGetters);
|
|
31
|
+
|
|
32
|
+
expect(config.prime).toBe(false);
|
|
33
|
+
expect(config.distribution).toBe('community');
|
|
34
|
+
expect(config.endpoint).toBe(DEFAULT_ENDPOINT);
|
|
35
|
+
expect(config.enabled).toBe(true);
|
|
36
|
+
expect(config.debug).toBe(false);
|
|
37
|
+
expect(config.log).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should enable debug and log modes when enabled setting is "debug"', () => {
|
|
41
|
+
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
|
|
42
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENABLED) {
|
|
43
|
+
return { value: 'debug' };
|
|
44
|
+
}
|
|
45
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENDPOINT) {
|
|
46
|
+
return { value: 'https://test.endpoint' };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const config = getConfig(mockGetters);
|
|
53
|
+
|
|
54
|
+
expect(config.enabled).toBe(true);
|
|
55
|
+
expect(config.debug).toBe(true);
|
|
56
|
+
expect(config.log).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should enable log mode when enabled setting is "log"', () => {
|
|
60
|
+
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
|
|
61
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENABLED) {
|
|
62
|
+
return { value: 'log' };
|
|
63
|
+
}
|
|
64
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENDPOINT) {
|
|
65
|
+
return { value: 'https://test.endpoint' };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const config = getConfig(mockGetters);
|
|
72
|
+
|
|
73
|
+
expect(config.enabled).toBe(true);
|
|
74
|
+
expect(config.debug).toBe(false);
|
|
75
|
+
expect(config.log).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should not use the endpoint from settings when community', () => {
|
|
79
|
+
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
|
|
80
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENDPOINT) {
|
|
81
|
+
return { value: 'https://custom.endpoint/rancher/$dist' };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const config = getConfig(mockGetters);
|
|
88
|
+
|
|
89
|
+
expect(config.endpoint).toBe(DEFAULT_ENDPOINT);
|
|
90
|
+
expect(config.enabled).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('prime distribution', () => {
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
(version.getVersionData as jest.Mock).mockReturnValue({ RancherPrime: 'true' });
|
|
97
|
+
(version.isRancherPrime as jest.Mock).mockReturnValue(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should return default prime config when no settings are present', () => {
|
|
101
|
+
mockGetters['management/byId'].mockReturnValue(null);
|
|
102
|
+
const config = getConfig(mockGetters);
|
|
103
|
+
|
|
104
|
+
expect(config.prime).toBe(true);
|
|
105
|
+
expect(config.distribution).toBe('prime');
|
|
106
|
+
expect(config.endpoint).toBe(DEFAULT_ENDPOINT);
|
|
107
|
+
expect(config.enabled).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should be disabled when the setting is "false"', () => {
|
|
111
|
+
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
|
|
112
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENABLED) {
|
|
113
|
+
return { value: 'false' };
|
|
114
|
+
}
|
|
115
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENDPOINT) {
|
|
116
|
+
return { value: 'https://test.endpoint' };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return null;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const config = getConfig(mockGetters);
|
|
123
|
+
|
|
124
|
+
expect(config.enabled).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should be enabled when the setting is "true"', () => {
|
|
128
|
+
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
|
|
129
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENABLED) {
|
|
130
|
+
return { value: 'true' };
|
|
131
|
+
}
|
|
132
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENDPOINT) {
|
|
133
|
+
return { value: 'https://test.endpoint' };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return null;
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const config = getConfig(mockGetters);
|
|
140
|
+
|
|
141
|
+
expect(config.enabled).toBe(true);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should NOT use the endpoint from settings if it is not a valid HTTPS URL', () => {
|
|
145
|
+
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
|
|
146
|
+
if (id === SETTING.DYNAMIC_CONTENT_ENDPOINT) {
|
|
147
|
+
return { value: 'http://insecure.endpoint/rancher/$dist' };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return null;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const config = getConfig(mockGetters);
|
|
154
|
+
|
|
155
|
+
expect(config.endpoint).toBe(DEFAULT_ENDPOINT); // Falls back to default
|
|
156
|
+
expect(config.enabled).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('general', () => {
|
|
161
|
+
it('should handle exceptions when reading settings and return defaults', () => {
|
|
162
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
163
|
+
const testError = new Error('Something went wrong');
|
|
164
|
+
|
|
165
|
+
(version.getVersionData as jest.Mock).mockReturnValue({ RancherPrime: 'false' });
|
|
166
|
+
(version.isRancherPrime as jest.Mock).mockReturnValue(false);
|
|
167
|
+
mockGetters['management/byId'].mockImplementation(() => {
|
|
168
|
+
throw testError;
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const config = getConfig(mockGetters);
|
|
172
|
+
|
|
173
|
+
// It should fall back to the default configuration
|
|
174
|
+
expect(config.prime).toBe(false);
|
|
175
|
+
expect(config.distribution).toBe('community');
|
|
176
|
+
expect(config.endpoint).toBe(DEFAULT_ENDPOINT);
|
|
177
|
+
expect(config.enabled).toBe(true);
|
|
178
|
+
expect(config.debug).toBe(false);
|
|
179
|
+
expect(config.log).toBe(false);
|
|
180
|
+
|
|
181
|
+
// And it should log the error
|
|
182
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Error reading dynamic content settings', testError);
|
|
183
|
+
|
|
184
|
+
consoleErrorSpy.mockRestore();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
});
|