Skip to content

Commit f856210

Browse files
committed
ci: use playwright in tests instead of selenium
Selenium was having issues doing 3D rendering. Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
1 parent 1756eec commit f856210

32 files changed

+74
-73
lines changed

tests/conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
HELPER = FixtureHelper(ROOT_PATH)
77

88

9-
@pytest.fixture()
10-
def baseline_image():
11-
HELPER.remove_page_urls()
12-
yield
13-
HELPER.remove_page_urls()
9+
@pytest.fixture
10+
def ref_dir() -> Path:
11+
return Path(__file__).parent / "refs"
1412

1513

1614
@pytest.fixture
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- document:
2+
- banner:
3+
- button
4+
- text: Int64 Validation 1
5+
- main:
6+
- img
38.1 KB
Loading

tests/refs/test_rendering_lut.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- document:
2+
- banner:
3+
- button
4+
- text: PyVista Lookup Table N Colors 1
5+
- main:
6+
- img
52.4 KB
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- document:
2+
- banner:
3+
- button
4+
- text: VTK Volume Rendering 1
5+
- main:
6+
- img
75.1 KB
Loading

tests/skip_test_volume_rendering.py

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

tests/test_big_int.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
from pathlib import Path
2-
import pytest
3-
from seleniumbase import SB
42

5-
from trame_client.utils.testing import set_browser_size, baseline_comparison
3+
from playwright.sync_api import Page, expect
4+
import pytest
65

7-
BASELINE_TEST = (
8-
Path(__file__).parent.parent
9-
/ "visual_baseline/test_rendering[examples/validation/PyVistaInt64.py]/init/baseline.png"
6+
from trame_client.utils.testing import (
7+
assert_screenshot_matches,
8+
assert_snapshot_matches,
109
)
1110

1211

1312
@pytest.mark.parametrize("server_path", ["examples/validation/PyVistaInt64.py"])
14-
def test_rendering(server, baseline_image):
15-
with SB() as sb:
16-
url = f"http://127.0.0.1:{server.port}/"
17-
sb.open(url)
18-
set_browser_size(sb, 600, 300)
19-
sb.assert_exact_text("1", ".readyCount")
20-
sb.check_window(name="init", level=3)
13+
def test_rendering(server, page: Page, ref_dir: Path):
14+
url = f"http://127.0.0.1:{server.port}/"
15+
page.goto(url)
16+
17+
page.set_viewport_size({"width": 600, "height": 300})
18+
expect(page.locator(".readyCount")).to_have_text("1")
2119

22-
# The CI is not rendering big int... Not sure why
23-
baseline_comparison(sb, BASELINE_TEST, 0.1)
20+
assert_snapshot_matches(page, ref_dir, "test_rendering_int64")
21+
assert_screenshot_matches(page, ref_dir, "test_rendering_int64", threshold=0.1)

tests/test_remote_rendering.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
from pathlib import Path
2-
import pytest
3-
from seleniumbase import SB
4-
from trame_client.utils.testing import set_browser_size, baseline_comparison
52

3+
from playwright.sync_api import Page, expect
4+
import pytest
65

7-
BASELINE_TEST = (
8-
Path(__file__).parent.parent
9-
/ "visual_baseline/test_rendering[examples/validation/PyVistaLookupTable.py]/init/baseline.png"
6+
from trame_client.utils.testing import (
7+
assert_screenshot_matches,
8+
assert_snapshot_matches,
109
)
1110

1211

1312
@pytest.mark.parametrize("server_path", ["examples/validation/PyVistaLookupTable.py"])
14-
def test_rendering(server, baseline_image):
15-
with SB() as sb:
16-
url = f"http://127.0.0.1:{server.port}/"
17-
sb.open(url)
18-
set_browser_size(sb, 600, 300)
19-
sb.assert_exact_text("1", ".readyCount")
20-
sb.check_window(name="init", level=3)
21-
baseline_comparison(sb, BASELINE_TEST, 0.1)
13+
def test_rendering(server, page: Page, ref_dir: Path):
14+
url = f"http://127.0.0.1:{server.port}/"
15+
page.goto(url)
16+
17+
page.set_viewport_size({"width": 600, "height": 300})
18+
expect(page.locator(".readyCount")).to_have_text("1")
19+
20+
assert_snapshot_matches(page, ref_dir, "test_rendering_lut")
21+
assert_screenshot_matches(page, ref_dir, "test_rendering_lut", threshold=0.1)

0 commit comments

Comments
 (0)