diff --git a/packages/cypress-commands/src/commands/fillAndSubmitLoginForm.js b/packages/cypress-commands/src/commands/fillAndSubmitLoginForm.js new file mode 100644 index 00000000..3d0ac887 --- /dev/null +++ b/packages/cypress-commands/src/commands/fillAndSubmitLoginForm.js @@ -0,0 +1,12 @@ +export const fillAndSubmitLoginForm = () => { + const loginUrl = Cypress.env('dhis2_base_url') + const username = Cypress.env('dhis2_username') + const password = Cypress.env('dhis2_password') + + 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) diff --git a/packages/cypress-commands/src/index.js b/packages/cypress-commands/src/index.js index b2615628..64e836ed 100644 --- a/packages/cypress-commands/src/index.js +++ b/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'