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

Deselect rows as actions are requested rather than completed #383

Merged
merged 5 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 10 additions & 5 deletions cypress/e2e/Incidents/incidents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {

it('Select all incidents', () => {
selectAllIncidents();
cy.get('.selected-incidents-badge').then(($el) => {
cy.get('.selected-incidents-badge').should(($el) => {
const text = $el.text();
const incidentNumbers = text.split(' ')[0].split('/');
expect(incidentNumbers[0]).to.equal(incidentNumbers[1]);
Expand All @@ -59,7 +59,7 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {
// Shift-select multiple incidents
selectIncident(0);
selectIncident(4, true);
cy.get('.selected-incidents-badge').then(($el) => {
cy.get('.selected-incidents-badge').should(($el) => {
const text = $el.text();
const incidentNumbers = text.split(' ')[0].split('/');
expect(incidentNumbers[0]).to.equal('5');
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {
checkActionAlertsModalContent('Requested additional response for incident(s)');
cy.get(`@selectedIncidentId_${incidentIdx}`).then((incidentId) => {
checkIncidentCellContent(incidentId, 'Responders', 'UA');
checkPopoverContent(incidentId, 'Responders', '[email protected]');
checkPopoverContent(incidentId, 'Responders', 'User A');
checkIncidentCellContent(incidentId, 'Latest Log Entry Type', 'responder_request');
});

Expand All @@ -185,7 +185,7 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {
checkActionAlertsModalContent('Requested additional response for incident(s)');
cy.get(`@selectedIncidentId_${incidentIdx}`).then((incidentId) => {
checkIncidentCellContent(incidentId, 'Responders', 'UA');
checkPopoverContent(incidentId, 'Responders', '[email protected]');
checkPopoverContent(incidentId, 'Responders', 'User A');
checkIncidentCellContent(incidentId, 'Latest Log Entry Type', 'responder_request');
});
});
Expand All @@ -199,7 +199,9 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {
checkActionAlertsModalContent('Requested additional response for incident(s)');
cy.get(`@selectedIncidentId_${incidentIdx}`).then((incidentId) => {
checkIncidentCellContent(incidentId, 'Responders', 'UA');
checkPopoverContent(incidentId, 'Responders', '[email protected]');
checkIncidentCellContent(incidentId, 'Responders', 'UB');
checkPopoverContent(incidentId, 'Responders', 'User A');
checkPopoverContent(incidentId, 'Responders', 'User B');
checkIncidentCellContent(incidentId, 'Latest Log Entry Type', 'responder_request');
});
});
Expand Down Expand Up @@ -230,6 +232,9 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {
selectIncident(0);
cy.get('#incident-action-resolve-button').click();
checkActionAlertsModalContent('have been resolved');
// and now show all resolved status (#380)
cy.get('.query-status-resolved-button').check({ force: true });
waitForIncidentTable();
});

it('Update priority of singular incidents', () => {
Expand Down
7 changes: 5 additions & 2 deletions cypress/support/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const waitForIncidentTable = () => {
export const waitForAlerts = () => {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000); // Required for query debounce
cy.get('.selected-incidents-ctr', { timeout: 60000 }).should('not.include.text', 'Fetching Alerts');
cy.get('.selected-incidents-ctr', { timeout: 60000 }).should(
'not.include.text',
'Fetching Alerts',
);
};

export const selectIncident = (incidentIdx = 0, shiftKey = false) => {
Expand All @@ -49,7 +52,7 @@ export const selectAllIncidents = () => {
};

export const checkNoIncidentsSelected = () => {
cy.get('.selected-incidents-badge').then(($el) => {
cy.get('.selected-incidents-badge').should(($el) => {
const text = $el.text();
const incidentNumbers = text.split(' ')[0].split('/');
expect(incidentNumbers[0]).to.equal('0');
Expand Down
25 changes: 16 additions & 9 deletions src/components/IncidentTable/IncidentTableComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,25 +438,32 @@
return () => {};
}, [selectedFlatRows]);

// Handle deselecting rows after incident action has completed
// Handle deselecting rows after incident action has been requested
useEffect(() => {
// TODO: Get user feedback on this workflow
if (incidentActionsStatus === 'ACTION_COMPLETED') {
toggleAllRowsSelected(false);
} else if (
!incidentActionsStatus.includes('TOGGLE')
&& incidentActionsStatus.includes('COMPLETED')
) {
// toggleAllRowsSelected only works on the currently filtered rows, therefore
// to fix #380 we can't wait for the incidentActionsStatus to be COMPLETED
//
// Workarounds using the stateReducer to clear selectedRowIds also don't appear to work on filtered out rows
// Therefore, clearing the checkbox in the UI before it is filtered out is the best we can do for now
const isActionRequested = incidentActionsStatus === 'ACTION_REQUESTED';
const isToggleAction = incidentActionsStatus.includes('TOGGLE');
const isRequestedOrCompleted = incidentActionsStatus.includes('REQUESTED') || incidentActionsStatus.includes('COMPLETED');

Check warning on line 451 in src/components/IncidentTable/IncidentTableComponent.jsx

View workflow job for this annotation

GitHub Actions / cypress-run (Incidents/incidents.spec.js)

This line has a length of 126. Maximum ***ed is 120

Check warning on line 451 in src/components/IncidentTable/IncidentTableComponent.jsx

View workflow job for this annotation

GitHub Actions / cypress-run (Query/query.spec.js)

This line has a length of 126. Maximum ***ed is 120

Check warning on line 451 in src/components/IncidentTable/IncidentTableComponent.jsx

View workflow job for this annotation

GitHub Actions / cypress-run (Search/search.spec.js)

This line has a length of 126. Maximum ***ed is 120

Check warning on line 451 in src/components/IncidentTable/IncidentTableComponent.jsx

View workflow job for this annotation

GitHub Actions / cypress-run (Settings/settings.spec.js)

This line has a length of 126. Maximum ***ed is 120

Check warning on line 451 in src/components/IncidentTable/IncidentTableComponent.jsx

View workflow job for this annotation

GitHub Actions / cypress-run (app.spec.js)

This line has a length of 126. Maximum ***ed is 120

if (isActionRequested || (!isToggleAction && isRequestedOrCompleted)) {
toggleAllRowsSelected(false);
}
}, [incidentActionsStatus]);

// deselect rows after response play has completed
// deselect rows after response play has requested
// not adding this to the above useEffect because I don't want to
// take a chance of deselecting too many times
useEffect(() => {
// TODO: Get user feedback on this workflow
if (responsePlaysStatus === 'RUN_RESPONSE_PLAY_COMPLETED') {
if (
responsePlaysStatus.includes('RUN_RESPONSE_PLAY_REQUESTED')
|| responsePlaysStatus.includes('RUN_RESPONSE_PLAY_COMPLETED')
) {
toggleAllRowsSelected(false);
}
}, [responsePlaysStatus]);
Expand Down