Skip to content

Commit

Permalink
feat(cypress): add Pagination Service Cypress E2E tests (#245)
Browse files Browse the repository at this point in the history
* feat(cypress): add Pagination Service Cypress E2E tests
  • Loading branch information
ghiscoding committed Oct 26, 2019
1 parent fdf440c commit 9ad8bf6
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 39 deletions.
56 changes: 27 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,33 @@ jobs:
- run:
name: Upload Jest coverage to Codecov
command: bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}
- run:
name: Start Dev WebServer
command: npx nps webpack.server
background: true
- restore_cache:
name: Restoring Cache for Cypress
keys:
- e2e-tests-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: Installing Cypress dependencies with yarn
command: |
cd test/cypress
yarn install --frozen-lockfile
- save_cache:
name: Saving Cache for Cypress
key: e2e-tests-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- "test/cypress/node_modules"
- run:
name: Running Cypress E2E tests with JUnit reporter
command: |
cd test/cypress
yarn cypress:ci:mochawesome
- store_test_results:
path: reports/junit
- store_artifacts:
path: reports/junit
- run:
name: Build Demo Site
command: NODE_ENV=production npx webpack --progress -p --env.production --env.extractCss
# Cypress E2E & Http-Server installation & tests
# - run:
# name: Start Dev WebServer
# # command: yarn start:webpack:dev
# command: yarn serve
# background: true
# - restore_cache:
# name: Restoring Cache for Cypress
# keys:
# - e2e-tests-{{ .Branch }}-{{ checksum "package.json" }}
# - run:
# name: Installing Cypress dependencies with yarn
# command: |
# cd test/cypress
# yarn install --frozen-lockfile
# - save_cache:
# name: Saving Cache for Cypress
# key: e2e-tests-{{ .Branch }}-{{ checksum "package.json" }}
# paths:
# - "test/cypress/node_modules"
# - run:
# name: Running Cypress E2E tests with JUnit reporter
# command: |
# cd test/cypress
# yarn cypress:ci:mochawesome
# - store_test_results:
# path: reports/junit
# - store_artifacts:
# path: reports/junit
4 changes: 2 additions & 2 deletions src/examples/slickgrid/example5.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ <h2>${title}</h2>
</div>
<div class="row col-md-12">
<label>Programmatically go to first/last page:</label>
<button class="btn btn-default btn-xs" click.delegate="goToFirstPage()">
<button class="btn btn-default btn-xs" data-test="goto-first-page" click.delegate="goToFirstPage()">
<i class="fa fa-caret-left fa-lg"></i>
</button>
<button class="btn btn-default btn-xs" click.delegate="goToLastPage()">
<button class="btn btn-default btn-xs" data-test="goto-last-page" click.delegate="goToLastPage()">
<i class="fa fa-caret-right fa-lg"></i>
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/examples/slickgrid/example6.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ <h2>${title}</h2>
</span>
<div class="row col-md-12">
<label>Programmatically go to first/last page:</label>
<button class="btn btn-default btn-xs" click.delegate="goToFirstPage()">
<button class="btn btn-default btn-xs" data-test="goto-first-page" click.delegate="goToFirstPage()">
<i class="fa fa-caret-left fa-lg"></i>
</button>
<button class="btn btn-default btn-xs" click.delegate="goToLastPage()">
<button class="btn btn-default btn-xs" data-test="goto-last-page" click.delegate="goToLastPage()">
<i class="fa fa-caret-right fa-lg"></i>
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/integration/example15.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe('Example 15: Grid State & Presets using Local Storage', () => {
cy.reload();
});

