diff --git a/pro/cypress/e2e/migrations/cookieBanner.cy.ts b/pro/cypress/e2e/migrations/cookieBanner.cy.ts index a8f200480d7..3d316dd01af 100644 --- a/pro/cypress/e2e/migrations/cookieBanner.cy.ts +++ b/pro/cypress/e2e/migrations/cookieBanner.cy.ts @@ -67,156 +67,178 @@ describe('Cookie management with no login', () => { cy.stepLog({ message: 'I open the choose cookies option' }) cy.findByText('Choisir les cookies').click() - // I select the "Beamer" cookie + cy.stepLog({ message: 'I select the "Beamer" cookie' }) cy.findByText('Beamer').click() - // I save my choices + cy.stepLog({ message: 'I save my choices' }) cy.findByText('Enregistrer mes choix').click() - // I open the cookie management option + cy.stepLog({ message: 'I open the cookie management option' }) cy.findByText('Gestion des cookies').click() - // The Beamer cookie should be checked + cy.stepLog({ message: 'the Beamer cookie should be checked' }) cy.get('#orejime-app-item-beamer').should('be.checked') }) it('The user can choose a specific cookie, reload the page and the status should not have been changed', () => { - // I open the choose cookies option + cy.stepLog({ message: 'I open the choose cookies option' }) cy.findByText('Choisir les cookies').click() - // I select the "Beamer" cookie + cy.stepLog({ message: 'I select the "Beamer" cookie' }) cy.findByText('Beamer').click() - // I open the "connexion" page + cy.stepLog({ message: 'I open the "connexion" page' }) cy.visit('/connexion') - // I open the choose cookies option + cy.stepLog({ message: 'I open the choose cookies option' }) cy.findByText('Choisir les cookies').click() - // The Beamer cookie should not be checked + cy.stepLog({ message: 'the Beamer cookie should not be checked' }) cy.get('#orejime-app-item-beamer').should('not.be.checked') }) it('The user can choose a specific cookie, close the modal and the status should not have been changed', () => { - // I open the choose cookies option + cy.stepLog({ message: 'I open the choose cookies option' }) cy.findByText('Choisir les cookies').click() - // I select the "Beamer" cookie + cy.stepLog({ message: 'I select the "Beamer" cookie' }) cy.findByText('Beamer').click() - // I close the cookie option + cy.stepLog({ message: 'I close the cookie option' }) cy.get('.orejime-Modal-closeButton').click() - // I open the choose cookies option + cy.stepLog({ message: 'I open the choose cookies option' }) cy.findByText('Choisir les cookies').click() - // The Beamer cookie should be checked + cy.stepLog({ message: 'the Beamer cookie should be checked' }) cy.get('#orejime-app-item-beamer').should('be.checked') }) }) describe('Cookie management no login', () => { let login = '' + let login2 = '' + let login3 = '' const password = 'user@AZERTY123' - beforeEach(() => { - cy.visit('/connexion') + before(() => { cy.request({ method: 'GET', url: 'http://localhost:5001/sandboxes/pro/create_regular_pro_user', }).then((response) => { - login = response.body.user.email + login3 = response.body.user.email }) }) - it('The user can choose a specific cookie, log in with another account and check that specific cookie is checked', function () { - // I clear all cookies in Browser + beforeEach(() => { + cy.visit('/connexion') + }) + + it('The user can choose a specific cookie, log in with another account and check that specific cookie is checked', () => { + cy.stepLog({ message: 'I clear all cookies in Browser' }) cy.clearCookies() - // I am logged in with account 1 - cy.log('login: ' + login) - cy.login({ - email: login, - password: password, - redirectUrl: '/', + cy.request({ + method: 'GET', + url: 'http://localhost:5001/sandboxes/pro/create_regular_pro_user', + }).then((response) => { + login = response.body.user.email + cy.stepLog({ message: 'I am logged in with account 1' }) + cy.log('login: ' + login) + cy.login({ + email: login, + password: password, + redirectUrl: '/', + }) }) homePageLoaded() - // I open the cookie management option + cy.stepLog({ message: 'I open the cookie management option' }) cy.findByText('Gestion des cookies').click() - // I select the "Beamer" cookie + cy.stepLog({ message: 'I select the "Beamer" cookie' }) cy.findByText('Beamer').click() - // I save my choices + cy.stepLog({ message: 'I save my choices' }) cy.findByText('Enregistrer mes choix').click() - // I disconnect of my account + cy.stepLog({ message: 'I disconnect of my account' }) cy.findByTestId('offerer-select').click() cy.findByTestId('header-dropdown-menu-div').should('exist') cy.contains('Se déconnecter').click() cy.url().should('contain', '/connexion') - // I am logged in with account 2 and no cookie selection - cy.login({ - email: login, - password: password, - refusePopupCookies: false, + cy.request({ + method: 'GET', + url: 'http://localhost:5001/sandboxes/pro/create_regular_pro_user', + }).then((response) => { + login2 = response.body.user.email + cy.stepLog({ + message: 'I am logged in with account 2 and no cookie selection', + }) + cy.login({ + email: login2, + password: password, + refusePopupCookies: false, + }) }) + homePageLoaded() - // I open the cookie management option + cy.stepLog({ message: 'I open the cookie management option' }) cy.findByText('Gestion des cookies').click() - // The Beamer cookie should be checked + cy.stepLog({ message: 'the Beamer cookie should be checked' }) cy.get('#orejime-app-item-beamer').should('be.checked') }) - it('The user log in, choose a specific cookie, open another browser, log in again and check that specific cookie not checked', function () { + it('The user log in, choose a specific cookie, open another browser, log in again and check that specific cookie not checked', () => { // Cypress cannot deal with 2 browsers or a tab. So we log out, and log in again with a clean browser // See https://docs.cypress.io/guides/references/trade-offs#Multiple-browsers-open-at-the-same-time - // I clear all cookies in Browser + + cy.stepLog({ message: 'I clear all cookies in Browser' }) cy.clearCookies() - // I am logged in with account 3 + cy.stepLog({ message: 'I am logged in with account 3' }) cy.login({ - email: login, + email: login3, password: password, }) + homePageLoaded() - // I open the cookie management option + cy.stepLog({ message: 'I open the cookie management option' }) cy.findByText('Gestion des cookies').click() - // I select the "Beamer" cookie + cy.stepLog({ message: 'I select the "Beamer" cookie' }) cy.findByText('Beamer').click() - // I save my choices + cy.stepLog({ message: 'I save my choices' }) cy.findByText('Enregistrer mes choix').click() - // I disconnect of my account + cy.stepLog({ message: 'I disconnect of my account' }) cy.findByTestId('offerer-select').click() cy.findByTestId('header-dropdown-menu-div').should('exist') cy.contains('Se déconnecter').click() cy.url().should('contain', '/connexion') - // I clear all cookies and storage + cy.stepLog({ message: 'I clear all cookies and storage' }) cy.clearAllCookies() cy.clearAllLocalStorage() cy.clearAllSessionStorage() - // I am logged in with account 3 + cy.stepLog({ message: 'I am logged in with account 3' }) cy.login({ - email: login, + email: login3, password: password, }) homePageLoaded() - // I open the cookie management option + cy.stepLog({ message: 'I open the cookie management option' }) cy.findByText('Gestion des cookies').click() - // The Beamer cookie should not be checked + cy.stepLog({ message: 'the Beamer cookie should not be checked' }) cy.get('#orejime-app-item-beamer').should('not.be.checked') }) })