From 38146191715b12b5ffb4fd94d5eed2052c7508e9 Mon Sep 17 00:00:00 2001 From: faria-ejaz Date: Mon, 1 Oct 2018 17:52:46 +0500 Subject: [PATCH 1/7] [test] filtersOrganisation --- .../integration/event-manager/filters_spec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 client/cypress/integration/event-manager/filters_spec.js diff --git a/client/cypress/integration/event-manager/filters_spec.js b/client/cypress/integration/event-manager/filters_spec.js new file mode 100644 index 0000000..eee0075 --- /dev/null +++ b/client/cypress/integration/event-manager/filters_spec.js @@ -0,0 +1,20 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +describe('Filters Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + context('Test for Organization Filters', () => { + it('should have an arrow button', () => { + cy.get('div .Select #react-select-2--value').click() + }); + }); +}); From f055909845c5c35a1b60f5a95a1cac6faf0760c7 Mon Sep 17 00:00:00 2001 From: faria-ejaz Date: Tue, 2 Oct 2018 17:32:02 +0500 Subject: [PATCH 2/7] [test] Oraganisation filter --- .../integration/event-manager/filters_spec.js | 47 ++++++++++++++++++- client/package.json | 3 +- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/client/cypress/integration/event-manager/filters_spec.js b/client/cypress/integration/event-manager/filters_spec.js index eee0075..09fc0a4 100644 --- a/client/cypress/integration/event-manager/filters_spec.js +++ b/client/cypress/integration/event-manager/filters_spec.js @@ -14,7 +14,50 @@ describe('Filters Testing', () => { }); context('Test for Organization Filters', () => { it('should have an arrow button', () => { - cy.get('div .Select #react-select-2--value').click() - }); + cy.get( + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', + { timeout: 30000 } + ) //Gets the location of the Organisation field with a delay of 30000 + .eq(0); + // .click(); //Clicks the toggle button + }); + + it('should select one option', () => { + cy.get( + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', + { timeout: 30000 } //gets the location with a delay of 30000 + ) + .eq(0) + .click(); + cy.contains('NES').click(); //Selects the dropdown menu option + }); + + it('should deselect option', () => { + cy.get(':nth-child(1)>.Select-value-icon').click(); //Deselects one of the option + }); + + it('should select multiple options', () => { + cy.get( + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', + { timeout: 30000 } //gets the location with a delay of 30000 + ) + .eq(0) + .click(); + cy.contains('NES').click(); //Selects the dropdown menu option + cy.get( + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', + { timeout: 30000 } //gets the location with a delay of 30000 + ) + .eq(0) + .click(); + cy.contains('Recurship').click(); //Selects the dropdown menu option + }); + + it('should deselect all the options', () => { + cy.get(':nth-child(1)>.Select-value-icon').click(); //Deselects one of the option + cy.get('.Select-value-icon').click(); //Deselects both + }); + + // cy.get('form .btn').click(); }); }); diff --git a/client/package.json b/client/package.json index d15a733..68ca795 100644 --- a/client/package.json +++ b/client/package.json @@ -40,7 +40,8 @@ "build-storybook": "build-storybook -s public", "commit": "git-cz", "precommit": "lint-staged", - "e2e": "cypress open" + "e2e": "cypress open", + "cypress": "cypress run" }, "lint-staged": { "src/**/*.{js,json,css,jsx}": [ From 7a6790c48bf46a06caad0b983f7c7e9178189878 Mon Sep 17 00:00:00 2001 From: faria-ejaz Date: Wed, 3 Oct 2018 17:15:22 +0500 Subject: [PATCH 3/7] [feat] more filters test cases added --- .../integration/event-manager/filters_spec.js | 244 ++++++++++++++++-- client/src/containers/Root/Root.dev.js | 2 +- 2 files changed, 217 insertions(+), 29 deletions(-) diff --git a/client/cypress/integration/event-manager/filters_spec.js b/client/cypress/integration/event-manager/filters_spec.js index 09fc0a4..71976fb 100644 --- a/client/cypress/integration/event-manager/filters_spec.js +++ b/client/cypress/integration/event-manager/filters_spec.js @@ -5,6 +5,20 @@ /* global cy */ /* eslint no-undef: "error" */ +const delay = 30000; +const org = + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const loc = + ':nth-child(4) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const spons = + ':nth-child(5) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const tag = + ':nth-child(6) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const time = + ':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const kw= + ':nth-child(8) > .form-control'; + describe('Filters Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { @@ -12,52 +26,226 @@ describe('Filters Testing', () => { cy.get('h3').should('contain', 'Welcome to Event Management'); }); }); - context('Test for Organization Filters', () => { - it('should have an arrow button', () => { - cy.get( - ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', - { timeout: 30000 } - ) //Gets the location of the Organisation field with a delay of 30000 - .eq(0); - // .click(); //Clicks the toggle button + + context('Test for Organization Filter', () => { + it('should have a clickable arrow button', () => { + cy.get(org, { timeout: delay }) + .eq(0) + .dblclick(); //Clicks the toggle button + // cy.get('div .Select').should('have.attr', 'is-open'); + }); + + it('should have one item', () => { + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('NES').click(); + cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); + }); + + it('should deselect item', () => { + cy.get(':nth-child(1)>.Select-value-icon').click(); + }); + + it('should have multiple items', () => { + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('NES').click(); + cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); + + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Recurship').click(); + cy.get('.Select-value #react-select-2--value-1').should( + 'contain', + 'Recurship' + ); }); - it('should select one option', () => { + it('should cancel all the items at once', () => { cy.get( - ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', - { timeout: 30000 } //gets the location with a delay of 30000 - ) + ':nth-child(1)> .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + // cy.get('form .btn').click(); + }); + + //BUGS FOUND + //no validation on the YYYY [year] beacuse it's accepting more than 4 digits + //event END date should not be less than the event START date + + context('Test for Date Filter', () => { + it('should only accept a correct date format', () => { + cy.get("input[name='filterDateTo']") + .type('2018-01-09') + .should('have.value', '2018-01-09'); //Start Event Date + cy.get("input[name='filterDateFrom']") + .type('2011-01-09') + .should('have.value', '2011-01-09'); //End Event date + }); + }); + + context('Test for location filter ', () => { + it('should only have single item', () => { + cy.get(loc, { timeout: delay }) .eq(0) .click(); - cy.contains('NES').click(); //Selects the dropdown menu option + cy.contains('NIC').click(); + cy.get('.Select-value #react-select-3--value-item').should( + 'contain', + 'NIC' + ); + cy.get(loc, { timeout: delay }) + .eq(0) + .click(); + cy.contains('neduet').click(); + cy.get('.Select-value #react-select-3--value-item').should( + 'contain', + 'neduet' + ); + }); + }); + + context('Test for sponsors filter', () => { + it('should have one item', () => { + cy.get(spons, { timeout: delay }) + .eq(0) + .click(); + cy.contains('tapal').click(); + cy.get('.Select-value #react-select-4--value-0').should( + 'contain', + 'tapal' + ); + }); + + it('should deselect item', () => { + cy.get('.Select-value-icon').click(); }); - it('should deselect option', () => { - cy.get(':nth-child(1)>.Select-value-icon').click(); //Deselects one of the option + it('should have multiple items', () => { + cy.get(spons, { timeout: delay }) + .eq(0) + .click(); + cy.contains('nokia').click(); + cy.get('.Select-value #react-select-4--value-0').should( + 'contain', + 'nokia' + ); + + cy.get(spons, { timeout: delay }) + .eq(0) + .click(); + cy.contains('apple').click(); + cy.get('.Select-value #react-select-4--value-1').should( + 'contain', + 'apple' + ); }); - it('should select multiple options', () => { + it('should cancel all the items at once', () => { cy.get( - ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', - { timeout: 30000 } //gets the location with a delay of 30000 - ) + ':nth-child(5) > .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + }); + + context('Test for Tags filter', () => { + it('should have one item', () => { + cy.get(tag, { timeout: delay }) + .eq(0) + .click(); + cy.contains('javascript').click(); + cy.get('.Select-value #react-select-5--value-0').should( + 'contain', + 'javascript' + ); + }); + + it('should deselect item', () => { + cy.get('.Select-value-icon').click(); + }); + + it('should have multiple items', () => { + cy.get(tag, { timeout: delay }) + .eq(0) + .click(); + cy.contains('abc').click(); + cy.get('.Select-value #react-select-5--value-0').should( + 'contain', + 'abc' + ); + + cy.get(tag, { timeout: delay }) .eq(0) .click(); - cy.contains('NES').click(); //Selects the dropdown menu option + cy.contains('javascript').click(); + cy.get('.Select-value #react-select-5--value-1').should( + 'contain', + 'javascript' + ); + }); + + it('should cancel all the items at once', () => { cy.get( - ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', - { timeout: 30000 } //gets the location with a delay of 30000 - ) + ':nth-child(6) > .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + + }) + + context('Test for Time filter', () => { + it('should have one item', () => { + cy.get(time, { timeout: delay }) .eq(0) .click(); - cy.contains('Recurship').click(); //Selects the dropdown menu option + cy.contains('Noon').click(); + cy.get('.Select-value #react-select-6--value-0').should( + 'contain', + 'Noon' + ); }); - it('should deselect all the options', () => { - cy.get(':nth-child(1)>.Select-value-icon').click(); //Deselects one of the option - cy.get('.Select-value-icon').click(); //Deselects both + it('should deselect item', () => { + cy.get('.Select-value-icon').click(); }); - // cy.get('form .btn').click(); + it('should have multiple items', () => { + cy.get(time, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Morning').click(); + cy.get('.Select-value #react-select-6--value-0').should( + 'contain', + 'Morning' + ); + + cy.get(time, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Evening').click(); + cy.get('.Select-value #react-select-6--value-1').should( + 'contain', + 'Evening' + ); + }); + + it('should cancel all the items at once', () => { + cy.get( + ':nth-child(7) > .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + + }) + + context('Test for Key Words filter', () => { + it('should accept word ', () => { + cy.get(kw).type('sasta') + cy.get(kw).should('have.value','sasta') + }); + }); + + }); diff --git a/client/src/containers/Root/Root.dev.js b/client/src/containers/Root/Root.dev.js index 32da054..d302a4c 100644 --- a/client/src/containers/Root/Root.dev.js +++ b/client/src/containers/Root/Root.dev.js @@ -5,7 +5,7 @@ import App from '../App/App'; const Root = () => (
- + {/* */}
); From 413b7539b56330f616bb1339814a051ddb49dac2 Mon Sep 17 00:00:00 2001 From: faria-ejaz Date: Fri, 5 Oct 2018 16:13:20 +0500 Subject: [PATCH 4/7] [WIP][test] Filters Testing --- .../event-manager/Filters/date_spec.js | 74 +++++++++++++++ .../event-manager/Filters/keywords_spec.js | 39 ++++++++ .../event-manager/Filters/location_spec.js | 54 +++++++++++ .../Filters/organisation_spec.js | 94 +++++++++++++++++++ .../event-manager/Filters/sortby_spec.js | 0 .../event-manager/Filters/sponsors_spec.js | 63 +++++++++++++ .../event-manager/Filters/tags_spec.js | 75 +++++++++++++++ .../event-manager/Filters/time_spec.js | 63 +++++++++++++ 8 files changed, 462 insertions(+) create mode 100644 client/cypress/integration/event-manager/Filters/date_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/keywords_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/location_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/organisation_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/sortby_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/sponsors_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/tags_spec.js create mode 100644 client/cypress/integration/event-manager/Filters/time_spec.js diff --git a/client/cypress/integration/event-manager/Filters/date_spec.js b/client/cypress/integration/event-manager/Filters/date_spec.js new file mode 100644 index 0000000..bbb6745 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/date_spec.js @@ -0,0 +1,74 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const URL = 'http://localhost:3000/events/'; + +describe('Date Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + + context('Test for Date Filter', () => { + it('should only accept a correct date format', () => { + cy.get("input[name='filterDateTo']") + .type('2018-10-03') + .should('have.value', '2018-10-03'); //Event END Date + cy.get("input[name='filterDateFrom']") + .type('2011-10-06') + .should('have.value', '2011-10-06'); //Event START date + cy.visit(URL); + }); + + //BUGS-NOT WORKING + // it('should display 1 result on Start date filter ', () => { + // cy.get("input[name='filterDateFrom']") + // .type('2018-10-03') + // .should('have.value', '2018-10-03'); //Start Event Date + + // cy.get('.btn').click(); + // cy.get('#event-list a') + // .should('have.attr', 'href') + // .and('include', '/events/2') + // .then(href => { + // cy.visit(href); + // cy.get( + // ':nth-child(3) > :nth-child(1) > .row > .col-md-10 > .text-dark' + // ).should('contain', 'Saturday, October 6, 2018 11:00 AM'); + // }); + // cy.visit('http://localhost:3000/events/'); + // }); + + // it('should display 3 results on end date filter ', () => { + // cy.get("input[name='filterDateTo']") + // .type('2011-10-06') + // .should('have.value', '2011-10-06'); //End Event date + + // cy.get('.btn').click(); + // cy.get('#event-list a') + // .should('have.attr', 'href') + // .and('include', '/events/2') + // .then(href => { + // cy.visit(href); + // cy.get( + // ':nth-child(1) > .card > .card-body > .card-subtitle > .text-muted' + // ).should('contain', 'Saturday, October 6, 2018 11:00 AM'); + // cy.get( + // ':nth-child(2) > .card > .card-body > .card-subtitle > .text-muted' + // ).should('contain', 'Wednesday, October 3, 2018 11:00 AM'); + // cy.get( + // ':nth-child(3) > .card > .card-body > .card-subtitle > .text-muted' + // ).should('contain', 'Tuesday, October 2, 2018 11:00 AM'); + // }); + // }); + + }); + + +}); \ No newline at end of file diff --git a/client/cypress/integration/event-manager/Filters/keywords_spec.js b/client/cypress/integration/event-manager/Filters/keywords_spec.js new file mode 100644 index 0000000..412d7ab --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/keywords_spec.js @@ -0,0 +1,39 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const kw = ':nth-child(8) > .form-control'; +const URL = 'http://localhost:3000/events/'; + +describe('KeyWords Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + context('Test for Key Words filter', () => { + it('should display 1 result', () => { + cy.get(kw).type('const'); + cy.get(kw).should('have.value', 'const'); + cy.get('.btn').click(); + cy.get('.card-text').should('contain', 'const'); + cy.visit(URL); + }); + it('should display 2 result', () => { + cy.get(kw).type('sasta'); + cy.get(kw).should('have.value', 'sasta'); + cy.get('.btn').click(); + cy.get('.card div') + .should('have.length', '2') + .each($div => { + cy.wrap($div) + .get('.card > .card-body > .card-text') + .should('contain', 'sasta'); + }); + }); + }); +}); diff --git a/client/cypress/integration/event-manager/Filters/location_spec.js b/client/cypress/integration/event-manager/Filters/location_spec.js new file mode 100644 index 0000000..12af2b8 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/location_spec.js @@ -0,0 +1,54 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const loc = + ':nth-child(4) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const delay = 30000; +const URL = 'http://localhost:3000/events/'; + +describe('Location Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + + context('Test for location filter ', () => { + it('should only have single item', () => { + cy.get(loc, { timeout: delay }) + .eq(0) + .click(); + cy.get('div.Select-menu-outer').should('be.visible'); + cy.contains('NIC').click(); + cy.get('.Select-value #react-select-3--value-item').should( + 'contain', + 'NIC' + ); + cy.get(loc, { timeout: delay }) + .eq(0) + .click(); + cy.contains('neduet').click(); + cy.get('.Select-value #react-select-3--value-item').should( + 'contain', + 'neduet' + ); + cy.get('.btn').click(); + cy.get('#event-list a') + .should('have.attr', 'href') + .and('include', '/events/2') + .then(href => { + cy.visit(href); + cy.get(':nth-child(3) > .row > .col-md-10 > .text-dark').should( + 'contain', + 'neduet johar' + ); + }); + cy.visit(URL); + }); + }); +}); diff --git a/client/cypress/integration/event-manager/Filters/organisation_spec.js b/client/cypress/integration/event-manager/Filters/organisation_spec.js new file mode 100644 index 0000000..8324795 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/organisation_spec.js @@ -0,0 +1,94 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const delay = 30000; +const org = + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const URL = 'http://localhost:3000/events/'; + + +describe('Organisation Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + + context('Test for Organization Filter', () => { + it('should have a clickable arrow button', () => { + cy.get(org, { timeout: delay }) + .eq(0) + .click(); //Clicks the toggle button + cy.get('div.Select-menu-outer').should('be.visible'); + }); + + it('should display 1 result on single item selection', () => { + cy.get(org, { timeout: delay }).eq(0); + cy.contains('NES').click(); + cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); + cy.get('.btn').click(); + cy.get('#event-list a') + .should('have.attr', 'href') + .and('include', '/events/2') + .then(href => { + cy.visit(href); + cy.get( + ':nth-child(3) > :nth-child(4) > .row > .col-md-10 > a > .text-dark' + ).should('contain', 'NES'); + }); + cy.visit(URL); + }); + + it('should display 2 results on 2 items selection', () => { + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('NES').click(); + cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); + + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Recurship').click(); + cy.get('.Select-value #react-select-2--value-1').should( + 'contain', + 'Recurship' + ); + cy.get('.btn').click(); + cy.get('#event-list a') + .eq(0) + .should('have.attr', 'href') + .and('include', '/events/1'); + + cy.get('#event-list a') + .eq(1) + .should('have.attr', 'href') + .and('include', '/events/2'); + }); + + it('should cancel all the items at once', () => { + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('NES').click(); + cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); + + cy.get(org, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Recurship').click(); + cy.get('.Select-value #react-select-2--value-1').should( + 'contain', + 'Recurship' + ); + cy.get( + ':nth-child(1)> .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + }); +}); diff --git a/client/cypress/integration/event-manager/Filters/sortby_spec.js b/client/cypress/integration/event-manager/Filters/sortby_spec.js new file mode 100644 index 0000000..e69de29 diff --git a/client/cypress/integration/event-manager/Filters/sponsors_spec.js b/client/cypress/integration/event-manager/Filters/sponsors_spec.js new file mode 100644 index 0000000..1fffac4 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/sponsors_spec.js @@ -0,0 +1,63 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const spons = + ':nth-child(5) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const delay = 30000; + +describe('Sponsors Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + + context('Test for sponsors filter', () => { + it('should have one item', () => { + cy.get(spons, { timeout: delay }) + .eq(0) + .click(); + cy.get('div.Select-menu-outer').should('be.visible'); + cy.contains('tapal').click(); + cy.get('.Select-value #react-select-4--value-0').should( + 'contain', + 'tapal' + ); + }); + + it('should deselect item', () => { + cy.get('.Select-value-icon').click(); + }); + + it('should have multiple items', () => { + cy.get(spons, { timeout: delay }) + .eq(0) + .click(); + cy.contains('nokia').click(); + cy.get('.Select-value #react-select-4--value-0').should( + 'contain', + 'nokia' + ); + + cy.get(spons, { timeout: delay }) + .eq(0) + .click(); + cy.contains('apple').click(); + cy.get('.Select-value #react-select-4--value-1').should( + 'contain', + 'apple' + ); + }); + + it('should cancel all the items at once', () => { + cy.get( + ':nth-child(5) > .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + }); +}); diff --git a/client/cypress/integration/event-manager/Filters/tags_spec.js b/client/cypress/integration/event-manager/Filters/tags_spec.js new file mode 100644 index 0000000..2272437 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/tags_spec.js @@ -0,0 +1,75 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const tag = + ':nth-child(6) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const delay = 30000; +const URL = 'http://localhost:3000/events/'; + +describe('Tags Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + context('Test for Tags filter', () => { + it('should have one item', () => { + cy.get(tag, { timeout: delay }) + .eq(0) + .click(); + cy.get('div.Select-menu-outer').should('be.visible'); + cy.contains('javascript').click(); + cy.get('.Select-value #react-select-5--value-0').should( + 'contain', + 'javascript' + ); + cy.get('.btn').click(); + cy.get('#event-list a') + .should('have.attr', 'href') + .and('include', '/events/1') + .then(href => { + cy.visit(href); + cy.get('.container > :nth-child(5)').should('contain', 'javascript'); + }); + cy.visit(URL); + }); + + it('should have multiple items', () => { + cy.get(tag, { timeout: delay }) + .eq(0) + .click(); + cy.contains('abc').click(); + cy.get('.Select-value #react-select-5--value-0').should('contain', 'abc'); + + cy.get(tag, { timeout: delay }) + .eq(0) + .click(); + cy.contains('javascript').click(); + cy.get('.Select-value #react-select-5--value-1').should( + 'contain', + 'javascript' + ); + cy.get('.btn').click(); + cy.get('#event-list a') + .eq(0) + .should('have.attr', 'href') + .and('include', '/events/1'); + + cy.get('#event-list a') + .eq(1) + .should('have.attr', 'href') + .and('include', '/events/2'); + }); + + it('should cancel all the items at once', () => { + cy.get( + ':nth-child(6) > .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + }); +}); diff --git a/client/cypress/integration/event-manager/Filters/time_spec.js b/client/cypress/integration/event-manager/Filters/time_spec.js new file mode 100644 index 0000000..da1851a --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/time_spec.js @@ -0,0 +1,63 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +const time = + ':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow'; +const delay = 30000; + +describe('Time Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + cy.visit('/events'); + cy.get('h3').should('contain', 'Welcome to Event Management'); + }); + }); + + context('Test for Time filter', () => { + it('should have one item', () => { + cy.get(time, { timeout: delay }) + .eq(0) + .click(); + cy.get('div.Select-menu-outer').should('be.visible'); + cy.contains('Noon').click(); + cy.get('.Select-value #react-select-6--value-0').should( + 'contain', + 'Noon' + ); + }); + + it('should deselect item', () => { + cy.get('.Select-value-icon').click(); + }); + + it('should have multiple items', () => { + cy.get(time, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Morning').click(); + cy.get('.Select-value #react-select-6--value-0').should( + 'contain', + 'Morning' + ); + + cy.get(time, { timeout: delay }) + .eq(0) + .click(); + cy.contains('Evening').click(); + cy.get('.Select-value #react-select-6--value-1').should( + 'contain', + 'Evening' + ); + }); + + it('should cancel all the items at once', () => { + cy.get( + ':nth-child(7) > .Select > .Select-control > .Select-clear-zone > .Select-clear' + ).click(); + }); + }); +}); From 96f1d4c84a40a0774f14539b036083dad45cc50f Mon Sep 17 00:00:00 2001 From: faria-ejaz Date: Mon, 8 Oct 2018 17:15:51 +0500 Subject: [PATCH 5/7] [WIP] Resolved issues --- .../event-manager/Filters/date_spec.js | 27 ++++++------ .../event-manager/Filters/keywords_spec.js | 15 ++++--- .../event-manager/Filters/location_spec.js | 21 ++++------ .../Filters/organisation_spec.js | 42 ++++++------------- .../event-manager/Filters/sponsors_spec.js | 18 ++++---- .../event-manager/Filters/tags_spec.js | 25 +++++------ .../event-manager/Filters/time_spec.js | 18 ++++---- .../integration/event-manager/dataSet.js | 27 ++++++++++++ 8 files changed, 97 insertions(+), 96 deletions(-) diff --git a/client/cypress/integration/event-manager/Filters/date_spec.js b/client/cypress/integration/event-manager/Filters/date_spec.js index bbb6745..169a5d4 100644 --- a/client/cypress/integration/event-manager/Filters/date_spec.js +++ b/client/cypress/integration/event-manager/Filters/date_spec.js @@ -5,25 +5,31 @@ /* global cy */ /* eslint no-undef: "error" */ -const URL = 'http://localhost:3000/events/'; +import { constants } from '../dataSet'; +const EVEND = Cypress.moment() + .subtract('5', 'days') + .format('YYYY-MM-DD'); +const EVSTRT = Cypress.moment() + .subtract('7', 'years') + .format('YYYY-MM-DD'); describe('Date Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get(':nth-child(2) > label').should('contain', 'Start Date'); }); }); context('Test for Date Filter', () => { it('should only accept a correct date format', () => { cy.get("input[name='filterDateTo']") - .type('2018-10-03') + .type(EVEND) .should('have.value', '2018-10-03'); //Event END Date cy.get("input[name='filterDateFrom']") - .type('2011-10-06') - .should('have.value', '2011-10-06'); //Event START date - cy.visit(URL); + .type(EVSTRT) + .should('have.value', '2011-10-08'); //Event START date + cy.visit(constants.URL); }); //BUGS-NOT WORKING @@ -31,7 +37,7 @@ describe('Date Filter Testing', () => { // cy.get("input[name='filterDateFrom']") // .type('2018-10-03') // .should('have.value', '2018-10-03'); //Start Event Date - + // cy.get('.btn').click(); // cy.get('#event-list a') // .should('have.attr', 'href') @@ -49,7 +55,7 @@ describe('Date Filter Testing', () => { // cy.get("input[name='filterDateTo']") // .type('2011-10-06') // .should('have.value', '2011-10-06'); //End Event date - + // cy.get('.btn').click(); // cy.get('#event-list a') // .should('have.attr', 'href') @@ -67,8 +73,5 @@ describe('Date Filter Testing', () => { // ).should('contain', 'Tuesday, October 2, 2018 11:00 AM'); // }); // }); - }); - - -}); \ No newline at end of file +}); diff --git a/client/cypress/integration/event-manager/Filters/keywords_spec.js b/client/cypress/integration/event-manager/Filters/keywords_spec.js index 412d7ab..ee9bd6e 100644 --- a/client/cypress/integration/event-manager/Filters/keywords_spec.js +++ b/client/cypress/integration/event-manager/Filters/keywords_spec.js @@ -5,27 +5,26 @@ /* global cy */ /* eslint no-undef: "error" */ -const kw = ':nth-child(8) > .form-control'; -const URL = 'http://localhost:3000/events/'; +import { constants } from '../dataSet'; describe('KeyWords Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get('.btn').should('contain', 'Search'); }); }); context('Test for Key Words filter', () => { it('should display 1 result', () => { - cy.get(kw).type('const'); - cy.get(kw).should('have.value', 'const'); + cy.get(constants.kw).type('const'); + cy.get(constants.kw).should('have.value', 'const'); cy.get('.btn').click(); cy.get('.card-text').should('contain', 'const'); - cy.visit(URL); + cy.visit(constants.URL); }); it('should display 2 result', () => { - cy.get(kw).type('sasta'); - cy.get(kw).should('have.value', 'sasta'); + cy.get(constants.kw).type('sasta'); + cy.get(constants.kw).should('have.value', 'sasta'); cy.get('.btn').click(); cy.get('.card div') .should('have.length', '2') diff --git a/client/cypress/integration/event-manager/Filters/location_spec.js b/client/cypress/integration/event-manager/Filters/location_spec.js index 12af2b8..1bc45c2 100644 --- a/client/cypress/integration/event-manager/Filters/location_spec.js +++ b/client/cypress/integration/event-manager/Filters/location_spec.js @@ -5,34 +5,31 @@ /* global cy */ /* eslint no-undef: "error" */ -const loc = - ':nth-child(4) .Select .Select-control .Select-arrow-zone .Select-arrow'; -const delay = 30000; -const URL = 'http://localhost:3000/events/'; +import { constants } from '../dataSet'; -describe('Location Filter Testing', () => { +describe('location Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get('.btn').should('contain', 'Search'); }); }); - context('Test for location filter ', () => { + context('Test for constants.location filter ', () => { it('should only have single item', () => { - cy.get(loc, { timeout: delay }) + cy.get(constants.loc, { timeout: constants.delay }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.contains('NIC').click(); + cy.get(constants.VAL5).click(); cy.get('.Select-value #react-select-3--value-item').should( 'contain', 'NIC' ); - cy.get(loc, { timeout: delay }) + cy.get(constants.loc, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('neduet').click(); + cy.get(constants.VAL6).click(); cy.get('.Select-value #react-select-3--value-item').should( 'contain', 'neduet' @@ -48,7 +45,7 @@ describe('Location Filter Testing', () => { 'neduet johar' ); }); - cy.visit(URL); + cy.visit(constants.URL); }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/organisation_spec.js b/client/cypress/integration/event-manager/Filters/organisation_spec.js index 8324795..7ff40cb 100644 --- a/client/cypress/integration/event-manager/Filters/organisation_spec.js +++ b/client/cypress/integration/event-manager/Filters/organisation_spec.js @@ -5,31 +5,27 @@ /* global cy */ /* eslint no-undef: "error" */ -const delay = 30000; -const org = - ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow'; -const URL = 'http://localhost:3000/events/'; +import { constants } from '../dataSet'; - -describe('Organisation Filter Testing', () => { +describe('constants.organisation Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get('.legend').should('contain', 'Filters'); }); }); - context('Test for Organization Filter', () => { + context('Test for constants.organization Filter', () => { it('should have a clickable arrow button', () => { - cy.get(org, { timeout: delay }) + cy.get(constants.org, { timeout: constants.delay }) .eq(0) .click(); //Clicks the toggle button cy.get('div.Select-menu-outer').should('be.visible'); }); it('should display 1 result on single item selection', () => { - cy.get(org, { timeout: delay }).eq(0); - cy.contains('NES').click(); + cy.get(constants.org, { timeout: constants.delay }).eq(0); + cy.get(constants.VAL4).click(); cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); cy.get('.btn').click(); cy.get('#event-list a') @@ -41,20 +37,20 @@ describe('Organisation Filter Testing', () => { ':nth-child(3) > :nth-child(4) > .row > .col-md-10 > a > .text-dark' ).should('contain', 'NES'); }); - cy.visit(URL); + cy.visit(constants.URL); }); it('should display 2 results on 2 items selection', () => { - cy.get(org, { timeout: delay }) + cy.get(constants.org, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('NES').click(); + cy.get(constants.VAL4).click(); cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); - cy.get(org, { timeout: delay }) + cy.get(constants.org, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('Recurship').click(); + cy.get(constants.VAL3).click(); cy.get('.Select-value #react-select-2--value-1').should( 'contain', 'Recurship' @@ -72,20 +68,6 @@ describe('Organisation Filter Testing', () => { }); it('should cancel all the items at once', () => { - cy.get(org, { timeout: delay }) - .eq(0) - .click(); - cy.contains('NES').click(); - cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); - - cy.get(org, { timeout: delay }) - .eq(0) - .click(); - cy.contains('Recurship').click(); - cy.get('.Select-value #react-select-2--value-1').should( - 'contain', - 'Recurship' - ); cy.get( ':nth-child(1)> .Select > .Select-control > .Select-clear-zone > .Select-clear' ).click(); diff --git a/client/cypress/integration/event-manager/Filters/sponsors_spec.js b/client/cypress/integration/event-manager/Filters/sponsors_spec.js index 1fffac4..fe5a91a 100644 --- a/client/cypress/integration/event-manager/Filters/sponsors_spec.js +++ b/client/cypress/integration/event-manager/Filters/sponsors_spec.js @@ -5,25 +5,23 @@ /* global cy */ /* eslint no-undef: "error" */ -const spons = - ':nth-child(5) .Select .Select-control .Select-arrow-zone .Select-arrow'; -const delay = 30000; +import { constants } from '../dataSet'; describe('Sponsors Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get('.btn').should('contain', 'Search'); }); }); context('Test for sponsors filter', () => { it('should have one item', () => { - cy.get(spons, { timeout: delay }) + cy.get(constants.spons, { timeout: constants.delay }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.contains('tapal').click(); + cy.get(constants.VAL7).click(); cy.get('.Select-value #react-select-4--value-0').should( 'contain', 'tapal' @@ -35,19 +33,19 @@ describe('Sponsors Filter Testing', () => { }); it('should have multiple items', () => { - cy.get(spons, { timeout: delay }) + cy.get(constants.spons, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('nokia').click(); + cy.get(constants.VAL8).click(); cy.get('.Select-value #react-select-4--value-0').should( 'contain', 'nokia' ); - cy.get(spons, { timeout: delay }) + cy.get(constants.spons, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('apple').click(); + cy.get(constants.VAL8).click(); cy.get('.Select-value #react-select-4--value-1').should( 'contain', 'apple' diff --git a/client/cypress/integration/event-manager/Filters/tags_spec.js b/client/cypress/integration/event-manager/Filters/tags_spec.js index 2272437..6aca247 100644 --- a/client/cypress/integration/event-manager/Filters/tags_spec.js +++ b/client/cypress/integration/event-manager/Filters/tags_spec.js @@ -5,25 +5,22 @@ /* global cy */ /* eslint no-undef: "error" */ -const tag = - ':nth-child(6) .Select .Select-control .Select-arrow-zone .Select-arrow'; -const delay = 30000; -const URL = 'http://localhost:3000/events/'; +import { constants } from '../dataSet'; -describe('Tags Filter Testing', () => { +describe('constants.tags Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get('.btn').should('contain', 'Search'); }); }); - context('Test for Tags filter', () => { + context('Test for constants.tags filter', () => { it('should have one item', () => { - cy.get(tag, { timeout: delay }) + cy.get(constants.tag, { timeout: constants.delay }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.contains('javascript').click(); + cy.get(constants.VAL2).click(); cy.get('.Select-value #react-select-5--value-0').should( 'contain', 'javascript' @@ -36,20 +33,20 @@ describe('Tags Filter Testing', () => { cy.visit(href); cy.get('.container > :nth-child(5)').should('contain', 'javascript'); }); - cy.visit(URL); + cy.visit(constants.URL); }); it('should have multiple items', () => { - cy.get(tag, { timeout: delay }) + cy.get(constants.tag, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('abc').click(); + cy.get(constants.VAL1).click(); cy.get('.Select-value #react-select-5--value-0').should('contain', 'abc'); - cy.get(tag, { timeout: delay }) + cy.get(constants.tag, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('javascript').click(); + cy.get(constants.VAL2).click(); cy.get('.Select-value #react-select-5--value-1').should( 'contain', 'javascript' diff --git a/client/cypress/integration/event-manager/Filters/time_spec.js b/client/cypress/integration/event-manager/Filters/time_spec.js index da1851a..075b056 100644 --- a/client/cypress/integration/event-manager/Filters/time_spec.js +++ b/client/cypress/integration/event-manager/Filters/time_spec.js @@ -5,25 +5,23 @@ /* global cy */ /* eslint no-undef: "error" */ -const time = - ':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow'; -const delay = 30000; +import { constants } from '../dataSet'; describe('Time Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { cy.visit('/events'); - cy.get('h3').should('contain', 'Welcome to Event Management'); + cy.get('.btn').should('contain', 'Search'); }); }); context('Test for Time filter', () => { it('should have one item', () => { - cy.get(time, { timeout: delay }) + cy.get(constants.time, { timeout: constants.delay }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.contains('Noon').click(); + cy.get(constants.VAL10).click(); cy.get('.Select-value #react-select-6--value-0').should( 'contain', 'Noon' @@ -35,19 +33,19 @@ describe('Time Filter Testing', () => { }); it('should have multiple items', () => { - cy.get(time, { timeout: delay }) + cy.get(constants.time, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('Morning').click(); + cy.get(constants.VAL9).click(); cy.get('.Select-value #react-select-6--value-0').should( 'contain', 'Morning' ); - cy.get(time, { timeout: delay }) + cy.get(constants.time, { timeout: constants.delay }) .eq(0) .click(); - cy.contains('Evening').click(); + cy.get(constants.VAL10).click(); cy.get('.Select-value #react-select-6--value-1').should( 'contain', 'Evening' diff --git a/client/cypress/integration/event-manager/dataSet.js b/client/cypress/integration/event-manager/dataSet.js index 65063fb..7c10ae6 100644 --- a/client/cypress/integration/event-manager/dataSet.js +++ b/client/cypress/integration/event-manager/dataSet.js @@ -46,3 +46,30 @@ export const userWithExistedEmail = { email: 'happy@person.com', username: `happyperson${getId()}`, }; + +export const constants = { + tag: + ':nth-child(6) .Select .Select-control .Select-arrow-zone .Select-arrow', + delay: 30000, + kw: ':nth-child(8) > .form-control', + URL: 'http://localhost:3000/events/', + org: + ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', + VAL1: '#react-select-5--option-2', + VAL2: '#react-select-5--option-1', + VAL3: '#react-select-2--option-0', + VAL4: '#react-select-2--option-1', + loc: + ':nth-child(4) .Select .Select-control .Select-arrow-zone .Select-arrow', + VAL5: '#react-select-3--option-0', + VAL6: '#react-select-3--option-1', + spons: + ':nth-child(5) .Select .Select-control .Select-arrow-zone .Select-arrow', + + VAL7: '#react-select-4--option-0', + VAL8: '#react-select-4--option-1', + time: + ':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow', + VAL9: '#react-select-6--option-0', + VAL10: '#react-select-6--option-1', +}; From 1b3b029ba38ea43a703afc74aab5136fabf63e41 Mon Sep 17 00:00:00 2001 From: faria-ejaz Date: Tue, 9 Oct 2018 17:14:02 +0500 Subject: [PATCH 6/7] Resolved Issues --- .../event-manager/Filters/date_spec.js | 19 +++---- .../event-manager/Filters/keywords_spec.js | 30 +++++----- .../event-manager/Filters/location_spec.js | 23 +++++--- .../Filters/organisation_spec.js | 55 +++++++++---------- .../event-manager/Filters/sponsors_spec.js | 47 +++++++++++----- .../event-manager/Filters/tags_spec.js | 25 +++++---- .../event-manager/Filters/time_spec.js | 29 +++++----- .../integration/event-manager/dataSet.js | 53 +++++++++++------- client/cypress/support/commands.js | 5 ++ 9 files changed, 160 insertions(+), 126 deletions(-) diff --git a/client/cypress/integration/event-manager/Filters/date_spec.js b/client/cypress/integration/event-manager/Filters/date_spec.js index 169a5d4..941ba78 100644 --- a/client/cypress/integration/event-manager/Filters/date_spec.js +++ b/client/cypress/integration/event-manager/Filters/date_spec.js @@ -6,30 +6,25 @@ /* eslint no-undef: "error" */ import { constants } from '../dataSet'; -const EVEND = Cypress.moment() - .subtract('5', 'days') - .format('YYYY-MM-DD'); -const EVSTRT = Cypress.moment() - .subtract('7', 'years') - .format('YYYY-MM-DD'); describe('Date Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get(':nth-child(2) > label').should('contain', 'Start Date'); + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for Date Filter', () => { it('should only accept a correct date format', () => { cy.get("input[name='filterDateTo']") - .type(EVEND) + .type(constants.EVENT_END_DATE) .should('have.value', '2018-10-03'); //Event END Date cy.get("input[name='filterDateFrom']") - .type(EVSTRT) - .should('have.value', '2011-10-08'); //Event START date - cy.visit(constants.URL); + .type(constants.EVENT_START_DATE) + .should('have.value', '2011-10-09'); //Event START date + cy.visit(constants.BASE_URL); }); //BUGS-NOT WORKING diff --git a/client/cypress/integration/event-manager/Filters/keywords_spec.js b/client/cypress/integration/event-manager/Filters/keywords_spec.js index ee9bd6e..20309dd 100644 --- a/client/cypress/integration/event-manager/Filters/keywords_spec.js +++ b/client/cypress/integration/event-manager/Filters/keywords_spec.js @@ -9,30 +9,28 @@ import { constants } from '../dataSet'; describe('KeyWords Filter Testing', () => { context('Test for Filters Route', () => { - it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get('.btn').should('contain', 'Search'); + it('Should be on Home Page', () => { + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for Key Words filter', () => { - it('should display 1 result', () => { - cy.get(constants.kw).type('const'); - cy.get(constants.kw).should('have.value', 'const'); + it('should display less results', () => { + cy.get(constants.KEYWORDS_INPUT_FIELD).type('const'); + cy.get(constants.KEYWORDS_INPUT_FIELD).should('have.value', 'const'); cy.get('.btn').click(); cy.get('.card-text').should('contain', 'const'); - cy.visit(constants.URL); }); it('should display 2 result', () => { - cy.get(constants.kw).type('sasta'); - cy.get(constants.kw).should('have.value', 'sasta'); + cy.get(constants.KEYWORDS_INPUT_FIELD).type('ReactKHI'); + cy.get(constants.KEYWORDS_INPUT_FIELD).should('have.value', 'ReactKHI'); cy.get('.btn').click(); - cy.get('.card div') - .should('have.length', '2') - .each($div => { - cy.wrap($div) - .get('.card > .card-body > .card-text') - .should('contain', 'sasta'); - }); + // cy.get('.card div') + // .each($div => { + // cy.wrap($div) + // .get('.card > .card-body').should('contain','ReactKHI'); + // }); }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/location_spec.js b/client/cypress/integration/event-manager/Filters/location_spec.js index 1bc45c2..c58f401 100644 --- a/client/cypress/integration/event-manager/Filters/location_spec.js +++ b/client/cypress/integration/event-manager/Filters/location_spec.js @@ -9,27 +9,32 @@ import { constants } from '../dataSet'; describe('location Filter Testing', () => { context('Test for Filters Route', () => { - it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get('.btn').should('contain', 'Search'); + it('Should be on Home page', () => { + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for constants.location filter ', () => { - it('should only have single item', () => { - cy.get(constants.loc, { timeout: constants.delay }) + it('should only accept single item at a time', () => { + cy.get(constants.LOCATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.get(constants.VAL5).click(); + cy.get(constants.LOCATION_FIELD_OPTION_1).click(); cy.get('.Select-value #react-select-3--value-item').should( 'contain', 'NIC' ); - cy.get(constants.loc, { timeout: constants.delay }) + cy.get(constants.LOCATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); - cy.get(constants.VAL6).click(); + cy.get(constants.LOCATION_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-3--value-item').should( 'contain', 'neduet' @@ -45,7 +50,7 @@ describe('location Filter Testing', () => { 'neduet johar' ); }); - cy.visit(constants.URL); + cy.visit(constants.BASE_URL); }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/organisation_spec.js b/client/cypress/integration/event-manager/Filters/organisation_spec.js index 7ff40cb..5c6b912 100644 --- a/client/cypress/integration/event-manager/Filters/organisation_spec.js +++ b/client/cypress/integration/event-manager/Filters/organisation_spec.js @@ -10,47 +10,37 @@ import { constants } from '../dataSet'; describe('constants.organisation Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get('.legend').should('contain', 'Filters'); + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for constants.organization Filter', () => { it('should have a clickable arrow button', () => { - cy.get(constants.org, { timeout: constants.delay }) + cy.get(constants.ORGANISATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); //Clicks the toggle button cy.get('div.Select-menu-outer').should('be.visible'); }); - it('should display 1 result on single item selection', () => { - cy.get(constants.org, { timeout: constants.delay }).eq(0); - cy.get(constants.VAL4).click(); - cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); - cy.get('.btn').click(); - cy.get('#event-list a') - .should('have.attr', 'href') - .and('include', '/events/2') - .then(href => { - cy.visit(href); - cy.get( - ':nth-child(3) > :nth-child(4) > .row > .col-md-10 > a > .text-dark' - ).should('contain', 'NES'); - }); - cy.visit(constants.URL); - }); - - it('should display 2 results on 2 items selection', () => { - cy.get(constants.org, { timeout: constants.delay }) + it('should display less results on items selection', () => { + cy.get(constants.ORGANISATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); - cy.get(constants.VAL4).click(); + cy.get(constants.ORGANISATION_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); - cy.get(constants.org, { timeout: constants.delay }) + cy.get(constants.ORGANISATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); - cy.get(constants.VAL3).click(); + cy.get(constants.ORGANISATION_FIELD_OPTION_1).click(); cy.get('.Select-value #react-select-2--value-1').should( 'contain', 'Recurship' @@ -65,12 +55,19 @@ describe('constants.organisation Filter Testing', () => { .eq(1) .should('have.attr', 'href') .and('include', '/events/2'); - }); - - it('should cancel all the items at once', () => { + cy.log('can cancel all the items at once'); + cy.get(constants.ORGANISATION_FIELD_VALUE).should( + 'have.class', + 'Select-value' + ); cy.get( - ':nth-child(1)> .Select > .Select-control > .Select-clear-zone > .Select-clear' + ':nth-child(1) > .Select > .Select-control > .Select-clear-zone > .Select-clear' ).click(); + cy.get('.btn').click(); + cy.get(constants.ORGANISATION_FIELD_VALUE).should( + 'not.have.class', + 'Select-value' + ); }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/sponsors_spec.js b/client/cypress/integration/event-manager/Filters/sponsors_spec.js index fe5a91a..c168418 100644 --- a/client/cypress/integration/event-manager/Filters/sponsors_spec.js +++ b/client/cypress/integration/event-manager/Filters/sponsors_spec.js @@ -10,52 +10,71 @@ import { constants } from '../dataSet'; describe('Sponsors Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get('.btn').should('contain', 'Search'); + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for sponsors filter', () => { it('should have one item', () => { - cy.get(constants.spons, { timeout: constants.delay }) + cy.get(constants.SPONSORS_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.get(constants.VAL7).click(); + cy.get(constants.SPONSORS_FIELD_OPTION_1).click(); cy.get('.Select-value #react-select-4--value-0').should( 'contain', 'tapal' ); - }); - - it('should deselect item', () => { + cy.log('should deselect item'); + cy.get(constants.SPONSORS_FIELD_VALUE).should( + 'have.class', + 'Select-value' + ); cy.get('.Select-value-icon').click(); + cy.get(constants.SPONSORS_FIELD_VALUE).should( + 'not.have.class', + 'Select-value' + ); }); it('should have multiple items', () => { - cy.get(constants.spons, { timeout: constants.delay }) + cy.get(constants.SPONSORS_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); - cy.get(constants.VAL8).click(); + cy.get(constants.SPONSORS_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-4--value-0').should( 'contain', 'nokia' ); - cy.get(constants.spons, { timeout: constants.delay }) + cy.get(constants.SPONSORS_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) .eq(0) .click(); - cy.get(constants.VAL8).click(); + cy.get(constants.SPONSORS_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-4--value-1').should( 'contain', 'apple' ); - }); - - it('should cancel all the items at once', () => { + cy.log('can cancel all the items at once'); + cy.get(constants.SPONSORS_FIELD_VALUE).should( + 'have.class', + 'Select-value' + ); cy.get( ':nth-child(5) > .Select > .Select-control > .Select-clear-zone > .Select-clear' ).click(); + cy.get(constants.SPONSORS_FIELD_VALUE).should( + 'not.have.class', + 'Select-value' + ); }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/tags_spec.js b/client/cypress/integration/event-manager/Filters/tags_spec.js index 6aca247..99e252c 100644 --- a/client/cypress/integration/event-manager/Filters/tags_spec.js +++ b/client/cypress/integration/event-manager/Filters/tags_spec.js @@ -9,18 +9,19 @@ import { constants } from '../dataSet'; describe('constants.tags Filter Testing', () => { context('Test for Filters Route', () => { - it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get('.btn').should('contain', 'Search'); + it('Should be on Home page', () => { + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for constants.tags filter', () => { it('should have one item', () => { - cy.get(constants.tag, { timeout: constants.delay }) + cy.get(constants.TAGS_INPUT_FIELD, { timeout: constants.WAITING_TIME }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.get(constants.VAL2).click(); + cy.get(constants.TAGS_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-5--value-0').should( 'contain', 'javascript' @@ -33,20 +34,19 @@ describe('constants.tags Filter Testing', () => { cy.visit(href); cy.get('.container > :nth-child(5)').should('contain', 'javascript'); }); - cy.visit(constants.URL); }); it('should have multiple items', () => { - cy.get(constants.tag, { timeout: constants.delay }) + cy.get(constants.TAGS_INPUT_FIELD, { timeout: constants.WAITING_TIME }) .eq(0) .click(); - cy.get(constants.VAL1).click(); + cy.get(constants.TAGS_FIELD_OPTION_1).click(); cy.get('.Select-value #react-select-5--value-0').should('contain', 'abc'); - cy.get(constants.tag, { timeout: constants.delay }) + cy.get(constants.TAGS_INPUT_FIELD, { timeout: constants.WAITING_TIME }) .eq(0) .click(); - cy.get(constants.VAL2).click(); + cy.get(constants.TAGS_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-5--value-1').should( 'contain', 'javascript' @@ -61,12 +61,13 @@ describe('constants.tags Filter Testing', () => { .eq(1) .should('have.attr', 'href') .and('include', '/events/2'); - }); - it('should cancel all the items at once', () => { + cy.log('can cancel all the items at once'); + cy.get(constants.TAG_FIELD_VALUE).should('have.class', 'Select-value'); cy.get( ':nth-child(6) > .Select > .Select-control > .Select-clear-zone > .Select-clear' ).click(); + cy.get(constants.TAG_FIELD_VALUE).should('not.have.class', 'Select-value'); }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/time_spec.js b/client/cypress/integration/event-manager/Filters/time_spec.js index 075b056..e191325 100644 --- a/client/cypress/integration/event-manager/Filters/time_spec.js +++ b/client/cypress/integration/event-manager/Filters/time_spec.js @@ -10,52 +10,53 @@ import { constants } from '../dataSet'; describe('Time Filter Testing', () => { context('Test for Filters Route', () => { it('Should be on Filters page', () => { - cy.visit('/events'); - cy.get('.btn').should('contain', 'Search'); + beforeEach(() => { + cy.homePage(); + }); }); }); context('Test for Time filter', () => { it('should have one item', () => { - cy.get(constants.time, { timeout: constants.delay }) + cy.get(constants.TIME_INPUT_FIELD, { timeout: constants.WAITING_TIME }) .eq(0) .click(); cy.get('div.Select-menu-outer').should('be.visible'); - cy.get(constants.VAL10).click(); + cy.get(constants.TIME_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-6--value-0').should( 'contain', 'Noon' ); - }); - - it('should deselect item', () => { + cy.log('should deselect item'); + cy.get(TIME_FIELD_VALUE).should('have.class', 'Select-value'); cy.get('.Select-value-icon').click(); + cy.get(TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); }); it('should have multiple items', () => { - cy.get(constants.time, { timeout: constants.delay }) + cy.get(constants.TIME_INPUT_FIELD, { timeout: constants.WAITING_TIME }) .eq(0) .click(); - cy.get(constants.VAL9).click(); + cy.get(constants.TIME_FIELD_OPTION_1).click(); cy.get('.Select-value #react-select-6--value-0').should( 'contain', 'Morning' ); - cy.get(constants.time, { timeout: constants.delay }) + cy.get(constants.TIME_INPUT_FIELD, { timeout: constants.WAITING_TIME }) .eq(0) .click(); - cy.get(constants.VAL10).click(); + cy.get(constants.TIME_FIELD_OPTION_2).click(); cy.get('.Select-value #react-select-6--value-1').should( 'contain', 'Evening' ); - }); - - it('should cancel all the items at once', () => { + cy.log('can cancel all the items at once'); + cy.get(TIME_FIELD_VALUE).should('have.class', 'Select-value'); cy.get( ':nth-child(7) > .Select > .Select-control > .Select-clear-zone > .Select-clear' ).click(); + cy.get(TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); }); }); }); diff --git a/client/cypress/integration/event-manager/dataSet.js b/client/cypress/integration/event-manager/dataSet.js index 7c10ae6..7761655 100644 --- a/client/cypress/integration/event-manager/dataSet.js +++ b/client/cypress/integration/event-manager/dataSet.js @@ -48,28 +48,41 @@ export const userWithExistedEmail = { }; export const constants = { - tag: + WAITING_TIME: 30000, + BASE_URL: '/events', + TAGS_INPUT_FIELD: ':nth-child(6) .Select .Select-control .Select-arrow-zone .Select-arrow', - delay: 30000, - kw: ':nth-child(8) > .form-control', - URL: 'http://localhost:3000/events/', - org: + TIME_INPUT_FIELD: + ':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow', + KEYWORDS_INPUT_FIELD: ':nth-child(8) > .form-control', + ORGANISATION_INPUT_FIELD: ':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow', - VAL1: '#react-select-5--option-2', - VAL2: '#react-select-5--option-1', - VAL3: '#react-select-2--option-0', - VAL4: '#react-select-2--option-1', - loc: + LOCATION_INPUT_FIELD: ':nth-child(4) .Select .Select-control .Select-arrow-zone .Select-arrow', - VAL5: '#react-select-3--option-0', - VAL6: '#react-select-3--option-1', - spons: + SPONSORS_INPUT_FIELD: ':nth-child(5) .Select .Select-control .Select-arrow-zone .Select-arrow', - - VAL7: '#react-select-4--option-0', - VAL8: '#react-select-4--option-1', - time: - ':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow', - VAL9: '#react-select-6--option-0', - VAL10: '#react-select-6--option-1', + TAGS_FIELD_OPTION_1: '#react-select-5--option-2', + TAGS_FIELD_OPTION_2: '#react-select-5--option-1', + ORGANISATION_FIELD_OPTION_1: '#react-select-2--option-0', + ORGANISATION_FIELD_OPTION_2: '#react-select-2--option-1', + LOCATION_FIELD_OPTION_1: '#react-select-3--option-0', + LOCATION_FIELD_OPTION_2: '#react-select-3--option-1', + SPONSORS_FIELD_OPTION_1: '#react-select-4--option-0', + SPONSORS_FIELD_OPTION_2: '#react-select-4--option-1', + TIME_FIELD_OPTION_1: '#react-select-6--option-0', + TIME_FIELD_OPTION_2: '#react-select-6--option-1', + EVENT_END_DATE: Cypress.moment() + .subtract('6', 'days') + .format('YYYY-MM-DD'), + EVENT_START_DATE: Cypress.moment() + .subtract('7', 'years') + .format('YYYY-MM-DD'), + TIME_FIELD_VALUE: + ' .Select > .Select-control > .Select-multi-value-wrapper#react-select-6--value > div', + TAG_FIELD_VALUE: + ' .Select > .Select-control > .Select-multi-value-wrapper#react-select-5--value > div', + ORGANISATION_FIELD_VALUE: + ' .Select > .Select-control > .Select-multi-value-wrapper#react-select-2--value > div', + SPONSORS_FIELD_VALUE: + ' .Select > .Select-control > .Select-multi-value-wrapper#react-select-4--value > div', }; diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index 196efa9..bcd1f9f 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -40,3 +40,8 @@ Cypress.Commands.add('visitEditPage', (ValidCredentials, username) => { .contains(username) .click(); }); + +Cypress.Commands.add('homePage',() => { + cy.visit('/events'); + cy.get('.btn').should('contain', 'Search'); +}) From 325f5a27f7f06eb107ba446754f6e2c328355aea Mon Sep 17 00:00:00 2001 From: faria ejaz Date: Sat, 24 Nov 2018 15:46:26 +0500 Subject: [PATCH 7/7] fixed bugs --- .../event-manager/Filters/date_spec.js | 46 +------------------ .../event-manager/Filters/time_spec.js | 8 ++-- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/client/cypress/integration/event-manager/Filters/date_spec.js b/client/cypress/integration/event-manager/Filters/date_spec.js index 941ba78..73c4e1a 100644 --- a/client/cypress/integration/event-manager/Filters/date_spec.js +++ b/client/cypress/integration/event-manager/Filters/date_spec.js @@ -20,53 +20,11 @@ describe('Date Filter Testing', () => { it('should only accept a correct date format', () => { cy.get("input[name='filterDateTo']") .type(constants.EVENT_END_DATE) - .should('have.value', '2018-10-03'); //Event END Date + .should('have.value', '2018-11-18'); //Event END Date cy.get("input[name='filterDateFrom']") .type(constants.EVENT_START_DATE) - .should('have.value', '2011-10-09'); //Event START date + .should('have.value', '2011-11-24'); //Event START date cy.visit(constants.BASE_URL); }); - - //BUGS-NOT WORKING - // it('should display 1 result on Start date filter ', () => { - // cy.get("input[name='filterDateFrom']") - // .type('2018-10-03') - // .should('have.value', '2018-10-03'); //Start Event Date - - // cy.get('.btn').click(); - // cy.get('#event-list a') - // .should('have.attr', 'href') - // .and('include', '/events/2') - // .then(href => { - // cy.visit(href); - // cy.get( - // ':nth-child(3) > :nth-child(1) > .row > .col-md-10 > .text-dark' - // ).should('contain', 'Saturday, October 6, 2018 11:00 AM'); - // }); - // cy.visit('http://localhost:3000/events/'); - // }); - - // it('should display 3 results on end date filter ', () => { - // cy.get("input[name='filterDateTo']") - // .type('2011-10-06') - // .should('have.value', '2011-10-06'); //End Event date - - // cy.get('.btn').click(); - // cy.get('#event-list a') - // .should('have.attr', 'href') - // .and('include', '/events/2') - // .then(href => { - // cy.visit(href); - // cy.get( - // ':nth-child(1) > .card > .card-body > .card-subtitle > .text-muted' - // ).should('contain', 'Saturday, October 6, 2018 11:00 AM'); - // cy.get( - // ':nth-child(2) > .card > .card-body > .card-subtitle > .text-muted' - // ).should('contain', 'Wednesday, October 3, 2018 11:00 AM'); - // cy.get( - // ':nth-child(3) > .card > .card-body > .card-subtitle > .text-muted' - // ).should('contain', 'Tuesday, October 2, 2018 11:00 AM'); - // }); - // }); }); }); diff --git a/client/cypress/integration/event-manager/Filters/time_spec.js b/client/cypress/integration/event-manager/Filters/time_spec.js index e191325..df388bf 100644 --- a/client/cypress/integration/event-manager/Filters/time_spec.js +++ b/client/cypress/integration/event-manager/Filters/time_spec.js @@ -28,9 +28,9 @@ describe('Time Filter Testing', () => { 'Noon' ); cy.log('should deselect item'); - cy.get(TIME_FIELD_VALUE).should('have.class', 'Select-value'); + cy.get(constants.TIME_FIELD_VALUE).should('have.class', 'Select-value'); cy.get('.Select-value-icon').click(); - cy.get(TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); + cy.get(constants.TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); }); it('should have multiple items', () => { @@ -52,11 +52,11 @@ describe('Time Filter Testing', () => { 'Evening' ); cy.log('can cancel all the items at once'); - cy.get(TIME_FIELD_VALUE).should('have.class', 'Select-value'); + cy.get(constants.TIME_FIELD_VALUE).should('have.class', 'Select-value'); cy.get( ':nth-child(7) > .Select > .Select-control > .Select-clear-zone > .Select-clear' ).click(); - cy.get(TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); + cy.get(constants.TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); }); }); });