Skip to content

Commit

Permalink
feat(login): add command to fill login form
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Nov 19, 2020
1 parent bdc2757 commit 5b226ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/cypress-commands/src/commands/fillAndSubmitLoginForm.js
@@ -0,0 +1,19 @@
/**
* @param {Object} args
* @param {string} args.userName
* @param {string} args.password
* @param {string} [args.loginUrl]
* When not provided, the server field will be ignored.
* If the server is already set through an env var,
* then not providing this property will produce the expected result
*
* @returns {void}
*/
export const fillAndSubmitLoginForm = ({ loginUrl, userName, password }) => {
loginUrl && cy.get('#server').type(loginUrl)
cy.get('#j_username').type(userName)
cy.get('#j_password').type(password)
cy.get('{loginsubmit}', { prefix: 'dhis2-adapter' }).click()
}

Cypress.Commands.add('fillAndSubmitLoginForm', fillAndSubmitLoginForm)
1 change: 1 addition & 0 deletions packages/cypress-commands/src/index.js
@@ -1,4 +1,5 @@
// will automatically create the commands
import './commands/fillAndSubmitLoginForm'
import './commands/find'
import './commands/get'
import './commands/login'
Expand Down

0 comments on commit 5b226ed

Please sign in to comment.