forked from ToolJet/ToolJet
-
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.
[Tests] Add cypress tests for login page (ToolJet#291)
- Loading branch information
1 parent
0979923
commit cff1ff8
Showing
6 changed files
with
99 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"baseUrl": "http://localhost:8082", | ||
"env": { | ||
"apiUrl": "http://localhost:3000" | ||
} | ||
} |
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,37 @@ | ||
describe('User login', () => { | ||
it('should take user to login page', () => { | ||
cy.visit('/login'); | ||
cy.get('.card-title') | ||
.should('have.text', 'Login to your account'); | ||
}); | ||
|
||
it('should redirect unauthenticated user to login page', () => { | ||
cy.visit('/'); | ||
cy.location('pathname').should('equal', '/login'); | ||
}); | ||
|
||
it('should display invalid email or password error', () => { | ||
cy.login('fake_email', 'abcdefg'); | ||
cy.checkToastMessage('toast-login-auth-error', 'Invalid email or password') | ||
}); | ||
|
||
it('should take user to the forgot password page', () => { | ||
cy.visit('/forgot-password'); | ||
cy.get('.card-title') | ||
.should('have.text', 'Forgot Password'); | ||
}) | ||
|
||
it('should take user to the signup page', () => { | ||
cy.visit('/signup'); | ||
cy.get('.card-title') | ||
.should('have.text', 'Create a ToolJet account'); | ||
}) | ||
|
||
it('should sign in the user', () => { | ||
cy.visit('/login'); | ||
cy.login('dev@tooljet.io', 'password'); | ||
cy.location('pathname').should('equal', '/'); | ||
cy.get('.page-title') | ||
.should('have.text', 'All applications'); | ||
}) | ||
}) |
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,22 @@ | ||
/// <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} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = (on, config) => { | ||
// `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,10 @@ | ||
Cypress.Commands.add('login', (email, password) => { | ||
cy.visit('/login'); | ||
cy.get('[data-testid="emailField"]').type(email); | ||
cy.get('[data-testid="passwordField"]').type(password); | ||
cy.get('[data-testid="loginButton"').click(); | ||
}) | ||
|
||
Cypress.Commands.add('checkToastMessage', (toastId, message) => { | ||
cy.get(`[id=${toastId}]`).should('contain', message); | ||
}); |
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,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') |
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