Merge branch 'release/cypress-testing' into release/sxc-149

This commit is contained in:
Jean-Baptiste Pasquier 2020-09-17 18:41:17 +02:00
commit 9b0c822873
25 changed files with 1277 additions and 37 deletions

View File

@ -44,6 +44,7 @@ test:e2e:
before_script:
# install missing dependencies
- npm install -g sirv-cli
- npm install cypress-localstorage-commands
# making sure the process is orphan
- sirv dist --port 3000 > /dev/null 2>&1 &
script:

View File

@ -1,6 +1,6 @@
{
"baseUrl": "http://127.0.0.1:3000",
"defaultCommandTimeout": 60000,
"defaultCommandTimeout": 1000,
"chromeWebSecurity": false,
"viewportWidth": 1920,
"viewportHeight": 1080,

54
cypress/README.md Normal file
View File

@ -0,0 +1,54 @@
## Users:
```
- signin
- signup
- create
- listing
- edit
// TO-FIX: Uncomment workaround (blocked by: nested routing bug)
```
## Job Offers:
```
- create
- edit
- listing
// TO-FIX: Search by title and description (blocked by: no search fields available)
- post
// TO-DO: Entire flow (blocked by: no published / unpublished flag)
```
## Channels:
```
- create
- edit
- leave
- retire
- delete
- join
// TO-DO: Join other user created project (blocked by: can't create new user to create a channel)
- invite
// TO-DO
```
## Projects:
```
- create
- edit
- leave
- retire
- delete
// TO-DO: Delete a project (blocked by: no option to delete a project)
- join
// TO-DO: Join other user created project (blocked by: can't create new user to create a project)
- invite
// TO-DO
```
## Breakdown:
```
DONE: 15
TO-FIX: 2
BLOCKED: 4
NOT DONE: 2
```

View File

@ -0,0 +1,4 @@
{
"username": "admin",
"password": "admin"
}

View File

@ -0,0 +1,116 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Create Channel Browser Testing', () => {
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Channel Creation process #1', () => {
let channelName = 'Test Channel ',
description = 'Test Description ';
it('should visit the channel creation screen', () => {
cy.visit('/admin/admin-circle-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-circle-create');
});
});
it('should enter correct channel data', () => {
cy.randomNum().then(num => {
channelName += num;
description += num;
cy.get('#admin-circle-create input[name="name"]').clear().type(channelName);
cy.get('#admin-circle-create input[name="name"]').should('have.value', channelName);
cy.get('#admin-circle-create input[name="description"]').clear().type(description);
cy.get('#admin-circle-create input[name="description"]').should('have.value', description);
});
});
it('should click on create channel button', () => {
cy.get('#admin-circle-create input[type="submit"]').click();
});
it('should land on channels list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should land newly created channel on channels list screen', () => {
cy.contains('solid-display-value[name="circle.name"]', channelName).should("exist");
cy.fixture('admin.json').then(admin => {
cy.contains('solid-display-value[name="username"]', admin.username).should("exist");
});
});
});
describe('Channel Creation process #2', () => {
let channelName = 'Test Channel ',
description = 'Test Description ';
it('should visit the channel creation screen', () => {
cy.visit('/admin/admin-circle-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-circle-create');
});
});
it('should enter correct channel data', () => {
cy.randomNum().then(num => {
channelName += num;
description += num;
cy.get('#admin-circle-create input[name="name"]').clear().type(channelName);
cy.get('#admin-circle-create input[name="name"]').should('have.value', channelName);
cy.get('#admin-circle-create input[name="description"]').clear().type(description);
cy.get('#admin-circle-create input[name="description"]').should('have.value', description);
});
});
it('should click on create channel button', () => {
cy.get('#admin-circle-create input[type="submit"]').click();
});
it('should land on channels list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should land newly created channel on channels list screen', () => {
cy.contains('solid-display-value[name="circle.name"]', channelName).should("exist");
cy.fixture('admin.json').then(admin => {
cy.contains('solid-display-value[name="username"]', admin.username).should("exist");
});
});
});
describe('Channel Creation process #3', () => {
let channelName = 'Test Channel ',
description = 'Test Description ';
it('should visit the channel creation screen', () => {
cy.visit('/admin/admin-circle-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-circle-create');
});
});
it('should enter correct channel data', () => {
cy.randomNum().then(num => {
channelName += num;
description += num;
cy.get('#admin-circle-create input[name="name"]').clear().type(channelName);
cy.get('#admin-circle-create input[name="name"]').should('have.value', channelName);
cy.get('#admin-circle-create input[name="description"]').clear().type(description);
cy.get('#admin-circle-create input[name="description"]').should('have.value', description);
});
});
it('should click on create channel button', () => {
cy.get('#admin-circle-create input[type="submit"]').click();
});
it('should land on channels list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should land newly created channel on channels list screen', () => {
cy.contains('solid-display-value[name="circle.name"]', channelName).should("exist");
cy.fixture('admin.json').then(admin => {
cy.contains('solid-display-value[name="username"]', admin.username).should("exist");
});
});
});
});

