From c548add2360a1fe1c218b33871ad73583b82fa57 Mon Sep 17 00:00:00 2001 From: Jure Ursic Date: Thu, 16 Jul 2020 15:50:16 +0200 Subject: [PATCH] update: wrapping up and final adjustments to completed test flows --- cypress/README.md | 54 +++++++++ cypress/integration/create-channel.spec.js | 88 ++++++++++---- cypress/integration/create-job-offer.spec.js | 18 +-- cypress/integration/create-project.spec.js | 73 +++++++----- cypress/integration/create-user.spec.js | 20 +--- cypress/integration/delete-channel.spec.js | 55 +++++++++ cypress/integration/edit-channel.spec.js | 2 +- cypress/integration/edit-job-offer.spec.js | 6 +- cypress/integration/edit-project.spec.js | 2 +- cypress/integration/edit-user.spec.js | 68 +++++++++++ cypress/integration/leave-channel.spec.js | 37 ++++++ cypress/integration/leave-project.spec.js | 17 +-- cypress/integration/list-job-offers.spec.js | 79 ++++++++++++ cypress/integration/list-users.spec.js | 119 +++++++++++++++++++ cypress/integration/retire-channel.spec.js | 55 +++++++++ cypress/integration/retire-project.spec.js | 28 +++-- 16 files changed, 607 insertions(+), 114 deletions(-) create mode 100644 cypress/README.md create mode 100644 cypress/integration/delete-channel.spec.js create mode 100644 cypress/integration/edit-user.spec.js create mode 100644 cypress/integration/leave-channel.spec.js create mode 100644 cypress/integration/list-job-offers.spec.js create mode 100644 cypress/integration/list-users.spec.js create mode 100644 cypress/integration/retire-channel.spec.js diff --git a/cypress/README.md b/cypress/README.md new file mode 100644 index 0000000..3081ad7 --- /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/integration/create-channel.spec.js b/cypress/integration/create-channel.spec.js index 7dda64b..54d2d8a 100644 --- a/cypress/integration/create-channel.spec.js +++ b/cypress/integration/create-channel.spec.js @@ -2,13 +2,7 @@ /* globals cy, expect */ context('Create Channel Browser Testing', () => { - let channelName = 'Test Channel ', - description = 'Test Description '; before(() => { - cy.randomNum().then(num => { - channelName += num; - description += num; - }); cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); @@ -16,28 +10,78 @@ context('Create Channel Browser Testing', () => { beforeEach(() => cy.restoreLocalStorage()); afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); - describe('Channel Creation process', () => { - it('should login', () => cy.login()); + 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.naviagte('/admin/admin-circle-create')); - /*it('should enter incorrect channel data', () => { - cy.get('#admin-circle-create input[name="name"]').type('!"#$%&'); - cy.get('#admin-circle-create input[name="name"]').should('have.value', '!"#$%&'); - cy.get('#admin-circle-create input[name="description"]').type(description); - cy.get('#admin-circle-create input[name="description"]').should('have.value', description); + 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 provide errors about incorrect channel data', () => { - // TO-DO: Check for error messages - cy.get('element') - .should('contain.text', 'Error message.'); - });*/ + 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.naviagte('/admin/admin-circle-create')); it('should enter correct channel data', () => { - 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); + 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.naviagte('/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(); diff --git a/cypress/integration/create-job-offer.spec.js b/cypress/integration/create-job-offer.spec.js index b4d6d43..0940eaa 100644 --- a/cypress/integration/create-job-offer.spec.js +++ b/cypress/integration/create-job-offer.spec.js @@ -20,25 +20,9 @@ context('Create Job Offer Browser Testing', () => { 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 login', () => cy.login()); it('should visit the job offer creation screen', () => cy.naviagte('/job-offers/job-offers-create')); - /*it('should enter incorrect job offer data', () => { - cy.get('#job-offers-create input[name="closingDate"]').type('!"#$%&'); - cy.get('#job-offers-create input[name="closingDate"]').should('have.value', '!"#$%&'); - cy.get('#job-offers-create input[name="title"]').type('!"#$%&'); - cy.get('#job-offers-create input[name="title"]').should('have.value', '!"#$%&'); - cy.get('#job-offers-create textarea[name="description"]').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 provide errors about incorrect job offer data', () => { - // TO-DO: Check for error messages - cy.get('element') - .should('contain.text', 'Error message.'); - });*/ 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); diff --git a/cypress/integration/create-project.spec.js b/cypress/integration/create-project.spec.js index 9322c21..ba198c7 100644 --- a/cypress/integration/create-project.spec.js +++ b/cypress/integration/create-project.spec.js @@ -2,15 +2,7 @@ /* globals cy, expect */ context('Create Project Browser Testing', () => { - let projectName = 'Test Project ', - customerName = 'Test Customer ', - description = 'Test Description '; before(() => { - cy.randomNum().then(num => { - projectName += num; - customerName += num; - description += num; - }); cy.clearLocalStorageSnapshot(); cy.clearLocalStorage({ domain: null }); cy.clearCookies({ domain: null }); @@ -18,32 +10,57 @@ context('Create Project Browser Testing', () => { beforeEach(() => cy.restoreLocalStorage()); afterEach(() => cy.saveLocalStorage()); it('should visit user login screen', () => cy.userLogin()); - describe('Project Creation process', () => { - it('should login', () => cy.login()); + 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.naviagte('/admin/admin-projects/admin-project-create')); - /*it('should enter incorrect project data', () => { - cy.get('#admin-project-create input[name="customer.name"]').type('!"#$%&'); - cy.get('#admin-project-create input[name="customer.name"]').should('have.value', '!"#$%&'); - cy.get('#admin-project-create input[name="name"]').type('!"#$%&'); - cy.get('#admin-project-create input[name="name"]').should('have.value', '!"#$%&'); - cy.get('#admin-project-create textarea[name="description"]').type(description); - cy.get('#admin-project-create textarea[name="description"]').should('have.value', description); + 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 provide errors about incorrect project data', () => { - // TO-DO: Check for error messages - cy.get('element') - .should('contain.text', 'Error message.'); - });*/ + 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.naviagte('/admin/admin-projects/admin-project-create')); it('should enter correct project data', () => { - 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); + 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(); diff --git a/cypress/integration/create-user.spec.js b/cypress/integration/create-user.spec.js index 1abd7a1..f3fe42c 100644 --- a/cypress/integration/create-user.spec.js +++ b/cypress/integration/create-user.spec.js @@ -20,27 +20,9 @@ context('Create User Browser Testing', () => { 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 login', () => cy.login()); it('should visit the user creation screen', () => cy.naviagte('/admin/admin-users/admin-users-create')); - /*it('should enter incorrect user data', () => { - cy.get('#admin-users-create input[name="first_name"]').type(firstName); - cy.get('#admin-users-create input[name="first_name"]').should('have.value', firstName); - cy.get('#admin-users-create input[name="last_name"]').type(lastName); - cy.get('#admin-users-create input[name="last_name"]').should('have.value', lastName); - cy.get('#admin-users-create input[name="username"]').type('!"#$%&'); - cy.get('#admin-users-create input[name="username"]').should('have.value', '!"#$%&'); - cy.get('#admin-users-create input[name="email"]').type(email.split('.')[0]); - cy.get('#admin-users-create input[name="email"]').should('have.value', email.split('.')[0]); - }); - it('should click on create user button', () => { - cy.get('#admin-users-create input[type="submit"]').click(); - }); - it('should provide errors about incorrect user data', () => { - // TO-DO: Check for error messages - cy.get('element') - .should('contain.text', 'Error message.'); - });*/ 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); diff --git a/cypress/integration/delete-channel.spec.js b/cypress/integration/delete-channel.spec.js new file mode 100644 index 0000000..e022546 --- /dev/null +++ b/cypress/integration/delete-channel.spec.js @@ -0,0 +1,55 @@ +/// +/* 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.naviagte('/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.naviagte('/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 index ea53551..f0baa3b 100644 --- a/cypress/integration/edit-channel.spec.js +++ b/cypress/integration/edit-channel.spec.js @@ -21,8 +21,8 @@ context('Edit Channel Browser Testing', () => { 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 login', () => cy.login()); it('should visit the channel list screen', () => cy.naviagte('/admin')); it('should visit the last channel edit screen', () => { cy.get(menuQuery.join(' ')) diff --git a/cypress/integration/edit-job-offer.spec.js b/cypress/integration/edit-job-offer.spec.js index 53d6dca..16c0f99 100644 --- a/cypress/integration/edit-job-offer.spec.js +++ b/cypress/integration/edit-job-offer.spec.js @@ -24,10 +24,10 @@ context('Edit Job Offer Browser Testing', () => { 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 login', () => cy.login()); it('should visit the job offers list screen', () => cy.naviagte('/job-offers')); - it('should visit the last project edit screen', () => { + it('should visit the last job offer edit screen', () => { cy.get(menuQuery.join(' ')) .invoke('attr', 'data-src') .then(url => cy.encodeUrl(url).then(id => { @@ -50,7 +50,7 @@ context('Edit Job Offer Browser Testing', () => { expect(loc.pathname).to.eq('/job-offers'); }); }); - it('should show edited project data on project information screen', () => { + 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 index 42e1386..766c252 100644 --- a/cypress/integration/edit-project.spec.js +++ b/cypress/integration/edit-project.spec.js @@ -23,8 +23,8 @@ context('Edit Project Browser Testing', () => { 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 login', () => cy.login()); it('should visit the project list screen', () => cy.naviagte('/admin/admin-projects')); it('should visit the last project edit screen', () => { cy.get(menuQuery.join(' ')) diff --git a/cypress/integration/edit-user.spec.js b/cypress/integration/edit-user.spec.js new file mode 100644 index 0000000..ac29f41 --- /dev/null +++ b/cypress/integration/edit-user.spec.js @@ -0,0 +1,68 @@ +/// +/* 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.naviagte('/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 0000000..638eb58 --- /dev/null +++ b/cypress/integration/leave-channel.spec.js @@ -0,0 +1,37 @@ +/// +/* 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.naviagte('/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 index 0ceef4c..8c623fe 100644 --- a/cypress/integration/leave-project.spec.js +++ b/cypress/integration/leave-project.spec.js @@ -21,30 +21,17 @@ context('Leave Project Browser Testing', () => { 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 login', () => cy.login()); it('should visit the projects list screen', () => cy.naviagte('/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', () => { + it('should check if project was left', () => { cy.get(tableListQuery.join(' ')).its('length').should(length => { expect(length).to.eq(this.projectsLength - 1); }); }); - /*it('should click button to retire the project', () => { - cy.scrollTo('bottom'); - cy.get('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'); - }); - })); - });*/ }); }); diff --git a/cypress/integration/list-job-offers.spec.js b/cypress/integration/list-job-offers.spec.js new file mode 100644 index 0000000..badf05d --- /dev/null +++ b/cypress/integration/list-job-offers.spec.js @@ -0,0 +1,79 @@ +/// +/* 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.naviagte('/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 0000000..9db3595 --- /dev/null +++ b/cypress/integration/list-users.spec.js @@ -0,0 +1,119 @@ +/// +/* 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.naviagte('/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 0000000..6f0a659 --- /dev/null +++ b/cypress/integration/retire-channel.spec.js @@ -0,0 +1,55 @@ +/// +/* 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.naviagte('/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.naviagte('/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 index 71d23b6..a660395 100644 --- a/cypress/integration/retire-project.spec.js +++ b/cypress/integration/retire-project.spec.js @@ -3,10 +3,15 @@ context('Retire Project Browser Testing', () => { let menuQuery = [ - 'solid-display.project-tab', - 'solid-display:last-child', - 'solid-display[order-by="customer.name"]' - ]; + '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 }); @@ -15,8 +20,9 @@ context('Retire Project Browser Testing', () => { beforeEach(() => cy.restoreLocalStorage()); afterEach(() => cy.saveLocalStorage()); it('should visit user login screend', () => cy.userLogin()); + it('should login', () => cy.login()); describe('Project Retirement process', () => { - it('should login', () => cy.login()); + let projectsLength; it('should visit the projects list screen', () => cy.naviagte('/admin/admin-projects')); it('should visit the last project edit screen', () => { cy.get(menuQuery.join(' ')) @@ -25,9 +31,11 @@ context('Retire Project Browser Testing', () => { cy.naviagte('/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.scrollTo('bottom'); - cy.get('solid-delete[data-label="Retirer"] button').click(); + cy.get('solid-multiple[name="members"] solid-delete[data-label="Retirer"] button').click(); }); it('should stay on project edit screen', () => { cy.get(menuQuery.join(' ')) @@ -38,6 +46,10 @@ context('Retire Project Browser Testing', () => { }); })); }); - // TO-DO: clearify what needs to happen after and do the checks + it('should check if project was retired', () => { + cy.get(menuCountQuery.join(' ')).its('length').should(length => { + expect(length).to.eq(projectsLength - 1); + }); + }); }); });