-
Notifications
You must be signed in to change notification settings - Fork 21
Make tests more resilient #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
50f7377
220aa2f
857a464
547a1ed
31dcc55
b37859f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,94 +6,15 @@ | |
| 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) | ||
|
Comment on lines
10
to
12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update stale inline comment about iframe count. Line 10 says “all three PDF viewers,” but Line 12 asserts a count of 🤖 Prompt for AI Agents |
||
|
|
||
| # 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 | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| @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 for canvas elements that indicate rendered content | ||
| canvas = pdf_viewer.locator("canvas").first | ||
| expect(canvas).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" | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: lfoppiano/streamlit-pdf-viewer
Length of output: 545
🏁 Script executed:
Repository: lfoppiano/streamlit-pdf-viewer
Length of output: 145
🏁 Script executed:
Repository: lfoppiano/streamlit-pdf-viewer
Length of output: 170
🏁 Script executed:
Repository: lfoppiano/streamlit-pdf-viewer
Length of output: 865
🏁 Script executed:
Repository: lfoppiano/streamlit-pdf-viewer
Length of output: 838
🏁 Script executed:
Repository: lfoppiano/streamlit-pdf-viewer
Length of output: 163
Guard
IntersectionObserverinitialization to prevent runtime failures in unsupported environments.Line 468 creates
new IntersectionObserver(...)unconditionally. This will crash at component setup time in environments lacking the API (older browsers, server-side rendering, or test runners using JSDOM). Add a feature check before instantiation.🔧 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents