chore: add tests for remote

This commit is contained in:
Phan An 2019-12-27 11:36:34 +07:00
parent 3958bd51ff
commit 3a5f585ea6
3 changed files with 14 additions and 3 deletions

View file

@ -0,0 +1,11 @@
describe('remote', () => {
it('requires login', () => {
cy.visit('/remote')
cy.get(['data=cy-loginForm']).should('be.visible')
})
it('logs in with valid username and password', () => {
cy.login('/remote')
cy.get('[data-cy=main]').should('be.visible')
})
})

View file

@ -24,12 +24,12 @@
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add('login', (email = 'me@phanan.net', password = 'secret') => {
Cypress.Commands.add('login', (path = '/', email = 'me@phanan.net', password = 'secret') => {
cy.server()
cy.route('POST', '/api/me', 'fixture:token.json')
cy.route('GET', '/api/data', 'fixture:data.json')
cy.route('GET', '/api/ping', '')
cy.visit('/')
cy.visit(path)
cy.get('[type=email]').type(email)
cy.get('[type=password]').type(password)
cy.get('[type=submit]').click()

@ -1 +1 @@
Subproject commit 4abb84d8478f2417824f7e508cc79a24ed9ec038
Subproject commit 2f14afc2e8a6e1c9579b38abf681572d888cbf90