diff --git a/cypress/e2e/adminHomeLink.cy.js b/cypress/e2e/adminHomeLink.cy.js new file mode 100644 index 0000000..bc9cb28 --- /dev/null +++ b/cypress/e2e/adminHomeLink.cy.js @@ -0,0 +1,43 @@ +describe('The admin home link', () => { + beforeEach(() => { + cy.exec('npm run db:seed') + cy.loginAsAdmin() + }) + afterEach(() => { + cy.exec('npm run db:wipe') + }) + + it('shows the home link on the admin page', () => { + cy.visit('/admin') + cy.get('#home-link') + .should('be.visible') + .and('have.attr', 'href', '/home') + .and('contain', 'Home') + }) + + it('shows the home link on the admin texts page', () => { + cy.visit('/admin/texts') + cy.get('#home-link') + .should('be.visible') + .and('have.attr', 'href', '/home') + .and('contain', 'Home') + }) + + it('shows the home link on an admin text page', () => { + cy.visit('/admin/texts') + cy.get('#newTextName').type('Home Link Text') + cy.get('#submit').click() + cy.get('a').contains('Home Link Text').click() + cy.get('#home-link') + .should('be.visible') + .and('have.attr', 'href', '/home') + .and('contain', 'Home') + }) + + it('navigates to the home page when clicked', () => { + cy.visit('/admin') + cy.get('#home-link').click() + cy.url().should('include', '/home') + cy.get('h1').should('contain', 'Home') + }) +}) diff --git a/views/templates/admin.php b/views/templates/admin.php index d69f685..9356654 100644 --- a/views/templates/admin.php +++ b/views/templates/admin.php @@ -11,6 +11,9 @@