-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify in email hint text that shared inbox is not allowed (#1746)
* Clarify in email hint text that shared inbox is not allowed - Changed the password field's validation message to clarify what a hard to guess password is - Fixed the aria-invalid attribute on text boxes - Add cypress tests for registration page - Use jsrsasign to generate JWTs for admin api access in cypress tests * Various cleanups * Remove unused import * Add missing translation * Undo unneeded changes to cypress.config.js * Clear cookies after login and register test suites * Refactor and clean up tests a bit - Pulled the wait for confirmation email code into it's own action and out of CreateAccount - Added nanoid and use it for unique aliases on the email address - Fetch the confirmation link in a more sane way * Installed nanoid in the wrong package.json...
- Loading branch information
Showing
16 changed files
with
511 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests_cypress/cypress/Notify/Admin/Pages/CreateAccountPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const { recurse } = require('cypress-recurse') | ||
|
||
|
||
let Components = { | ||
FullName: () => cy.get("#name"), | ||
EmailAddress: () => cy.get('#email_address'), | ||
MobileNumber: () => cy.get('#mobile_number'), | ||
Password: () => cy.get('#password'), | ||
TwoFactorCode: () => cy.get('#two_factor_code'), | ||
SubmitButton: () => cy.get('button[type="submit"]'), | ||
} | ||
|
||
|
||
let Actions = { | ||
VisitPage: () => { | ||
cy.visit(CreateAccountPage.URL) | ||
}, | ||
|
||
EmptySubmit: () => { | ||
Components.SubmitButton().click(); | ||
}, | ||
|
||
Submit: (name, email, mobile, password) => { | ||
Components.FullName().type(name); | ||
Components.EmailAddress().type(email); | ||
Components.MobileNumber().type(mobile); | ||
Components.Password().type(password); | ||
Components.SubmitButton().click(); | ||
}, | ||
|
||
WaitForConfirmationEmail: () => { | ||
recurse( | ||
() => cy.task('getLastEmail', {}), // Cypress commands to retry | ||
Cypress._.isObject, | ||
{ | ||
log: true, | ||
limit: 250, // max number of iterations | ||
timeout: 120000, // time limit in ms | ||
delay: 500, // delay before next iteration, ms | ||
}, | ||
) | ||
.its('html') | ||
.then((html) => ( | ||
cy.document({ log: false }).invoke({ log: false }, 'write', html) | ||
)); | ||
}, | ||
|
||
CreateAccount: (name, email, mobile, password) => { | ||
cy.task('deleteAllEmails', {}); | ||
Components.FullName().type(name); | ||
Components.EmailAddress().type(email); | ||
Components.MobileNumber().type(mobile); | ||
Components.Password().type(password); | ||
Components.SubmitButton().click(); | ||
} | ||
}; | ||
|
||
let CreateAccountPage = { | ||
URL: '/register', | ||
Components, | ||
...Actions | ||
}; | ||
|
||
export default CreateAccountPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// import './gca_pages.cy'; | ||
import './login.cy'; | ||
import './register.cy'; | ||
import './qualtrics.cy'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import { CreateAccountPage } from "../../Notify/Admin/Pages/all"; | ||
import { Utilities, Admin } from "../../Notify/NotifyAPI"; | ||
|
||
describe('Create Account Page', () => { | ||
|
||
beforeEach(() => { | ||
CreateAccountPage.VisitPage(); | ||
}); | ||
|
||
// Clear cookies for the next suite of tests | ||
after(() => { | ||
cy.clearCookie('notify_admin_session'); | ||
}); | ||
|
||
it('Display the correct title', () => { | ||
cy.contains('h1', 'Create an account').should('be.visible'); | ||
}); | ||
|
||
it('Display error when submitting an empty form', () => { | ||
CreateAccountPage.EmptySubmit(); | ||
cy.contains('span', 'This cannot be empty').should('be.visible'); | ||
cy.contains('span', 'Enter an email address').should('be.visible'); | ||
}); | ||
|
||
it('Display an error when submitting and invalid phone number and non-government email', () => { | ||
CreateAccountPage.Submit('John Doe', '[email protected]', '123', 'password123') | ||
cy.contains('span', "not-a-gov-email.ca is not on our list of government domains").should('be.visible'); | ||
cy.contains('span', "Not a valid phone number").should('be.visible'); | ||
}); | ||
|
||
it('Display an error if password is shorter than 8 characters', () => { | ||
CreateAccountPage.Submit("john doe", "[email protected]", "1234567890", "1234567"); | ||
cy.contains('span', 'Must be at least 8 characters').should('be.visible'); | ||
}); | ||
|
||
it('Display an error if password is not strong enough', () => { | ||
CreateAccountPage.Submit("john doe", "[email protected]", "1234567890", "123456789"); | ||
cy.contains('span', 'A password that is hard to guess contains:').should('be.visible'); | ||
cy.contains('li', 'Uppercase and lowercase letters.').should('be.visible'); | ||
cy.contains('li', 'Numbers and special characters.').should('be.visible'); | ||
cy.contains('li', 'Words separated by a space.').should('be.visible'); | ||
}); | ||
|
||
it('Succeeds with a valid form', () => { | ||
let email = `notify-ui-tests+${Utilities.GenerateID()}@cds-snc.ca`; | ||
|
||
CreateAccountPage.CreateAccount("john doe", email, "16132532223", "BestPassword123!"); | ||
cy.contains('h1', 'Check your email').should('be.visible'); | ||
cy.contains('p', `An email has been sent to ${email}.`).should('be.visible'); | ||
|
||
CreateAccountPage.WaitForConfirmationEmail(); | ||
// Ensure registration email is received and click registration link | ||
cy.contains('p', 'To complete your registration for GC Notify, please click the link:').should('be.visible'); | ||
cy.get('a') | ||
.should('have.attr', 'href') | ||
.and('include', 'verify-email') | ||
.then((href) => { | ||
cy.visit(href); | ||
}); | ||
|
||
cy.contains('h1', 'Check your phone messages').should('be.visible') | ||
|
||
Admin.GetUserByEmail({ email: email }).then((user) => { | ||
// TODO: Ideally we'd want the ability to completely delete the test user rather than archive it. | ||
Admin.ArchiveUser({ userId: user.body.data.id }) | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.