From d64ef379cb1d262a24f48fc373e1eab7c9fa9872 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Fri, 25 Mar 2022 17:20:53 -0600 Subject: [PATCH] Add dashboard utils --- .../cypress/utils/dashboard.utils.ts | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 projects/nshmp-apps/cypress/utils/dashboard.utils.ts diff --git a/projects/nshmp-apps/cypress/utils/dashboard.utils.ts b/projects/nshmp-apps/cypress/utils/dashboard.utils.ts new file mode 100644 index 000000000..0158cac1f --- /dev/null +++ b/projects/nshmp-apps/cypress/utils/dashboard.utils.ts @@ -0,0 +1,57 @@ +import {NavigationList} from '@ghsc/nshmp-template'; + +export function hasDashboard(navList: NavigationList[]) { + it('Has nshmp-template main', () => { + cy.get('nshmp-template-main').should('be.visible'); + }); + + it('Has background image', () => { + cy.get('.dashboard').should( + 'have.css', + 'background-image', + `url("${Cypress.config().baseUrl}dashboard-background.png")` + ); + }); + + it('Has dashboard title', () => { + cy.get('.dashboard').find('.dashboard--title').should('be.visible'); + }); + + it('Has dashboard description', () => { + cy.get('.dashboard').find('.dashboard--description').should('be.visible'); + }); + + it('Has mat cards for applications', () => { + cy.get('.dashboard').find('mat-card').should('have.length.above', 0).should('be.visible'); + }); + + navList.forEach(nav => { + if (nav.subHeader) { + it(`Has "${nav.subHeader}" application list header`, () => { + cy.get('.dashboard').find('.app-section').contains(nav.subHeader); + }); + } + + nav.navigation.forEach(app => { + const routerLink = app.routerLink.startsWith('/') + ? app.routerLink.substring(1) + : app.routerLink; + + it(`Has "${app.display}" application`, () => { + if (app.routerLink.includes('/aws/')) { + cy.intercept('GET', 'https://earthquake.usgs.gov/ws/nshmp/hazard-runs/auth', { + fixture: 'aws-auth.json', + }); + } + + cy.get('.dashboard') + .find('mat-card') + .contains('mat-card-title', app.display) + .parent() + .click() + .url() + .should('contain', `${Cypress.config().baseUrl}${routerLink}`); + }); + }); + }); +} -- GitLab