Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests after PF5 migration #2115

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions cypress/utils/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,26 @@ export const itHasNoActiveFilter = () => {
};

export const itExportsDataToFile = (jsonData, filenamePrefix) => {
it.skip('exports data to JSON and CSV files', () => {
it('exports data to JSON and CSV files', () => {
cy.clock(Date.now());

cy.get('.pf-v5-c-toolbar__content-section > :nth-child(2) > .pf-v5-c-menu-toggle').click();
cy.get('[data-ouia-component-id=Export] .pf-v5-c-dropdown__menu-item').should(
// the toggle of the export dropdown has aria-label of "Export"
// the actual dropdown has ouiaId of "Export"

cy.get('[aria-label=Export]').click();

cy.get('[data-ouia-component-id=Export] .pf-v5-c-menu__item').should(
'have.length',
3
);
cy.get('[data-ouia-component-id=Export] .pf-v5-c-dropdown__menu-item')

cy.get('[data-ouia-component-id=Export] .pf-v5-c-menu__item')
leSamo marked this conversation as resolved.
Show resolved Hide resolved
.contains('Export to JSON')
.click();

cy.get('[data-ouia-component-id=Export] button').click();
cy.get('[aria-label=Export]').click();

cy.get('[data-ouia-component-id=Export] .pf-v5-c-dropdown__menu-item')
cy.get('[data-ouia-component-id=Export] .pf-v5-c-menu__item')
.contains('Export to CSV')
.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import CVEDetailsPageDescription from './CVEDetailsPageDescription';
import { render } from '@testing-library/react';
import { IntlProvider } from '@redhat-cloud-services/frontend-components-translations';
import { CVEPageContext } from '../../SmartComponents/CVEDetailsPage/CVEDetailsPage';

describe('CVEDetailsPageDescription component', () => {
const cveAttributes = {
Expand All @@ -22,10 +23,12 @@ describe('CVEDetailsPageDescription component', () => {
systems_status_detail: { 0: 2 }
};

it.skip('should render without props', () => {
it('should render without props', () => {
const { asFragment } = render(
<IntlProvider locale="en">
<CVEDetailsPageDescription cveAttributes={cveAttributes} />
<CVEPageContext.Provider value={{ isLoading: false }}>
<CVEDetailsPageDescription cveAttributes={cveAttributes} />
</CVEPageContext.Provider>
</IntlProvider>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,228 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CVEDetailsPageDescription component should render without props 1`] = `
<injectIntl(CVEDetailsPageDescription)
cveAttributes={
{
"business_risk": "Not defined",
"business_risk_id": 0,
"business_risk_justification": null,
"cvss3_metrics": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H",
"cvss3_score": "5.900",
"description": "It was found that ghostscript could leak sensitive operators on the operand stack when a pseudo-operator pushes a subroutine. A specially crafted PostScript file could use this flaw to escape the -dSAFER protection in order to, for example, have access to the file system and execute commands.",
"impact": "Important",
"public_date": "12 May 2020",
"status": "Resolved via mitigation",
"status_id": 6,
"synopsis": "CVE-2020-10711",
"systems_status_detail": {
"0": 2,
},
}
}
>
<CVEDetailsPageDescription
cveAttributes={
{
"business_risk": "Not defined",
"business_risk_id": 0,
"business_risk_justification": null,
"cvss3_metrics": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H",
"cvss3_score": "5.900",
"description": "It was found that ghostscript could leak sensitive operators on the operand stack when a pseudo-operator pushes a subroutine. A specially crafted PostScript file could use this flaw to escape the -dSAFER protection in order to, for example, have access to the file system and execute commands.",
"impact": "Important",
"public_date": "12 May 2020",
"status": "Resolved via mitigation",
"status_id": 6,
"synopsis": "CVE-2020-10711",
"systems_status_detail": {
"0": 2,
},
}
}
intl={
{
"$t": [Function],
"defaultFormats": {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": {},
"formatters": {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": {
"default.cancel": "Cancel",
"default.delete": "Delete",
"default.remove": "Remove",
"default.save": "Save",
},
"onError": [Function],
"onWarn": [Function],
"textComponent": Symbol(react.fragment),
"timeZone": undefined,
"wrapRichTextChunksInFragment": undefined,
}
}
<DocumentFragment>
<div
class="pf-v5-l-stack pf-m-gutter"
>
<Stack
hasGutter={true}
<div
class="pf-v5-l-stack__item pf-v5-u-mt-sm"
>
<div
className="pf-l-stack pf-m-gutter"
class="pf-v5-l-flex"
>
<StackItem
className="pf-u-mt-sm"
<div
class=""
>
<div
className="pf-l-stack__item pf-u-mt-sm"
>
<Flex>
<div
className="pf-l-flex"
>
<FlexItem>
<div
className=""
>
Publish date
:
</div>
</FlexItem>
<FlexItem
grow={
{
"default": "grow",
}
}
>
<div
className="pf-m-grow"
>
<WithLoader
isLoading={true}
size="sm"
variant="inlineSkeleton"
>
<Skeleton
size="sm"
style={
{
"display": "inline-block",
}
}
>
<Skeleton
className="ins-c-skeleton ins-c-skeleton__sm"
style={
{
"display": "inline-block",
}
}
>
<div
className="pf-c-skeleton ins-c-skeleton ins-c-skeleton__sm"
style={
{
"display": "inline-block",
}
}
>
<span
className="pf-u-screen-reader"
/>
</div>
</Skeleton>
</Skeleton>
</WithLoader>
</div>
</FlexItem>
</div>
</Flex>
</div>
</StackItem>
<StackItem>
<div
className="pf-l-stack__item"
>
<WithLoader
isLoading={true}
style={
{
"height": "132px",
"width": "100%",
}
}
variant="rectangle"
>
<Skeleton
shape="square"
style={
{
"height": "132px",
"width": "100%",
}
}
>
<Skeleton
className="ins-c-skeleton ins-c-skeleton__md"
shape="square"
style={
{
"height": "132px",
"width": "100%",
}
}
>
<div
className="pf-c-skeleton pf-m-square ins-c-skeleton ins-c-skeleton__md"
style={
{
"height": "132px",
"width": "100%",
}
}
>
<span
className="pf-u-screen-reader"
/>
</div>
</Skeleton>
</Skeleton>
</WithLoader>
</div>
</StackItem>
<StackItem
className="pf-u-mt-sm pf-u-mb-md"
Publish date:
</div>
<div
class="pf-m-grow"
>
<div
className="pf-l-stack__item pf-u-mt-sm pf-u-mb-md"
>
For most up-to-date information,
</div>
</StackItem>
12 May 2020
</div>
</div>
</Stack>
</CVEDetailsPageDescription>
</injectIntl(CVEDetailsPageDescription)>
</div>
<div
class="pf-v5-l-stack__item"
>
<div
class="pf-v5-c-content"
style="text-align: justify;"
>
<p
class=""
data-ouia-component-id="OUIA-Generated-Text-1"
data-ouia-component-type="PF5/Text"
data-ouia-safe="true"
data-pf-content="true"
>
It was found that ghostscript could leak sensitive operators on the operand stack when a pseudo-operator pushes a subroutine. A specially crafted PostScript file could use this flaw to escape the -dSAFER protection in order to, for example, have access to the file system and execute commands.
</p>
</div>
</div>
<div
class="pf-v5-l-stack__item pf-v5-u-mt-sm pf-v5-u-mb-md"
>
For most up-to-date information,
</div>
</div>
</DocumentFragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import CVEDetailsPageSidebar from './CVEDetailsPageSidebar';
import { render } from '@testing-library/react';
import { IntlProvider } from '@redhat-cloud-services/frontend-components-translations';
import { CVEPageContext } from '../../SmartComponents/CVEDetailsPage/CVEDetailsPage';

const cveAttributes = {
business_risk: "Low",
Expand All @@ -26,10 +27,12 @@ const cveAttributes = {
}

describe('CVEDetailsPageSidebar component', () => {
it.skip('should render correctly', () => {
it('should render correctly', () => {
const { asFragment } = render(
<IntlProvider locale="en">
<CVEDetailsPageSidebar cveAttributes={cveAttributes} />
<CVEPageContext.Provider value={{ isLoading: false }}>
<CVEDetailsPageSidebar cveAttributes={cveAttributes} />
</CVEPageContext.Provider>
</IntlProvider>
);
expect(asFragment()).toMatchSnapshot();
Expand Down
Loading
Loading