Skip to content

Commit 1c9523f

Browse files
authored
Merge pull request #266 from martinRenou/add_ui_tests
Add ui tests
2 parents fa8afcf + b724334 commit 1c9523f

File tree

59 files changed

+8603
-1167
lines changed

Some content is hidden

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

59 files changed

+8603
-1167
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
coverage
4+
**/*.d.ts
5+
ui-tests
6+
docs

.eslintrc.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/eslint-recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended'
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
project: 'tsconfig.json',
11+
sourceType: 'module'
12+
},
13+
plugins: ['@typescript-eslint'],
14+
rules: {
15+
'@typescript-eslint/naming-convention': [
16+
'error',
17+
{
18+
selector: 'interface',
19+
format: ['PascalCase'],
20+
custom: {
21+
regex: '^I[A-Z]',
22+
match: true
23+
}
24+
}
25+
],
26+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
27+
'@typescript-eslint/no-explicit-any': 'off',
28+
'@typescript-eslint/no-namespace': 'off',
29+
'@typescript-eslint/no-use-before-define': 'off',
30+
'@typescript-eslint/quotes': [
31+
'error',
32+
'single',
33+
{ avoidEscape: true, allowTemplateLiterals: false }
34+
],
35+
curly: ['error', 'all'],
36+
eqeqeq: 'error',
37+
'prefer-arrow-callback': 'error'
38+
}
39+
};

.github/workflows/main.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defaults:
1313
shell: bash -l {0}
1414

1515
jobs:
16-
run:
16+
lint:
1717
runs-on: ${{ matrix.os }}
1818

1919
strategy:
@@ -36,22 +36,6 @@ jobs:
3636
auto-activate-base: false
3737
channels: conda-forge
3838

39-
- name: Install ipycanvas
40-
run: pip install -e .
41-
42-
- name: Check installation files
43-
run: |
44-
test -d $CONDA_PREFIX/share/jupyter/nbextensions/ipycanvas
45-
test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipycanvas/extension.js
46-
test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipycanvas/index.js
47-
test -d $CONDA_PREFIX/share/jupyter/labextensions/ipycanvas
48-
test -f $CONDA_PREFIX/share/jupyter/labextensions/ipycanvas/package.json
49-
50-
- name: Check nbextension and labextension
51-
run: |
52-
jupyter nbextension list 2>&1 | grep -ie "ipycanvas/extension.*enabled" -
53-
jupyter labextension list 2>&1 | grep -ie "ipycanvas.*enabled.*ok" -
54-
5539
- name: Test PEP8
5640
run: black --check ipycanvas
5741

@@ -87,18 +71,16 @@ jobs:
8771
name: dist ${{ github.run_number }}
8872
path: ./dist
8973

90-
install:
74+
tests:
9175
runs-on: ${{ matrix.os }}-latest
9276
needs: [build]
9377

9478
strategy:
9579
fail-fast: false
9680
matrix:
97-
os: [ubuntu, macos]
98-
python: ['3.7', '3.10']
81+
os: [ubuntu]
82+
python: ['3.10']
9983
include:
100-
- python: '3.7'
101-
dist: 'ipycanvas*.tar.gz'
10284
- python: '3.10'
10385
dist: 'ipycanvas*.whl'
10486

@@ -142,3 +124,32 @@ jobs:
142124

143125
- name: Validate the labextension
144126
run: jupyter labextension list 2>&1 | grep ipycanvas
127+
128+
- name: Install Galata
129+
run: |
130+
yarn install
131+
yarn playwright install chromium
132+
working-directory: ui-tests
133+
134+
- name: Launch JupyterLab
135+
run: yarn run start:detached
136+
working-directory: ui-tests
137+
138+
- name: Wait for JupyterLab
139+
uses: ifaxity/wait-on-action@v1
140+
with:
141+
resource: http-get://localhost:8888/api
142+
timeout: 20000
143+
144+
- name: Run UI Tests
145+
run: yarn run test
146+
working-directory: ui-tests
147+
148+
- name: Upload UI Test artifacts
149+
if: always()
150+
uses: actions/upload-artifact@v2
151+
with:
152+
name: ui-test-output
153+
path: |
154+
ui-tests/playwright-report
155+
ui-tests/test-results

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,7 @@ package-lock.json
161161

162162
# Untitled notebooks
163163
*Untitled*.ipynb
164+
165+
# UI tests
166+
ui-tests/tests/notebooks/smoke_texture0.png
167+
ui-tests/tests/notebooks/smoke_texture1.png

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
dist
3+
**/node_modules
4+
**/lib
5+
**/package.json
6+
ui-tests
7+
ipycanvas
8+
docs

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "none",
4+
"arrowParens": "avoid",
5+
"endOfLine": "auto"
6+
}

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ If you have any question, or if you want to share what you do with ipycanvas, [s
2626

2727
Or join the gitter channel: [![Join the chat at https://gitter.im/martinRenou/ipycanvas](https://badges.gitter.im/martinRenou/ipycanvas.svg)](https://gitter.im/martinRenou/ipycanvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2828

29-
3029
## Installation
3130

3231
You can install using `pip`:
@@ -48,24 +47,30 @@ conda install -c conda-forge yarn
4847
jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas
4948
```
5049

51-
A development installation guide, can be found [here](https://ipycanvas.readthedocs.io/en/latest/installation.html#development-installation)
50+
A development installation guide, can be found [here](https://ipycanvas.readthedocs.io/en/latest/installation.html#development-installation)
5251

5352
## Examples
5453

5554
### Create John Conway's Game Of Life
55+
5656
![John Conway's Game Of Life](docs/source/images/ipycanvas_gameoflife.png)
5757

5858
### Give a "hand-drawn" style to your drawings using the RoughCanvas
59+
5960
![RoughCanvas](docs/source/images/ipycanvas_rough.png)
6061

6162
### Draw Particles from IPython
63+
6264
![Particles](docs/source/images/ipycanvas_particles.png)
6365

6466
### Custom Sprites
67+
6568
![Sprites](docs/source/images/ipycanvas_sprites.png)
6669

6770
### Draw data directly from a NumPy array
71+
6872
![NumPy](docs/source/images/ipycanvas_binary.png)
6973

7074
### Create your own plotting library **fully** in Python
75+
7176
![Plotting](docs/source/images/ipycanvas_scatter.png)

dev-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dependencies:
1111
- wheel
1212
- twine
1313
- jupytext
14-
- black=22.1.0
14+
- black

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
"clean:lib": "rimraf lib",
4040
"clean:nbextension": "rimraf ipycanvas/nbextension/static/index.js",
4141
"clean:labextension": "rimraf ipycanvas/labextension",
42+
"lint": "yarn prettier && yarn eslint",
43+
"lint:check": "yarn prettier:check && yarn eslint:check",
44+
"prettier": "yarn prettier:base --write --list-different",
45+
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
46+
"prettier:check": "yarn prettier:base --check",
4247
"prepack": "yarn run build",
4348
"watch:lib": "tsc -w",
4449
"watch:nbextension": "webpack --watch"
@@ -55,10 +60,16 @@
5560
"@phosphor/widgets": "^1.6.0",
5661
"@types/node": "^10.11.6",
5762
"@types/webpack-env": "^1.13.6",
63+
"@typescript-eslint/eslint-plugin": "^4.8.1",
64+
"@typescript-eslint/parser": "^4.8.1",
5865
"acorn": "^6.2.0",
66+
"eslint": "^7.3.1",
67+
"eslint-config-prettier": "^6.11.0",
68+
"eslint-plugin-prettier": "^3.1.4",
5969
"expect.js": "^0.3.1",
6070
"fs-extra": "^7.0.0",
6171
"mkdirp": "^0.5.1",
72+
"prettier": "^2.0.5",
6273
"rimraf": "^2.6.2",
6374
"source-map-loader": "^0.2.4",
6475
"ts-loader": "^5.2.1",

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// Some static assets may be required by the custom widget javascript. The base
99
// url for the notebook is not known at build time and is therefore computed
1010
// dynamically.
11-
(window as any).__webpack_public_path__ = document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/ipycanvas';
11+
(window as any).__webpack_public_path__ =
12+
document.querySelector('body')!.getAttribute('data-base-url') +
13+
'nbextensions/ipycanvas';
1214

1315
export * from './index';

0 commit comments

Comments
 (0)