diff --git a/cypress/integration/create-channel.spec.js b/cypress/integration/create-channel.spec.js index ba1eaaf..7dda64b 100644 --- a/cypress/integration/create-channel.spec.js +++ b/cypress/integration/create-channel.spec.js @@ -9,10 +9,12 @@ context('Create Channel Browser Testing', () => { channelName += num; description += num; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('Channel Creation process', () => { it('should login', () => cy.login()); @@ -44,10 +46,6 @@ context('Create Channel Browser Testing', () => { cy.location().should((loc) => { expect(loc.pathname).to.eq('/admin'); }); - // Workaround - component reactivity bug - cy.reload(); - cy.get('.accept-button').click(); - // End workaround }); it('should land newly created channel on channels list screen', () => { cy.contains('solid-display-value[name="circle.name"]', channelName).should("exist"); diff --git a/cypress/integration/create-job-offer.spec.js b/cypress/integration/create-job-offer.spec.js index 1c5b225..b4d6d43 100644 --- a/cypress/integration/create-job-offer.spec.js +++ b/cypress/integration/create-job-offer.spec.js @@ -13,10 +13,12 @@ context('Create Job Offer Browser Testing', () => { jobTitle += num; description += num; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('Job Offer Creation process', () => { it('should login', () => cy.login()); @@ -52,10 +54,6 @@ context('Create Job Offer Browser Testing', () => { cy.location().should((loc) => { expect(loc.pathname).to.eq('/job-offers'); }); - // Workaround - component reactivity bug - cy.reload(); - cy.get('.accept-button').click(); - // End workaround }); it('should land newly created job offer on job offers list screen', () => { cy.contains('solid-display-value[name="title"]', jobTitle).should("exist"); diff --git a/cypress/integration/create-project.spec.js b/cypress/integration/create-project.spec.js index 77652c6..9322c21 100644 --- a/cypress/integration/create-project.spec.js +++ b/cypress/integration/create-project.spec.js @@ -11,10 +11,12 @@ context('Create Project Browser Testing', () => { customerName += num; description += num; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('Project Creation process', () => { it('should login', () => cy.login()); @@ -50,10 +52,6 @@ context('Create Project Browser Testing', () => { cy.location().should((loc) => { expect(loc.pathname).to.eq('/admin/admin-projects'); }); - // Workaround - component reactivity bug - cy.reload(); - cy.get('.accept-button').click(); - // End workaround }); it('should land newly created project on projects list screen', () => { cy.contains('solid-display-value[name="project.name"]', projectName).should("exist"); diff --git a/cypress/integration/create-user.spec.js b/cypress/integration/create-user.spec.js index f2d9416..1abd7a1 100644 --- a/cypress/integration/create-user.spec.js +++ b/cypress/integration/create-user.spec.js @@ -13,10 +13,12 @@ context('Create User Browser Testing', () => { username += num; email = username + '@testemail.com'; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('User Creation process', () => { it('should login', () => cy.login()); diff --git a/cypress/integration/edit-channel.spec.js b/cypress/integration/edit-channel.spec.js index 03f3fc5..ea53551 100644 --- a/cypress/integration/edit-channel.spec.js +++ b/cypress/integration/edit-channel.spec.js @@ -14,10 +14,12 @@ context('Edit Channel Browser Testing', () => { channelName += num; description += num; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('Channel Edition process', () => { it('should login', () => cy.login()); @@ -46,10 +48,6 @@ context('Edit Channel Browser Testing', () => { expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information'); }); })); - // Workaround - component reactivity bug - cy.reload(); - cy.get('.accept-button').click(); - // End workaround }); it('should show edited channel data on channel information screen', () => { cy.contains('solid-display-value[name="name"]', channelName).should("exist"); diff --git a/cypress/integration/edit-job-offer.spec.js b/cypress/integration/edit-job-offer.spec.js index 649a469..53d6dca 100644 --- a/cypress/integration/edit-job-offer.spec.js +++ b/cypress/integration/edit-job-offer.spec.js @@ -17,10 +17,12 @@ context('Edit Job Offer Browser Testing', () => { jobTitle += num; description += num; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('Job Offer Edition process', () => { it('should login', () => cy.login()); @@ -47,10 +49,6 @@ context('Edit Job Offer Browser Testing', () => { cy.location().should((loc) => { expect(loc.pathname).to.eq('/job-offers'); }); - // Workaround - component reactivity bug - cy.reload(); - cy.get('.accept-button').click(); - // End workaround }); it('should show edited project data on project information screen', () => { cy.contains('solid-display-value[name="title"]', jobTitle).should("exist"); diff --git a/cypress/integration/edit-project.spec.js b/cypress/integration/edit-project.spec.js index 31482bb..42e1386 100644 --- a/cypress/integration/edit-project.spec.js +++ b/cypress/integration/edit-project.spec.js @@ -16,10 +16,12 @@ context('Edit Project Browser Testing', () => { customerName += num; description += num; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); describe('Project Edition process', () => { it('should login', () => cy.login()); @@ -50,10 +52,6 @@ context('Edit Project Browser Testing', () => { expect(loc.pathname).to.eq('/project/@' + id + '/project-information'); }); })); - // Workaround - component reactivity bug - cy.reload(); - cy.get('.accept-button').click(); - // End workaround }); it('should show edited project data on project information screen', () => { cy.contains('solid-display-value[name="customer.name"]', customerName).should("exist"); diff --git a/cypress/integration/retire-project.spec.js b/cypress/integration/retire-project.spec.js index 102f0a5..e319d83 100644 --- a/cypress/integration/retire-project.spec.js +++ b/cypress/integration/retire-project.spec.js @@ -6,12 +6,14 @@ context('Retire Project Browser Testing', () => { 'solid-display.project-tab', 'solid-display:last-child', 'solid-display[order-by="customer.name"]' - ];; + ]; before(() => { + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); - beforeEach(() => cy.setToken()); + beforeEach(() => cy.restoreLocalStorage()); + afterEach(() => cy.saveLocalStorage()); it('should visit user login screend', () => cy.userLogin()); describe('Project Retirement process', () => { it('should login', () => cy.login()); diff --git a/cypress/integration/signin.spec.js b/cypress/integration/signin.spec.js index 62e1265..53457ed 100644 --- a/cypress/integration/signin.spec.js +++ b/cypress/integration/signin.spec.js @@ -3,6 +3,7 @@ context('Browser testing', () => { before(() => { + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null}); cy.clearCookies({ domain: null }); }); diff --git a/cypress/integration/signup.spec.js b/cypress/integration/signup.spec.js index 9597980..05ee1b8 100644 --- a/cypress/integration/signup.spec.js +++ b/cypress/integration/signup.spec.js @@ -10,6 +10,7 @@ context('Signup Browser Testing', () => { username += num; email = username + '@testemail.com'; }); + cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 6700e64..2ece0ad 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -26,6 +26,8 @@ /* globals Cypress, cy, expect */ +import 'cypress-localstorage-commands'; + Cypress.Commands.add('login', () => { cy.fixture('admin.json').then(admin => { cy.get('#id_username').type(admin.username); @@ -33,20 +35,14 @@ Cypress.Commands.add('login', () => { cy.get('#id_password').type(admin.password); cy.get('#id_password').should('have.value', admin.password); cy.get('.connection-btn').click(); + cy.location('pathname').should('include', '/authorize'); cy.get('.accept-button').click(); - cy.location().should((loc) => { - expect(loc.pathname).to.eq('/'); - cy.wrap(Cypress.localStorage.getItem('solid-auth-client')).as('currentUser'); + cy.location().should(location => { + expect(location.pathname).to.eq('/'); }); }); }); -Cypress.Commands.add('setToken', () => { - if ( this.currentUser ) { - Cypress.localStorage.setItem('solid-auth-client', this.currentUser); - } -}); - Cypress.Commands.add('naviagte', route => { cy.visit(route); cy.location().should((loc) => { diff --git a/package-lock.json b/package-lock.json index f19ba14..5c89a88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1468,6 +1468,12 @@ } } }, + "cypress-localstorage-commands": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/cypress-localstorage-commands/-/cypress-localstorage-commands-1.2.1.tgz", + "integrity": "sha512-wWGElZS5fHAQDonZM8xtOA1tM+bTBUdwEMm6XrshLMKjq8Nxw4+Ysbl9/Yc+gZyv66EQe4hPNDLWANnp/zPkcA==", + "dev": true + }, "cypress-terminal-report": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/cypress-terminal-report/-/cypress-terminal-report-1.2.1.tgz", diff --git a/package.json b/package.json index 3792914..7f979d3 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ }, "devDependencies": { "cypress": "^4.5.0", + "cypress-localstorage-commands": "^1.2.1", "cypress-terminal-report": "^1.2.1" } }