View File

@ -0,0 +1,52 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Create Job Offer Browser Testing', () => {
let jobDate = '',
jobTitle = 'Test Job Offer ',
description = 'Test Description ';
before(() => {
cy.nextYear(1).then(year => {
jobDate = year + '-12-31';
});
cy.randomNum().then(num => {
jobTitle += num;
description += num;
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Job Offer Creation process', () => {
it('should visit the job offer creation screen', () => {
cy.visit('/job-offers/job-offers-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/job-offers/job-offers-create');
});
});
it('should enter correct job offer data', () => {
cy.get('#job-offers-create input[name="closingDate"]').clear().type(jobDate);
cy.get('#job-offers-create input[name="closingDate"]').should('have.value', jobDate);
cy.get('#job-offers-create input[name="title"]').clear().type(jobTitle);
cy.get('#job-offers-create input[name="title"]').should('have.value', jobTitle);
cy.get('#job-offers-create textarea[name="description"]').clear().type(description);
cy.get('#job-offers-create textarea[name="description"]').should('have.value', description);
});
it('should click on create job offer button', () => {
cy.get('#job-offers-create input[type="submit"]').click();
});
it('should land on job offers list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/job-offers');
});
});
it('should land newly created job offer on job offers list screen', () => {
cy.contains('solid-display-value[name="title"]', jobTitle).should("exist");
cy.contains('solid-display-value[name="description"]', description).should("exist");
});
});
});

View File

@ -0,0 +1,90 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Create Project Browser Testing', () => {
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Project Creation process #1', () => {
let projectName = 'Test Project ',
customerName = 'Test Customer ',
description = 'Test Description ';
it('should visit the project creation screen', () => {
cy.visit('/admin/admin-projects/admin-project-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects/admin-project-create');
});
});
it('should enter correct project data', () => {
cy.randomNum().then(num => {
projectName += num;
customerName += num;
description += num;
cy.get('#admin-project-create input[name="customer.name"]').clear().type(customerName);
cy.get('#admin-project-create input[name="customer.name"]').should('have.value', customerName);
cy.get('#admin-project-create input[name="name"]').clear().type(projectName);
cy.get('#admin-project-create input[name="name"]').should('have.value', projectName);
cy.get('#admin-project-create textarea[name="description"]').clear().type(description);
cy.get('#admin-project-create textarea[name="description"]').should('have.value', description);
});
});
it('should click on create project button', () => {
cy.get('#admin-project-create input[type="submit"]').click();
});
it('should land on projects list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects');
});
});
it('should land newly created project on projects list screen', () => {
cy.contains('solid-display-value[name="project.name"]', projectName).should("exist");
cy.fixture('admin.json').then(admin => {
cy.contains('solid-display-value[name="username"]', admin.username).should("exist");
});
});
});
describe('Project Creation process #2', () => {
let projectName = 'Test Project ',
customerName = 'Test Customer ',
description = 'Test Description ';
it('should visit the project creation screen', () => {
cy.visit('/admin/admin-projects/admin-project-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects/admin-project-create');
});
});
it('should enter correct project data', () => {
cy.randomNum().then(num => {
projectName += num;
customerName += num;
description += num;
cy.get('#admin-project-create input[name="customer.name"]').clear().type(customerName);
cy.get('#admin-project-create input[name="customer.name"]').should('have.value', customerName);
cy.get('#admin-project-create input[name="name"]').clear().type(projectName);
cy.get('#admin-project-create input[name="name"]').should('have.value', projectName);
cy.get('#admin-project-create textarea[name="description"]').clear().type(description);
cy.get('#admin-project-create textarea[name="description"]').should('have.value', description);
});
});
it('should click on create project button', () => {
cy.get('#admin-project-create input[type="submit"]').click();
});
it('should land on projects list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects');
});
});
it('should land newly created project on projects list screen', () => {
cy.contains('solid-display-value[name="project.name"]', projectName).should("exist");
cy.fixture('admin.json').then(admin => {
cy.contains('solid-display-value[name="username"]', admin.username).should("exist");
});
});
});
});

