forked from frappe/frappe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI tests using Cypress (frappe#6562)
* test(UI): Add UI tests using cypress * test: Add test configuration for travis * fix: Lock redis version * fix: Refactor fill_field command * fix: Rename setup_wizard test to run first * test: Add setup for dashboard service * test: Add build matrix for ui test * test: Add name to each build matrix * test: Only include ui test for an extra build stage * fix: Exclude UI test with python 3.6 * test: Test order * test: Enable developer_mode * test(login): Check session user and not hash * test: Refactor assert * test: Refactor setup wizard test * test: Remove setup wizard test * test: Add blank seed database * test(form): Scroll to top before save * test: Fix form test * test: timeout * test: more wait * test: Remove specific selector * test: Remove wait, delay typing * test: Blur input after typing * test: Wait for form to get dirty * test: Add credentials for frappe org * test: Remove node install step * style: Fix linting issues * fix: List view filters - ToDo: Dont override frappe.route_options if it is already set * test: Dont reload page before test
- Loading branch information
1 parent
8ec0bdc
commit 83d6659
Showing
19 changed files
with
913 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,3 +185,7 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
# cypress | ||
cypress/screenshots | ||
cypress/videos |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"baseUrl": "http://test_site_ui:8000", | ||
"projectId": "92odwv" | ||
} |
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,52 @@ | ||
context('Awesome Bar', () => { | ||
before(() => { | ||
cy.login('Administrator', 'qwe'); | ||
cy.visit('/desk'); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.get('.navbar-home').click(); | ||
}); | ||
|
||
it('navigates to modules', () => { | ||
cy.get('#navbar-search') | ||
.type('modules{downarrow}{enter}', { delay: 100 }); | ||
|
||
cy.location('hash').should('eq', '#modules'); | ||
}); | ||
|
||
it('navigates to doctype list', () => { | ||
cy.get('#navbar-search') | ||
.type('todo{downarrow}{enter}', { delay: 100 }); | ||
|
||
cy.get('h1').should('contain', 'To Do'); | ||
|
||
cy.location('hash').should('eq', '#List/ToDo/List'); | ||
}); | ||
|
||
it('find text in doctype list', () => { | ||
cy.get('#navbar-search') | ||
.type('test in todo{downarrow}{enter}', { delay: 100 }); | ||
|
||
cy.get('h1').should('contain', 'To Do'); | ||
|
||
cy.get('.toggle-filter') | ||
.should('have.length', 1) | ||
.should('contain', 'ID like %test%'); | ||
}); | ||
|
||
it('navigates to new form', () => { | ||
cy.get('#navbar-search') | ||
.type('new blog post{downarrow}{enter}', { delay: 100 }); | ||
|
||
cy.get('.title-text:visible').should('have.text', 'New Blog Post 1'); | ||
}); | ||
|
||
it('calculates math expressions', () => { | ||
cy.get('#navbar-search') | ||
.type('55 + 32{downarrow}{enter}', { delay: 100 }); | ||
|
||
cy.get('.modal-title').should('contain', 'Result'); | ||
cy.get('.msgprint').should('contain', '55 + 32 = 87'); | ||
}); | ||
}); |
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,16 @@ | ||
context('Form', () => { | ||
before(() => { | ||
cy.login('Administrator', 'qwe'); | ||
cy.visit('/desk'); | ||
}); | ||
|
||
it('create a new form', () => { | ||
cy.visit('/desk#Form/ToDo/New ToDo 1'); | ||
cy.fill_field('description', 'this is a test todo', 'Text Editor').blur(); | ||
cy.get('.page-title').should('contain', 'Not Saved'); | ||
cy.get('.primary-action').click(); | ||
cy.visit('/desk#List/ToDo'); | ||
cy.location('hash').should('eq', '#List/ToDo/List'); | ||
cy.get('.list-row').should('contain', 'this is a test todo'); | ||
}); | ||
}); |
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,39 @@ | ||
context('Login', () => { | ||
beforeEach(() => { | ||
cy.visit('/login'); | ||
}); | ||
|
||
it('greets with login screen', () => { | ||
cy.get('.page-card-head').contains('Sign In'); | ||
}); | ||
|
||
it('validates password', () => { | ||
cy.get('#login_email').type('Administrator'); | ||
cy.get('.btn-login').click(); | ||
cy.location('pathname').should('eq', '/login'); | ||
}); | ||
|
||
it('validates email', () => { | ||
cy.get('#login_password').type('qwe'); | ||
cy.get('.btn-login').click(); | ||
cy.location('pathname').should('eq', '/login'); | ||
}); | ||
|
||
it('logs in using correct credentials', () => { | ||
cy.get('#login_email').type('Administrator'); | ||
cy.get('#login_password').type('qwe'); | ||
|
||
cy.get('.btn-login').click(); | ||
cy.location('pathname').should('eq', '/desk'); | ||
cy.window().its('frappe.session.user').should('eq', 'Administrator'); | ||
}); | ||
|
||
it('shows invalid login if incorrect credentials', () => { | ||
cy.get('#login_email').type('Administrator'); | ||
cy.get('#login_password').type('qwer'); | ||
|
||
cy.get('.btn-login').click(); | ||
cy.get('.page-card-head').contains('Invalid Login. Try again.'); | ||
cy.location('pathname').should('eq', '/login'); | ||
}); | ||
}); |
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,17 @@ | ||
// *********************************************************** | ||
// 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) | ||
|
||
module.exports = () => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
}; |
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,52 @@ | ||
// *********************************************** | ||
// 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 is will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }); | ||
Cypress.Commands.add('login', (email, password) => { | ||
cy.request({ | ||
url: '/', | ||
method: 'POST', | ||
body: { | ||
cmd: 'login', | ||
usr: email, | ||
pwd: password | ||
} | ||
}); | ||
}); | ||
|
||
Cypress.Commands.add('fill_field', (fieldname, value, fieldtype='Data') => { | ||
let selector = `.form-control[data-fieldname="${fieldname}"]`; | ||
|
||
if (fieldtype === 'Text Editor') { | ||
selector = `[data-fieldname="${fieldname}"] .ql-editor`; | ||
} | ||
|
||
cy.get(selector).as('input'); | ||
|
||
if (fieldtype === 'Select') { | ||
return cy.get('@input').select(value); | ||
} else { | ||
return cy.get('@input').type(value); | ||
} | ||
}); |
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,25 @@ | ||
// *********************************************************** | ||
// 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') | ||
|
||
Cypress.Cookies.defaults({ | ||
whitelist: 'sid' | ||
}); |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"baseUrl": "../node_modules", | ||
"types": [ | ||
"cypress" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.*" | ||
] | ||
} |
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
Binary file not shown.
Oops, something went wrong.