describe('The admin page', () => { beforeEach(() => { cy.exec('npm run db:seed') cy.visit('/admin') }) afterEach(() => { cy.exec('npm run db:wipe') }) it('navigates to texts page', () => { cy.get('#texts').click() cy.url().should('include', '/admin/texts') }) it('shows texts page with heading and form', () => { cy.visit('/admin/texts') cy.get('h1').should('contain', 'Texts') cy.get('#newTextName').should('exist') cy.get('#submit').should('exist') }) it('creates a new text', () => { cy.visit('/admin/texts') cy.get('#newTextName').type('Test Text') cy.get('#submit').click() cy.contains('Test Text') }) it('shows one root node on the text page', () => { cy.visit('/admin/texts') cy.get('#newTextName').type('My Node Text') cy.get('#submit').click() cy.intercept('GET', '/api/texts/1/nodes').as('getNodes') cy.get('a').contains('My Node Text').click() cy.wait('@getNodes') cy.get('#text-detail > ul').should('have.length', 1) }) it('navigates to a specific texts page', () => { cy.visit('/admin/texts') cy.get('#newTextName').type('My New Text') cy.get('#submit').click() cy.intercept('GET', '/admin/texts/1').as('textPage') cy.get('a') .contains('My New Text') .should('have.attr', 'href', '/admin/texts/1') .click() cy.url().should('include', '/admin/texts/1') cy.wait('@textPage').its('response.statusCode').should('eq', 200) }) })