Skip to content

Commit 550cb68

Browse files
author
Dou Du
committed
update the test workflow
1 parent 94de3a4 commit 550cb68

File tree

3 files changed

+73
-16
lines changed

3 files changed

+73
-16
lines changed
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Voila test
1+
name: screenshot comparison
22

33
on:
44
push:
@@ -9,27 +9,27 @@ on:
99
- '*'
1010

1111
jobs:
12-
voila:
12+
check-screenshot:
13+
name: Check Screenshot
1314
runs-on: ubuntu-latest
1415
steps:
1516
- name: Checkout
16-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1718
- name: Install node
18-
uses: actions/setup-node@v1
19+
uses: actions/setup-node@v4
1920
with:
20-
node-version: '18.x'
21+
node-version: '21.x'
2122
- name: Install Python
22-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v5
2324
with:
24-
python-version: '3.9'
25+
python-version: '3.11'
2526
architecture: 'x64'
2627
- name: Install dependencies
2728
run:
2829
pip install --upgrade pip
2930
pip install --upgrade jupyterlab
3031
pip install --upgrade voila
3132
pip install --upgrade voila-osscar-template
32-
pip install --upgrade ase
3333
pip install -e .
3434

3535
- name: Run the voila server
@@ -45,13 +45,5 @@ jobs:
4545
chromedriver --url-base=/wd/hub &
4646
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
4747
python3 $GITHUB_WORKSPACE/test/test.py
48-
49-
- uses: actions/upload-artifact@v2
50-
with:
51-
name: quantum-screenshot
52-
path: './*.png'
53-
54-
- name: Run the figures test
55-
run: |
5648
python3 $GITHUB_WORKSPACE/test/test_figures.py
5749

.github/workflows/widget-test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: widget test
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
check-elements:
13+
name: Check Element
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Install node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '21.x'
22+
- name: Install Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.11'
26+
architecture: 'x64'
27+
- name: Install dependencies
28+
run:
29+
pip install --upgrade pip
30+
pip install --upgrade jupyterlab
31+
pip install --upgrade voila
32+
pip install --upgrade voila-osscar-template
33+
pip install -e .
34+
35+
- name: Run the voila server
36+
run: |
37+
voila --template=osscar --enable_nbextensions=True example/ --port 8383 --no-browser &
38+
pip install --upgrade pytest
39+
pip install --upgrade selenium
40+
pip install --upgrade Pillow
41+
42+
- uses: nanasess/setup-chromedriver@master
43+
- run: |
44+
export DISPLAY=:99
45+
chromedriver --url-base=/wd/hub &
46+
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
47+
python3 $GITHUB_WORKSPACE/test/test.py
48+
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: artifact
52+
path: './*.png'
53+

test/test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ def setup_method(self, method):
2323
def teardown_method(self, method):
2424
self.driver.quit()
2525

26+
def test_elements(self):
27+
self.driver.get("http://localhost:8383/voila/render/example.ipynb")
28+
self.driver.set_window_size(1280, 1080)
29+
time.sleep(3)
30+
31+
try:
32+
self.driver.find_element(By.CLASS_NAME, 'bz-canvas3d')
33+
print("Brillouin zone visualizer is fund!")
34+
except:
35+
raise Exception("The visualizer is NOT found!!!")
36+
2637
def download_widget_image(self):
2738
self.driver.get("http://localhost:8383/voila/render/example.ipynb")
2839
self.driver.set_window_size(1280, 720)
@@ -35,5 +46,6 @@ def download_widget_image(self):
3546
test = test_widget()
3647
test.setup_method('Chrome')
3748
test.download_widget_image()
49+
test.test_elements()
3850
test.teardown_method('Chrome')
3951

0 commit comments

Comments
 (0)