Skip to content

Commit

Permalink
fix(RHINENG-12310): Tag filter error on Reports page
Browse files Browse the repository at this point in the history
To reproduce:
Go to https://console.redhat.com/insights/vulnerability/cves
At top in 'Filter by tag' select a value with systems
Navigate to https://console.redhat.com/insights/vulnerability/reports#SIDs=&tags=
Select Create report
Error is displayed

The issue is that the `useSelector` on ReportsPage was not putting the tags into an array, AND if there were no tags, then it wasn't returning an empty array properly.

Make sure to apply multiple variations of workloads, SAP IDs, and tags to make sure this feature works correctly.
  • Loading branch information
Michael Johnson committed Nov 25, 2024
1 parent d50a402 commit 4923367
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Components/SmartComponents/Reports/ReportsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const ReportsPage = () => {
const [inheritGlobalTags, setInheritGlobalTags] = useState(true);
const [cvesWithoutErrata, setCvesWithoutErrata] = useState(false);

const globalFilterTags = useSelector(({ ReportsPageStore }) => ReportsPageStore.parameters.tags) ?? [];
const globalFilterTags = useSelector(({ ReportsPageStore }) =>
ReportsPageStore.parameters.tags?.length && ReportsPageStore.parameters.tags.split(',')) || [];

const dispatch = useDispatch();

Expand Down
20 changes: 19 additions & 1 deletion src/Components/SmartComponents/Reports/ReportsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jest.mock("../../../Helpers/APIHelper.js", () => ({
getCveListByAccount: () => new Promise(() => {}, () => {})
}));

const state = {
let state = {
parameters: {}
}

Expand Down Expand Up @@ -205,4 +205,22 @@ describe('Reports page component', () => {

expect(screen.getByText(/systems: 1 or more conventional \(rpm\-dnf\), 1 or more immutable \(ostree\)/i)).toBeVisible();
});

it('Should apply global tags.', async () => {
state.parameters = { tags: "AAaNIKhDBt/LorNtSjoRt=WRTmPByfQ,BMCRfrl/kgWDqQYPT=KVdLiE" };
render(
<TestWrapper store={ store }>
<ReportsPage />
</TestWrapper>
);

await waitFor(() => {
fireEvent.click(screen.getByText(/create report/i));
});

screen.logTestingPlaygroundURL();

expect(screen.getByText(/tags: aaanikhdbt: lorntsjort = wrtmpbyfq, bmcrfrl: kgwdqqypt = kvdlie/i)).toBeVisible();
expect(screen.queryByText(/tags: all/i)).toBeFalsy();
});
});

0 comments on commit 4923367

Please sign in to comment.