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')
|
2018-02-19 02:54:38 +01:00
|
|
|
cy.wait(500)
|
2018-02-18 23:31:28 +01:00
|
|
|
cy.get('#instanceInput').clear().type('localhost:3000')
|
|
|
|
cy.get('.add-new-instance').submit()
|
2018-02-19 02:54:38 +01:00
|
|
|
cy.wait(500)
|
2018-02-18 23:31:28 +01:00
|
|
|
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) => {
|
2018-02-19 01:57:38 +01:00
|
|
|
return cy.get(`.virtual-list-item[aria-hidden=false] article[aria-posinset=${n}]`)
|
2018-02-19 00:30:42 +01:00
|
|
|
})
|
2018-02-19 01:43:39 +01:00
|
|
|
|
|
|
|
Cypress.Commands.add('validateTimeline', (timeline) => {
|
|
|
|
timeline.forEach((status, i) => {
|
|
|
|
if (status.content) {
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-content p').should('contain', status.content)
|
|
|
|
}
|
|
|
|
if (status.spoiler) {
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-spoiler p').should('contain', status.spoiler)
|
|
|
|
}
|
2018-02-19 01:57:38 +01:00
|
|
|
if (status.followedBy) {
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', status.followedBy)
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', 'followed you')
|
|
|
|
}
|
2018-02-19 18:01:02 +01:00
|
|
|
if (status.rebloggedBy) {
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', status.rebloggedBy)
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', 'boosted')
|
|
|
|
}
|
|
|
|
if (status.favoritedBy) {
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', status.favoritedBy)
|
|
|
|
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', 'favorited')
|
|
|
|
}
|
2018-02-19 04:57:27 +01:00
|
|
|
cy.wait(50)
|
2018-02-19 01:43:39 +01:00
|
|
|
cy.getNthVirtualArticle(i).scrollIntoView()
|
2018-02-19 02:28:08 +01:00
|
|
|
cy.get('.loading-footer').should('not.exist')
|
2018-02-19 01:43:39 +01:00
|
|
|
})
|
|
|
|
})
|