-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress UI testing & verify template tests #153
base: ui-tests
Are you sure you want to change the base?
Changes from 4 commits
b07c3cf
95e0cd2
b338bf8
2815c70
3bb8583
e114946
6dd6456
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ coverage/ | |
package-lock.json | ||
.env | ||
.DS_Store | ||
cypress/screenshots/ | ||
cypress/videos/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:3002" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"id": 8739, | ||
"name": "Jane", | ||
"email": "[email protected]" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
[ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these fixture files being used in the tests? They seem like generic files part of some auto configuration process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are example fixtures I left in as a placeholder for when we have mocks for integration tests, but it is a good idea to remove them. I do want to keep the directory around if possible, since it does have special meaning to Cypress (the data for API mocks go in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think having a README.md or a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the example files, and wrote up a quick README.md that links to the Cypress documentation on how the files that were in the fixtures directory should be used. |
||
{ | ||
"id": 1, | ||
"name": "Leanne Graham", | ||
"username": "Bret", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Kulas Light", | ||
"suite": "Apt. 556", | ||
"city": "Gwenborough", | ||
"zipcode": "92998-3874", | ||
"geo": { | ||
"lat": "-37.3159", | ||
"lng": "81.1496" | ||
} | ||
}, | ||
"phone": "1-770-736-8031 x56442", | ||
"website": "hildegard.org", | ||
"company": { | ||
"name": "Romaguera-Crona", | ||
"catchPhrase": "Multi-layered client-server neural-net", | ||
"bs": "harness real-time e-markets" | ||
} | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "Ervin Howell", | ||
"username": "Antonette", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Victor Plains", | ||
"suite": "Suite 879", | ||
"city": "Wisokyburgh", | ||
"zipcode": "90566-7771", | ||
"geo": { | ||
"lat": "-43.9509", | ||
"lng": "-34.4618" | ||
} | ||
}, | ||
"phone": "010-692-6593 x09125", | ||
"website": "anastasia.net", | ||
"company": { | ||
"name": "Deckow-Crist", | ||
"catchPhrase": "Proactive didactic contingency", | ||
"bs": "synergize scalable supply-chains" | ||
} | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "Clementine Bauch", | ||
"username": "Samantha", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Douglas Extension", | ||
"suite": "Suite 847", | ||
"city": "McKenziehaven", | ||
"zipcode": "59590-4157", | ||
"geo": { | ||
"lat": "-68.6102", | ||
"lng": "-47.0653" | ||
} | ||
}, | ||
"phone": "1-463-123-4447", | ||
"website": "ramiro.info", | ||
"company": { | ||
"name": "Romaguera-Jacobson", | ||
"catchPhrase": "Face to face bifurcated interface", | ||
"bs": "e-enable strategic applications" | ||
} | ||
}, | ||
{ | ||
"id": 4, | ||
"name": "Patricia Lebsack", | ||
"username": "Karianne", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Hoeger Mall", | ||
"suite": "Apt. 692", | ||
"city": "South Elvis", | ||
"zipcode": "53919-4257", | ||
"geo": { | ||
"lat": "29.4572", | ||
"lng": "-164.2990" | ||
} | ||
}, | ||
"phone": "493-170-9623 x156", | ||
"website": "kale.biz", | ||
"company": { | ||
"name": "Robel-Corkery", | ||
"catchPhrase": "Multi-tiered zero tolerance productivity", | ||
"bs": "transition cutting-edge web services" | ||
} | ||
}, | ||
{ | ||
"id": 5, | ||
"name": "Chelsey Dietrich", | ||
"username": "Kamren", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Skiles Walks", | ||
"suite": "Suite 351", | ||
"city": "Roscoeview", | ||
"zipcode": "33263", | ||
"geo": { | ||
"lat": "-31.8129", | ||
"lng": "62.5342" | ||
} | ||
}, | ||
"phone": "(254)954-1289", | ||
"website": "demarco.info", | ||
"company": { | ||
"name": "Keebler LLC", | ||
"catchPhrase": "User-centric fault-tolerant solution", | ||
"bs": "revolutionize end-to-end systems" | ||
} | ||
}, | ||
{ | ||
"id": 6, | ||
"name": "Mrs. Dennis Schulist", | ||
"username": "Leopoldo_Corkery", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Norberto Crossing", | ||
"suite": "Apt. 950", | ||
"city": "South Christy", | ||
"zipcode": "23505-1337", | ||
"geo": { | ||
"lat": "-71.4197", | ||
"lng": "71.7478" | ||
} | ||
}, | ||
"phone": "1-477-935-8478 x6430", | ||
"website": "ola.org", | ||
"company": { | ||
"name": "Considine-Lockman", | ||
"catchPhrase": "Synchronised bottom-line interface", | ||
"bs": "e-enable innovative applications" | ||
} | ||
}, | ||
{ | ||
"id": 7, | ||
"name": "Kurtis Weissnat", | ||
"username": "Elwyn.Skiles", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Rex Trail", | ||
"suite": "Suite 280", | ||
"city": "Howemouth", | ||
"zipcode": "58804-1099", | ||
"geo": { | ||
"lat": "24.8918", | ||
"lng": "21.8984" | ||
} | ||
}, | ||
"phone": "210.067.6132", | ||
"website": "elvis.io", | ||
"company": { | ||
"name": "Johns Group", | ||
"catchPhrase": "Configurable multimedia task-force", | ||
"bs": "generate enterprise e-tailers" | ||
} | ||
}, | ||
{ | ||
"id": 8, | ||
"name": "Nicholas Runolfsdottir V", | ||
"username": "Maxime_Nienow", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Ellsworth Summit", | ||
"suite": "Suite 729", | ||
"city": "Aliyaview", | ||
"zipcode": "45169", | ||
"geo": { | ||
"lat": "-14.3990", | ||
"lng": "-120.7677" | ||
} | ||
}, | ||
"phone": "586.493.6943 x140", | ||
"website": "jacynthe.com", | ||
"company": { | ||
"name": "Abernathy Group", | ||
"catchPhrase": "Implemented secondary concept", | ||
"bs": "e-enable extensible e-tailers" | ||
} | ||
}, | ||
{ | ||
"id": 9, | ||
"name": "Glenna Reichert", | ||
"username": "Delphine", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Dayna Park", | ||
"suite": "Suite 449", | ||
"city": "Bartholomebury", | ||
"zipcode": "76495-3109", | ||
"geo": { | ||
"lat": "24.6463", | ||
"lng": "-168.8889" | ||
} | ||
}, | ||
"phone": "(775)976-6794 x41206", | ||
"website": "conrad.com", | ||
"company": { | ||
"name": "Yost and Sons", | ||
"catchPhrase": "Switchable contextually-based project", | ||
"bs": "aggregate real-time technologies" | ||
} | ||
}, | ||
{ | ||
"id": 10, | ||
"name": "Clementina DuBuque", | ||
"username": "Moriah.Stanton", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "Kattie Turnpike", | ||
"suite": "Suite 198", | ||
"city": "Lebsackbury", | ||
"zipcode": "31428-2261", | ||
"geo": { | ||
"lat": "-38.2386", | ||
"lng": "57.2232" | ||
} | ||
}, | ||
"phone": "024-648-3804", | ||
"website": "ambrose.net", | ||
"company": { | ||
"name": "Hoeger LLC", | ||
"catchPhrase": "Centralized empowering task-force", | ||
"bs": "target end-to-end models" | ||
} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/// <reference types="Cypress" /> | ||
|
||
// `verify` function template UI-only tests | ||
|
||
const testNumber = "5555555555"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a good habit to get used to formatting phone numbers with e.164 formatting. Here's probably more info than you need on the subject https://support.twilio.com/hc/en-us/articles/223183008-Formatting-International-Phone-Numbers TLDR: Make sure to add the country code to the number There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd go one further and use specifically a valid phone number (since the one you listed is not valid). The typical one we have in examples is: I'm using it in this test for example: https://github.com/twilio-labs/configure-env/blob/main/src/__tests__/validators.test.ts#L22 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I switched it to Dom's suggestion of |
||
const testEmail = "[email protected]"; | ||
|
||
describe('verify Template UI', () => { | ||
beforeEach(() => { | ||
cy.visit('/verify/index.html'); | ||
}); | ||
|
||
it('should identify itself as the Verify example', () => { | ||
cy.contains('Twilio Verify'); | ||
}); | ||
|
||
it('should accept a number to verify via SMS by default', () => { | ||
cy | ||
.get('[data-cy=input-phone]') | ||
.type(testNumber) | ||
.get('[data-cy=submit]') | ||
.click(); | ||
|
||
// NOTE: This response will change when Cypress integration tests are incorporated | ||
cy.contains('Error'); | ||
}); | ||
|
||
it('should support verifying via a phone call', () => { | ||
cy | ||
.get('[data-cy=radio-call]') | ||
.click() | ||
.get('[data-cy=input-phone]') | ||
.type(testNumber) | ||
.get('[data-cy=submit]') | ||
.click(); | ||
|
||
// NOTE: This response will change when Cypress integration tests are incorporated | ||
cy.contains('Error'); | ||
}); | ||
|
||
it('should support verifying via email', () => { | ||
cy | ||
.get('[data-cy=radio-email]') | ||
.click() | ||
.get('[data-cy=input-email]') | ||
.type(testEmail) | ||
.get('[data-cy=submit]') | ||
.click(); | ||
|
||
// NOTE: This response will change when Cypress integration tests are incorporated | ||
cy.contains('Error'); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something I think i failed to go over with you, there are It would be good to make sure that is captured in our tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote up a quick test for the verify template that uses a DOM |
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// 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 will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't actually track those videos, I wonder if by default we should just turn those off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good idea -- I'll add
"video": false
tocypress.json
. I would still like to keepcypress/videos/
in.gitignore
just in case a contributor enables recording video by hand, so that video files don't end up getting accidentally committed.