Skip to content

Commit

Permalink
fix: Bulk select doesn't properly add data to rows (#1867)
Browse files Browse the repository at this point in the history
When a user selects a CVE and then selects systems one-by-one, the `selectedRows` array in `entities` contains all of the data needed for the remediation wizard.

When a user bulk selects any number of systems, the `selectedRows` array in `entities` does not include all of the necessary data. This leaves out critical `rules` data needed to provide the proper call to the resolution api.

Steps to Reproduce:
Go to vulnerabilities -> CVEs
Click the link for a CVE (make sure it's a CVE with multiple resolutions)
Select systems one-by-one and check the entities.selectedRows array, it will have the full data for each row
Now, bulk select any number of systems and check the entities.selectedRows array again. it will have much less data

Co-authored-by: Michael Johnson <[email protected]>
  • Loading branch information
johnsonm325 and Michael Johnson authored Feb 14, 2023
1 parent ccaa377 commit 21613c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@
"build:components:umd": "rollup -c ./config/rollup.config.js --format=umd --environment NODE_ENV:production,FORMAT:umd",
"test:ct": "BABEL_ENV=componentTest cypress run --component",
"test:openct": "cypress open --component",
"test:jest": "jest --silent --no-cache --passWithNoTests --env=jsdom",
"test:jest": "TZ=UTC jest --silent --no-cache --passWithNoTests --env=jsdom",
"test": "npm run test:jest",
"test:jest:watch": "jest --watch --passWithNoTests --no-cache",
"test:jest:update": "jest --updateSnapshot --passWithNoTests --no-cache",
"test:jest:watch": "TZ=UTC jest --watch --passWithNoTests --no-cache",
"test:jest:update": "TZ=UTC jest --updateSnapshot --passWithNoTests --no-cache",
"coverage:clean": "rm -rf .nyc_output coverage reports",
"coverage": "bash coverage.sh && npm run coverage:clean",
"lint": "npm-run-all lint:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,29 @@ describe('SystemsTableToolbar component', () => {
selectAllToggle.simulate('click');

wrapper.find('Dropdown').first().find("button").at(2).simulate('click');

expect(handleSelectMock).toHaveBeenCalledWith(
[
{ display_name: "hypervisor.beav", id: "ece17ad9-97db-4480-a486-3eb4edd6c330", opt_out: false, remediation: undefined, selected: true },
{ display_name: "client01.apex.example.com", id: "84b763c8-9611-4bf0-9fb8-4f737253b994", opt_out: true, remediation: undefined, selected: true },
{ display_name: "edge-host-1", id: "9ad25b17-b805-437b-8fc3-074559c453b8", opt_out: false, remediation: undefined, selected: true },
{ display_name: "rhel7-insights-client-prod.virbr0.akofink-laptop",id: "ae7a9d76-ccc8-44d8-b8f0-692199199f10", opt_out: false, remediation: undefined, selected: true },
{ display_name: "vm-9-105.lab.eng.tlv2.redhat.com",id: "721d9b9f-0db5-46f4-ba71-5611d6c12887", opt_out: false, remediation: undefined, selected: true },
{ display_name: "dhcp-2-44.vms.sat.rdu2.redhat.com",id: "57c715fd-c49c-4c0d-81bc-f95599cd28f8", opt_out: false, remediation: undefined, selected: true }
], true
);
const bulkSelectedSystems = systems.data.map((system) => {
return {
display_name: system.display_name,
id: system.id,
opt_out: system.attributes.opt_out,
culled_timestamp: system.culled_timestamp,
cve_count: system.cve_count,
insights_id: system.insights_id,
last_evaluation: system.last_evaluation,
last_upload: system.last_upload,
os: system.os,
rules_evaluation: system.rules_evaluation,
stale_timestamp: system.stale_timestamp,
stale_warning_timestamp: system.stale_warning_timestamp,
tags: system.tags,
type: system.type,
updated: system.updated,
remediation: system.remediation,
selected: true
};
});

expect(handleSelectMock).toHaveBeenCalledWith(bulkSelectedSystems, true);

});

Expand Down
3 changes: 2 additions & 1 deletion src/Helpers/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ export const useOptOutSystems = onRefreshInventory => {
};

// eslint-disable-next-line camelcase
const mapSelectedRows = ({ id, inventory_id: inventoryId, attributes, remediation, display_name, opt_out }) =>
const mapSelectedRows = ({ id, inventory_id: inventoryId, attributes, remediation, display_name, opt_out, ...rest }) =>
({
...rest,
id: id ? id : inventoryId,
selected: true,
remediation: attributes ? attributes.remediation : remediation,
Expand Down

0 comments on commit 21613c4

Please sign in to comment.