Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit b83cb97

Browse files
3.1 refactor tests (#113)
* props fixes * update changelog * bump version * filter typing * - delete unused usage files - restructure tests folder * - separate cypress and visual tests into 2 ci jobs * - build before tests! * add browsers to the node image for visual-test
1 parent 5499429 commit b83cb97

37 files changed

+116
-444
lines changed

.circleci/config.yml

+31-1
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,40 @@ jobs:
4949
command: npm run build:py
5050

5151
- run:
52-
name: Run hosts
52+
name: Run tests
5353
command: |
5454
. venv/bin/activate
5555
npm run test
5656
57+
58+
"visual-test":
59+
docker:
60+
- image: circleci/node:8.11.3-browsers
61+
62+
steps:
63+
- checkout
64+
65+
- restore_cache:
66+
key: deps1-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}-{{ checksum "package.json" }}
67+
68+
- run:
69+
name: Install package.json
70+
command: npm i
71+
72+
- save_cache:
73+
key: deps1-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}-{{ checksum "package.json" }}
74+
paths:
75+
- node_modules
76+
77+
- run:
78+
name: Run build:js
79+
command: npm run build:js
80+
81+
- run:
82+
name: Run visual tests
83+
command: npm run test.visual
84+
85+
5786
"node":
5887
docker:
5988
- image: circleci/node:8.11.3
@@ -143,3 +172,4 @@ workflows:
143172
- "python-3.6"
144173
- "node"
145174
- "test"
175+
- "visual-test"

