Skip to content

Commit

Permalink
Advisory details fixes (#2873)
Browse files Browse the repository at this point in the history
* Open bugzilla links and cves in new tabs

* Add render test to AdvisoryDetailsPage
  • Loading branch information
dottorblaster authored Aug 8, 2024
1 parent b9972ab commit 69ff1ea
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions assets/js/pages/AdvisoryDetails/AdvisoryDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ function AdvisoryDetails({
<li key={`bug-${id}`}>
<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 @@ -110,6 +112,8 @@ function AdvisoryDetails({
<li key={cve}>
<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
4 changes: 3 additions & 1 deletion assets/js/pages/AdvisoryDetails/AdvisoryDetailsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function AdvisoryDetailsPage() {
return (
<>
<BackButton url={`/hosts/${hostID}`}>Back</BackButton>
{!isLoading ? <AdvisoryDetails errata={advisoryErrata} /> : null}
{!isLoading ? (
<AdvisoryDetails advisoryName={advisoryID} errata={advisoryErrata} />
) : null}
</>
);
}
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 69ff1ea

Please sign in to comment.