Skip to content

Commit fe01e56

Browse files
authored
Merge pull request #25 from yacchin1205/feature/e2e-tests
Add E2E tests
2 parents bd76654 + 0401d7b commit fe01e56

14 files changed

+1918
-10
lines changed

.dockerignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
lib/
2+
node_modules/
3+
components/lib/
4+
components/node_modules/
5+
nbextension/lib/
6+
nbextension/node_modules/
7+
nbextension/diff_match_patch.js
8+
lc_notebook_diff/labextension/
9+
lc_notebook_diff/nbextension/diff_match_patch.js
10+
lc_notebook_diff/nbextension/jupyter-notebook-diff.js
11+
lc_notebook_diff/nbextension/jupyter-notebook-diff.js.map
12+
*.tsbuildinfo
13+
ui-tests/test-results/
14+
ui-tests/playwright-report/
15+
ui-tests/e2e-notebook/artifacts/
16+
.git/
17+
.github/
18+
.eslintcache
19+
.stylelintcache
20+
__pycache__/
21+
.DS_Store

.github/workflows/e2e-tests.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
notebook-e2e:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Cache pip dependencies
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-${{ hashFiles('ui-tests/e2e-notebook/requirements.txt') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
33+
- name: Install Python dependencies
34+
run: |
35+
set -euxo pipefail
36+
pip install --upgrade pip
37+
pip install -r ui-tests/e2e-notebook/requirements.txt
38+
39+
- name: Install Playwright browsers
40+
run: |
41+
set -euxo pipefail
42+
python -m playwright install --with-deps
43+
44+
- name: Build Docker image
45+
run: |
46+
set -euxo pipefail
47+
docker build -t lc_notebook_diff:test .
48+
49+
- name: Prepare test workspace
50+
run: |
51+
set -euxo pipefail
52+
mkdir -p ui-tests/e2e-notebook/artifacts/jupyter-work
53+
cp -r html/* ui-tests/e2e-notebook/artifacts/jupyter-work/
54+
chmod -R a+w ui-tests/e2e-notebook/artifacts/jupyter-work
55+
56+
- name: Start lc_notebook_diff container
57+
run: |
58+
set -euxo pipefail
59+
docker run -d \
60+
--name lc-notebook-diff-test \
61+
-p 8888:8888 \
62+
-v $(pwd)/ui-tests/e2e-notebook/artifacts/jupyter-work:/home/jovyan/work \
63+
lc_notebook_diff:test \
64+
start-notebook.sh --ServerApp.token='test-token' --ServerApp.allow_origin='*' --ServerApp.root_dir='/home/jovyan/work'
65+
sleep 30
66+
# Health check
67+
curl --retry 10 --retry-delay 5 --retry-connrefused --fail http://localhost:8888/lab?token=test-token || (docker logs lc-notebook-diff-test && exit 1)
68+
69+
- name: Run notebook E2E tests
70+
env:
71+
E2E_TRANSITION_TIMEOUT: '60000'
72+
E2E_DEFAULT_DELAY: '200'
73+
JUPYTERLAB_URL: 'http://localhost:8888/lab?token=test-token'
74+
NOTEBOOK7_URL: 'http://localhost:8888/tree?token=test-token'
75+
NBCLASSIC_URL: 'http://localhost:8888/nbclassic/tree?token=test-token'
76+
JUPYTER_WORK_DIR: ${{ github.workspace }}/ui-tests/e2e-notebook/artifacts/jupyter-work
77+
run: |
78+
set -euxo pipefail
79+
python ui-tests/e2e-notebook/run_notebooks.py --skip-failed-test
80+
81+
- name: Gather Docker logs
82+
if: always()
83+
run: |
84+
set -euxo pipefail
85+
mkdir -p ui-tests/e2e-notebook/artifacts
86+
docker logs lc-notebook-diff-test > ui-tests/e2e-notebook/artifacts/lc-notebook-diff-container.log 2>&1 || true
87+
88+
- name: Upload artifacts
89+
if: always()
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: e2e-results
93+
path: |
94+
ui-tests/e2e-notebook/artifacts
95+
96+
- name: Shutdown container
97+
if: always()
98+
run: |
99+
set -euxo pipefail
100+
docker stop lc-notebook-diff-test || true
101+
docker rm lc-notebook-diff-test || true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ lc_notebook_diff/_version.py
1414
# Integration tests
1515
ui-tests/test-results/
1616
ui-tests/playwright-report/
17+
ui-tests/e2e-notebook/artifacts/
1718

1819
# Created by https://www.gitignore.io/api/python
1920
# Edit at https://www.gitignore.io/?templates=python

Dockerfile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
FROM jupyter/scipy-notebook:latest
1+
FROM quay.io/jupyter/scipy-notebook:notebook-7.4.7
22

33
USER root
44

5-
### extensions for jupyter
5+
# Install Node.js 20.x (required for Etherpad build)
6+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
7+
apt-get install -y nodejs && \
8+
apt-get clean && \
9+
mkdir -p /.npm && \
10+
chown jovyan:users -R /.npm && \
11+
rm -rf /var/lib/apt/lists/*
12+
ENV NPM_CONFIG_PREFIX=/.npm
13+
ENV PATH=/.npm/bin/:${PATH}
14+
15+
RUN pip install --no-cache jupyter_nbextensions_configurator
16+
617
COPY . /tmp/notebook_diff
7-
RUN pip --no-cache-dir install jupyter_nbextensions_configurator \
8-
/tmp/notebook_diff
18+
RUN cd /tmp/notebook_diff/components && npm install && npm run build && \
19+
cd /tmp/notebook_diff/nbextension && npm install && npm run build && \
20+
pip install --no-cache /tmp/notebook_diff
21+
922
RUN jupyter labextension enable lc_notebook_diff
1023

1124
RUN jupyter nbclassic-extension install --py jupyter_nbextensions_configurator --sys-prefix && \

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ Jupyter-LC\_notebook\_diff is an extension that compares two or three Jupyter no
99

1010
## Install
1111

12-
To install the extension, execute:
12+
To install the extension, download the tar.gz file from the [latest release](https://github.com/NII-cloud-operation/Jupyter-LC_notebook_diff/releases) and execute:
1313

1414
```bash
15-
$ pip install git+https://github.com/NII-cloud-operation/Jupyter-LC_notebook_diff.git
15+
$ pip install lc_notebook_diff-*.tar.gz
1616
```
1717

18-
To use the extension you will also need to install and enable, you can use Jupyter subcommand:
18+
For nbclassic users, you will also need to install and enable the extension:
1919

20-
```
21-
$ jupyter nbclassic-extension install --py lc_notebook_diff
22-
$ jupyter nbclassic-extension enable --py lc_notebook_diff
20+
```bash
21+
$ jupyter nbclassic-extension install --py lc_notebook_diff --sys-prefix
22+
$ jupyter nbclassic-extension enable --py lc_notebook_diff --sys-prefix
2323
```
2424

2525
then restart Jupyter notebook.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ exclude = [".github", "binder"]
4747
[tool.hatch.build.targets.wheel.shared-data]
4848
"lc_notebook_diff/labextension" = "share/jupyter/labextensions/lc_notebook_diff"
4949
"install.json" = "share/jupyter/labextensions/lc_notebook_diff/install.json"
50+
"lc_notebook_diff/nbextension" = "share/jupyter/nbextensions/notebook_diff"
5051

5152
[tool.hatch.build.hooks.version]
5253
path = "lc_notebook_diff/_version.py"

ui-tests/e2e-notebook/notebooks/01_Basic_Notebook_Diff_Test_JupyterLab.ipynb

Lines changed: 462 additions & 0 deletions
Large diffs are not rendered by default.

ui-tests/e2e-notebook/notebooks/02_Basic_Notebook_Diff_Test_Notebook7.ipynb

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

ui-tests/e2e-notebook/notebooks/03_Basic_Notebook_Diff_Test_NBClassic.ipynb

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.

ui-tests/e2e-notebook/notebooks/scripts/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)