View File

@ -0,0 +1,54 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Create User Browser Testing', () => {
let firstName = 'First ',
lastName = 'Last ',
username = 'testuser_creation_',
email = '';
before(() => {
cy.randomNum().then(num => {
firstName += num;
lastName += num;
username += num;
email = username + '@testemail.com';
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('User Creation process', () => {
it('should visit the user creation screen', () => {
cy.visit('/admin/admin-users/admin-users-create');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-users/admin-users-create');
});
});
it('should enter correct user data', () => {
cy.get('#admin-users-create input[name="first_name"]').clear().type(firstName);
cy.get('#admin-users-create input[name="first_name"]').should('have.value', firstName);
cy.get('#admin-users-create input[name="last_name"]').clear().type(lastName);
cy.get('#admin-users-create input[name="last_name"]').should('have.value', lastName);
cy.get('#admin-users-create input[name="username"]').clear().type(username);
cy.get('#admin-users-create input[name="username"]').should('have.value', username);
cy.get('#admin-users-create input[name="email"]').clear().type(email);
cy.get('#admin-users-create input[name="email"]').should('have.value', email);
});
it('should click on create user button', () => {
cy.get('#admin-users-create input[type="submit"]').click();
});
it('should land on users list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-users');
});
});
it('should land newly created user on users list screen', () => {
cy.contains('solid-display-value[name="name"]', firstName + ' ' + lastName).should("exist");
cy.contains('solid-display-value[name="username"]', username).should("exist");
});
});
});

View File

@ -0,0 +1,63 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Delete Channel Browser Testing', () => {
let menuQuery = [
'solid-display.circle-tab',
'solid-display:last-child',
'solid-display[order-by="name"]'
],
menuCountQuery = [
'solid-display.circle-tab',
'solid-display',
'solid-display[order-by="name"]'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screend', () => cy.userLogin());
it('should login', () => cy.login());
describe('Channel Retirement process', () => {
let channelsLength;
it('should visit the channels list screen', () => {
cy.visit('/admin');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should visit the last channel edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/circle/@' + id + '/circle-information');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information');
});
}));
});
it('should count the number of joined channels', () => {
cy.get(menuCountQuery.join(' ')).its('length').then(length => channelsLength = length);
});
it('should click button to retire the channel', () => {
cy.get('#circle-profile solid-delete[data-label="Supprimer le canal"] button').click();
});
it('should stay on channel edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information');
});
}));
});
it('should check if chennel was retired', () => {
cy.get(menuCountQuery.join(' ')).its('length').should(length => {
expect(length).to.eq(channelsLength - 1);
});
});
});
});

View File

