test: Update handlers in test files
This updates handlers used directly in the test files to match current API.
This commit is contained in:
parent
501323b476
commit
797ceddcd1
5 changed files with 33 additions and 30 deletions
|
|
@ -3,7 +3,7 @@ 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 { http, HttpResponse } from 'msw';
|
||||
|
||||
import CreateImageWizard from '../../../Components/CreateImageWizard';
|
||||
import LandingPage from '../../../Components/LandingPage/LandingPage';
|
||||
|
|
@ -58,8 +58,8 @@ describe('Blueprints', () => {
|
|||
});
|
||||
test('renders blueprint empty state', async () => {
|
||||
server.use(
|
||||
rest.get(`${IMAGE_BUILDER_API}/blueprints`, (req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json(emptyGetBlueprints));
|
||||
http.get(`${IMAGE_BUILDER_API}/blueprints`, () => {
|
||||
return HttpResponse.json(emptyGetBlueprints);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -217,12 +217,9 @@ describe('Blueprints', () => {
|
|||
});
|
||||
test('redirect to index page when blueprint is invalid', async () => {
|
||||
server.use(
|
||||
rest.get(
|
||||
`${IMAGE_BUILDER_API}/blueprints/invalid-compose-id`,
|
||||
(req, res, ctx) => {
|
||||
return res(ctx.status(404));
|
||||
}
|
||||
)
|
||||
http.get(`${IMAGE_BUILDER_API}/blueprints/invalid-compose-id`, () => {
|
||||
return new HttpResponse(null, { status: 404 });
|
||||
})
|
||||
);
|
||||
await renderCustomRoutesWithReduxRouter(
|
||||
'imagewizard/invalid-compose-id',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import '@testing-library/jest-dom';
|
|||
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 { http, HttpResponse } from 'msw';
|
||||
|
||||
import CreateImageWizard from '../../../Components/CreateImageWizard/CreateImageWizard';
|
||||
import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal';
|
||||
|
|
@ -289,9 +289,9 @@ describe('Step Upload to Azure', () => {
|
|||
|
||||
test('component renders error state correctly', async () => {
|
||||
server.use(
|
||||
rest.get(`${PROVISIONING_API}/sources`, (req, res, ctx) =>
|
||||
res(ctx.status(500))
|
||||
)
|
||||
http.get(`${PROVISIONING_API}/sources`, () => {
|
||||
return new HttpResponse(null, { status: 500 });
|
||||
})
|
||||
);
|
||||
|
||||
await setUp();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
within,
|
||||
} from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { rest } from 'msw';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
|
||||
import {
|
||||
enterBlueprintName,
|
||||
|
|
@ -346,9 +346,9 @@ describe('Step Upload to AWS', () => {
|
|||
|
||||
test('component renders error state correctly', async () => {
|
||||
server.use(
|
||||
rest.get(`${PROVISIONING_API}/sources`, (req, res, ctx) =>
|
||||
res(ctx.status(500))
|
||||
)
|
||||
http.get(`${PROVISIONING_API}/sources`, () => {
|
||||
return new HttpResponse(null, { status: 500 });
|
||||
})
|
||||
);
|
||||
await setUp();
|
||||
await screen.findByText(
|
||||
|
|
@ -607,8 +607,8 @@ describe('Step Registration', () => {
|
|||
|
||||
test('activation key dropdown empty state', async () => {
|
||||
server.use(
|
||||
rest.get(`${RHSM_API}/activation_keys`, (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json({ body: [] }))
|
||||
http.get(`${RHSM_API}/activation_keys`, () =>
|
||||
HttpResponse.json({ body: [] })
|
||||
)
|
||||
);
|
||||
await setUp();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import '@testing-library/jest-dom';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { rest } from 'msw';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
|
||||
import { IMAGE_BUILDER_API } from '../../../constants';
|
||||
import { mockComposesEmpty } from '../../fixtures/composes';
|
||||
|
|
@ -42,8 +42,8 @@ describe('Landing Page', () => {
|
|||
|
||||
test('renders EmptyState child component', async () => {
|
||||
server.use(
|
||||
rest.get(`${IMAGE_BUILDER_API}/composes`, (req, res, ctx) => {
|
||||
return res(ctx.status(200), ctx.json(mockComposesEmpty));
|
||||
http.get(`${IMAGE_BUILDER_API}/composes`, () => {
|
||||
return HttpResponse.json(mockComposesEmpty);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
|||
22
src/test/fixtures/composes.ts
vendored
22
src/test/fixtures/composes.ts
vendored
|
|
@ -1,5 +1,3 @@
|
|||
import { PathParams, RestRequest } from 'msw';
|
||||
|
||||
import { RHEL_8, RHEL_9 } from '../../constants';
|
||||
import {
|
||||
AwsUploadStatus,
|
||||
|
|
@ -26,12 +24,20 @@ export const mockComposesEmpty: ComposesResponse = {
|
|||
const currentDate = new Date();
|
||||
const currentDateInString = currentDate.toISOString();
|
||||
|
||||
export const composesEndpoint = (
|
||||
req: RestRequest<never, PathParams<string>>
|
||||
) => {
|
||||
const params = req.url.searchParams;
|
||||
const limit = Number(params.get('limit')) || 100;
|
||||
const offset = Number(params.get('offset')) || 0;
|
||||
type Params = {
|
||||
limit: number;
|
||||
offset: number;
|
||||
ignoreImageTypes: string;
|
||||
};
|
||||
|
||||
type Url = {
|
||||
searchParams: Params;
|
||||
};
|
||||
|
||||
export const composesEndpoint = (url: Url) => {
|
||||
const params = url.searchParams;
|
||||
const limit = Number(params.limit) || 100;
|
||||
const offset = Number(params.offset) || 0;
|
||||
|
||||
return {
|
||||
meta: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue