Skip to content

Commit eed95c7

Browse files
bourdakos1lresende
authored andcommitted
Add test cases and CI integration (elyra-ai#58)
1 parent a18d629 commit eed95c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+12540
-803
lines changed

.codesandbox/ci.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"sandboxes": ["new"]
3+
}

.eslintrc.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,19 @@ const allExtensions = [".ts", ".tsx", ".d.ts", ".js", ".jsx"];
1818

1919
module.exports = {
2020
root: true,
21-
extends: "react-app",
21+
extends: [
22+
"react-app",
23+
"plugin:jest/recommended",
24+
"plugin:jest/style",
25+
"plugin:testing-library/react",
26+
"plugin:jest-dom/recommended",
27+
],
2228
plugins: ["import", "header"],
2329
rules: {
30+
"testing-library/prefer-screen-queries": ["warn"],
31+
"jest/no-large-snapshots": ["warn", { maxSize: 20 }],
32+
"jest/expect-expect": ["off"],
33+
"jest/valid-title": ["off"],
2434
"header/header": [
2535
"warn",
2636
"block",
@@ -86,7 +96,17 @@ module.exports = {
8696
},
8797
overrides: [
8898
{
89-
files: ["webpack.*.js"],
99+
files: ["cypress/**"],
100+
rules: {
101+
"testing-library/prefer-screen-queries": "off",
102+
},
103+
},
104+
{
105+
files: ["stories/**"],
106+
rules: { "import/no-anonymous-default-export": ["off"] },
107+
},
108+
{
109+
files: ["webpack.*.js", "*.test.tsx", "*.test.ts", "cypress/**"],
90110
rules: {
91111
"import/no-extraneous-dependencies": [
92112
"warn",

.github/workflows/size.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Bundle Size
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
name: Check compressed size
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2-beta
12+
with:
13+
fetch-depth: 1
14+
- uses: preactjs/compressed-size-action@v1
15+
with:
16+
repo-token: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/build.yml renamed to .github/workflows/test.yaml

+14-9
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
name: Elyra Pipeline Editor Tests
16+
name: Tests
17+
1718
on:
1819
push:
19-
branches: '*'
2020
pull_request:
21-
branches: '*'
2221
schedule:
2322
# once a day at 3 am (UTC) (7 pm (PST))
2423
- cron: '0 3 * * *'
@@ -30,7 +29,7 @@ jobs:
3029

3130
strategy:
3231
matrix:
33-
node-version: [10.x, 12.x, 14.x, 15.x]
32+
node-version: [12.x, 14.x, 15.x]
3433

3534
steps:
3635
- uses: actions/checkout@v2
@@ -43,14 +42,20 @@ jobs:
4342
- name: Install dependencies
4443
run: yarn --frozen-lockfile
4544

45+
- name: Lint
46+
run: make lint
47+
env:
48+
FORCE_COLOR: true
49+
4650
- name: Build
4751
run: make build
52+
env:
53+
FORCE_COLOR: true
4854

4955
- name: Test
5056
run: make test
57+
env:
58+
FORCE_COLOR: true
5159

52-
- name: Test
53-
run: make test
54-
55-
- name: Lint
56-
run: make lint
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v1

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
cypress/videos
2+
cypress/screenshots
3+
14
# production
25
dist
36
build

.storybook/main.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
stories: [
3+
"../stories/**/*.stories.mdx",
4+
"../stories/**/*.stories.@(js|jsx|ts|tsx)",
5+
],
6+
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
7+
};

.storybook/preview.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const parameters = {
2+
actions: { argTypesRegex: "^on[A-Z].*" },
3+
};

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ clean:
66
.PHONY: install
77
install:
88
yarn install
9-
yarn lerna bootstrap
109

1110
.PHONY: link
1211
link:
@@ -30,4 +29,5 @@ lint:
3029

3130
.PHONY: test
3231
test:
33-
yarn lerna run test --stream
32+
yarn jest --coverage
33+
yarn test:cypress

cypress.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"baseUrl": "http://localhost:6006",
3+
"video": false
4+
}

cypress/.eslintrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
plugins: ["cypress"],
19+
env: {
20+
"cypress/globals": true,
21+
},
22+
};

cypress/integration/no-toolbar.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
describe("no toolbar", () => {
18+
before(() => {
19+
cy.visit("/iframe.html?id=example-pipelineeditor--no-toolbar");
20+
});
21+
22+
it("renders empty pipeline message", () => {
23+
cy.findByText(/your flow is empty/i).should("exist");
24+
});
25+
});

cypress/plugins/index.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = (_on, _config) => {
18+
// `on` is used to hook into various events Cypress emits
19+
// `config` is the resolved Cypress config
20+
};

cypress/support/index.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import "@testing-library/cypress/add-commands";

cypress/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"compilerOptions": {
4+
"isolatedModules": false,
5+
"target": "es5",
6+
"lib": ["es5", "dom"],
7+
"types": ["cypress", "@testing-library/cypress"]
8+
},
9+
"include": ["**/*.ts"]
10+
}

jest.config.base.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2018-2021 Elyra Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
preset: "ts-jest",
19+
testEnvironment: "node",
20+
testMatch: [
21+
// Match all typescript tests.
22+
"**/*.test.{ts,tsx}",
23+
// Ignore snapshot tests.
24+
"!**/*.snap.test.{ts,tsx}",
25+
],
26+
};

jest.config.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515
*/
1616

1717
module.exports = {
18-
preset: "ts-jest",
19-
testEnvironment: "node",
20-
roots: ["<rootDir>/src"],
18+
collectCoverageFrom: [
19+
// Collect coverage for all typescript files.
20+
"**/*.{ts,tsx}",
21+
// Ignore `src/index.ts`, because it should only be exports.
22+
"!**/src/index.ts",
23+
// Ignore any typescript declaration files.
24+
"!**/*.d.ts",
25+
// Ignore any test utils.
26+
"!**/test-utils.{ts,tsx}",
27+
// ignore tests and snapshot tests.
28+
"!**/*.test.{ts,tsx}",
29+
],
30+
coverageReporters: ["lcov", "text"],
31+
projects: ["<rootDir>/packages/*"],
2132
};

package.json

+25-1
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,37 @@
1414
},
1515
"main": "./packages/extension/dist/index.js",
1616
"devDependencies": {
17+
"@babel/core": "^7.13.8",
18+
"@storybook/addon-actions": "^6.1.20",
19+
"@storybook/addon-essentials": "^6.1.20",
20+
"@storybook/addon-links": "^6.1.20",
21+
"@storybook/react": "^6.1.20",
22+
"@testing-library/cypress": "^7.0.4",
1723
"@types/jest": "^26.0.20",
1824
"@typescript-eslint/eslint-plugin": "^4.5.0",
1925
"@typescript-eslint/parser": "^4.5.0",
2026
"babel-eslint": "^10.0.0",
27+
"babel-loader": "^8.2.2",
28+
"core-js": "^3.9.1",
29+
"cypress": "^6.6.0",
2130
"eslint": "^7.11.0",
2231
"eslint-config-react-app": "^6.0.0",
32+
"eslint-plugin-cypress": "^2.11.2",
2333
"eslint-plugin-flowtype": "^5.2.0",
2434
"eslint-plugin-header": "^3.1.0",
2535
"eslint-plugin-import": "^2.22.1",
2636
"eslint-plugin-jest": "^24.1.0",
37+
"eslint-plugin-jest-dom": "^3.6.5",
2738
"eslint-plugin-jsx-a11y": "^6.3.1",
2839
"eslint-plugin-react": "^7.21.5",
2940
"eslint-plugin-react-hooks": "^4.2.0",
41+
"eslint-plugin-testing-library": "^3.10.1",
3042
"husky": "^3.1.0",
3143
"jest": "^26.6.3",
3244
"lerna": "^3.22.1",
3345
"lint-staged": "^9.4.3",
3446
"prettier": "^2.2.1",
47+
"start-server-and-test": "^1.12.0",
3548
"ts-jest": "^26.5.1",
3649
"typescript": "4.1.3"
3750
},
@@ -45,5 +58,16 @@
4558
"prettier --write",
4659
"git add"
4760
]
48-
}
61+
},
62+
"scripts": {
63+
"postinstall": "lerna bootstrap",
64+
"build": "lerna run build",
65+
"sb:start": "start-storybook -p 6006",
66+
"sb:ci": "start-storybook -p 6006 --ci",
67+
"test:cypress:dev": "start-server-and-test sb:ci http://localhost:6006 cy:open",
68+
"test:cypress": "start-server-and-test sb:ci http://localhost:6006 cy:run",
69+
"cy:run": "cypress run",
70+
"cy:open": "cypress open"
71+
},
72+
"dependencies": {}
4973
}

packages/pipeline-editor/jest.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
const baseConfig = require("../../jest.config");
17+
const baseConfig = require("../../jest.config.base");
1818

1919
module.exports = {
2020
...baseConfig,
21+
testEnvironment: "jest-environment-jsdom",
22+
setupFilesAfterEnv: [
23+
"@testing-library/jest-dom/extend-expect",
24+
"./jest.setup.js",
25+
],
26+
roots: ["<rootDir>/src"],
2127
};

0 commit comments

Comments
 (0)