update: loccalStorage persistance using externallibrary

This commit is contained in:
Jure Ursic 2020-07-08 15:41:05 +02:00
parent ff41638e2b
commit 9a6ea85bbb
13 changed files with 39 additions and 42 deletions

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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());

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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());

View File

@ -3,6 +3,7 @@
context('Browser testing', () => {
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null});
cy.clearCookies({ domain: null });
});

View File

@ -10,6 +10,7 @@ context('Signup Browser Testing', () => {
username += num;
email = username + '@testemail.com';
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});

View File

@ -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) => {

6
package-lock.json generated
View File

@ -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",

View File

@ -68,6 +68,7 @@
},
"devDependencies": {
"cypress": "^4.5.0",
"cypress-localstorage-commands": "^1.2.1",
"cypress-terminal-report": "^1.2.1"
}
}