@ -0,0 +1,65 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Edit Channel Browser Testing', () => {
let channelName = 'Edited Test Channel ',
description = 'Edited Test Description ',
menuQuery = [
'solid-display.circle-tab',
'solid-display:last-child',
'solid-display[order-by="name"]'
];
before(() => {
cy.randomNum().then(num => {
channelName += num;
description += num;
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Channel Edition process', () => {
it('should visit the channel list screen', () => {
cy.visit('/admin');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should visit the last channel edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/circle/@' + id + '/circle-information/circle-edit');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information/circle-edit');
});
}));
});
it('should enter new channel data', () => {
cy.get('#circle-edit input[name="name"]').clear().type(channelName);
cy.get('#circle-edit input[name="name"]').should('have.value', channelName);
cy.get('#circle-edit input[name="description"]').clear().type(description);
cy.get('#circle-edit input[name="description"]').should('have.value', description);
});
it('should click button to save the channel', () => {
cy.get('#circle-edit input[value="Enregistrer"]').click();
});
it('should land on channel information screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information');
});
}));
});
it('should show edited channel data on channel information screen', () => {
cy.contains('solid-display-value[name="name"]', channelName).should("exist");
cy.contains('solid-display-value[name="description"]', description).should("exist");
});
});
});

View File

@ -0,0 +1,66 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Edit Job Offer Browser Testing', () => {
let jobDate = '',
jobTitle = 'Edited Test Job Offer ',
description = 'Edited Test Description ',
menuQuery = [
'solid-display.job-board__list',
'solid-display:last-child'
];
before(() => {
cy.nextYear(2).then(year => {
jobDate = year + '-12-31';
});
cy.randomNum().then(num => {
jobTitle += num;
description += num;
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Job Offer Edition process', () => {
it('should visit the job offers list screen', () => {
cy.visit('/job-offers');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/job-offers');
});
});
it('should visit the last job offer edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/job-offers/job-offers-edit/@' + id);
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/job-offers/job-offers-edit/@' + id);
});
}));
});
it('should enter new job offer data', () => {
cy.get('#job-offers-edit input[name="closingDate"]').clear().type(jobDate);
cy.get('#job-offers-edit input[name="closingDate"]').should('have.value', jobDate);
cy.get('#job-offers-edit input[name="title"]').clear().type(jobTitle);
cy.get('#job-offers-edit input[name="title"]').should('have.value', jobTitle);
cy.get('#job-offers-edit textarea[name="description"]').clear().type(description);
cy.get('#job-offers-edit textarea[name="description"]').should('have.value', description);
});
it('should click button to save the job offer', () => {
cy.get('#job-offers-edit input[type="submit"]').click();
});
it('should land on job offers list screen', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/job-offers');
});
});
it('should show edited job offer data on job offer information screen', () => {
cy.contains('solid-display-value[name="title"]', jobTitle).should("exist");
cy.contains('solid-display-value[name="description"]', description).should("exist");
});
});
});

View File

@ -0,0 +1,69 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Edit Project Browser Testing', () => {
let projectName = 'Edited Test Project ',
customerName = 'Edited Test Customer ',
description = 'Edited Test Description ',
menuQuery = [
'solid-display.project-tab',
'solid-display:last-child',
'solid-display[order-by="customer.name"]'
];
before(() => {
cy.randomNum().then(num => {
projectName += num;
customerName += num;
description += num;
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Project Edition process', () => {
it('should visit the project list screen', () => {
cy.visit('/admin/admin-projects');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects');
});
});
it('should visit the last project edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/project/@' + id + '/project-information/project-edit');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/project/@' + id + '/project-information/project-edit');
});
}));
});
it('should enter new project data', () => {
cy.get('#project-edit input[name="customer.name"]').clear().type(customerName);
cy.get('#project-edit input[name="customer.name"]').should('have.value', customerName);
cy.get('#project-edit input[name="name"]').clear().type(projectName);
cy.get('#project-edit input[name="name"]').should('have.value', projectName);
cy.get('#project-edit textarea[name="description"]').clear().type(description);
cy.get('#project-edit textarea[name="description"]').should('have.value', description);
});
it('should click button to save the project', () => {
cy.get('#project-edit input[value="Enregistrer"]').click();
});
it('should land on project information screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/project/@' + id + '/project-information');
});
}));
});
it('should show edited project data on project information screen', () => {
cy.contains('solid-display-value[name="customer.name"]', customerName).should("exist");
cy.contains('solid-display-value[name="name"]', projectName).should("exist");
});
});
});

View File

