improved config

master
helenanull 4 years ago
parent 70e8b882ca
commit 4b826dc7b4

@ -7,6 +7,6 @@
"apiUrl": "https://conduit.productionready.io/api",
"device": "desktop",
"email": "test@test.com",
"password": "Testtest1"
"password": "Cypress123"
}
}

@ -1,4 +1,4 @@
import login from '../selectors/login.sel'
import login, { passwordField } from '../selectors/login.sel'
import header from '../selectors/header.sel'
describe('Login', () => {
@ -49,8 +49,10 @@ describe('Login', () => {
})
it('can log in', function () {
const password = Cypress.env('password')
cy.get(login.emailField).type(this.email)
cy.get(login.passwordField).type('Testtest1')
cy.get(login.passwordField).type(password)
cy.get(login.signInButton).click()
cy.get(header.settingsLink).should('be.visible')
})

@ -18,7 +18,7 @@ describe('Register', () => {
// added delay as sometimes it can make tests flaky if typing too fast (default is 10)
cy.get(registration.usernameField).type(username, { delay: 50 })
cy.get(registration.emailField).type(email)
cy.get(registration.passwordField).type('Testtest1')
cy.get(registration.passwordField).type('Cypress12')
cy.get(registration.signUpButton).click()
cy.get(header.settingsLink).should('be.visible')
})
@ -27,12 +27,12 @@ describe('Register', () => {
cy.intercept('/api/users').as('loginRequest')
cy.get(registration.usernameField).type(username)
cy.get(registration.emailField).type(email)
cy.get(registration.passwordField).type('Testtest1{enter}')
cy.get(registration.passwordField).type('Cypress12{enter}')
cy.wait('@loginRequest').then((xhr) => {
// check request body
expect(xhr.request.body.user.email).to.eq(email)
expect(xhr.request.body.user.password).to.eq('Testtest1')
expect(xhr.request.body.user.password).to.eq('Cypress12')
expect(xhr.request.body.user.username).to.eq(username)
// check response body
expect(xhr.response.body.user.email).to.eq(email)

@ -17,7 +17,7 @@ describe('Register - duplicate of register.spec', () => {
// added delay as sometimes it can make tests flaky if typing too fast (default is 10)
cy.get(registration.usernameField).type(this.username, { delay: 50 })
cy.get(registration.emailField).type(this.email)
cy.get(registration.passwordField).type('Testtest1')
cy.get(registration.passwordField).type('Cypress12')
cy.get(registration.signUpButton).click()
cy.get(header.settingsLink).should('be.visible')
})
@ -26,12 +26,12 @@ describe('Register - duplicate of register.spec', () => {
cy.intercept('/api/users').as('loginRequest')
cy.get(registration.usernameField).type(this.username)
cy.get(registration.emailField).type(this.email)
cy.get(registration.passwordField).type('Testtest1{enter}')
cy.get(registration.passwordField).type('Cypress12{enter}')
cy.wait('@loginRequest').then((xhr) => {
// check request body
expect(xhr.request.body.user.email).to.eq(this.email)
expect(xhr.request.body.user.password).to.eq('Testtest1')
expect(xhr.request.body.user.password).to.eq('Cypress12')
expect(xhr.request.body.user.username).to.eq(this.username)
// check response body
expect(xhr.response.body.user.email).to.eq(this.email)

@ -2,6 +2,7 @@ Cypress.Commands.add('register', () => {
const apiUrl = Cypress.env('apiUrl')
const username = `cy${Math.random().toString().slice(2, 11)}`
const email = `${username}@mailinator.com`
const password = Cypress.env('password')
cy.request({
url: `${apiUrl}/users`,
@ -10,7 +11,7 @@ Cypress.Commands.add('register', () => {
user: {
username: username,
email: email,
password: 'Testtest1'
password: password
}
}
})
@ -18,7 +19,7 @@ Cypress.Commands.add('register', () => {
expect(response.status).to.eq(200)
cy.log('**user created**')
cy.log(`**email: ${email}**`)
cy.log('**password: Testtest1**')
cy.log(`**password: ${password}**`)
})
// return email so that we can use that to log in
.then(() => email)

Loading…
Cancel
Save