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

fix(RHINENG-9046): report details remove Usechrome hook #1992

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('report details: kba loaded', () => {
});

it('renders a loaded kba link', () => {
cy.mount(<ReportDetails {...{ ...props, kbaLoading: true, isProd: true }} />);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are calling cy.mount twice (one in beforeEach, and one in it). It's not healthy for the test, and we better keep only one mount command. Can we just add this prop in cy.mount in beforeEach above?

cy.get(`${ROOT} .ins-c-report-details__kba .pf-v5-c-card__body`).find('.pf-v5-c-skeleton').should('have.length', 0);
cy.get(`${ROOT} .ins-c-report-details__kba .pf-v5-c-card__body`)
.contains(props.kbaDetail.publishedTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import React, { useState } from 'react';
import { Alert, Card, CardBody, CardHeader, Divider, Stack, StackItem } from '@patternfly/react-core';
import { BullseyeIcon, InfoCircleIcon, LightbulbIcon, ThumbsUpIcon } from '@patternfly/react-icons';
import { Skeleton, SkeletonSize } from '@redhat-cloud-services/frontend-components/Skeleton';
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';

import { RuleContentOcp, RuleContentRhel } from '../types';
import { TemplateProcessor } from '../TemplateProcessor';
Expand All @@ -25,6 +24,7 @@ interface ReportDetailsProps {
view_uri: string;
};
kbaLoading: boolean; // if true, renders skeleton instead of kba link
isProd: boolean;
}

const ReportDetails: React.FC<ReportDetailsProps> = ({
Expand All @@ -35,10 +35,10 @@ const ReportDetails: React.FC<ReportDetailsProps> = ({
view_uri: '',
},
kbaLoading,
isProd,
}) => {
const { rule, details, resolution } = report;
const [error, setError] = useState<Error | null>(null);
const { isProd } = useChrome();

const handleError = (e: Error) => {
if (error === null) {
Expand All @@ -48,7 +48,7 @@ const ReportDetails: React.FC<ReportDetailsProps> = ({

const linkEditor = (url: string) => {
const linkToArray = url?.split('/');
if (isProd()) {
if (isProd) {
return `https://access.redhat.com/${linkToArray?.at(-2)}/${linkToArray?.at(-1)}`;
} else {
return `https://access.stage.redhat.com/${linkToArray?.at(-2)}/${linkToArray?.at(-1)}`;
Expand Down