Skip to content

Commit

Permalink
Cypress test for password changes
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Dec 14, 2024
1 parent 58549ed commit 7b10144
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/views/containers/access/PasswordModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang='pug'>
modal-template(class='is-centered is-left-aligned' back-on-mobile=true ref='modalTemplate' :a11yTitle='L("Change Password")')
modal-template(class='is-centered is-left-aligned' back-on-mobile=true ref='modalTemplate' data-test='PasswordModal' :a11yTitle='L("Change Password")')
template(slot='title') Change password

form(
Expand Down Expand Up @@ -50,11 +50,13 @@ modal-template(class='is-centered is-left-aligned' back-on-mobile=true ref='moda
.buttons
i18n.is-outlined(
tag='button'
data-test='cancel'
@click='closeModal'
) Cancel

i18n.is-success(
tag='button'
data-test='submit'
@click='changePassword'
:disabled='$v.form.$invalid || processing'
) Change password
Expand Down
29 changes: 29 additions & 0 deletions test/cypress/integration/signup-and-login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,33 @@ describe('Signup, Profile and Login', () => {

cy.closeModal()
})

it('change user password', () => {
cy.giLogin(username)
cy.getByDT('settingsBtn').click()
cy.getByDT('passwordBtn').click()
const oldPassword = '123456789'
const newPassword = 'abcdefghi'
cy.getByDT('PasswordModal').within(() => {
cy.getByDT('current').type('{selectall}{del}' + oldPassword)
cy.getByDT('newPassword').type('{selectall}{del}' + newPassword)
cy.getByDT('confirm').type('{selectall}{del}' + newPassword)
cy.getByDT('submit').click()
})
cy.getByDT('PasswordModal').should('not.exist')
cy.giLogout({ bypassUI: true })

// Login using old password
cy.getByDT('loginBtn').click()
cy.getByDT('loginName').type('{selectall}{del}' + username)
cy.getByDT('password').type('{selectall}{del}' + oldPassword)

cy.getByDT('loginSubmit').click()
cy.getByDT('loginError').should('contain', 'Incorrect username or password')
cy.closeModal()

// Now, log in with the correct changed password
cy.giLogin(username, { password: newPassword })
cy.giLogout({ bypassUI: true })
})
})

0 comments on commit 7b10144

Please sign in to comment.