-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
|
||
import streamlit as st | ||
|
||
from streamlit_pdf_viewer import pdf_viewer | ||
from tests import ROOT_DIRECTORY | ||
|
||
st.subheader("Test PDF Viewer using legacy embed with specified height") | ||
|
||
pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='unwrap', height='500') | ||
pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='unwrap', width='500') | ||
pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='unwrap', width='500', height='500') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
from playwright.sync_api import Page, expect | ||
|
||
from tests import ROOT_DIRECTORY | ||
from tests.e2e_utils import StreamlitRunner | ||
|
||
BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_invalid_params.py") | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def browser_type_launch_args(browser_type_launch_args): | ||
return { | ||
**browser_type_launch_args, | ||
"firefox_user_prefs": { | ||
"pdfjs.disabled": False, | ||
} | ||
} | ||
|
||
|
||
@pytest.fixture(autouse=True, scope="module") | ||
def streamlit_app(): | ||
with StreamlitRunner(Path(BASIC_EXAMPLE_FILE)) as runner: | ||
yield runner | ||
|
||
|
||
@pytest.fixture(autouse=True, scope="function") | ||
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() | ||
|
||
|
||
def test_should_fail_rendering(page: Page): | ||
expect(page.get_by_text("Test PDF Viewer using legacy embed with specified height")).to_be_visible() | ||
|
||
iframe_component = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0) | ||
expect(iframe_component).not_to_be_visible() | ||
|
||
iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]') | ||
pdf_container = iframe_frame.locator('div[id="pdfContainer"]') | ||
expect(pdf_container).not_to_be_visible() | ||
|
||
pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]') | ||
expect(pdf_viewer).not_to_be_visible() |