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 0000000000000000000000000000000000000000..0158cac1fba2be501378e4fcaf4cbeef0d510281 --- /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}`); + }); + }); + }); +}