Skip to content

Commit 65f5ed8

Browse files
authored
Merge pull request #1019 from MLH-Fellowship/feat/integration-testing
Add Integration Tests
2 parents b4876a4 + d985a5a commit 65f5ed8

18 files changed

+1751
-82
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
coverage
44
**/*.d.ts
55
tests
6+
ui-tests

.github/workflows/build.yml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ on:
44
push:
55
branches: master
66
pull_request:
7-
branches: "*"
7+
branches: '*'
88

99
jobs:
1010
test-3x:
1111
name: Test Python ${{ matrix.python-version }}
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: ["3.6", "3.7", "3.8", "3.9"]
15+
python-version: ['3.6', '3.7', '3.8', '3.9']
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v2
1919
- name: Install node
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: "12.x"
22+
node-version: '12.x'
2323
- name: Setup Python ${{ matrix.python-version }}
2424
uses: actions/setup-python@v2
2525
with:
2626
python-version: ${{ matrix.python-version }}
27-
architecture: "x64"
27+
architecture: 'x64'
2828

2929
- name: Get pip cache dir
3030
id: pip-cache
@@ -84,3 +84,48 @@ jobs:
8484
python -m jupyterlab.browser_check
8585
# Run our extension-specific browser integration test
8686
# python tests/test-browser/run_browser_test.py
87+
88+
- uses: actions/upload-artifact@v2
89+
if: matrix.python-version == '3.9'
90+
with:
91+
name: extension
92+
path: |
93+
jupyterlab_git
94+
jupyter-config
95+
96+
ui-test:
97+
name: Integration tests
98+
runs-on: ubuntu-latest
99+
100+
needs: test-3x
101+
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@v2
105+
- uses: actions/download-artifact@v2
106+
with:
107+
name: extension
108+
109+
- name: UI tests
110+
run: |
111+
docker-compose -f ./docker/docker-compose.yml down || true
112+
docker-compose -f ./docker/docker-compose.yml pull -q || true
113+
docker-compose -f ./docker/docker-compose.yml build
114+
docker-compose -f ./docker/docker-compose.yml run --rm e2e
115+
working-directory: ui-tests
116+
117+
- name: Upload UI Test artifacts
118+
if: always()
119+
uses: actions/upload-artifact@v2
120+
with:
121+
name: ui-test-output
122+
path: |
123+
ui-tests/test-results
124+
125+
- name: Stop containers
126+
if: always()
127+
run: |
128+
# Print jupyterlab logs before removing the containers using the container name set in docker-compose file
129+
docker logs jupyterlab
130+
docker-compose -f ./docker/docker-compose.yml down
131+
working-directory: ui-tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,7 @@ dmypy.json
135135
*.swp
136136

137137
src/version.ts
138+
139+
# Integration tests
140+
ui-tests/node_modules/
141+
ui-tests/test-results/

examples/demo.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin luctus nec arcu quis accumsan. Vivamus facilisis egestas commodo.
2+
Aenean mollis sodales auctor. Vestibulum fermentum feugiat dui efficitur porttitor. Maecenas id lectus velit. Phasellus vel
3+
quam faucibus, tristique velit vitae, laoreet dui. Vivamus id eros finibus, dictum risus eu, placerat lectus. Suspendisse
4+
potenti. Proin fermentum, magna sed finibus rutrum, felis enim sollicitudin felis, at condimentum urna elit vel velit. Class
5+
aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec et massa sed dolor ornare suscipit.
6+
Vivamus hendrerit turpis ligula, blandit tincidunt metus volutpat eu. Nulla tellus ligula, tempus et purus dapibus, molestie
7+
blandit ex. Donec convallis magna magna, eu iaculis ex venenatis in. Nam at convallis dolor. Aliquam erat volutpat.
8+
9+
Fusce varius lectus vitae tellus mollis ultrices. Ut id gravida ipsum. Vivamus eleifend felis in aliquet pellentesque. Nullam
10+
vitae placerat lacus. Proin accumsan, massa eget mollis convallis, justo augue dapibus leo, at luctus velit elit nec ipsum. Ut
11+
eros nisi, iaculis in lorem vel, fermentum hendrerit magna. Orci varius natoque penatibus et magnis dis parturient montes,
12+
nascetur ridiculus mus. Etiam non faucibus eros. Aenean nisl massa, facilisis ac quam in, elementum consectetur risus. Maecenas
13+
sagittis rhoncus orci at egestas.
14+
15+
Vivamus nec odio ac libero porttitor mattis. Morbi ac tincidunt velit, a aliquet ipsum. Etiam a aliquet massa. In dapibus,
16+
ex malesuada aliquam dictum, enim ante suscipit est, in tempus tortor felis sed nunc. Vestibulum ante ipsum primis in faucibus
17+
orci luctus et ultrices posuere cubilia curae; Phasellus sodales sit amet justo gravida sagittis. Pellentesque habitant morbi
18+
tristique senectus et netus et malesuada fames ac turpis egestas. Ut vulputate facilisis felis, ac scelerisque tortor
19+
condimentum sed. Nulla ut consequat risus. Aenean volutpat facilisis luctus. Phasellus at egestas sapien, in blandit dolor.
20+
Vestibulum commodo ligula ut orci rhoncus, eu cursus diam luctus. Pellentesque at accumsan tortor, non tempor nunc. Phasellus
21+
ultricies consequat libero, quis tempus mauris auctor quis. Fusce bibendum augue sed augue sollicitudin, eu volutpat turpis
22+
vestibulum. Proin auctor aliquam nisi a dapibus.
23+
24+
Nam eget finibus elit. Cras in sapien ante. Curabitur facilisis interdum ligula, ut molestie orci molestie sit amet. Etiam
25+
euismod rhoncus velit, sit amet tempor magna egestas quis. In sed nunc porta, tincidunt risus ornare, elementum lorem. Class
26+
aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed quis velit ac leo eleifend efficitur
27+
at id velit. In et ante tempus, sollicitudin dui at, euismod est. Aenean eleifend scelerisque turpis, id egestas turpis dictum
28+
nec.
29+
30+
Praesent luctus, neque et egestas hendrerit, lorem sapien varius lacus, sit amet tincidunt nisi orci quis lacus. Pellentesque
31+
suscipit accumsan mi vel convallis. Fusce ullamcorper scelerisque augue id sollicitudin. Curabitur tempus nec diam in
32+
pellentesque. Maecenas suscipit ex id facilisis posuere. Proin rutrum blandit leo. Donec bibendum velit vel ipsum mattis rutrum.
33+
Nulla eu enim vel neque ultricies hendrerit eget sed turpis. Mauris efficitur lectus id mi sollicitudin, ultricies tempor
34+
tellus molestie. Phasellus mollis odio risus, ut fringilla tellus eleifend ac. Interdum et malesuada fames ac ante ipsum
35+
primis in faucibus. Nulla eu neque consequat sem aliquam semper quis eget arcu.

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
'<rootDir>/jupyter-config'
2727
],
2828
setupFiles: ['<rootDir>/testutils/jest-setup-files.js'],
29-
testPathIgnorePatterns: ['/lib/', '/node_modules/', '/jupyterlab_git/'],
29+
testPathIgnorePatterns: ['/lib/', '/node_modules/', '/jupyterlab_git/', '/ui-tests/'],
3030
testRegex: '/tests/.*.spec.ts[x]?$',
3131
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`],
3232
globals: {

tests/test-browser/chrome-test.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

tests/test-browser/run_browser_test.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

ui-tests/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Test
2+
3+
The test will produce a video to help debugging and check what happened.
4+
5+
To execute integration tests, you have two options:
6+
7+
- use docker-compose (cons: needs to know and use docker) - this is a more reliable solution.
8+
- run tests locally (cons: will interact with your JupyterLab user settings)
9+
10+
## Test on docker
11+
12+
1. Compile the extension:
13+
14+
```
15+
jlpm install
16+
```
17+
18+
2. Execute the docker stack in the ui-tests folder:
19+
20+
```
21+
docker-compose -f ./docker/docker-compose.yml build --no-cache
22+
docker-compose -f ./docker/docker-compose.yml run --rm e2e
23+
docker-compose -f ./docker/docker-compose.yml down
24+
```
25+
26+
## Test locally
27+
28+
1. Compile the extension:
29+
30+
```
31+
jlpm install
32+
jlpm run build:prod
33+
```
34+
35+
2. Start JupyterLab _with the extension installed_ without any token or password
36+
37+
```
38+
jupyter lab --ServerApp.token= --ServerApp.password=
39+
```
40+
41+
3. Execute in another console the [Playwright](https://playwright.dev/docs/intro) tests:
42+
43+
```
44+
cd ui-tests
45+
jlpm install
46+
npx playwright install
47+
npx playwright test
48+
```
49+
50+
# Create tests
51+
52+
To create tests, the easiest way is to use the code generator tool of playwright:
53+
54+
1. Compile the extension:
55+
56+
```
57+
jlpm install
58+
jlpm run build:prod
59+
```
60+
61+
2. Start JupyterLab _with the extension installed_ without any token or password:
62+
63+
**Using docker**
64+
65+
```
66+
docker-compose -f ./docker/docker-compose.yml run --rm -p 8888:8888 lab
67+
```
68+
69+
**Using local installation**
70+
71+
```
72+
jupyter lab --ServerApp.token= --ServerApp.password=
73+
```
74+
75+
3. Launch the code generator tool:
76+
77+
```
78+
cd ui-tests
79+
jlpm install
80+
npx playwright install
81+
npx playwright codegen localhost:8888
82+
```
83+
84+
# Debug tests
85+
86+
To debug tests, a good way is to use the inspector tool of playwright:
87+
88+
1. Compile the extension:
89+
90+
```
91+
jlpm install
92+
jlpm run build:prod
93+
```
94+
95+
2. Start JupyterLab _with the extension installed_ without any token or password:
96+
97+
**Using docker**
98+
99+
```
100+
docker-compose -f ./docker/docker-compose.yml run --rm -p 8888:8888 lab
101+
```
102+
103+
**Using local installation**
104+
105+
```
106+
jupyter lab --ServerApp.token= --ServerApp.password=
107+
```
108+
109+
3. Launch the debug tool:
110+
111+
```
112+
cd ui-tests
113+
jlpm install
114+
npx playwright install
115+
PWDEBUG=1 npx playwright test
116+
```

ui-tests/docker/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Use base jupyter image that comes with jupyterlab
2+
FROM jupyter/base-notebook
3+
4+
USER root
5+
6+
# Upgrade JupyterLab
7+
RUN mamba install -c conda-forge -y git jupyterlab nbdime
8+
9+
# Copy and unarchive merge conflict example repo
10+
# Cannot use symlinks, need another examples folder just for ui-tests
11+
ADD --chown=1000:1000 data/merge-conflict-example.tar.gz /home/jovyan/work
12+
13+
USER 1000
Binary file not shown.

0 commit comments

Comments
 (0)