@ -0,0 +1,73 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Edit User Browser Testing', () => {
let userFirstName = 'Edited User First Name ',
userLastName = 'Edited User Last Name ',
jobDescription = 'Edited Job Description ',
city = 'Edited City ',
phone = '+1234',
website = 'https://test.site/';
before(() => {
cy.randomNum().then(num => {
userFirstName += num;
userLastName += num;
jobDescription += num;
city += num;
phone += num;
website += num;
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('User Edition process', () => {
it('should visit the user edit screen', () => {
cy.visit('/profile/solid-profile-edit-profile');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/profile/solid-profile-edit-profile');
});
});
/// Workaround - Routing bug - user won't land on edit profile screen
it('should navigate to user edit screen', () => {
cy.get('#solid-profile-my-profile solid-link[next="solid-profile-edit-profile"]').click();
});
/// End workaround
it('should enter new user data', () => {
cy.get('#solid-profile-edit-profile input[name="first_name"]').clear().type(userFirstName);
cy.get('#solid-profile-edit-profile input[name="first_name"]').should('have.value', userFirstName);
cy.get('#solid-profile-edit-profile input[name="last_name"]').clear().type(userLastName);
cy.get('#solid-profile-edit-profile input[name="last_name"]').should('have.value', userLastName);
cy.get('#solid-profile-edit-profile textarea[name="profile.job"]').clear().type(jobDescription);
cy.get('#solid-profile-edit-profile textarea[name="profile.job"]').should('have.value', jobDescription);
cy.get('#solid-profile-edit-profile input[name="profile.city"]').clear().type(city);
cy.get('#solid-profile-edit-profile input[name="profile.city"]').should('have.value', city);
cy.get('#solid-profile-edit-profile input[name="profile.phone"]').clear().type(phone);
cy.get('#solid-profile-edit-profile input[name="profile.phone"]').should('have.value', phone);
cy.get('#solid-profile-edit-profile input[name="profile.website"]').clear().type(website);
cy.get('#solid-profile-edit-profile input[name="profile.website"]').should('have.value', website);
});
it('should click button to save the user', () => {
cy.get('#solid-profile-edit-profile input[value="ENREGISTRER"]').click();
});
it('should land on user information screen', () => {
cy.location().should(location => {
/// Workaround - Routing bug - route pathname won't be /profile as it should
expect(location.pathname).to.eq('/');
// expect(location.pathname).to.eq('/profile');
/// End workaround
});
});
it('should show edited user data on user information screen', () => {
cy.contains('solid-display-value[name="name"]', userFirstName + ' ' + userLastName).should("exist");
cy.contains('solid-display-value[name="profile.job"]', jobDescription).should("exist");
cy.contains('solid-display-value[name="profile.city"]', city).should("exist");
cy.contains('solid-display-tel[name="profile.phone"] a', phone).should("exist");
cy.contains('profile-website[name="profile.website"] a', website).should("exist");
});
});
});

View File

@ -0,0 +1,42 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Leave Channel Browser Testing', () => {
let tableQuery = [
'solid-display.table-body',
'solid-display:last-child',
'hubl-admin-circle-leave-button',
'solid-delete'
],
tableListQuery = [
'solid-display[nested-field="circles"]',
'div >',
'solid-display'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screend', () => cy.userLogin());
it('should login', () => cy.login());
describe('Channel Leaving process', () => {
it('should visit the channels list screen', () => {
cy.visit('/admin');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should click the last channel leave button', () => {
cy.get(tableListQuery.join(' ')).its('length').as('channelsLength');
cy.get(tableQuery.join(' ')).click();
});
it('should check if chennel was left', () => {
cy.get(tableListQuery.join(' ')).its('length').should(length => {
expect(length).to.eq(this.channelsLength - 1);
});
});
});
});

View File

@ -0,0 +1,42 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Leave Project Browser Testing', () => {
let tableQuery = [
'solid-display.table-body',
'solid-display:last-child',
'hubl-admin-project-leave-button',
'solid-delete'
],
tableListQuery = [
'solid-display[nested-field="projects"]',
'div >',
'solid-display'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screend', () => cy.userLogin());
it('should login', () => cy.login());
describe('Project Leaving process', () => {
it('should visit the projects list screen', () => {
cy.visit('/admin/admin-projects');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects');
});
});
it('should click the last project leave button', () => {
cy.get(tableListQuery.join(' ')).its('length').as('projectsLength');
cy.get(tableQuery.join(' ')).click();
});
it('should check if project was left', () => {
cy.get(tableListQuery.join(' ')).its('length').should(length => {
expect(length).to.eq(this.projectsLength - 1);
});
});
});
});

