Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
run: |
pip install .[dev]
pip install -r tests/requirements.txt
playwright install

- name: Install OSMesa for Linux
if: matrix.config.os == 'ubuntu-latest'
Expand All @@ -72,7 +73,7 @@ jobs:
- name: Run Tests
run: |
# Run the tests with coverage so we get a coverage report too
coverage run --source . -m pytest ./tests --firefox --headless --html=report-${{ matrix.config.name }}-${{ matrix.python-version }}.html
coverage run --source . -m pytest ./tests
# Print the coverage report
coverage report -m

Expand All @@ -85,9 +86,9 @@ jobs:
with:
name: pytest-results-${{ matrix.config.name }}
path: |
visual_baseline/**/*.png
tests/refs/*.yml
tests/refs/**/*.png
assets/**
report-*.html
retention-days: 1

release:
Expand Down Expand Up @@ -120,4 +121,4 @@ jobs:

- name: Publish package distributions to PyPI
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
8 changes: 3 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
HELPER = FixtureHelper(ROOT_PATH)


@pytest.fixture()
def baseline_image():
HELPER.remove_page_urls()
yield
HELPER.remove_page_urls()
@pytest.fixture
def ref_dir() -> Path:
return Path(__file__).parent / "refs"


@pytest.fixture
Expand Down
6 changes: 6 additions & 0 deletions tests/refs/test_rendering_int64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- document:
- banner:
- button
- text: Int64 Validation 1
- main:
- img
Binary file added tests/refs/test_rendering_int64/ref1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/test_rendering_int64/ref2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions tests/refs/test_rendering_lut.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- document:
- banner:
- button
- text: PyVista Lookup Table N Colors 1
- main:
- img
Binary file added tests/refs/test_rendering_lut/ref1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/test_rendering_lut/ref2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions tests/refs/test_rendering_volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- document:
- banner:
- button
- text: VTK Volume Rendering 1
- main:
- img
Binary file added tests/refs/test_rendering_volume/ref1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/test_rendering_volume/ref2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ trame-vuetify
vtk==9.4.2
pyvista[all]==0.45.2
pytest-asyncio
pytest-playwright
coverage
28 changes: 0 additions & 28 deletions tests/skip_test_volume_rendering.py

This file was deleted.

35 changes: 21 additions & 14 deletions tests/test_big_int.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
from pathlib import Path
import pytest
from seleniumbase import SB
import time

from trame_client.utils.testing import set_browser_size, baseline_comparison
from playwright.sync_api import expect, sync_playwright
import pytest

BASELINE_TEST = (
Path(__file__).parent.parent
/ "visual_baseline/test_rendering[examples/validation/PyVistaInt64.py]/init/baseline.png"
from trame_client.utils.testing import (
assert_screenshot_matches,
assert_snapshot_matches,
)


@pytest.mark.parametrize("server_path", ["examples/validation/PyVistaInt64.py"])
def test_rendering(server, baseline_image):
with SB() as sb:
def test_rendering(server, ref_dir: Path):
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()

url = f"http://127.0.0.1:{server.port}/"
sb.open(url)
set_browser_size(sb, 600, 300)
sb.assert_exact_text("1", ".readyCount")
sb.check_window(name="init", level=3)
page.goto(url)

page.set_viewport_size({"width": 600, "height": 300})

# Wait for the page to get ready
time.sleep(1)

expect(page.locator(".readyCount")).to_have_text("1")

# The CI is not rendering big int... Not sure why
baseline_comparison(sb, BASELINE_TEST, 0.1)
assert_snapshot_matches(page, ref_dir, "test_rendering_int64")
assert_screenshot_matches(page, ref_dir, "test_rendering_int64", threshold=0.1)
35 changes: 22 additions & 13 deletions tests/test_remote_rendering.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
from pathlib import Path
import pytest
from seleniumbase import SB
from trame_client.utils.testing import set_browser_size, baseline_comparison
import time

from playwright.sync_api import expect, sync_playwright
import pytest

BASELINE_TEST = (
Path(__file__).parent.parent
/ "visual_baseline/test_rendering[examples/validation/PyVistaLookupTable.py]/init/baseline.png"
from trame_client.utils.testing import (
assert_screenshot_matches,
assert_snapshot_matches,
)


@pytest.mark.parametrize("server_path", ["examples/validation/PyVistaLookupTable.py"])
def test_rendering(server, baseline_image):
with SB() as sb:
def test_rendering(server, ref_dir: Path):
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()

url = f"http://127.0.0.1:{server.port}/"
sb.open(url)
set_browser_size(sb, 600, 300)
sb.assert_exact_text("1", ".readyCount")
sb.check_window(name="init", level=3)
baseline_comparison(sb, BASELINE_TEST, 0.1)
page.goto(url)

page.set_viewport_size({"width": 600, "height": 300})

# Wait for the page to get ready
time.sleep(1)

expect(page.locator(".readyCount")).to_have_text("1")

assert_snapshot_matches(page, ref_dir, "test_rendering_lut")
assert_screenshot_matches(page, ref_dir, "test_rendering_lut", threshold=0.1)
30 changes: 30 additions & 0 deletions tests/test_volume_rendering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pathlib import Path
import time

from playwright.sync_api import expect, sync_playwright
import pytest

from trame_client.utils.testing import (
assert_screenshot_matches,
assert_snapshot_matches,
)


@pytest.mark.parametrize("server_path", ["examples/validation/VolumeRendering.py"])
def test_rendering(server, ref_dir: Path):
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()

url = f"http://127.0.0.1:{server.port}/"
page.goto(url)

page.set_viewport_size({"width": 600, "height": 300})

# Try to make sure the remote rendering has the proper size
time.sleep(1)

expect(page.locator(".readyCount")).to_have_text("1")

assert_snapshot_matches(page, ref_dir, "test_rendering_volume")
assert_screenshot_matches(page, ref_dir, "test_rendering_volume", threshold=0.1)
2 changes: 0 additions & 2 deletions visual_baseline/.gitignore

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Loading