-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLD-385]Install cypress and add login test cases (#226)
- Loading branch information
NghiaPham
authored
Dec 27, 2019
1 parent
7f99fe6
commit c822aad
Showing
21 changed files
with
1,550 additions
and
271 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"supportFile": "./cypress/support/index.ts", | ||
"video": false | ||
} |
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,70 @@ | ||
import loginPage from '../pages/loginPage' | ||
import clientAppsPage from '../pages/clientAppsPage' | ||
import developerAppsPage from '../pages/developerAppsPage' | ||
import adminApprovalsPage from '../pages/adminApprovalsPage' | ||
|
||
describe('Login flow', () => { | ||
describe('works when testing the happycase flow', () => { | ||
const { | ||
selectors: { inputEmail, inputPassword, buttonLogin }, | ||
loginAsAdminUrl, | ||
loginAsClientUrl, | ||
loginAsDeveloperUrl | ||
} = loginPage | ||
|
||
const { | ||
url: pageClientAppsUrl, | ||
selectors: { container: clientAppsPageContainer } | ||
} = clientAppsPage | ||
|
||
const { | ||
url: developerPageUrl, | ||
selectors: { container: developerPageContainer } | ||
} = developerAppsPage | ||
|
||
const { | ||
url: adminPageUrl, | ||
selectors: { container: adminPageContainer } | ||
} = adminApprovalsPage | ||
|
||
const testCases = [ | ||
{ | ||
testCaseName: 'login successfully using DEVELOPER account', | ||
email: Cypress.env('DEVELOPER_ACCOUNT_EMAIL'), | ||
password: Cypress.env('DEVELOPER_ACCOUNT_PASSWORD'), | ||
container: developerPageContainer, | ||
url: developerPageUrl, | ||
loginUrl: loginAsDeveloperUrl | ||
}, | ||
{ | ||
testCaseName: 'login successfully using CLIENT account', | ||
email: Cypress.env('CLIENT_ACCOUNT_EMAIL'), | ||
password: Cypress.env('CLIENT_ACCOUNT_PASSWORD'), | ||
container: clientAppsPageContainer, | ||
url: pageClientAppsUrl, | ||
loginUrl: loginAsClientUrl | ||
}, | ||
{ | ||
testCaseName: 'login successfully using ADMIN account', | ||
email: Cypress.env('ADMIN_ACCOUNT_EMAIL'), | ||
password: Cypress.env('ADMIN_ACCOUNT_PASSWORD'), | ||
container: adminPageContainer, | ||
url: adminPageUrl, | ||
loginUrl: loginAsAdminUrl | ||
} | ||
] | ||
for (const { container, email, password, testCaseName, loginUrl } of testCases) { | ||
it(testCaseName, done => { | ||
cy.visit(loginUrl) | ||
cy.get(inputEmail).type(email) | ||
cy.get(inputPassword).type(password) | ||
cy.get(buttonLogin).click() | ||
cy.get(container).should('have.length', 1) | ||
cy.window().then(window => { | ||
window.localStorage.clear() | ||
done() | ||
}) | ||
}) | ||
} | ||
}) | ||
}) |
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 @@ | ||
export default { | ||
url: '/admin/approvals', | ||
selectors: { | ||
container: '#page-admin-approvals-container' | ||
} | ||
} |
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 @@ | ||
export default { | ||
url: '/client/apps', | ||
selectors: { | ||
container: '#page-client-apps-container' | ||
} | ||
} |
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 @@ | ||
export default { | ||
url: '/developer/apps', | ||
selectors: { | ||
container: '#page-developer-apps-container' | ||
} | ||
} |
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 @@ | ||
export default { | ||
loginAsClientUrl: '/client/login', | ||
loginAsDeveloperUrl: '/developer/login', | ||
loginAsAdminUrl: '/admin/login', | ||
selectors: { | ||
inputEmail: 'input#userName', | ||
inputPassword: 'input#password', | ||
buttonLogin: "button[type='submit']" | ||
} | ||
} |
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,38 @@ | ||
const path = require('path') | ||
const wp = require('@cypress/webpack-preprocessor') | ||
|
||
module.exports = (on, config) => { | ||
// https://basarat.gitbooks.io/typescript/docs/testing/cypress.html | ||
const options = { | ||
webpackOptions: { | ||
resolve: { | ||
extensions: ['.ts', '.tsx', '.js'], | ||
modules: [ | ||
/* assuming that one up is where your node_modules sit, | ||
relative to the currently executing script | ||
*/ | ||
path.join(__dirname, '../../node_modules') | ||
] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
loader: 'ts-loader', | ||
options: { transpileOnly: true } | ||
} | ||
] | ||
} | ||
} | ||
} | ||
on('file:preprocessor', wp(options)) | ||
|
||
|
||
// Retries plugin | ||
require('cypress-plugin-retries/lib/plugin')(on) | ||
|
||
// Config ENV | ||
require('dotenv').config({ path: path.resolve(__dirname, '../../src/constants/.env') }) | ||
const baseUrl = process.env.APPLICATION_URL | ||
return { ...config, baseUrl, env: { ...process.env } } | ||
} |
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 @@ | ||
import 'cypress-plugin-retries' |
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": { | ||
"strict": true, | ||
"baseUrl": "../node_modules", | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress"] | ||
}, | ||
"include": [ | ||
"**/*.ts" | ||
] | ||
} |
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
Oops, something went wrong.