2018-01-07 00:51:25 +01:00
|
|
|
// ***********************************************
|
|
|
|
// This example commands.js shows you how to
|
|
|
|
// create various custom commands and overwrite
|
|
|
|
// existing commands.
|
|
|
|
//
|
|
|
|
// For more comprehensive examples of custom
|
|
|
|
// commands please read more here:
|
|
|
|
// https://on.cypress.io/custom-commands
|
|
|
|
// ***********************************************
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is a parent command --
|
|
|
|
// Cypress.Commands.add("login", (email, password) => { ... })
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is a child command --
|
|
|
|
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is a dual command --
|
|
|
|
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is will overwrite an existing command --
|
|
|
|
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
2018-02-18 23:31:28 +01:00
|
|
|
|
|
|
|
Cypress.Commands.add('login', (email, password) => {
|
|
|
|
// mastodon throws some uncaught TypeErrors
|
|
|
|
cy.on('uncaught:exception', (err) => {
|
|
|
|
expect(err.name).to.include('TypeError')
|
|
|
|
expect(err.message).to.include('Illegal invocation')
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.visit('/settings/instances/add')
|
|
|
|
cy.get('#instanceInput').clear().type('localhost:3000')
|
|
|
|
cy.get('.add-new-instance').submit()
|
|
|
|
cy.url().should('equal', 'http://localhost:3000/auth/sign_in')
|
|
|
|
cy.get('input#user_email').should('exist')
|
|
|
|
cy.get('input#user_password').should('exist')
|
|
|
|
cy.get('input#user_email').type(email)
|
|
|
|
cy.get('input#user_password').type(password)
|
|
|
|
cy.get('form#new_user').submit()
|
|
|
|
cy.url().should('contain', '/oauth/authorize')
|
|
|
|
|
|
|
|
cy.get('button').contains('Authorize').click()
|
|
|
|
cy.url().should('equal', 'http://localhost:4002/')
|
2018-02-19 00:28:42 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add('getNthVirtualArticle', (n) => {
|
|
|
|
return cy.get(`.virtual-list-item[aria-hidden=false] .status-article[aria-posinset=${n}]`)
|
2018-02-18 23:31:28 +01:00
|
|
|
})
|