diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 66ea16ef..aa3b052c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -22,4 +22,16 @@ // // // -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) \ No newline at end of file +// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) + +// start of a login command with sessions +// TODO: resolve issues with the CSRF token +Cypress.Commands.add('login', (username, password) => { + cy.session([username, password], () => { + cy.visit('/login'); + cy.get('[data-test=username]').type(username); + cy.get('[data-test=password]').type(password); + cy.get('[data-test=login]').click(); + cy.url().should('contain', '/admin/profile'); + }); +});