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..73c4e1a --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/date_spec.js @@ -0,0 +1,30 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('Date Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + + context('Test for Date Filter', () => { + it('should only accept a correct date format', () => { + cy.get("input[name='filterDateTo']") + .type(constants.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-11-24'); //Event START date + cy.visit(constants.BASE_URL); + }); + }); +}); 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..20309dd --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/keywords_spec.js @@ -0,0 +1,36 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('KeyWords Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Home Page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + context('Test for Key Words filter', () => { + 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'); + }); + it('should display 2 result', () => { + 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') + // .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 new file mode 100644 index 0000000..c58f401 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/location_spec.js @@ -0,0 +1,56 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('location Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Home page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + + context('Test for constants.location filter ', () => { + 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.LOCATION_FIELD_OPTION_1).click(); + cy.get('.Select-value #react-select-3--value-item').should( + 'contain', + 'NIC' + ); + cy.get(constants.LOCATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) + .eq(0) + .click(); + cy.get(constants.LOCATION_FIELD_OPTION_2).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(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 new file mode 100644 index 0000000..5c6b912 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/organisation_spec.js @@ -0,0 +1,73 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('constants.organisation Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + + context('Test for constants.organization Filter', () => { + it('should have a clickable arrow button', () => { + 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 less results on items selection', () => { + cy.get(constants.ORGANISATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) + .eq(0) + .click(); + cy.get(constants.ORGANISATION_FIELD_OPTION_2).click(); + cy.get('.Select-value #react-select-2--value-0').should('contain', 'NES'); + + cy.get(constants.ORGANISATION_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) + .eq(0) + .click(); + cy.get(constants.ORGANISATION_FIELD_OPTION_1).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'); + 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' + ).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/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..c168418 --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/sponsors_spec.js @@ -0,0 +1,80 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('Sponsors Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + + context('Test for sponsors filter', () => { + it('should have one item', () => { + 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.SPONSORS_FIELD_OPTION_1).click(); + cy.get('.Select-value #react-select-4--value-0').should( + 'contain', + 'tapal' + ); + 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.SPONSORS_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) + .eq(0) + .click(); + cy.get(constants.SPONSORS_FIELD_OPTION_2).click(); + cy.get('.Select-value #react-select-4--value-0').should( + 'contain', + 'nokia' + ); + + cy.get(constants.SPONSORS_INPUT_FIELD, { + timeout: constants.WAITING_TIME, + }) + .eq(0) + .click(); + cy.get(constants.SPONSORS_FIELD_OPTION_2).click(); + cy.get('.Select-value #react-select-4--value-1').should( + 'contain', + 'apple' + ); + 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 new file mode 100644 index 0000000..99e252c --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/tags_spec.js @@ -0,0 +1,73 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('constants.tags Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Home page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + context('Test for constants.tags filter', () => { + it('should have one item', () => { + 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.TAGS_FIELD_OPTION_2).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'); + }); + }); + + it('should have multiple items', () => { + cy.get(constants.TAGS_INPUT_FIELD, { timeout: constants.WAITING_TIME }) + .eq(0) + .click(); + cy.get(constants.TAGS_FIELD_OPTION_1).click(); + cy.get('.Select-value #react-select-5--value-0').should('contain', 'abc'); + + cy.get(constants.TAGS_INPUT_FIELD, { timeout: constants.WAITING_TIME }) + .eq(0) + .click(); + cy.get(constants.TAGS_FIELD_OPTION_2).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'); + + 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 new file mode 100644 index 0000000..df388bf --- /dev/null +++ b/client/cypress/integration/event-manager/Filters/time_spec.js @@ -0,0 +1,62 @@ +/* global describe */ +/* global context */ +/* global it */ +/* global expect */ +/* global cy */ +/* eslint no-undef: "error" */ + +import { constants } from '../dataSet'; + +describe('Time Filter Testing', () => { + context('Test for Filters Route', () => { + it('Should be on Filters page', () => { + beforeEach(() => { + cy.homePage(); + }); + }); + }); + + context('Test for Time filter', () => { + it('should have one item', () => { + 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.TIME_FIELD_OPTION_2).click(); + cy.get('.Select-value #react-select-6--value-0').should( + 'contain', + 'Noon' + ); + cy.log('should deselect item'); + cy.get(constants.TIME_FIELD_VALUE).should('have.class', 'Select-value'); + cy.get('.Select-value-icon').click(); + cy.get(constants.TIME_FIELD_VALUE).should('not.have.class', 'Select-value'); + }); + + it('should have multiple items', () => { + cy.get(constants.TIME_INPUT_FIELD, { timeout: constants.WAITING_TIME }) + .eq(0) + .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_INPUT_FIELD, { timeout: constants.WAITING_TIME }) + .eq(0) + .click(); + cy.get(constants.TIME_FIELD_OPTION_2).click(); + cy.get('.Select-value #react-select-6--value-1').should( + 'contain', + 'Evening' + ); + cy.log('can cancel all the items at once'); + 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(constants.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 65063fb..7761655 100644 --- a/client/cypress/integration/event-manager/dataSet.js +++ b/client/cypress/integration/event-manager/dataSet.js @@ -46,3 +46,43 @@ export const userWithExistedEmail = { email: 'happy@person.com', username: `happyperson${getId()}`, }; + +export const constants = { + WAITING_TIME: 30000, + BASE_URL: '/events', + TAGS_INPUT_FIELD: + ':nth-child(6) .Select .Select-control .Select-arrow-zone .Select-arrow', + 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', + LOCATION_INPUT_FIELD: + ':nth-child(4) .Select .Select-control .Select-arrow-zone .Select-arrow', + SPONSORS_INPUT_FIELD: + ':nth-child(5) .Select .Select-control .Select-arrow-zone .Select-arrow', + 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/integration/event-manager/filters_spec.js b/client/cypress/integration/event-manager/filters_spec.js new file mode 100644 index 0000000..71976fb --- /dev/null +++ b/client/cypress/integration/event-manager/filters_spec.js @@ -0,0 +1,251 @@ +/* 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 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', () => { + 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) + .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 cancel all the items at once', () => { + cy.get( + ':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('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 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(); + }); + }); + + 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('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(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('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(); + }); + + }) + + 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/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'); +}) 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}": [ 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 = () => (
- + {/* */}
);