diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbb9c8a1ba160b833d16c404b3342b0155014e4f..704c6db2afa86bbc24fc04cb966dad2963ffaf4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/cypress.json b/cypress.json index 2f9683b2c96c0bdb6da413e97ffca14f8f30a325..eaf20811489fa4bc0a026afa591cbc924a1303b0 100644 --- a/cypress.json +++ b/cypress.json @@ -1,7 +1,8 @@ { "baseUrl": "http://127.0.0.1:3000", - "defaultCommandTimeout": 60000, + "defaultCommandTimeout": 1000, "chromeWebSecurity": false, "viewportWidth": 1920, - "viewportHeight": 1080 + "viewportHeight": 1080, + "video": false } diff --git a/cypress/README.md b/cypress/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3081ad79af88bc4cace65dae79506e36e7ac443f --- /dev/null +++ b/cypress/README.md @@ -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 +``` diff --git a/cypress/fixtures/admin.json b/cypress/fixtures/admin.json new file mode 100644 index 0000000000000000000000000000000000000000..fb25ded15af10c288a0fb2faa82f35905243c2bd --- /dev/null +++ b/cypress/fixtures/admin.json @@ -0,0 +1,4 @@ +{ + "username": "admin", + "password": "admin" +} \ No newline at end of file diff --git a/cypress/integration/create-channel.spec.js b/cypress/integration/create-channel.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..b28c0f12555feb78a0865a0eb447955ef084530f --- /dev/null +++ b/cypress/integration/create-channel.spec.js @@ -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"); + }); + }); + }); +}); diff --git a/cypress/integration/create-job-offer.spec.js b/cypress/integration/create-job-offer.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..ad960d442b3a123b40b5da0e0a287e4cdb497a8c --- /dev/null +++ b/cypress/integration/create-job-offer.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/integration/create-project.spec.js b/cypress/integration/create-project.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..8775a1ec6ff88cd968fcba831e1c81cd6c8d36d9 --- /dev/null +++ b/cypress/integration/create-project.spec.js @@ -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"); + }); + }); + }); +}); diff --git a/cypress/integration/create-user.spec.js b/cypress/integration/create-user.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..8cf9ee94f08d53fddcf66eb8831cf9d4ad342ceb --- /dev/null +++ b/cypress/integration/create-user.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/integration/delete-channel.spec.js b/cypress/integration/delete-channel.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..ac978616cb2cb3dad896b09bc6b95da10b927c59 --- /dev/null +++ b/cypress/integration/delete-channel.spec.js @@ -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); + }); + }); + }); +}); diff --git a/cypress/integration/edit-channel.spec.js b/cypress/integration/edit-channel.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..b1a82276d4235d2a75f440af45dbe4f95afb4ce3 --- /dev/null +++ b/cypress/integration/edit-channel.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/integration/edit-job-offer.spec.js b/cypress/integration/edit-job-offer.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..0ce7690fe9e46e06348d643c7b81702068ba692a --- /dev/null +++ b/cypress/integration/edit-job-offer.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/integration/edit-project.spec.js b/cypress/integration/edit-project.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..f3d7c543bbbf336e6af765f1a95d6962e9e81344 --- /dev/null +++ b/cypress/integration/edit-project.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/integration/edit-user.spec.js b/cypress/integration/edit-user.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..5bc2923b0003b7dd5d69e36cd2b8694a095e59f7 --- /dev/null +++ b/cypress/integration/edit-user.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/integration/leave-channel.spec.js b/cypress/integration/leave-channel.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..3b762c3e431225d1fd1d757975aad9b7facb6d6d --- /dev/null +++ b/cypress/integration/leave-channel.spec.js @@ -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); + }); + }); + }); +}); diff --git a/cypress/integration/leave-project.spec.js b/cypress/integration/leave-project.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..886d3a2790e6d740bdce4318be106826997f871e --- /dev/null +++ b/cypress/integration/leave-project.spec.js @@ -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); + }); + }); + }); +}); diff --git a/cypress/integration/list-job-offers.spec.js b/cypress/integration/list-job-offers.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..8def06bdf90ee8fcb8970b59cfb236aa78385d59 --- /dev/null +++ b/cypress/integration/list-job-offers.spec.js @@ -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); + }); + });*/ + }); +}); diff --git a/cypress/integration/list-users.spec.js b/cypress/integration/list-users.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..ddd848e42eeac51b4787dd27d3616560db32a822 --- /dev/null +++ b/cypress/integration/list-users.spec.js @@ -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); + }); + }); + }); +}); diff --git a/cypress/integration/retire-channel.spec.js b/cypress/integration/retire-channel.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..6ae42d29f073a2ae188928e829653a46dcf08960 --- /dev/null +++ b/cypress/integration/retire-channel.spec.js @@ -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); + }); + }); + }); +}); diff --git a/cypress/integration/retire-project.spec.js b/cypress/integration/retire-project.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..b54b90d6f1ec4a0e9777e57ebff54e8289837531 --- /dev/null +++ b/cypress/integration/retire-project.spec.js @@ -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); + }); + }); + }); +}); diff --git a/cypress/integration/tests.spec.js b/cypress/integration/signin.spec.js similarity index 70% rename from cypress/integration/tests.spec.js rename to cypress/integration/signin.spec.js index ba535717ac5d283266803d6c6d28426281a0366e..53457ed0ce9ca7a3978492707ead9a0c307c9807 100644 --- a/cypress/integration/tests.spec.js +++ b/cypress/integration/signin.spec.js @@ -1,43 +1,37 @@ /// <reference types="Cypress" /> - +/* globals cy, expect */ context('Browser testing', () => { - before(() => { - cy.clearLocalStorage({ domain: null}); - cy.clearCookies({ domain: null }); + before(() => { + cy.clearLocalStorageSnapshot(); + cy.clearLocalStorage({ domain: null}); + cy.clearCookies({ domain: null }); + }); + 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'); + cy.get('#id_username').should('have.value', 'admin'); + cy.get('#id_password').type('password'); + cy.get('#id_password').should('have.value', 'password'); + }); + it('should click on login button', () => { + cy.get(':nth-child(1) > .flex-column > [type="submit"]').click(); }); - it('visit the homepage', () => { - cy.visit('/'); + 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.'); }); - it('should await for an user login', () => { + it('should write "admin" on password field then press the login button', () => { + cy.get('#id_password').type('admin'); + cy.get('#id_password').should('have.value', 'admin'); + cy.get(':nth-child(1) > .flex-column > [type="submit"]').click(); + }); + it('should ask for user permission to access their datas.', () => { cy.location().should((loc) => { - expect(loc.pathname).to.eq('/auth/login/'); + expect(loc.pathname).to.eq('/authorize'); }); + cy.get('.accept-button').click(); }); - describe('Login process', () => { - it('should write "admin" on username field and "password" on password field', () => { - cy.get('#id_username').type('admin'); - cy.get('#id_username').should('have.value', 'admin'); - cy.get('#id_password').type('password'); - cy.get('#id_password').should('have.value', 'password'); - }); - it('should click on login button', () => { - 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.') - }); - it('should write "admin" on password field then press the login button', () => { - cy.get('#id_password').type('admin'); - cy.get('#id_password').should('have.value', 'admin'); - cy.get(':nth-child(1) > .flex-column > [type="submit"]').click(); - }); - it('should ask for user permission to access their datas.', () => { - cy.location().should((loc) => { - expect(loc.pathname).to.eq('/authorize') - }); - cy.get('.accept-button').click(); - }); // it('should redirect the user to the app.', () => { // cy.get('.accept-button').click(); // cy.location().should((loc) => { @@ -103,6 +97,5 @@ context('Browser testing', () => { // expect(loc.pathname).to.eq('/auth/login/'); // }); // }); - }); }); - +}); diff --git a/cypress/integration/signup.spec.js b/cypress/integration/signup.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..05ee1b811b7fc610b9db3822e0bbc0103665ecd9 --- /dev/null +++ b/cypress/integration/signup.spec.js @@ -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"); + }); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index ca4d256f3eb15dfabad1f5760c9b2d0ceb4c24b9..cff385857f2ec5f3e9fa6f3010fec45247d4003b 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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 ); +}); diff --git a/cypress/support/index.js b/cypress/support/index.js index 92fa6f5a3311e92658fd4a5fe063d8fc780e03e6..c1a0001e9ca04371ea2e5b69dd98907d09819132 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -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(); + } +}); diff --git a/package-lock.json b/package-lock.json index f19ba147dfc6cd1b8f43611f0ef96e49e8720ed3..5c89a88267c1a6af70091b39fd1262f5d9c2e73b 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 59aa0ac3e7640764c72626b4f729a196efce2c83..5de4183fc080522a0fbb9f222107e2a7b0374dac 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" } } diff --git a/src/menu-left.pug b/src/menu-left.pug index 6538c0988c630a3b26fc3585f76b9061945fb80d..3180ce7da310a7cad44953cdc0cb2858ae2b6f23 100644 --- a/src/menu-left.pug +++ b/src/menu-left.pug @@ -71,10 +71,12 @@ solid-router#navbar-router(default-route='dashboard') div.divider if endpoints.projects || (endpoints.get && endpoints.get.projects) div - solid-link(next='admin-project-list') + solid-link + //- (next='admin-project-list') div.menu div.menu-chevron - div.menu-icon.icon-arrow-right-circle + div.menu-icon + //- div.menu-icon.icon-arrow-right-circle div.menu-label Projets div.menu-icon.icon-folder-alt solid-route(name='project', rdf-type='hd:project', use-id='', hidden) @@ -98,10 +100,12 @@ solid-router#navbar-router(default-route='dashboard') div.divider if endpoints.circles || (endpoints.get && endpoints.get.circles) div - solid-link(next='admin-circle-list') + solid-link + //- (next='admin-circle-list') div.menu div.menu-chevron - div.menu-icon.icon-arrow-right-circle + div.menu-icon + //- div.menu-icon.icon-arrow-right-circle div.menu-label Cercles div.menu-icon.icon-folder-alt solid-route(name='circle', rdf-type='hd:circle', use-id='', hidden) diff --git a/src/scripts/menu-toggle.js b/src/scripts/menu-toggle.js new file mode 100644 index 0000000000000000000000000000000000000000..8f966706a8d181dc68770deab3bb1db5431c6e43 --- /dev/null +++ b/src/scripts/menu-toggle.js @@ -0,0 +1,11 @@ +document.addEventListener("DOMContentLoaded", () => { + const menuWrappers = Array.from(document.querySelectorAll(".menu-wrapper")); + + //- Toggle sub-menus + menuWrappers.forEach(menuWrapper => { + const menu = menuWrapper.querySelector(".menu"); + menu.addEventListener("click", e => { + menuWrapper.classList.toggle("is-closed"); + }); + }); +}); \ No newline at end of file diff --git a/src/scripts/unreads-menu.js b/src/scripts/unreads-menu.js index bd6abc71383b88332f392d0906a14340a78e86fa..ae5dc2ca00cc398bea10d6767da96c7075ff649a 100644 --- a/src/scripts/unreads-menu.js +++ b/src/scripts/unreads-menu.js @@ -1,7 +1,7 @@ document.addEventListener("DOMContentLoaded", function (event) { window.addEventListener('newMessage', event => { let jid = event.detail.jid; - Array.from(document.querySelectorAll('[data-jabberID="'+jid+'"]')).forEach(el => { + Array.from(document.querySelectorAll('[data-jabberID="' + jid + '"]')).forEach(el => { el.parentElement.parentElement.classList.add('unread'); }); }); @@ -9,7 +9,12 @@ document.addEventListener("DOMContentLoaded", function (event) { window.addEventListener('read', (event) => { if (event.detail && event.detail.resource && event.detail.resource['@id']) { const badge = document.querySelector(`solid-badge[data-src="${event.detail.resource['@id']}"]`); - if (badge) badge.parentElement.parentElement.classList.remove('unread'); + if (badge) { + badge.parentElement.parentElement.classList.remove('unread'); + const project = badge.parentElement.parentElement.querySelector('.unread'); + if (project) project.classList.remove('unread'); + } + } }); }); \ No newline at end of file diff --git a/src/styles/base/main.scss b/src/styles/base/main.scss index 6a74e9b130823e3cc43c845faa3433da11751969..8daeb97f25e5986cfd155b3885c499b79bdff9ba 100644 --- a/src/styles/base/main.scss +++ b/src/styles/base/main.scss @@ -61,7 +61,7 @@ solid-dashboard section { position: sticky; top: 0; overflow-x: hidden; - overflow-y: auto; + overflow-y: scroll; } &.jsLeftMenu { diff --git a/src/styles/base/menu-left.scss b/src/styles/base/menu-left.scss index a018b5d7b07a2d97d58200d556a753e91a2e546f..6996fb63fdc7879dfa753567ae623da8de4abd24 100644 --- a/src/styles/base/menu-left.scss +++ b/src/styles/base/menu-left.scss @@ -13,13 +13,21 @@ solid-router { .menu-wrapper { - &.is-closed { - .sub-menu { - display: none; + .menu-icon.icon-arrow-up { + visibility: hidden; + } + @include breakpoint(lg) { + .menu-icon.icon-arrow-up { + visibility: visible; } + &.is-closed { + .sub-menu { + display: none; + } - .menu-chevron { - transform: rotate(180deg); + .menu-chevron { + transform: rotate(180deg); + } } } } diff --git a/src/styles/base/user-thumb.scss b/src/styles/base/user-thumb.scss index 394e5e7d440d00457aba150ee65ff7495074caf8..c29e8d8097632b0d95d79a147605d25483019383 100644 --- a/src/styles/base/user-thumb.scss +++ b/src/styles/base/user-thumb.scss @@ -38,6 +38,21 @@ text-align: left; } +.user-thumb__send { + position: relative; + bottom: 7px; + left: -5px; + + solid-link { + @include icon('speech'); + + &::before { + display: inline-block; + color: #FF6765; + } + } +} + .user-thumb__admin:not(:empty) { display: block !important; @extend %tag-admin;