Skip to content

Commit

Permalink
Remove unnecessary waiting
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Nov 27, 2023
1 parent f07ca37 commit c90cc40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
8 changes: 0 additions & 8 deletions cypress/e2e/Search/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {

it('Search for `Service A1` returns incidents only on Service A1', () => {
cy.get('#global-search-input').clear().type('Service A1');
cy.wait(1000);
cy.get('[data-incident-header="Service"]').each(($el) => {
cy.wrap($el).should('have.text', 'Service A1');
});
Expand All @@ -39,21 +38,18 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
cy.get(`@selectedIncidentId_${incidentIdx}`).then((incidentId) => {
cy.get('#global-search-input').clear().type(incidentId);
});
cy.wait(1000);
cy.get('.selected-incidents-badge').then(($el) => {
const text = $el.text().split(' ')[0];
expect(text).to.equal('1/1');
});
// Click the select all checkbox twice to unselect all
cy.get('#global-search-input').clear();
cy.wait(1000);
selectAllIncidents();
selectAllIncidents();
});

it('Search for `zzzzzz` returns no incidents', () => {
cy.get('#global-search-input').clear().type('zzzzzz');
cy.wait(1000);
cy.get('.empty-incidents-badge').should('be.visible');
cy.get('#global-search-input').clear();
});
Expand All @@ -67,7 +63,6 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
checkActionAlertsModalContent('have been updated with a note');
selectIncident(incidentIdx);
cy.get('#global-search-input').clear().type('foobar');
cy.wait(1000);
cy.get('[data-incident-header="Latest Note"]').each(($el) => {
// cy.wrap($el).should('have.text', 'foobar');
cy.wrap($el)
Expand All @@ -88,7 +83,6 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {

it('Fuzzy search disabled does not return incident with note fuzzy match', () => {
cy.get('#global-search-input').clear().type('foobaz');
cy.wait(1000);
cy.get('.empty-incidents-badge').should('be.visible');
cy.get('#global-search-input').clear();
});
Expand All @@ -100,7 +94,6 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {

cy.get(`@selectedIncidentId_${incidentIdx}`).then(() => {
cy.get('#global-search-input').clear().type('foobaz');
cy.wait(1000);
cy.get('[data-incident-header="Latest Note"]').each(($el) => {
cy.wrap($el)
.find('*')
Expand All @@ -121,7 +114,6 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => {
it('Column filtering on Service column for `A1` returns incidents only on Service A1', () => {
cy.get('#service-filter-icon').realHover();
cy.get('input[placeholder="Filter"]').filter(':visible').click().type('A1');
cy.wait(1000);
cy.get('[data-incident-header="Service"]').each(($el) => {
cy.wrap($el).should('have.text', 'Service A1');
});
Expand Down
11 changes: 4 additions & 7 deletions cypress/support/util/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable cypress/no-unnecessary-waiting */
/* eslint-disable cypress/unsafe-to-chain-command */
/* eslint-disable import/prefer-default-export */
import {
Expand All @@ -22,6 +21,7 @@ export const acceptDisclaimer = () => {

export const waitForIncidentTable = () => {
// Ref: https://stackoverflow.com/a/60065672/6480733
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000); // Required for query debounce
cy.get('#incident-table-ctr', { timeout: 60000 }).should('be.visible');
// will move on to next command even if table is not scrollable
Expand Down Expand Up @@ -53,12 +53,10 @@ export const checkNoIncidentsSelected = () => {
};

export const checkActionAlertsModalContent = (content) => {
cy.wait(2000);
cy.get('.chakra-alert__title').contains(content, { timeout: 10000 });
};

export const checkPopoverContent = (incidentId, incidentHeader, content) => {
cy.wait(2000);
cy.get(
`[data-incident-header="${incidentHeader}"][data-incident-cell-id="${incidentId}"]`,
).within(() => {
Expand All @@ -68,14 +66,12 @@ export const checkPopoverContent = (incidentId, incidentHeader, content) => {
};

export const checkIncidentCellContent = (incidentId, incidentHeader, content) => {
cy.wait(2000);
cy.get(`[data-incident-header="${incidentHeader}"][data-incident-cell-id="${incidentId}"]`)
.should('be.visible')
.contains(content);
};

export const checkIncidentCellContentAllRows = (incidentHeader, content) => {
cy.wait(2000);
cy.get('.incident-table-fixed-list').scrollTo('top', { ensureScrollable: true });
cy.get('.incident-table-fixed-list > div').then(($tbody) => {
const visibleIncidentCount = $tbody.find('[role="row"]').length;
Expand All @@ -101,7 +97,6 @@ export const checkIncidentCellIcon = (incidentIdx, incidentHeader, icon) => {
};

export const checkIncidentCellIconAllRows = (incidentHeader, icon) => {
cy.wait(2000);
cy.get('.incident-table-fixed-list > div').then(($tbody) => {
const visibleIncidentCount = $tbody.find('[role="row"]').length;
for (let incidentIdx = 0; incidentIdx < visibleIncidentCount; incidentIdx++) {
Expand All @@ -111,7 +106,6 @@ export const checkIncidentCellIconAllRows = (incidentHeader, icon) => {
};

export const checkIncidentCellContentHasLink = (incidentId, incidentHeader, text, link) => {
cy.wait(2000);
cy.get(`[data-incident-header="${incidentHeader}"][data-incident-cell-id="${incidentId}"]`)
.should('be.visible')
.contains('a', text)
Expand Down Expand Up @@ -144,8 +138,10 @@ export const escalate = (escalationLevel) => {
export const reassign = (assignment) => {
cy.get('#incident-action-reassign-button').click();
cy.get('#reassign-select').click();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(200);
cy.contains('.react-select__option', assignment).click({ force: true });
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(200);
cy.get('#reassign-button').click({ force: true });
};
Expand Down Expand Up @@ -198,6 +194,7 @@ export const addNote = (note) => {
};

const toggleRunAction = () => {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000); // Unsure why we can't find DOM of action without wait
cy.get('.incident-action-run-action-button').click();
};
Expand Down

0 comments on commit c90cc40

Please sign in to comment.