View File

@ -0,0 +1,84 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('List Job Offers Browser Testing', () => {
let listQuery = 'solid-display.job-board__list',
filtersQuery = [
listQuery,
'solid-form',
'input'
],
listingCountQuery = [
listQuery,
'solid-display'
],
firstListingQuery = [
listQuery,
'solid-display:first-child',
'solid-display-value'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Job Offer Listing process', () => {
let listingTitle,
listingDesccription,
listingCount;
it('should visit the job offers listing screen', () => {
cy.visit('/job-offers');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/job-offers');
});
});
it('should get the listing count', () => {
cy.get(listingCountQuery.join(' ')).its('length').then(length => listingCount = length);
});
it('should get the first job offer listing data', () => {
cy.get(firstListingQuery.join(' ') + '[name="title"]').invoke('text').then(text => listingTitle = text);
cy.get(firstListingQuery.join(' ') + '[name="description"]').invoke('text').then(text => listingDesccription = text);
});
// TO-DO: Search by title and description
/*it('should filter the listing by first name', () => {
cy.get(filtersQuery.join(' ') + '[name="title"]').clear().type(listingTitle);
cy.get(filtersQuery.join(' ') + '[name="title"]').should('have.value', listingTitle);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).its('length').then(length => {
expect(length).to.eq(1);
});
});
it('should clear the first name filter', () => {
cy.get(filtersQuery.join(' ') + '[name="title"]').clear();
cy.get(filtersQuery.join(' ') + '[name="title"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).its('length').then(length => {
expect(length).to.eq(listingCount);
});
});
it('should filter the listing by first name', () => {
cy.get(filtersQuery.join(' ') + '[name="description"]').clear().type(listingDesccription);
cy.get(filtersQuery.join(' ') + '[name="description"]').should('have.value', listingDesccription);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).its('length').then(length => {
expect(length).to.eq(1);
});
});
it('should clear the first name filter', () => {
cy.get(filtersQuery.join(' ') + '[name="description"]').clear();
cy.get(filtersQuery.join(' ') + '[name="description"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).its('length').then(length => {
expect(length).to.eq(listingCount);
});
});*/
});
});

View File

