diff --git a/cypress.json b/cypress.json index 5221569..cc1e3f3 100644 --- a/cypress.json +++ b/cypress.json @@ -7,6 +7,6 @@ "apiUrl": "https://conduit.productionready.io/api", "device": "desktop", "email": "test@test.com", - "password": "Testtest1" + "password": "Cypress123" } } diff --git a/cypress/integration/login.spec.js b/cypress/integration/login.spec.js index 801a61d..8e3eaa8 100644 --- a/cypress/integration/login.spec.js +++ b/cypress/integration/login.spec.js @@ -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') }) diff --git a/cypress/integration/register.spec.js b/cypress/integration/register.spec.js index 0a26a88..63e301e 100644 --- a/cypress/integration/register.spec.js +++ b/cypress/integration/register.spec.js @@ -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) diff --git a/cypress/integration/register_better.spec.js b/cypress/integration/register_better.spec.js index d6806d7..19216ee 100644 --- a/cypress/integration/register_better.spec.js +++ b/cypress/integration/register_better.spec.js @@ -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) diff --git a/cypress/support/register.cmd.js b/cypress/support/register.cmd.js index f185447..81819ea 100644 --- a/cypress/support/register.cmd.js +++ b/cypress/support/register.cmd.js @@ -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)