pinafore/cypress/integration/02-login-spec.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-02-18 23:31:28 +01:00
describe('Login spec', () => {
2018-02-19 00:30:42 +01:00
beforeEach(() => {
cy.visit('/')
2018-02-19 02:54:38 +01:00
cy.wait(500)
2018-02-19 00:30:42 +01:00
})
2018-02-18 23:31:28 +01:00
2018-02-19 00:30:42 +01:00
it('Cannot log in to a fake instance', () => {
cy.get('a').contains('log in to an instance').click()
2018-02-18 23:31:28 +01:00
cy.get('#instanceInput').clear().type('fake.nolanlawson.com')
cy.get('.add-new-instance').submit()
cy.get('.form-error', {timeout: 20000}).contains('Is this a valid Mastodon instance?')
cy.get('#instanceInput').type('.biz')
cy.get('.form-error').should('not.exist')
cy.get('#instanceInput').clear().type('fake.nolanlawson.com')
cy.get('.form-error').should('exist')
2018-02-19 00:30:42 +01:00
})
2018-02-18 23:31:28 +01:00
it('Logs in to localhost:3000', () => {
cy.login('foobar@localhost:3000', 'foobarfoobar')
cy.url().should('equal', 'http://localhost:4002/')
cy.get('article.status-article').should('exist')
})
it('Logs out', () => {
cy.login('foobar@localhost:3000', 'foobarfoobar')
2018-02-19 02:54:38 +01:00
cy.wait(500)
2018-02-19 02:28:08 +01:00
cy.get('nav a[aria-label=Settings]').click()
2018-02-18 23:31:28 +01:00
cy.get('a').contains('Instances').click()
cy.get('a').contains('localhost:3000').click()
cy.url().should('contain', '/settings/instances/localhost:3000')
cy.get('button').contains('Log out').click()
2018-02-19 02:28:08 +01:00
cy.get('#modal-dialog button').contains('OK').click()
2018-02-18 23:31:28 +01:00
cy.url().should('contain', '/settings/instances')
cy.contains("You're not logged in to any instances")
})
2018-02-19 00:30:42 +01:00
})