.config/webpack/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = (preprocessor = {}, mode = 'development') => {
6262
},
6363
resolve: {
6464
alias: {
65-
'cypress': path.resolve('./tests/e2e/cypress/src'),
65+
'cypress': path.resolve('./tests/cypress/src'),
6666
'dash-table': path.resolve('./src/dash-table'),
6767
'core': path.resolve('./src/core'),
6868
'tests': path.resolve('./tests')

TODO.md

-95
This file was deleted.

cypress.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"video": false,
3-
"fixturesFolder": "./tests/e2e/cypress/fixtures",
4-
"integrationFolder": "./tests/e2e/cypress/integration",
5-
"pluginsFile": "./tests/e2e/cypress/plugins/index.js",
6-
"screenshotsFolder": "./tests/e2e/cypress/screenshots",
7-
"supportFile": "./tests/e2e/cypress/support/index.js",
8-
"videoFolder": "./tests/e2e/cypress/videos"
3+
"fixturesFolder": "./tests/cypress/fixtures",
4+
"integrationFolder": "./tests/cypress/tests",
5+
"pluginsFile": "./tests/cypress/plugins/index.js",
6+
"screenshotsFolder": "./tests/cypress/screenshots",
7+
"supportFile": "./tests/cypress/support/index.js",
8+
"videoFolder": "./tests/cypress/videos"
99
}

dash_table/bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_table/demo.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_table/package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"preprivate::opentests": "run-s private::wait*",
88
"preprivate::runtests": "run-s private::wait*",
99
"private::build": "webpack --display-reasons --bail",
10-
"private::host_dash8081": "python tests/e2e/dash/v_be_page.py",
11-
"private::host_dash8082": "python tests/e2e/dash/v_copy_paste.py",
10+
"private::host_dash8081": "python tests/cypress/dash/v_be_page.py",
11+
"private::host_dash8082": "python tests/cypress/dash/v_copy_paste.py",
1212
"private::host_js": "http-server ./dash_table -c-1 --silent",
1313
"private::wait_dash8081": "wait-on http://localhost:8081",
1414
"private::wait_dash8082": "wait-on http://localhost:8082",
@@ -17,15 +17,14 @@
1717
"private::lint.ts": "tslint --project . src/**/*.ts",
1818
"private::opentests": "cypress open",
1919
"private::runtests": "cypress run --browser chrome",
20-
"private::test-e2e": "run-p --race private::host* private::runtests",
21-
"private::test-visual": "build-storybook && percy-storybook",
2220
"build.watch": "webpack-dev-server --content-base dash_table --mode development",
2321
"build:js": "run-s \"private::build -- --mode production\"",
2422
"build:js-dev": "run-s \"private::build -- --mode development\"",
2523
"build:js-test": "webpack --display-reasons --bail --config webpack.test.config.js",
2624
"build:py": "./extract-meta src/dash-table/Table.js > dash_table/metadata.json && cp package.json dash_table",
2725
"lint": "run-s private::lint.js private::lint.ts",
28-
"test": "run-s private::test-*",
26+
"test": "run-p --race private::host* private::runtests",
27+
"test.visual": "build-storybook && percy-storybook",
2928
"test.watch": "run-p --race \"build:js-test -- --watch\" --race private::host* private::opentests"
3029
},
3130
"author": "Chris P <[email protected]",

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"preprivate::opentests": "run-s private::wait*",
88
"preprivate::runtests": "run-s private::wait*",
99
"private::build": "webpack --display-reasons --bail",
10-
"private::host_dash8081": "python tests/e2e/dash/v_be_page.py",
11-
"private::host_dash8082": "python tests/e2e/dash/v_copy_paste.py",
10+
"private::host_dash8081": "python tests/cypress/dash/v_be_page.py",
11+
"private::host_dash8082": "python tests/cypress/dash/v_copy_paste.py",
1212
"private::host_js": "http-server ./dash_table -c-1 --silent",
1313
"private::wait_dash8081": "wait-on http://localhost:8081",
1414
"private::wait_dash8082": "wait-on http://localhost:8082",
@@ -17,15 +17,14 @@
1717
"private::lint.ts": "tslint --project . src/**/*.ts",
1818
"private::opentests": "cypress open",
1919
"private::runtests": "cypress run --browser chrome",
20-
"private::test-e2e": "run-p --race private::host* private::runtests",
21-
"private::test-visual": "build-storybook && percy-storybook",
2220
"build.watch": "webpack-dev-server --content-base dash_table --mode development",
2321
"build:js": "run-s \"private::build -- --mode production\"",
2422
"build:js-dev": "run-s \"private::build -- --mode development\"",
2523
"build:js-test": "webpack --display-reasons --bail --config webpack.test.config.js",
2624
"build:py": "./extract-meta src/dash-table/Table.js > dash_table/metadata.json && cp package.json dash_table",
2725
"lint": "run-s private::lint.js private::lint.ts",
28-
"test": "run-s private::test-*",
26+
"test": "run-p --race private::host* private::runtests",
27+
"test.visual": "build-storybook && percy-storybook",
2928
"test.watch": "run-p --race \"build:js-test -- --watch\" --race private::host* private::opentests"
3029
},
3130
"author": "Chris P <[email protected]",
File renamed without changes.
File renamed without changes.

tests/e2e/cypress/plugins/index.js renamed to tests/cypress/plugins/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const wp = require('@cypress/webpack-preprocessor')
22

33
module.exports = (on) => {
44
const options = {
5-
webpackOptions: require('../../../../webpack.test.config.js'),
5+
webpackOptions: require('../../../webpack.test.config.js'),
66
}
77

88
on('file:preprocessor', wp(options))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import DashTable from 'cypress/DashTable';
2+
3+
describe('delete', () => {
4+
beforeEach(() => cy.visit('http://localhost:8081'));
5+
6+
it('can delete row', () => {
7+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '0'));
8+
DashTable.getDelete(0).click();
9+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '1'));
10+
});
11+
12+
it('can delete row when sorted', () => {
13+
cy.get('tr th.column-0 .sort').click({ force: true });
14+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '28155'));
15+
DashTable.getDelete(0).click();
16+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '28154'));
17+
});
18+
});
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import DashTable from 'cypress/DashTable';
22

