Skip to content

Commit

Permalink
Add render test to AdvisoryDetailsPage
Browse files Browse the repository at this point in the history
  • Loading branch information
dottorblaster committed Aug 7, 2024
1 parent 805c2f1 commit a3898ad
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assets/js/pages/AdvisoryDetails/AdvisoryDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function AdvisoryDetails({
<a
className="text-jungle-green-500 hover:opacity-75"
target="_blank"
rel="noreferrer"
href={`https://bugzilla.suse.com/show_bug.cgi?id=${id}`}
>
{fix}
Expand All @@ -112,6 +113,7 @@ function AdvisoryDetails({
<a
className="text-jungle-green-500 hover:opacity-75"
target="_blank"
rel="noreferrer"
href={`https://cve.mitre.org/cgi-bin/cvename.cgi?name=${cve}`}
>
{cve}
Expand Down
44 changes: 44 additions & 0 deletions assets/js/pages/AdvisoryDetails/AdvisoryDetailsPage.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { screen, act } from '@testing-library/react';
import MockAdapter from 'axios-mock-adapter';
import { networkClient } from '@lib/network';
import '@testing-library/jest-dom';

import { faker } from '@faker-js/faker';

import {
renderWithRouterMatch,
defaultInitialState,
withState,
} from '@lib/test-utils';
import { advisoryErrataFactory } from '@lib/test-utils/factories';

import AdvisoryDetailsPage from '.';

describe('Advisory Details Page', () => {
it('should render correctly', async () => {
const axiosMock = new MockAdapter(networkClient);

const hostID = faker.string.uuid();
const advisoryName = faker.string.uuid();
const errata = advisoryErrataFactory.build();

axiosMock
.onGet(`/api/v1/software_updates/errata_details/${advisoryName}`)
.reply(200, errata);

const [StatefulPage] = withState(
<AdvisoryDetailsPage />,
defaultInitialState
);

await act(async () => {
renderWithRouterMatch(StatefulPage, {
path: 'hosts/:hostID/patches/:advisoryID',
route: `/hosts/${hostID}/patches/${advisoryName}`,
});
});

expect(screen.getByText(advisoryName)).toBeVisible();
});
});

0 comments on commit a3898ad

Please sign in to comment.