|
| 1 | +context('Applications Page', () => { |
| 2 | + beforeEach(() => { |
| 3 | + cy.task('reset') |
| 4 | + cy.task('stubSignIn') |
| 5 | + cy.signIn() |
| 6 | + cy.visit('/') |
| 7 | + |
| 8 | + cy.fixture('sections.json').then(data => { |
| 9 | + this.sections = data |
| 10 | + }) |
| 11 | + }) |
| 12 | + |
| 13 | + it('should display the page title', () => { |
| 14 | + cy.title().should('include', 'Applications') |
| 15 | + }) |
| 16 | + |
| 17 | + it('should display the banner with the correct content', () => { |
| 18 | + cy.get('.applications-landing-page__banner') |
| 19 | + .should('exist') |
| 20 | + .within(() => { |
| 21 | + cy.get('h1').contains('Applications') |
| 22 | + cy.get('p').eq(0).contains('Log, action and reply to prisoner applications.') |
| 23 | + cy.get('p').eq(1).contains('Give us your').find('a').should('exist') |
| 24 | + }) |
| 25 | + }) |
| 26 | + |
| 27 | + it('should display the log an application button', () => { |
| 28 | + cy.get('a.govuk-button').should('exist').and('have.text', '\n Log an application\n').and('have.attr', 'href', '#') |
| 29 | + }) |
| 30 | + |
| 31 | + it('should display all sections with their items', () => { |
| 32 | + cy.fixture('sections.json').then(({ sections }) => { |
| 33 | + sections.forEach(section => { |
| 34 | + cy.contains('h2.govuk-heading-m', section.title).should('exist') |
| 35 | + |
| 36 | + section.items.forEach(item => { |
| 37 | + cy.contains('.applications-landing-page__list-menu-item', item.name) |
| 38 | + .should('exist') |
| 39 | + .within(() => { |
| 40 | + cy.get('.applications-landing-page__list-menu-item-notification').should('exist') |
| 41 | + cy.get('a').contains(item.name) |
| 42 | + }) |
| 43 | + }) |
| 44 | + }) |
| 45 | + }) |
| 46 | + }) |
| 47 | + |
| 48 | + it('should ensure links are functional (if paths are set)', () => { |
| 49 | + cy.get('.applications-landing-page__list-menu-item a').each($link => { |
| 50 | + const href = $link.attr('href') |
| 51 | + if (href && href !== '#') { |
| 52 | + cy.request(href).its('status').should('eq', 200) |
| 53 | + } |
| 54 | + }) |
| 55 | + }) |
| 56 | +}) |
0 commit comments