Files
grafana/e2e/utils/support/localStorage.ts
Ashley Harrison ba7f77f25d Chore: remove scenario wrapping in cypress tests (#74674)
* remove scenario wrapping in cypress tests

* remove more hardcoded logins

* don't forget the various suite!

* make sure we log in for every test

* fix afterAll revert

* stability
2023-09-13 13:24:20 +01:00

20 lines
709 B
TypeScript

// @todo this actually returns type `Cypress.Chainable`
const get = (key: string): any =>
cy.wrap({ getLocalStorage: () => localStorage.getItem(key) }, { log: false }).invoke('getLocalStorage');
// @todo this actually returns type `Cypress.Chainable`
export const getLocalStorage = (key: string): any =>
get(key).then((value: any) => {
if (value === null) {
return value;
} else {
return JSON.parse(value);
}
});
// @todo this actually returns type `Cypress.Chainable`
export const requireLocalStorage = (key: string): any =>
get(key) // `getLocalStorage()` would turn 'null' into `null`
.should('not.equal', null)
.then((value: any) => JSON.parse(value as string));