@ -0,0 +1,124 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('List Users Browser Testing', () => {
let listQuery = 'solid-display#members-list__content',
filtersQuery = [
listQuery,
'solid-form',
'input'
],
listingCountQuery = [
listQuery,
'div:first-child',
'span'
],
firstListingQuery = [
listQuery,
'solid-display:first-child',
'solid-display-value'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('User Listing process', () => {
let listingFirstName,
listingLastName,
listingJob,
listingCity,
listingCount;
it('should visit the users listing screen', () => {
cy.visit('/members');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/members');
});
});
it('should get the listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => listingCount = text);
});
it('should get the first user listing data', () => {
cy.get(firstListingQuery.join(' ') + '[name="first_name"]').invoke('text').then(text => listingFirstName = text);
cy.get(firstListingQuery.join(' ') + '[name="last_name"]').invoke('text').then(text => listingLastName = text);
cy.get(firstListingQuery.join(' ') + '[name="profile.job"]').invoke('text').then(text => listingJob = text);
cy.get(firstListingQuery.join(' ') + '[name="profile.city"]').invoke('text').then(text => listingCity = text);
});
it('should filter the listing by first name', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear().type(listingFirstName);
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', listingFirstName);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the first name filter', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear();
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
it('should filter the listing by last name', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear().type(listingLastName);
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', listingLastName);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the last name filter', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear();
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
it('should filter the listing by job description', () => {
cy.get(filtersQuery.join(' ') + '[name="member-job"]').clear().type(listingJob);
cy.get(filtersQuery.join(' ') + '[name="member-job"]').should('have.value', listingJob);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the job description filter', () => {
cy.get(filtersQuery.join(' ') + '[name="member-job"]').clear();
cy.get(filtersQuery.join(' ') + '[name="member-job"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
it('should filter the listing by city', () => {
cy.get(filtersQuery.join(' ') + '[name="member-city"]').clear().type(listingCity);
cy.get(filtersQuery.join(' ') + '[name="member-city"]').should('have.value', listingCity);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the city filter', () => {
cy.get(filtersQuery.join(' ') + '[name="member-city"]').clear();
cy.get(filtersQuery.join(' ') + '[name="member-city"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
});
});

View File

@ -0,0 +1,63 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Retire Channel Browser Testing', () => {
let menuQuery = [
'solid-display.circle-tab',
'solid-display:last-child',
'solid-display[order-by="name"]'
],
menuCountQuery = [
'solid-display.circle-tab',
'solid-display',
'solid-display[order-by="name"]'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screend', () => cy.userLogin());
it('should login', () => cy.login());
describe('Channel Retirement process', () => {
let channelsLength;
it('should visit the channels list screen', () => {
cy.visit('/admin');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin');
});
});
it('should visit the last channel edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/circle/@' + id + '/circle-information/circle-edit');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information/circle-edit');
});
}));
});
it('should count the number of joined channels', () => {
cy.get(menuCountQuery.join(' ')).its('length').then(length => channelsLength = length);
});
it('should click button to retire the channel', () => {
cy.get('solid-multiple[name="members"] solid-delete[data-label="Retirer"] button').click();
});
it('should stay on channel edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information/circle-edit');
});
}));
});
it('should check if chennel was retired', () => {
cy.get(menuCountQuery.join(' ')).its('length').should(length => {
expect(length).to.eq(channelsLength - 1);
});
});
});
});

View File

@ -0,0 +1,63 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Retire Project Browser Testing', () => {
let menuQuery = [
'solid-display.project-tab',
'solid-display:last-child',
'solid-display[order-by="customer.name"]'
],
menuCountQuery = [
'solid-display.project-tab',
'solid-display',
'solid-display[order-by="customer.name"]'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screend', () => cy.userLogin());
it('should login', () => cy.login());
describe('Project Retirement process', () => {
let projectsLength;
it('should visit the projects list screen', () => {
cy.visit('/admin/admin-projects');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin/admin-projects');
});
});
it('should visit the last project edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/project/@' + id + '/project-information/project-edit');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/project/@' + id + '/project-information/project-edit');
});
}));
});
it('should count the number of joined projects', () => {
cy.get(menuCountQuery.join(' ')).its('length').then(length => projectsLength = length);
});
it('should click button to retire the project', () => {
cy.get('solid-multiple[name="members"] solid-delete[data-label="Retirer"] button').click();
});
it('should stay on project edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/project/@' + id + '/project-information/project-edit');
});
}));
});
it('should check if project was retired', () => {
cy.get(menuCountQuery.join(' ')).its('length').should(length => {
expect(length).to.eq(projectsLength - 1);
});
});
});
});

View File

@ -1,19 +1,13 @@
/// <reference types="Cypress" />
/* globals cy, expect */
context('Browser testing', () => {
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null});
cy.clearCookies({ domain: null });
});
it('visit the homepage', () => {
cy.visit('/');
});
it('should await for an user login', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/auth/login/');
});
});
it('should visit user login screen', () => cy.userLogin());
describe('Login process', () => {
it('should write "admin" on username field and "password" on password field', () => {
cy.get('#id_username').type('admin');
@ -25,7 +19,7 @@ context('Browser testing', () => {
cy.get(':nth-child(1) > .flex-column > [type="submit"]').click();
});
it('should provide an error, username and password mismatch.', () => {
cy.get('.error').should('contain.text', 'Ton nom d\'utilisateur et ton mot de passe ne correspondent pas. Réessaye.')
cy.get('.error').should('contain.text', 'Ton nom d\'utilisateur et ton mot de passe ne correspondent pas. Réessaye.');
});
it('should write "admin" on password field then press the login button', () => {
cy.get('#id_password').type('admin');
@ -34,7 +28,7 @@ context('Browser testing', () => {
});
it('should ask for user permission to access their datas.', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/authorize')
expect(loc.pathname).to.eq('/authorize');
});
cy.get('.accept-button').click();
});
@ -104,5 +98,4 @@ context('Browser testing', () => {
// });
// });
});
});
});

