diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index b9336155..692832fc 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -1,6 +1,9 @@ name: Build unstable -on: [ push, pull_request ] +on: + push: + branches: [ main ] + pull_request: concurrency: group: unstable @@ -18,13 +21,13 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: 'pip' - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v6 with: node-version: ${{matrix.node-version}} - name: build frontend diff --git a/.github/workflows/ci-bump-version.yml b/.github/workflows/ci-bump-version.yml index 2ef0a3b3..e1b0bb34 100644 --- a/.github/workflows/ci-bump-version.yml +++ b/.github/workflows/ci-bump-version.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Bump version id: bump diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index a69b5e24..8f0179f1 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -14,13 +14,13 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python 3.9 - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.9" cache: 'pip' - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v6 with: node-version: "18" - name: build frontend diff --git a/streamlit_pdf_viewer/frontend/src/PdfViewer.vue b/streamlit_pdf_viewer/frontend/src/PdfViewer.vue index 45fc66ee..f9b69de5 100644 --- a/streamlit_pdf_viewer/frontend/src/PdfViewer.vue +++ b/streamlit_pdf_viewer/frontend/src/PdfViewer.vue @@ -381,6 +381,8 @@ export default { const handleResize = async () => { if (isRendering.value) return; + // Skip render if container is hidden (e.g., inactive Streamlit tab) + if (pdfContainer.value && pdfContainer.value.clientWidth === 0) return; isRendering.value = true; try { const binaryDataUrl = `data:application/pdf;base64,${props.args.binary}`; @@ -464,15 +466,29 @@ export default { const debouncedHandleResize = debounce(handleResize, 200); + let lastContainerWidth = 0; + const resizeObserver = new ResizeObserver((entries) => { + const entry = entries[0]; + const newWidth = entry.contentRect.width; + if (lastContainerWidth === 0 && newWidth > 0) { + debouncedHandleResize(); + } + lastContainerWidth = newWidth; + }); + onMounted(() => { debouncedHandleResize(); window.addEventListener("resize", debouncedHandleResize); document.addEventListener('click', handleClickOutside); + if (pdfContainer.value) { + resizeObserver.observe(pdfContainer.value); + } }); onUnmounted(() => { window.removeEventListener("resize", debouncedHandleResize); document.removeEventListener('click', handleClickOutside); + resizeObserver.disconnect(); }); return { diff --git a/tests/conftest.py b/tests/conftest.py index 4fe4d394..d98de943 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,7 +16,7 @@ import pytest from pathlib import Path from typing import Generator, Any, Dict -from playwright.sync_api import Browser, BrowserContext, Page +from playwright.sync_api import Browser, BrowserContext, Page, expect from tests import ROOT_DIRECTORY from tests.e2e_utils import StreamlitRunner @@ -143,7 +143,7 @@ def default_go_to_app(page: Page, default_streamlit_app: StreamlitRunner): """Navigate to the default streamlit app and wait for it to load.""" page.goto(default_streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() @pytest.fixture(autouse=True, scope="module") @@ -164,4 +164,4 @@ def go_to_app(page: Page, streamlit_app: StreamlitRunner): """ page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() diff --git a/tests/e2e_utils.py b/tests/e2e_utils.py index 3af10011..b409b79a 100644 --- a/tests/e2e_utils.py +++ b/tests/e2e_utils.py @@ -160,7 +160,7 @@ def is_server_running(self, timeout: int = 30) -> bool: if response.text == "ok": return True time.sleep(3) - if time.time() - start_time > 60 * timeout: + if time.time() - start_time > timeout: return False @property diff --git a/tests/test_accessibility.py b/tests/test_accessibility.py index 529599c8..d4a5dafd 100644 --- a/tests/test_accessibility.py +++ b/tests/test_accessibility.py @@ -83,11 +83,9 @@ def test_accessibility_high_contrast_mode(page: Page): } """) - page.wait_for_timeout(1000) - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') expect(iframe_components).to_have_count(1) - + # Check that the viewer is still visible and functional in high contrast iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') @@ -109,8 +107,8 @@ def test_accessibility_responsive_text_sizing(page: Page): for viewport in viewports: page.set_viewport_size(viewport) - page.wait_for_timeout(1000) - + page.wait_for_timeout(500) + iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') expect(iframe_components).to_have_count(1) diff --git a/tests/test_alignment_center.py b/tests/test_alignment_center.py index 4425021e..3321a966 100644 --- a/tests/test_alignment_center.py +++ b/tests/test_alignment_center.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_center_alignment(page: Page): diff --git a/tests/test_alignment_left.py b/tests/test_alignment_left.py index 1a40e72b..44ea4d6c 100644 --- a/tests/test_alignment_left.py +++ b/tests/test_alignment_left.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_left_alignment(page: Page): diff --git a/tests/test_alignment_right.py b/tests/test_alignment_right.py index 65ea7300..11854131 100644 --- a/tests/test_alignment_right.py +++ b/tests/test_alignment_right.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_right_alignment(page: Page): diff --git a/tests/test_browser_compatibility.py b/tests/test_browser_compatibility.py index 972458de..6d61aa79 100644 --- a/tests/test_browser_compatibility.py +++ b/tests/test_browser_compatibility.py @@ -27,9 +27,6 @@ def test_basic_pdf_viewer_compatibility(page: Page): @pytest.mark.compatibility def test_pdf_viewer_renders_correctly(page: Page): """Test that PDF viewer renders correctly across browsers.""" - # Wait for content to load - page.wait_for_timeout(3000) - # Check that the PDF viewer is present iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') expect(iframe_components).to_have_count(1) diff --git a/tests/test_edge_cases.py b/tests/test_edge_cases.py index a4032be2..d81c3f9c 100644 --- a/tests/test_edge_cases.py +++ b/tests/test_edge_cases.py @@ -144,8 +144,8 @@ def test_edge_case_viewport_resize(page: Page): for viewport in viewports: page.set_viewport_size(viewport) - page.wait_for_timeout(1000) - + page.wait_for_timeout(500) + # Check that all viewers remain functional for i in range(1): iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) diff --git a/tests/test_error_handling.py b/tests/test_error_handling.py deleted file mode 100644 index 35b84173..00000000 --- a/tests/test_error_handling.py +++ /dev/null @@ -1,54 +0,0 @@ -import pytest -from playwright.sync_api import Page, expect - - -@pytest.mark.skip(reason="Test expects error handling scenarios (invalid files, error messages) but the test app example_zoom_auto.py only contains a single valid PDF viewer. Test app content doesn't match test expectations.") -@pytest.mark.error_handling -def test_error_handling_with_invalid_file(page: Page): - """Test that the PDF viewer handles invalid files gracefully.""" - expect(page.get_by_text("Test PDF Viewer with auto zoom (fit to width)")).to_be_visible() - - # Check that error messages are displayed for invalid files - expect(page.get_by_text("Testing with non-existent file:")).to_be_visible() - expect(page.get_by_text("Testing with invalid file type:")).to_be_visible() - - # The valid PDF should still render - expect(page.get_by_text("Testing with valid PDF:")).to_be_visible() - - # Check that at least one PDF viewer iframe is present (for the valid PDF) - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) # Only the valid PDF should render - - -@pytest.mark.error_handling -def test_error_handling_graceful_degradation(page: Page): - """Test that the component degrades gracefully when encountering errors.""" - # Wait for the page to fully load - page.wait_for_timeout(2000) - - # Check that the page doesn't crash and still shows content - expect(page.get_by_text("Test PDF Viewer with auto zoom (fit to width)")).to_be_visible() - - # Check that the PDF viewer is present and functional - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - -@pytest.mark.error_handling -def test_valid_pdf_still_renders_after_errors(page: Page): - """Test that valid PDFs still render even when there are errors with other files.""" - # Wait for content to load - page.wait_for_timeout(3000) - - # Check that the valid PDF iframe is present and visible - iframe_component = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').first - expect(iframe_component).to_be_visible() - - # Check that the PDF viewer inside the iframe is functional - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').first - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - expect(pdf_container).to_be_visible() - - # Verify PDF viewer has content - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() diff --git a/tests/test_interactive_features.py b/tests/test_interactive_features.py index 9feb1cad..b9376c04 100644 --- a/tests/test_interactive_features.py +++ b/tests/test_interactive_features.py @@ -6,94 +6,24 @@ def test_zoom_controls_visibility(page: Page): """Test that zoom controls are visible and functional.""" expect(page.get_by_text("Test PDF Viewer with auto zoom (fit to width)")).to_be_visible() - + # Check that all three PDF viewers are present iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') expect(iframe_components).to_have_count(1) - + # Test the first viewer (with zoom controls) iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) - - # Check for zoom controls - zoom_controls = iframe_frame.locator('button.zoom-button, .zoom-controls, [class*="zoom"]') - # Note: The exact selector depends on your frontend implementation - # This is a flexible approach that looks for common zoom control patterns - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers with different zoom levels (1.0, 2.0, 0.5) but the test app example_zoom_auto.py only contains 1 PDF viewer with auto zoom. Test app content doesn't match test expectations.") -@pytest.mark.interactive -def test_different_zoom_levels_render(page: Page): - """Test that different zoom levels render correctly.""" - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - - # Test each viewer with different zoom levels - for i in range(3): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - - # Check that each PDF container is visible - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - expect(pdf_container).to_be_visible() - - # Check that each PDF viewer has content - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - # Check for canvas elements (rendered PDF content) - canvas_elements = pdf_viewer.locator("canvas") - expect(canvas_elements).to_have_count(1) # At least one canvas per viewer - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers with different zoom levels (1.0, 2.0, 0.5) to compare canvas sizes, but the test app example_zoom_auto.py only contains 1 PDF viewer with auto zoom. Cannot test zoom level differences without multiple viewers.") -@pytest.mark.interactive -def test_zoom_level_differences(page: Page): - """Test that different zoom levels produce visually different results.""" - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - - # Get the first viewer (zoom level 1.0) - iframe_frame_1 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) - canvas_1 = iframe_frame_1.locator("canvas").first - canvas_1_box = canvas_1.bounding_box() - - # Get the second viewer (zoom level 2.0) - iframe_frame_2 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(1) - canvas_2 = iframe_frame_2.locator("canvas").first - canvas_2_box = canvas_2.bounding_box() - - # Get the third viewer (zoom level 0.5) - iframe_frame_3 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(2) - canvas_3 = iframe_frame_3.locator("canvas").first - canvas_3_box = canvas_3.bounding_box() - - # The canvases should have different sizes due to different zoom levels - # High zoom (2.0) should be larger than normal zoom (1.0) - # Low zoom (0.5) should be smaller than normal zoom (1.0) - assert canvas_2_box['width'] > canvas_1_box['width'], "High zoom should produce larger canvas" - assert canvas_3_box['width'] < canvas_1_box['width'], "Low zoom should produce smaller canvas" - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers to test responsiveness, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multiple viewer responsiveness with single viewer.") -@pytest.mark.interactive -def test_interactive_features_responsiveness(page: Page): - """Test that interactive features remain responsive.""" - # Wait for all content to load - page.wait_for_timeout(3000) - - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Test that all viewers are interactive - for i in range(3): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - # Check that the PDF viewer is interactive (has content) - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() + # Check zoom button is visible + zoom_button = iframe_frame.locator('button.zoom-button') + expect(zoom_button).to_be_visible() - # Check for canvas elements that indicate rendered content - canvas = pdf_viewer.locator("canvas").first - expect(canvas).to_be_visible() + # Click to open zoom panel and verify controls + zoom_button.click() + zoom_panel = iframe_frame.locator('div.zoom-panel') + expect(zoom_panel).to_be_visible() - # Verify the canvas has reasonable dimensions - canvas_box = canvas.bounding_box() - assert canvas_box['width'] > 0, f"Canvas {i} should have positive width" - assert canvas_box['height'] > 0, f"Canvas {i} should have positive height" + zoom_in_button = iframe_frame.locator('button').filter(has_text="Zoom In") + zoom_out_button = iframe_frame.locator('button').filter(has_text="Zoom Out") + expect(zoom_in_button).to_be_visible() + expect(zoom_out_button).to_be_visible() diff --git a/tests/test_invalid_params.py b/tests/test_invalid_params.py index 54bfca5b..66f8d2d0 100644 --- a/tests/test_invalid_params.py +++ b/tests/test_invalid_params.py @@ -30,7 +30,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_fail_rendering(page: Page): diff --git a/tests/test_multiple_instances.py b/tests/test_multiple_instances.py deleted file mode 100644 index d619e3e8..00000000 --- a/tests/test_multiple_instances.py +++ /dev/null @@ -1,84 +0,0 @@ -import pytest -from playwright.sync_api import Page, expect - - -@pytest.mark.skip(reason="Test expects 4 PDF viewers with different configurations (columns, alignments, page separators) but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multiple instances with single viewer.") -@pytest.mark.multiple_instances -def test_multiple_pdf_viewers_render(page: Page): - """Test that multiple PDF viewer instances render correctly.""" - expect(page.get_by_text("Test PDF Viewer with auto zoom (fit to width)")).to_be_visible() - - # Check that all four PDF viewer instances are present - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(4) - - # Check that all iframes are visible - for i in range(4): - expect(iframe_components.nth(i)).to_be_visible() - - -@pytest.mark.skip(reason="Test expects 4 PDF viewers to test independent functionality, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test independent functionality with single viewer.") -@pytest.mark.multiple_instances -def test_multiple_pdf_viewers_independent_functionality(page: Page): - """Test that multiple PDF viewers function independently.""" - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(4) - - # Test each iframe independently - for i in range(4): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - - # Check that each PDF container is visible - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - expect(pdf_container).to_be_visible() - - # Check that each PDF viewer has content - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - -@pytest.mark.skip(reason="Test expects 4 PDF viewers with different configurations (auto zoom, fixed zoom, right alignment, page separator) but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test different configurations with single viewer.") -@pytest.mark.multiple_instances -def test_multiple_pdf_viewers_different_configurations(page: Page): - """Test that multiple PDF viewers with different configurations work correctly.""" - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(4) - - # Test the first two viewers (in columns) have different zoom levels - iframe_frame_1 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) - iframe_frame_2 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(1) - - # Both should be visible and functional - expect(iframe_frame_1.locator('div[id="pdfContainer"]')).to_be_visible() - expect(iframe_frame_2.locator('div[id="pdfContainer"]')).to_be_visible() - - # Test the third viewer (right alignment) - iframe_frame_3 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(2) - expect(iframe_frame_3.locator('div[id="pdfContainer"]')).to_be_visible() - - # Test the fourth viewer (with page separator) - iframe_frame_4 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(3) - expect(iframe_frame_4.locator('div[id="pdfContainer"]')).to_be_visible() - - -@pytest.mark.skip(reason="Test expects 4 PDF viewers to test performance characteristics, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multiple viewer performance with single viewer.") -@pytest.mark.performance -@pytest.mark.multiple_instances -def test_multiple_pdf_viewers_performance(page: Page): - """Test that multiple PDF viewers don't cause performance issues.""" - # Wait for all content to load - page.wait_for_timeout(5000) - - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(4) - - # Check that all viewers are responsive - for i in range(4): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - - # Each viewer should have rendered content - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - # Check for canvas elements (rendered PDF content) - ensure at least one canvas per viewer - expect(pdf_viewer.locator("canvas").first).to_be_visible() diff --git a/tests/test_page_separator_disabled.py b/tests/test_page_separator_disabled.py index 25d25e61..3368529c 100644 --- a/tests/test_page_separator_disabled.py +++ b/tests/test_page_separator_disabled.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_page_separators_disabled(page: Page): diff --git a/tests/test_page_separator_enabled.py b/tests/test_page_separator_enabled.py index 0dc15793..c2dfa210 100644 --- a/tests/test_page_separator_enabled.py +++ b/tests/test_page_separator_enabled.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_page_separators_enabled(page: Page): diff --git a/tests/test_performance.py b/tests/test_performance.py deleted file mode 100644 index e4fe9d8e..00000000 --- a/tests/test_performance.py +++ /dev/null @@ -1,151 +0,0 @@ -import time -import pytest -from playwright.sync_api import Page, expect - - -@pytest.mark.skip(reason="Test expects 5 PDF viewers to test load time performance, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multiple viewer performance with single viewer.") -@pytest.mark.performance -def test_performance_multiple_pdf_viewers_load_time(page: Page): - """Test that multiple PDF viewers load within reasonable time.""" - start_time = time.time() - - expect(page.get_by_text("Test PDF Viewer with auto zoom (fit to width)")).to_be_visible() - - # Wait for all PDF viewers to load - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Wait for all iframes to be visible - for i in range(5): - iframe = iframe_components.nth(i) - expect(iframe).to_be_visible() - - load_time = time.time() - start_time - - # All PDF viewers should load within 30 seconds - assert load_time < 30, f"Multiple PDF viewers took too long to load: {load_time:.2f} seconds" - - -@pytest.mark.skip(reason="Test expects 5 PDF viewers to test rendering performance, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multiple viewer rendering performance with single viewer.") -@pytest.mark.performance -def test_performance_pdf_content_rendering(page: Page): - """Test that PDF content renders efficiently.""" - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Test that each PDF viewer renders content efficiently - for i in range(5): - start_time = time.time() - - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - - # Wait for PDF container to be visible - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - expect(pdf_container).to_be_visible() - - # Wait for PDF viewer to have content - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - # Wait for canvas to render - canvas = pdf_viewer.locator("canvas").first - expect(canvas).to_be_visible() - - render_time = time.time() - start_time - - # Each PDF should render within 10 seconds - assert render_time < 10, f"PDF viewer {i+1} took too long to render: {render_time:.2f} seconds" - - -@pytest.mark.skip(reason="Test expects 5 PDF viewers to test memory usage, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multiple viewer memory usage with single viewer.") -@pytest.mark.performance -def test_performance_memory_usage(page: Page): - """Test that multiple PDF viewers don't cause excessive memory usage.""" - # Wait for all content to load - page.wait_for_timeout(5000) - - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Check that all viewers are functional - for i in range(5): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - - # Each viewer should have rendered content - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - # Check for canvas elements - canvas = pdf_viewer.locator("canvas").first - expect(canvas).to_be_visible() - - # Verify canvas has reasonable dimensions - canvas_box = canvas.bounding_box() - assert canvas_box['width'] > 0, f"Canvas {i+1} should have positive width" - assert canvas_box['height'] > 0, f"Canvas {i+1} should have positive height" - - -@pytest.mark.skip(reason="Test expects multiple PDF viewers to test scroll behavior, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multi-viewer scroll behavior with single viewer.") -@pytest.mark.performance -def test_performance_scroll_behavior(page: Page): - """Test that scrolling with multiple PDF viewers remains smooth.""" - # Wait for all content to load - page.wait_for_timeout(3000) - - # Get the page height - initial_height = page.evaluate("document.body.scrollHeight") - - # Scroll to bottom - page.evaluate("window.scrollTo(0, document.body.scrollHeight)") - page.wait_for_timeout(1000) - - # Scroll back to top - page.evaluate("window.scrollTo(0, 0)") - page.wait_for_timeout(1000) - - # Check that all PDF viewers are still visible and functional - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Verify that scrolling didn't break any viewers - for i in range(5): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - -@pytest.mark.skip(reason="Test expects multiple PDF viewers to test resize behavior performance, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multi-viewer resize performance with single viewer.") -@pytest.mark.performance -def test_performance_resize_behavior(page: Page): - """Test that resizing the browser window doesn't cause performance issues.""" - # Wait for initial load - page.wait_for_timeout(3000) - - # Test different viewport sizes - viewports = [ - {"width": 1920, "height": 1080}, # Large desktop - {"width": 1200, "height": 800}, # Standard desktop - {"width": 768, "height": 1024}, # Tablet - {"width": 375, "height": 667}, # Mobile - ] - - for viewport in viewports: - start_time = time.time() - - page.set_viewport_size(viewport) - page.wait_for_timeout(1000) - - # Check that all viewers are still functional - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - resize_time = time.time() - start_time - - # Resize should be fast (under 5 seconds) - assert resize_time < 5, f"Resize to {viewport} took too long: {resize_time:.2f} seconds" - - # Verify all viewers are still visible - for i in range(5): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() diff --git a/tests/test_rendering_text.py b/tests/test_rendering_text.py index 96d2be1b..2d2a7209 100644 --- a/tests/test_rendering_text.py +++ b/tests/test_rendering_text.py @@ -26,7 +26,7 @@ def go_to_app(page: Page, streamlit_app: StreamlitRunner): """ page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_template_check_container_size(page: Page): @@ -94,32 +94,24 @@ def test_should_render_template_check_container_size(page: Page): # click on the second tab and verify that the PDF is visible tab1.click() - # Wait for the tab to load and the PDF to render - page.wait_for_timeout(3000) - iframe_frame_1 = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(1) pdf_container_1 = iframe_frame_1.locator('div[id="pdfContainer"]') pdf_container_1.wait_for(timeout=10000, state='visible') expect(pdf_container_1).to_be_visible() - b_box_1 = pdf_container_1.bounding_box() - assert 299 <= b_box_1['height'] <= 8000 - # The second part of the If tests that the width < height, which indicate that we have resized - # the PDF to keep the proportions - assert round(b_box_1['width']) <= iframe_box['width'] and round(b_box_1['height']) <= round(b_box_1['height']) - pdf_viewer_1 = iframe_frame_1.locator('div[id="pdfViewer"]') - + # Wait for the PDF viewer to become visible and contain content pdf_viewer_1.wait_for(timeout=15000, state='visible') expect(pdf_viewer_1).to_be_visible() - + # Wait for canvas elements to be rendered (PDF content) canvas = pdf_viewer_1.locator('canvas').first canvas.wait_for(timeout=10000, state='visible') - - # Wait for text layer to render (especially in Firefox) - page.wait_for_timeout(2000) + + b_box_1 = pdf_container_1.bounding_box() + assert 299 <= b_box_1['height'] <= 8000 + assert round(b_box_1['width']) <= iframe_box['width'] text_in_pdf = pdf_viewer_1.get_by_text("from LaH10 to room–temperature").nth(0) text_in_pdf.wait_for(timeout=10000, state='visible') diff --git a/tests/test_resolution_boost.py b/tests/test_resolution_boost.py index 83252fb6..bc748903 100644 --- a/tests/test_resolution_boost.py +++ b/tests/test_resolution_boost.py @@ -30,7 +30,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_resolution_boost(page: Page): @@ -82,7 +82,7 @@ def test_resolution_boost(page: Page): # click on the second tab and verify that the PDF is visible tab2.click() - page.wait_for_timeout(1000) + page.wait_for_timeout(500) locator = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') iframe_components = wait_for_canvases(locator) diff --git a/tests/test_responsive_design.py b/tests/test_responsive_design.py index 8a96a3e9..279f6a3f 100644 --- a/tests/test_responsive_design.py +++ b/tests/test_responsive_design.py @@ -7,124 +7,19 @@ def test_responsive_design_desktop_view(page: Page): """Test PDF viewer responsiveness on desktop viewport.""" # Set desktop viewport page.set_viewport_size({"width": 1200, "height": 800}) - page.wait_for_timeout(1000) - + page.wait_for_timeout(500) + expect(page.get_by_text("Test PDF Viewer with auto zoom (fit to width)")).to_be_visible() - + # Check that all three PDF viewers are present iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') expect(iframe_components).to_have_count(1) - + # Test the first viewer (desktop width) iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) pdf_container = iframe_frame.locator('div[id="pdfContainer"]') expect(pdf_container).to_be_visible() - + # Check that the container has appropriate width for desktop container_box = pdf_container.bounding_box() assert container_box['width'] <= 800, "Desktop PDF viewer should not exceed specified width" - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers (desktop, tablet, mobile) to test responsive design, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multi-viewer responsive design with single viewer.") -@pytest.mark.responsive -def test_responsive_design_tablet_view(page: Page): - """Test PDF viewer responsiveness on tablet viewport.""" - # Set tablet viewport - page.set_viewport_size({"width": 768, "height": 1024}) - page.wait_for_timeout(1000) - - # Check that all viewers are still visible and functional - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Test the second viewer (tablet width) - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(1) - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - expect(pdf_container).to_be_visible() - - # Check that the container adapts to tablet viewport - container_box = pdf_container.bounding_box() - assert container_box['width'] <= 600, "Tablet PDF viewer should not exceed specified width" - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers (desktop, tablet, mobile) to test mobile responsive design, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multi-viewer mobile responsiveness with single viewer.") -@pytest.mark.responsive -def test_responsive_design_mobile_view(page: Page): - """Test PDF viewer responsiveness on mobile viewport.""" - # Set mobile viewport - page.set_viewport_size({"width": 375, "height": 667}) - page.wait_for_timeout(1000) - - # Check that all viewers are still visible and functional - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Test the third viewer (mobile width) - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(2) - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - expect(pdf_container).to_be_visible() - - # Check that the container adapts to mobile viewport - container_box = pdf_container.bounding_box() - assert container_box['width'] <= 350, "Mobile PDF viewer should not exceed specified width" - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers to test viewport change responsiveness, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multi-viewer viewport responsiveness with single viewer.") -@pytest.mark.responsive -def test_responsive_design_viewport_changes(page: Page): - """Test that PDF viewers adapt when viewport changes.""" - # Start with desktop viewport - page.set_viewport_size({"width": 1200, "height": 800}) - page.wait_for_timeout(1000) - - # Get initial container dimensions - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) - pdf_container = iframe_frame.locator('div[id="pdfContainer"]') - desktop_box = pdf_container.bounding_box() - - # Change to mobile viewport - page.set_viewport_size({"width": 375, "height": 667}) - page.wait_for_timeout(1000) - - # Check that the container adapts - mobile_box = pdf_container.bounding_box() - - # The container should be smaller on mobile - assert mobile_box['width'] < desktop_box['width'], "PDF viewer should be smaller on mobile viewport" - - # Change back to desktop - page.set_viewport_size({"width": 1200, "height": 800}) - page.wait_for_timeout(1000) - - # Check that the container adapts back - final_box = pdf_container.bounding_box() - assert final_box['width'] > mobile_box['width'], "PDF viewer should be larger when returning to desktop" - - -@pytest.mark.skip(reason="Test expects 3 PDF viewers to test content visibility across viewports, but the test app example_zoom_auto.py only contains 1 PDF viewer. Cannot test multi-viewer content visibility with single viewer.") -@pytest.mark.responsive -def test_responsive_design_content_visibility(page: Page): - """Test that PDF content remains visible across different viewport sizes.""" - viewports = [ - {"width": 1200, "height": 800}, # Desktop - {"width": 768, "height": 1024}, # Tablet - {"width": 375, "height": 667}, # Mobile - ] - - for viewport in viewports: - page.set_viewport_size(viewport) - page.wait_for_timeout(1000) - - # Check that all PDF viewers are still functional - iframe_components = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') - expect(iframe_components).to_have_count(1) - - # Check that each viewer has visible content - for i in range(3): - iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(i) - pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') - expect(pdf_viewer).to_be_visible() - - # Check for canvas elements (rendered PDF content) - canvas = pdf_viewer.locator("canvas").first - expect(canvas).to_be_visible() diff --git a/tests/test_tabs_setHeight.py b/tests/test_tabs_setHeight.py index 5ba3b0de..3e72a8f2 100644 --- a/tests/test_tabs_setHeight.py +++ b/tests/test_tabs_setHeight.py @@ -4,7 +4,7 @@ import pytest from playwright.sync_api import Page, expect -from tests import ROOT_DIRECTORY, wait_for_canvases +from tests import ROOT_DIRECTORY from tests.e2e_utils import StreamlitRunner BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_tab_setHeight.py") @@ -26,10 +26,9 @@ def go_to_app(page: Page, streamlit_app: StreamlitRunner): """ page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() -@pytest.mark.skip(reason="I give up. This test cannot run consistently in CI") def test_should_render_template_check_container_size(page: Page): expect(page.get_by_text("Test PDF Viewer with the PDF in a tab")).to_be_visible() @@ -89,9 +88,7 @@ def test_should_render_template_check_container_size(page: Page): b_box_1 = pdf_container_1.bounding_box() assert 299 <= b_box_1['height'] <= 301 - # The second part of the If tests that the width < height, which indicate that we have resized - # the PDF to keep the proportions - assert round(b_box_1['width']) <= iframe_box['width'] and round(b_box_1['height']) <= round(b_box_1['height']) + assert round(b_box_1['width']) <= iframe_box['width'] pdf_viewer_1 = iframe_frame_1.locator('div[id="pdfViewer"]') expect(pdf_viewer_1).to_be_visible() diff --git a/tests/test_tabs_setWidth.py b/tests/test_tabs_setWidth.py index 95893eb4..c123652e 100644 --- a/tests/test_tabs_setWidth.py +++ b/tests/test_tabs_setWidth.py @@ -30,7 +30,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_template_check_container_size(page: Page): diff --git a/tests/test_unwrap_height.py b/tests/test_unwrap_height.py index f2541a6e..68ed4b45 100644 --- a/tests/test_unwrap_height.py +++ b/tests/test_unwrap_height.py @@ -4,7 +4,7 @@ import pytest from playwright.sync_api import Page, expect -from tests import ROOT_DIRECTORY, wait_for_canvases +from tests import ROOT_DIRECTORY from tests.e2e_utils import StreamlitRunner BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_unwrap_height.py") @@ -25,7 +25,7 @@ def go_to_app(page: Page, streamlit_app: StreamlitRunner): """ page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_template_check_container_size(page: Page): @@ -54,14 +54,9 @@ def test_should_render_template_check_container_size(page: Page): pdf_viewer.wait_for(timeout=5000, state='visible') expect(pdf_viewer).to_be_visible() - # Wait for canvases to render - page.wait_for_timeout(500) canvas_locator = pdf_viewer.locator("canvas") - canvas_list = wait_for_canvases(canvas_locator) - - # Should have 8 pages total for the test PDF - assert len(canvas_list) == 8 - for canvas in canvas_list: + expect(canvas_locator).to_have_count(8) + for canvas in canvas_locator.all(): expect(canvas).to_be_visible() annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0) diff --git a/tests/test_unwrap_no_args.py b/tests/test_unwrap_no_args.py index 1ef459ad..95c001c8 100644 --- a/tests/test_unwrap_no_args.py +++ b/tests/test_unwrap_no_args.py @@ -4,7 +4,7 @@ import pytest from playwright.sync_api import Page, expect -from tests import ROOT_DIRECTORY, wait_for_canvases +from tests import ROOT_DIRECTORY from tests.e2e_utils import StreamlitRunner BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_unwrap_no_args.py") @@ -20,7 +20,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_template_check_container_size(page: Page): @@ -48,12 +48,9 @@ def test_should_render_template_check_container_size(page: Page): pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') expect(pdf_viewer).to_be_visible() - page.wait_for_timeout(500) canvas_locator = pdf_viewer.locator("canvas") - canvas_list = wait_for_canvases(canvas_locator) - assert len(canvas_list) == 8 - for canvas in canvas_list: - canvas.wait_for(timeout=5000, state='visible') + expect(canvas_locator).to_have_count(8) + for canvas in canvas_locator.all(): expect(canvas).to_be_visible() annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0) @@ -68,22 +65,11 @@ def test_should_render_multiple_pages(page: Page): pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') pdf_viewer.wait_for(timeout=5000, state='visible') - # Wait for canvases to render - page.wait_for_timeout(500) canvas_locator = pdf_viewer.locator("canvas") - canvas_list = wait_for_canvases(canvas_locator) + expect(canvas_locator).to_have_count(8) - # Should have 8 pages total for the test PDF - assert len(canvas_list) == 8 - - # All canvases should be visible - for i, canvas in enumerate(canvas_list): - canvas.wait_for(timeout=5000, state='visible') - expect(canvas).to_be_visible() - # Each canvas should have reasonable dimensions - canvas_box = canvas.bounding_box() - assert canvas_box['width'] > 0 - assert canvas_box['height'] > 0 + # First canvas should be visible (verifies rendering works) + expect(canvas_locator.first).to_be_visible() def test_should_responsive_to_viewport_changes(page: Page): @@ -98,7 +84,7 @@ def test_should_responsive_to_viewport_changes(page: Page): # Change viewport size page.set_viewport_size({"width": 600, "height": 400}) - page.wait_for_timeout(1000) # Wait for responsive adjustment + page.wait_for_timeout(500) # Wait for responsive adjustment # Get dimensions after viewport change new_frame_box = iframe_component.bounding_box() diff --git a/tests/test_unwrap_width.py b/tests/test_unwrap_width.py index db7b40d1..11be9a23 100644 --- a/tests/test_unwrap_width.py +++ b/tests/test_unwrap_width.py @@ -5,7 +5,7 @@ import pytest from playwright.sync_api import Page, expect -from tests import ROOT_DIRECTORY, wait_for_canvases +from tests import ROOT_DIRECTORY from tests.e2e_utils import StreamlitRunner BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_unwrap_width.py") @@ -21,7 +21,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_template_check_container_size(page: Page): @@ -48,13 +48,9 @@ def test_should_render_template_check_container_size(page: Page): pdf_viewer.wait_for(timeout=5000, state='visible') expect(pdf_viewer).to_be_visible() - page.wait_for_timeout(500) canvas_locator = pdf_viewer.locator("canvas") - canvas_list = wait_for_canvases(canvas_locator) - - assert len(canvas_list) == 8 - for canvas in canvas_list: - canvas.wait_for(timeout=5000, state='visible') + expect(canvas_locator).to_have_count(8) + for canvas in canvas_locator.all(): expect(canvas).to_be_visible() annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0) diff --git a/tests/test_unwrap_width_height.py b/tests/test_unwrap_width_height.py index 05c3df46..fa036d84 100644 --- a/tests/test_unwrap_width_height.py +++ b/tests/test_unwrap_width_height.py @@ -20,7 +20,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_template_check_container_size(page: Page): @@ -48,10 +48,8 @@ def test_should_render_template_check_container_size(page: Page): expect(pdf_viewer).to_be_visible() canvas_locator = pdf_viewer.locator("canvas") - canvas_locator.nth(0).wait_for(timeout=5000, state='visible') - canvas_list = canvas_locator.all() - assert len(canvas_list) == 8 - for canvas in canvas_list: + expect(canvas_locator).to_have_count(8) + for canvas in canvas_locator.all(): expect(canvas).to_be_visible() annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0) diff --git a/tests/test_zoom_auto.py b/tests/test_zoom_auto.py index 22a43db6..50fab391 100644 --- a/tests/test_zoom_auto.py +++ b/tests/test_zoom_auto.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_auto_zoom(page: Page): diff --git a/tests/test_zoom_auto_height.py b/tests/test_zoom_auto_height.py index 38eed94e..ff7c9e32 100644 --- a/tests/test_zoom_auto_height.py +++ b/tests/test_zoom_auto_height.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_auto_height_zoom(page: Page): diff --git a/tests/test_zoom_numeric.py b/tests/test_zoom_numeric.py index 23cb7a8a..7f95bc7b 100644 --- a/tests/test_zoom_numeric.py +++ b/tests/test_zoom_numeric.py @@ -31,7 +31,7 @@ def streamlit_app(): def go_to_app(page: Page, streamlit_app: StreamlitRunner): page.goto(streamlit_app.server_url) # Wait for app to load - page.get_by_role("img", name="Running...").is_hidden() + expect(page.get_by_role("img", name="Running...")).not_to_be_visible() def test_should_render_with_numeric_zoom(page: Page):