Skip to content

Commit

Permalink
Merge pull request #383 from PagerDuty/fix-380
Browse files Browse the repository at this point in the history
  • Loading branch information
gsreynolds authored Jan 9, 2024
2 parents 7e54d56 + 4d46421 commit 9bf2a45
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
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 @@ const IncidentTableComponent = () => {
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');

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

0 comments on commit 9bf2a45

Please sign in to comment.