View File

@ -0,0 +1,61 @@
/// <reference types="Cypress" />
/* globals cy */
context('Signup Browser Testing', () => {
let username = 'testuser_creation_',
email = '',
password = 'testpwd';
before(() => {
cy.randomNum().then(num => {
username += num;
email = username + '@testemail.com';
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
it('should visit user login screen', () => cy.userLogin());
describe('Signup process', () => {
it('should click on signup page link', () => {
cy.get('.sib-link.sib-register-link').click();
});
it('should write incorrect user data', () => {
cy.get('#id_username').type('!"#$%&');
cy.get('#id_username').should('have.value', '!"#$%&');
cy.get('#id_email').type(email.split('.')[0]);
cy.get('#id_email').should('have.value', email.split('.')[0]);
cy.get('#id_password1').type(password + 'wrong1');
cy.get('#id_password1').should('have.value', password + 'wrong1');
cy.get('#id_password2').type(password + 'wrong2');
cy.get('#id_password2').should('have.value', password + 'wrong2');
});
it('should click on signup button', () => {
cy.get('.sib-registration-btn').click();
});
it('should provide errors about incorrect user data', () => {
cy.get('tbody tr:nth-child(1) ul.errorlist li')
.should('contain.text', 'Enter a valid username. This value may contain only letters, numbers, and ./+/-/_ characters.');
cy.get('tbody tr:nth-child(2) ul.errorlist li')
.should('contain.text', 'Enter a valid email address.');
cy.get('tbody tr:nth-child(4) ul.errorlist li')
.should('contain.text', 'The two password fields didn\'t match.');
});
it('should write correct user data', () => {
cy.get('#id_username').clear().type(username);
cy.get('#id_username').should('have.value', username);
cy.get('#id_email').clear().type(email);
cy.get('#id_email').should('have.value', email);
cy.get('#id_password1').clear().type(password);
cy.get('#id_password1').should('have.value', password);
cy.get('#id_password2').clear().type(password);
cy.get('#id_password2').should('have.value', password);
});
it('should click on signup button', () => {
cy.get('.sib-registration-btn').click();
});
it('should show email confirmation dialog', () => {
cy.contains('h1.text-center', 'Un e-mail d\'activation a été envoyé.').should("exist");
cy.contains('p.text-center', 'Vérifie ta boite mail et clique sur le lien pour activer ton compte.').should("exist");
});
});
});

View File

@ -23,3 +23,50 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
/* 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);
cy.get('#id_username').should('have.value', admin.username);
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(location => {
expect(location.pathname).to.eq('/');
});
});
});
Cypress.Commands.add('userLogin', () => {
cy.visit('/');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/auth/login/');
});
});
Cypress.Commands.add('encodeUrl', url => {
const encodeIdReplacement = [
['~', '~~'],
['.', '~!'],
[':', '~@'],
['/', '~_'],
];
encodeIdReplacement.forEach(([char, repl]) => {
url = url.split(char).join(repl);
});
return url;
});
Cypress.Commands.add('randomNum', () => {
return Math.floor(1000 + Math.random() * 9000);
});
Cypress.Commands.add('nextYear', increment => {
return new Date().getFullYear() + ( increment || 1 );
});

View File

@ -13,8 +13,10 @@
// https://on.cypress.io/configuration
// ***********************************************************
/* globals Cypress */
// Import commands.js using ES2015 syntax:
import './commands'
import './commands';
//require('cypress-terminal-report').installSupport();
@ -27,4 +29,9 @@ Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});
Cypress.on('fail', () => Cypress.runner.abort())
Cypress.on('fail', (error) => {
console.log(error);
if ( typeof Cypress.runner.abort == 'function' ) {
Cypress.runner.abort();
}
});

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"
}
}