test: Move mocks to setup file

This moves all the mocks used throughout our test files into the test setup file.
This commit is contained in:
regexowl 2024-08-07 11:07:29 +02:00 committed by Klara Simickova
parent 79d54eed7b
commit 1554d78cba
25 changed files with 43 additions and 632 deletions

View file

@ -15,6 +15,49 @@ const MockResizeObserver = vi.fn(() => ({
}));
vi.stubGlobal('ResizeObserver', MockResizeObserver);
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
useChrome: () => ({
auth: {
getUser: () => {
return {
identity: {
internal: {
org_id: 5,
},
},
};
},
},
isBeta: () => true,
isProd: () => true,
getEnvironment: () => 'prod',
}),
}));
vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn((flag) => {
switch (flag) {
case 'image-builder.import.enabled':
return true;
case 'image-builder.firstboot.enabled':
return true;
case 'image-builder.snapshots.enabled':
return true;
case 'image-builder.wsl.enabled':
return true;
case 'image-builder.pkgrecs.enabled':
return true;
case 'edgeParity.image-list':
return true;
case 'image-builder.edge.local-image-table':
return true;
default:
return false;
}
}),
}));
// Remove DOM dump from the testing-library output
configure({
getElementError: (message: string) => {