Skip to content

Commit

Permalink
Don't use Cypress commands to clear state
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Dec 5, 2023
1 parent 17aac1d commit e099611
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 7 additions & 2 deletions cypress/e2e/app.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment/min/moment-with-locales';

import {
acceptDisclaimer, waitForIncidentTable, pd,
acceptDisclaimer, waitForIncidentTable, clearLocalCache, pd,
} from '../support/util/common';

import packageConfig from '../../package.json';
Expand Down Expand Up @@ -41,6 +41,11 @@ describe('PagerDuty Live', { failFast: { enabled: true } }, () => {
}
});

afterEach(() => {
// Reset hover state
cy.get('body').realHover({ position: 'topLeft' }).click();
});

it('Renders the main application page', () => {
cy.get('#navbar-ctr').contains('Live Incidents Console');
});
Expand All @@ -62,7 +67,7 @@ describe('PagerDuty Live', { failFast: { enabled: true } }, () => {
cy.intercept('https://api.pagerduty.com/abilities*', {
abilities: ['teams', 'read_only_users', 'service_support_hours', 'urgencies'],
}).as('getAbilities');
cy.visit('/');
clearLocalCache();
acceptDisclaimer();
cy.wait('@getAbilities', { timeout: 30000 });

Expand Down
11 changes: 6 additions & 5 deletions cypress/support/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ export const pd = api({ token: Cypress.env('PD_USER_TOKEN') });
Cypress Helpers
*/
export const acceptDisclaimer = () => {
cy.clearLocalStorage();
cy.clearAllSessionStorage();
cy.clearCookies();
cy.visit('/');
cy.get('.modal-title', { timeout: 30000 }).contains('Disclaimer & License');
cy.get('#disclaimer-agree-checkbox').click({ force: true });
Expand Down Expand Up @@ -282,8 +279,7 @@ export const updateDefaultSinceDateLookback = (tenor = '1 Day') => {

cy.get('#save-settings-button').click();
checkActionAlertsModalContent('Updated user profile settings');
cy.reload();
acceptDisclaimer();
cy.visit('/');
};

export const updateAutoRefreshInterval = (autoRefreshInterval = 5) => {
Expand Down Expand Up @@ -342,6 +338,11 @@ export const updateDarkMode = () => {
cy.get('[aria-label="Toggle Dark Mode"]').click();
};

export const clearLocalCache = () => {
cy.get('.settings-panel-dropdown').click();
cy.get('.dropdown-item').contains('Clear Local Cache').click();
};

export const priorityNames = ['--', 'P5', 'P4', 'P3', 'P2', 'P1'];

/*
Expand Down

0 comments on commit e099611

Please sign in to comment.