From 823da967e43d1eae09a2fb2af977f46c89baa911 Mon Sep 17 00:00:00 2001 From: Jack Kelly Date: Tue, 22 Oct 2024 16:38:44 +0100 Subject: [PATCH] test: started setup for pages which are behind auth --- cypress/support/commands.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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'); + }); +});