42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
describe('The admin page', () => {
|
|
beforeEach(() => {
|
|
cy.exec('npm run db:seed')
|
|
cy.loginAsAdmin()
|
|
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('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)
|
|
})
|
|
})
|