3-
describe('delete', () => {
3+
describe('select row', () => {
44
describe('be pagination & sort', () => {
55
beforeEach(() => cy.visit('http://localhost:8081'));
66

@@ -22,26 +22,4 @@ describe('delete', () => {
2222
DashTable.getSelect(0).within(() => cy.get('input').should('not.be.checked'));
2323
});
2424
});
25-
26-
describe('fe pagination & sort', () => {
27-
beforeEach(() => cy.visit('http://localhost:8080'));
28-
29-
it('can select row', () => {
30-
DashTable.getSelect(0).within(() => cy.get('input').click());
31-
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
32-
});
33-
34-
it('can select row when sorted', () => {
35-
cy.get('tr th.column-0 .sort').click({ force: true });
36-
DashTable.getSelect(0).within(() => cy.get('input').click());
37-
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
38-
});
39-
40-
it('select, sort, new row is not selected', () => {
41-
DashTable.getSelect(0).within(() => cy.get('input').click());
42-
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
43-
cy.get('tr th.column-0 .sort').click({ force: true });
44-
DashTable.getSelect(0).within(() => cy.get('input').should('not.be.checked'));
45-
});
46-
});
4725
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import DashTable from 'cypress/DashTable';
2+
3+
describe('delete', () => {
4+
beforeEach(() => cy.visit('http://localhost:8080'));
5+
6+
it('can delete row', () => {
7+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '1'));
8+
DashTable.getDelete(0).click();
9+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '2'));
10+
});
11+
12+
it('can delete row when sorted', () => {
13+
cy.get('tr th.column-0 .sort').click({ force: true });
14+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '4999'));
15+
DashTable.getDelete(0).click();
16+
DashTable.getCell(0, 0).within(() => cy.get('.dash-cell-value').should('have.html', '4998'));
17+
});
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import DashTable from 'cypress/DashTable';
2+
3+
describe('select row', () => {
4+
describe('fe pagination & sort', () => {
5+
beforeEach(() => cy.visit('http://localhost:8080'));
6+
7+
it('can select row', () => {
8+
DashTable.getSelect(0).within(() => cy.get('input').click());
9+
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
10+
});
11+
12+
it('can select row when sorted', () => {
13+
cy.get('tr th.column-0 .sort').click({ force: true });
14+
DashTable.getSelect(0).within(() => cy.get('input').click());
15+
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
16+
});
17+
18+
it('select, sort, new row is not selected', () => {
19+
DashTable.getSelect(0).within(() => cy.get('input').click());
20+
DashTable.getSelect(0).within(() => cy.get('input').should('be.checked'));
21+
cy.get('tr th.column-0 .sort').click({ force: true });
22+
DashTable.getSelect(0).within(() => cy.get('input').should('not.be.checked'));
23+
});
24+
});
25+
});

tests/e2e/cypress/integration/unit/derivedViewport_test.ts renamed to tests/cypress/tests/unit/derivedViewport_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as R from 'ramda';
22

33
import derivedViewportDataframe from 'dash-table/derived/viewportDataframe';
44

5-
describe.only('derived viewport', () => {
5+
describe('derived viewport', () => {
66
const viewportDataframe = derivedViewportDataframe();
77

88
describe('virtual dataframe <= page size', () => {
@@ -48,7 +48,7 @@ describe.only('derived viewport', () => {
4848
});
4949
});
5050
});
51-
51+
5252
describe('virtual dataframe > page size', () => {
5353
describe('with fe pagination', () => {
5454
it('returns slice of dataframe', () => {
@@ -68,4 +68,4 @@ describe.only('derived viewport', () => {
6868
});
6969
});
7070
});
71-
});
71+
});

tests/e2e/cypress/tsconfig.json renamed to tests/cypress/tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"allowJs": true,
44
"allowSyntheticDefaultImports": true,
5-
"baseUrl": "./..",
5+
"baseUrl": ".",
66
"emitDecoratorMetadata": false,
77
"experimentalDecorators": true,
88
"lib": ["esnext", "dom"],
@@ -12,7 +12,7 @@
1212
"noUnusedLocals": true,
1313
"noUnusedParameters": true,
1414
"paths": {
15-
"cypress/*": ["cypress/src/*"],
15+
"cypress/*": ["./src/*"],
1616
"core/*": ["./../../src/core/*"],
1717
"dash-table/*": ["./../../src/dash-table/*"]
1818

0 commit comments

Comments
 (0)