test: Update test files to work with Vitest
This updates the files to be compatible with Vitest. Changes include: - adding `@testing-library/jest-dom` import to enable custom jest matchers - renaming `jest.` to `vi.` - setting flags to false as default where needed
This commit is contained in:
parent
da16a42128
commit
2a48966bba
23 changed files with 196 additions and 63 deletions
|
|
@ -1,12 +1,14 @@
|
|||
import '@testing-library/jest-dom';
|
||||
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
import { renderWithReduxRouter } from '../../test/testUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
isBeta: () => true,
|
||||
isProd: () => true,
|
||||
|
|
@ -16,9 +18,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
|
||||
window.HTMLElement.prototype.scrollTo = function () {};
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) => {
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) => {
|
||||
switch (flag) {
|
||||
case 'image-builder.import.enabled':
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import React from 'react';
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { rest } from 'msw';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import CreateImageWizard from '../../../Components/CreateImageWizardV2';
|
||||
import LandingPage from '../../../Components/LandingPage/LandingPage';
|
||||
|
|
@ -13,11 +15,10 @@ import {
|
|||
renderCustomRoutesWithReduxRouter,
|
||||
renderWithReduxRouter,
|
||||
} from '../../testUtils';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
isBeta: () => true,
|
||||
isProd: () => true,
|
||||
|
|
@ -25,9 +26,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) =>
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) =>
|
||||
flag === 'image-builder.new-wizard.enabled' ? true : false
|
||||
),
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import type { Router as RemixRouter } from '@remix-run/router';
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { rest } from 'msw';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import CreateImageWizard from '../../../Components/CreateImageWizardV2/CreateImageWizard';
|
||||
import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal';
|
||||
|
|
@ -18,6 +19,8 @@ import {
|
|||
verifyCancelButton,
|
||||
} from '../../testUtils';
|
||||
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'insights/image-builder/*',
|
||||
|
|
@ -32,7 +35,7 @@ const routes = [
|
|||
element: <ShareImageModal />,
|
||||
},
|
||||
];
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -51,6 +54,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
// The router is just initiliazed here, it's assigned a value in the tests
|
||||
let router: RemixRouter | undefined = undefined;
|
||||
|
||||
|
|
@ -60,7 +68,7 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
router = undefined;
|
||||
server.resetHandlers();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@ import '@testing-library/jest-dom';
|
|||
|
||||
import { screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import CreateImageWizard from '../../../Components/CreateImageWizardV2/CreateImageWizard';
|
||||
import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal';
|
||||
import { clickNext, renderCustomRoutesWithReduxRouter } from '../../testUtils';
|
||||
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'insights/image-builder/*',
|
||||
|
|
@ -24,7 +27,7 @@ const routes = [
|
|||
},
|
||||
];
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -43,9 +46,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) =>
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) =>
|
||||
flag === 'image-builder.wizard.oscap.enabled' ? true : false
|
||||
),
|
||||
}));
|
||||
|
|
@ -56,7 +59,7 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
const selectRhel8 = async () => {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import '@testing-library/jest-dom';
|
|||
import type { Router as RemixRouter } from '@remix-run/router';
|
||||
import { screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import CreateImageWizard from '../../../Components/CreateImageWizardV2/CreateImageWizard';
|
||||
import {
|
||||
|
|
@ -14,6 +15,8 @@ import {
|
|||
verifyCancelButton,
|
||||
} from '../../testUtils';
|
||||
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'insights/image-builder/*',
|
||||
|
|
@ -28,7 +31,7 @@ const routes = [
|
|||
// The router is just initiliazed here, it's assigned a value in the tests
|
||||
let router: RemixRouter | undefined = undefined;
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -48,9 +51,10 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}));
|
||||
|
||||
let mockContentSourcesEnabled: boolean;
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) => {
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) => {
|
||||
switch (flag) {
|
||||
case 'image-builder.enable-content-sources':
|
||||
return mockContentSourcesEnabled;
|
||||
|
|
@ -69,7 +73,7 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
mockContentSourcesEnabled = true;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
} from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { rest } from 'msw';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import {
|
||||
enterBlueprintName,
|
||||
|
|
@ -29,6 +30,8 @@ import {
|
|||
verifyCancelButton,
|
||||
} from '../../testUtils';
|
||||
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'insights/image-builder/*',
|
||||
|
|
@ -46,7 +49,7 @@ const routes = [
|
|||
|
||||
let router: RemixRouter | undefined = undefined;
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -65,6 +68,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const switchToAWSManual = async () => {
|
||||
const user = userEvent.setup();
|
||||
const manualRadio = await screen.findByRole('radio', {
|
||||
|
|
@ -96,7 +104,7 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
router = undefined;
|
||||
server.resetHandlers();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import { mockBlueprintIds } from '../../../../fixtures/blueprints';
|
||||
|
|
@ -18,7 +19,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -37,6 +40,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToDetailsStep = async () => {
|
||||
await clickNext();
|
||||
await clickNext();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { screen, waitFor, within } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import {
|
||||
CREATE_BLUEPRINT,
|
||||
|
|
@ -22,7 +23,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -41,6 +44,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToFileSystemConfigurationStep = async () => {
|
||||
const guestImageCheckBox = await screen.findByRole('checkbox', {
|
||||
name: /virtualization guest image checkbox/i,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import {
|
||||
CREATE_BLUEPRINT,
|
||||
|
|
@ -23,9 +25,10 @@ import {
|
|||
renderCreateMode,
|
||||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -39,11 +42,18 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
},
|
||||
},
|
||||
isBeta: () => true,
|
||||
isProd: () => true,
|
||||
getEnvironment: () => 'prod',
|
||||
isProd: () => false,
|
||||
getEnvironment: () => 'stage',
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) =>
|
||||
flag === 'image-builder.firstboot.enabled' ? true : false
|
||||
),
|
||||
}));
|
||||
|
||||
const goToFirstBootStep = async (): Promise<void> => {
|
||||
const guestImageCheckBox = await screen.findByRole('checkbox', {
|
||||
name: /virtualization guest image checkbox/i,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import '@testing-library/jest-dom';
|
|||
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import CreateImageWizard from '../../../../../Components/CreateImageWizardV2/CreateImageWizard';
|
||||
import {
|
||||
|
|
@ -45,13 +46,16 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'insights/image-builder/imagewizard/:composeId?',
|
||||
element: <CreateImageWizard />,
|
||||
},
|
||||
];
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -70,13 +74,18 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
beforeAll(() => {
|
||||
// scrollTo is not defined in jsdom
|
||||
window.HTMLElement.prototype.scrollTo = function () {};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
server.resetHandlers();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import { CreateBlueprintRequest } from '../../../../../store/imageBuilderApi';
|
||||
|
|
@ -19,7 +20,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -38,6 +41,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToOscapStep = async () => {
|
||||
const guestImageCheckBox = await screen.findByRole('checkbox', {
|
||||
name: /virtualization guest image checkbox/i,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor, within } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import { CreateBlueprintRequest } from '../../../../../store/imageBuilderApi';
|
||||
|
|
@ -24,7 +26,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -43,9 +47,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) =>
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) =>
|
||||
flag === 'image-builder.pkgrecs.enabled' ? true : false
|
||||
),
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import {
|
||||
CREATE_BLUEPRINT,
|
||||
|
|
@ -24,7 +25,9 @@ import {
|
|||
interceptEditBlueprintRequest,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -43,6 +46,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const selectActivationKey = async () => {
|
||||
const activationKeyDropdown = await screen.findByRole('textbox', {
|
||||
name: 'Select activation key',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import {
|
||||
|
|
@ -25,7 +27,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -44,6 +48,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToRepositoriesStep = async () => {
|
||||
const guestImageCheckBox = await screen.findByRole('checkbox', {
|
||||
name: /virtualization guest image checkbox/i,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import { CreateBlueprintRequest } from '../../../../../store/imageBuilderApi';
|
||||
|
|
@ -21,7 +23,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -40,6 +44,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToSnapshotStep = async () => {
|
||||
const guestImageCheckBox = await screen.findByRole('checkbox', {
|
||||
name: /virtualization guest image checkbox/i,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import {
|
||||
|
|
@ -20,7 +21,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -39,6 +42,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToAwsStep = async () => {
|
||||
await clickNext();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import {
|
||||
|
|
@ -20,7 +21,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -39,6 +42,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const goToAzureStep = async () => {
|
||||
await clickNext();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { userEvent } from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { CREATE_BLUEPRINT, EDIT_BLUEPRINT } from '../../../../../constants';
|
||||
import {
|
||||
|
|
@ -23,7 +24,9 @@ import {
|
|||
renderEditMode,
|
||||
} from '../../wizardTestUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
auth: {
|
||||
getUser: () => {
|
||||
|
|
@ -42,6 +45,11 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
const GCP_ACCOUNT = 'test@gmail.com';
|
||||
|
||||
const goToReview = async () => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
import {
|
||||
mockComposes,
|
||||
mockClones,
|
||||
|
|
@ -9,7 +10,9 @@ import {
|
|||
} from '../../fixtures/composes';
|
||||
import { renderWithReduxRouter } from '../../testUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
isBeta: () => false,
|
||||
isProd: () => true,
|
||||
|
|
@ -17,9 +20,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) => {
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) => {
|
||||
switch (flag) {
|
||||
case 'edgeParity.image-list':
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { rest } from 'msw';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { IMAGE_BUILDER_API } from '../../../constants';
|
||||
import { mockComposesEmpty } from '../../fixtures/composes';
|
||||
import { server } from '../../mocks/server';
|
||||
import { renderWithReduxRouter } from '../../testUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
isBeta: () => false,
|
||||
isProd: () => true,
|
||||
|
|
@ -14,9 +18,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) => {
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) => {
|
||||
switch (flag) {
|
||||
case 'edgeParity.image-list':
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -3,11 +3,14 @@ import React from 'react';
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal';
|
||||
import { renderCustomRoutesWithReduxRouter } from '../../testUtils';
|
||||
|
||||
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
Object.assign(global, { fetch: nodeFetch, Request, Response });
|
||||
|
||||
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
|
||||
useChrome: () => ({
|
||||
isBeta: () => false,
|
||||
isProd: () => true,
|
||||
|
|
@ -97,7 +100,7 @@ describe('Create Share To Regions Modal', () => {
|
|||
});
|
||||
|
||||
test('select options disabled correctly based on status and region', async () => {
|
||||
renderCustomRoutesWithReduxRouter(`share/${composeId}`, {}, routes);
|
||||
await renderCustomRoutesWithReduxRouter(`share/${composeId}`, {}, routes);
|
||||
|
||||
const selectToggle = await screen.findByRole('button', {
|
||||
name: /menu toggle/i,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import '@testing-library/jest-dom';
|
|||
|
||||
import { useFlag } from '@unleash/proxy-client-react';
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) =>
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) =>
|
||||
flag === 'image-builder.edge.local-image-table' ? true : false
|
||||
),
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import '@testing-library/jest-dom';
|
|||
|
||||
import { useFlag } from '@unleash/proxy-client-react';
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn((flag) =>
|
||||
vi.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => vi.fn(),
|
||||
useFlag: vi.fn((flag) =>
|
||||
flag === 'image-builder.edge.local-image-table' ? true : false
|
||||
),
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue