Fix unit tests

This commit is contained in:
Neil MacDougall 2025-10-01 16:39:35 +01:00
parent 6a777350c2
commit c35801aa7c
2 changed files with 6 additions and 8 deletions

View File

@ -3,9 +3,7 @@ import { SETTING } from '@shell/config/settings';
import * as version from '@shell/config/version';
// Mock dependencies
jest.mock('@shell/config/version', () => ({
getVersionData: jest.fn(),
}));
jest.mock('@shell/config/version', () => ({ getVersionData: jest.fn() }));
describe('getConfig', () => {
let mockGetters: any;
@ -18,7 +16,7 @@ describe('getConfig', () => {
mockGetters = { 'management/byId': jest.fn() };
});
describe('Community Distribution', () => {
describe('community distribution', () => {
beforeEach(() => {
(version.getVersionData as jest.Mock).mockReturnValue({ RancherPrime: 'false' });
});
@ -90,7 +88,7 @@ describe('getConfig', () => {
});
});
describe('Prime Distribution', () => {
describe('prime distribution', () => {
beforeEach(() => {
(version.getVersionData as jest.Mock).mockReturnValue({ RancherPrime: 'true' });
});
@ -156,13 +154,14 @@ describe('getConfig', () => {
});
});
describe('General', () => {
describe('general', () => {
it('should be disabled if no endpoint is configured, regardless of other settings', () => {
(version.getVersionData as jest.Mock).mockReturnValue({ RancherPrime: 'true' });
mockGetters['management/byId'].mockImplementation((type: string, id: string) => {
if (id === SETTING.DYNAMIC_CONTENT_ENABLED) {
return { value: 'true' }; // Explicitly enabled
}
// No endpoint setting
return null;
});

View File

@ -203,7 +203,6 @@ export async function fetchDynamicContent(context: Context): Promise<Partial<Dyn
const activeFetch = window.localStorage.getItem(LOCAL_STORAGE_UPDATE_FETCHING);
if (activeFetch) {
const activeFetchDate = day(activeFetch);