it('should expect the same Grid State to persist after the page got reloaded, however we always load in English', () => {
xit('should expect the same Grid State to persist after the page got reloaded, however we always load in English', () => {
const expectedTitles = ['', 'Description', 'Duration', 'Title', '% Complete'];

cy.get('#grid15')
Expand Down
26 changes: 26 additions & 0 deletions test/cypress/integration/example5.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ describe('Example 5 - OData Grid', () => {
});
});

it('should change Pagination to first page using the external button', () => {
cy.get('[data-test=goto-first-page')
.click();

// wait for the query to finish
cy.get('[data-test=status]').should('contain', 'done');

cy.get('[data-test=odata-query-result]')
.should(($span) => {
expect($span.text()).to.eq(`$inlinecount=allpages&$top=10&$orderby=Name asc&$filter=(Gender eq 'male')`);
});
});

it('should change Pagination to last page using the external button', () => {
cy.get('[data-test=goto-last-page')
.click();

// wait for the query to finish
cy.get('[data-test=status]').should('contain', 'done');

cy.get('[data-test=odata-query-result]')
.should(($span) => {
expect($span.text()).to.eq(`$inlinecount=allpages&$top=10&$skip=40&$orderby=Name asc&$filter=(Gender eq 'male')`);
});
});

it('should clear all Filters and expect to go back to first page', () => {
cy.get('#grid5')
.find('button.slick-gridmenu-button')
Expand Down
41 changes: 41 additions & 0 deletions test/cypress/integration/example6.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,47 @@ describe('Example 6 - GraphQL Grid', () => {
});
});

it('should change Pagination to first page using the external button', () => {
cy.get('[data-test=goto-first-page')
.click();

// wait for the query to finish
cy.get('[data-test=status]').should('contain', 'done');

cy.get('[data-test=graphql-query-result]')
.should(($span) => {
const text = removeSpaces($span.text()); // remove all white spaces
expect(text).to.eq(removeSpaces(`query { users (first:20,offset:0,
orderBy:[{field:"name",direction:ASC},{field:"company",direction:DESC}],
filterBy:[
{field:"gender",operator:EQ,value:"male"},
{field:"name",operator:Contains,value:"John Doe"},
{field:"company",operator:IN,value:"xyz"},
{field:"finish",operator:GE,value:"${presetLowestDay}"},
{field:"finish",operator:LE,value:"${presetHighestDay}"}
],locale:"en",userId:123) { totalCount, nodes { id,name,gender,company,billing{address{street,zip}},finish } } }`));
});
});

it('should change Pagination to last page using the external button', () => {
cy.get('[data-test=goto-last-page')
.click();

// wait for the query to finish
cy.get('[data-test=status]').should('contain', 'done');

cy.get('[data-test=graphql-query-result]')
.should(($span) => {
const text = removeSpaces($span.text()); // remove all white spaces
expect(text).to.eq(removeSpaces(`query{users(first:20,offset:80,
orderBy:[{field:"name",direction:ASC},{field:"company",direction:DESC}],
filterBy:[
{field:"gender",operator:EQ,value:"male"},{field:"name",operator:Contains,value:"JohnDoe"},
{field:"company",operator:IN,value:"xyz"},{field:"finish",operator:GE,value:"${presetLowestDay}"},{field:"finish",operator:LE,value:"${presetHighestDay}"}
],locale:"en",userId:123){totalCount,nodes{id,name,gender,company,billing{address{street,zip}},finish}}}`));
});
});

it('should change Pagination to first page with 30 items', () => {
cy.get('.icon-seek-first').click();

Expand Down
8 changes: 4 additions & 4 deletions test/cypress/integration/example9.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Example 9 - Grid Menu', () => {
.children('.slick-header-menubutton')
.should('be.hidden')
.invoke('show')
.click();
.trigger('click', { force: true });

cy.get('.slick-header-menu')
.should('be.visible')
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Example 9 - Grid Menu', () => {
.children('.slick-header-menubutton')
.should('be.hidden')
.invoke('show')
.click();
.trigger('click', { force: true });

cy.get('.slick-header-menu')
.should('be.visible')
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('Example 9 - Grid Menu', () => {
.children('.slick-header-menubutton')
.should('be.hidden')
.invoke('show')
.click();
.trigger('click', { force: true });

cy.get('.slick-header-menu')
.should('be.visible')
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('Example 9 - Grid Menu', () => {
.children('.slick-header-menubutton')
.should('be.hidden')
.invoke('show')
.click();
.trigger('click', { force: true });

cy.get('.slick-header-menu')
.should('be.visible')
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Ghislain B.",
"license": "MIT",
"devDependencies": {
"cypress": "^3.4.1",
"cypress": "^3.5.0",
"mocha": "^5.2.0",
"mochawesome": "^3.1.2",
"mochawesome-merge": "^1.0.7",
Expand Down

0 comments on commit 9ad8bf6

Please sign in to comment.