test: Add unleash flag mocking to the tests

The functionality is currently gated behind an unleash flag. This adds the mocked flag to the tests.
This commit is contained in:
regexowl 2024-04-23 15:06:44 +02:00 committed by Lucas Garfield
parent 473d750145
commit 3b7a1338ec
2 changed files with 17 additions and 5 deletions

View file

@ -50,11 +50,16 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
let mockContentSourcesEnabled: boolean;
jest.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => jest.fn(),
useFlag: jest.fn((flag) =>
flag === 'image-builder.enable-content-sources'
? mockContentSourcesEnabled
: false
),
useFlag: jest.fn((flag) => {
switch (flag) {
case 'image-builder.enable-content-sources':
return mockContentSourcesEnabled;
case 'image-builder.pkgrecs.enabled':
return true;
default:
return false;
}
}),
}));
beforeAll(() => {

View file

@ -31,6 +31,13 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
}),
}));
jest.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => jest.fn(),
useFlag: jest.fn((flag) =>
flag === 'image-builder.pkgrecs.enabled' ? true : false
),
}));
const goToPackagesStep = async () => {
const bareMetalCheckBox = await screen.findByRole('checkbox', {
name: /bare metal installer checkbox/i,