Skip to content

Commit

Permalink
extend tests to cover all combination of parameters (width, height, r…
Browse files Browse the repository at this point in the history
…endering)
  • Loading branch information
lfoppiano committed Mar 5, 2024
1 parent a66cc04 commit a988ef2
Show file tree
Hide file tree
Showing 25 changed files with 558 additions and 28 deletions.
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pathlib import Path

ROOT_DIRECTORY = Path(__file__).parent.parent.absolute()
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import streamlit as st

from streamlit_pdf_viewer import pdf_viewer
from tests.test_template_args import ROOT_DIRECTORY
from tests import ROOT_DIRECTORY

st.subheader("Test PDF Viewer using legacy embed")
st.subheader("Test PDF Viewer using legacy embed with specified height")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_embed', height=500)
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_embed_no_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 no args")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_embed')
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_embed_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 width")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_embed', width=500)
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_embed_width_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 width and height")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_embed', width=600, height=500)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import streamlit as st

from streamlit_pdf_viewer import pdf_viewer
from tests.test_template_args import ROOT_DIRECTORY
from tests import ROOT_DIRECTORY

st.subheader("Test PDF Viewer using legacy iframe")
st.subheader("Test PDF Viewer using legacy iframe with specified height")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_iframe', height=500)
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_iframe_no_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 iframe with no args")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_iframe')
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_iframe_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 iframe with specified width")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_iframe', width=500)
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_iframe_width_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 iframe with specified width and height")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), rendering='legacy_iframe', width=700, height=500)
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_unwrap_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

import streamlit as st

from streamlit_pdf_viewer import pdf_viewer
from tests import ROOT_DIRECTORY

st.subheader("Test PDF Viewer with specified height")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), height=300)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import streamlit as st

from streamlit_pdf_viewer import pdf_viewer
from tests.test_template_args import ROOT_DIRECTORY
from tests import ROOT_DIRECTORY

st.subheader("Test PDF Viewer with no arguments")
st.subheader("Test PDF Viewer with no args")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"))
10 changes: 10 additions & 0 deletions tests/streamlit_apps/example_unwrap_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

import streamlit as st
from tests import ROOT_DIRECTORY

from streamlit_pdf_viewer import pdf_viewer

st.subheader("Test PDF Viewer with arguments with specified width")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), width=400)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import streamlit as st

from streamlit_pdf_viewer import pdf_viewer
from tests.test_template_no_args import ROOT_DIRECTORY
from tests import ROOT_DIRECTORY

st.subheader("Test PDF Viewer with arguments")
st.subheader("Test PDF Viewer with specified width and height")

pdf_viewer(os.path.join(ROOT_DIRECTORY, "resources/test.pdf"), width=400, height=300)
8 changes: 3 additions & 5 deletions tests/test_template_embed.py → tests/test_embed_height.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
from pathlib import Path
from time import sleep

import pytest

from playwright.sync_api import Page, expect

from tests import ROOT_DIRECTORY
from tests.e2e_utils import StreamlitRunner

ROOT_DIRECTORY = Path(__file__).parent.parent.absolute()
BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_embed.py")
BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_embed_height.py")


@pytest.fixture(scope="session")
Expand All @@ -36,7 +34,7 @@ def go_to_app(page: Page, streamlit_app: StreamlitRunner):


def test_should_render_template_check_container_size(page: Page):
expect(page.get_by_text("Test PDF Viewer using legacy embed")).to_be_visible()
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).to_be_visible()
Expand Down
58 changes: 58 additions & 0 deletions tests/test_embed_no_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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_embed_no_args.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_render_template_check_container_size(page: Page):
expect(page.get_by_text("Test PDF Viewer using legacy embed with no args")).to_be_visible()

iframe_component = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0)
expect(iframe_component).to_be_visible()

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.10, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.10, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.9, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.9, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.11, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.11, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.8, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.8, 20)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.11, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.12, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.7, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.7, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.10, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.12, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.12, 20)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.9, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.9, 20)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.7, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.8, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_no_args.py

View workflow job for this annotation

GitHub Actions / build (3.8, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

iframe_box = iframe_component.bounding_box()
assert iframe_box['width'] > 0
assert iframe_box['height'] > 0

iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]')
pdf_container = iframe_frame.locator('div[id="pdfContainer"]')
expect(pdf_container).to_be_visible()

b_box = pdf_container.bounding_box()
assert b_box['width'] == 400
assert b_box['height'] > 0

pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]')
expect(pdf_viewer).not_to_be_visible()

annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0)
expect(annotations_locator).to_be_hidden()
58 changes: 58 additions & 0 deletions tests/test_embed_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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_embed_width.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_render_template_check_container_size(page: Page):
expect(page.get_by_text("Test PDF Viewer using legacy embed with specified width")).to_be_visible()

iframe_component = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0)
expect(iframe_component).to_be_visible()

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.10, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.10, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.9, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.9, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.11, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.11, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.8, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.8, 20)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.11, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.12, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.7, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.7, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.10, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.12, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.12, 20)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.9, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.9, 20)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.7, 20)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.8, 18)

test_should_render_template_check_container_size[firefox] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

Check failure on line 40 in tests/test_embed_width.py

View workflow job for this annotation

GitHub Actions / build (3.8, 18)

test_should_render_template_check_container_size[chromium] AssertionError: Locator expected to be visible Actual value: False Call log: LocatorAssertions.to_be_visible with timeout 5000ms - waiting for locator("iframe[title=\"streamlit_pdf_viewer.streamlit_pdf_viewer\"]").first - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden" - locator resolved to <iframe height="0" width="704" scrolling="no" title="str…></iframe> - unexpected value "hidden"

iframe_box = iframe_component.bounding_box()
assert iframe_box['width'] > 0
assert iframe_box['height'] > 0

iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]')
pdf_container = iframe_frame.locator('div[id="pdfContainer"]')
expect(pdf_container).to_be_visible()

b_box = pdf_container.bounding_box()
assert b_box['width'] == 400
assert b_box['height'] > 0

pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]')
expect(pdf_viewer).not_to_be_visible()

annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0)
expect(annotations_locator).to_be_hidden()
59 changes: 59 additions & 0 deletions tests/test_embed_width_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import math
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_embed_width_height.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_render_template_check_container_size(page: Page):
expect(page.get_by_text("Test PDF Viewer using legacy embed with specified width and height")).to_be_visible()

iframe_component = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0)
expect(iframe_component).to_be_visible()

iframe_box = iframe_component.bounding_box()
assert iframe_box['width'] > 0
assert iframe_box['height'] > 0

iframe_frame = page.frame_locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]')
pdf_container = iframe_frame.locator('div[id="pdfContainer"]')
expect(pdf_container).to_be_visible()

b_box = pdf_container.bounding_box()
assert b_box['width'] == 600
assert math.floor(b_box['height']) == 500

pdf_viewer = iframe_frame.locator('div[id="pdfViewer"]')
expect(pdf_viewer).not_to_be_visible()

annotations_locator = page.locator('div[id="pdfAnnotations"]').nth(0)
expect(annotations_locator).to_be_hidden()
8 changes: 3 additions & 5 deletions tests/test_template_iframe.py → tests/test_iframe_height.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
from pathlib import Path
from time import sleep

import pytest

from playwright.sync_api import Page, expect

from tests import ROOT_DIRECTORY
from tests.e2e_utils import StreamlitRunner

ROOT_DIRECTORY = Path(__file__).parent.parent.absolute()
BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_iframe.py")
BASIC_EXAMPLE_FILE = os.path.join(ROOT_DIRECTORY, "tests", "streamlit_apps", "example_iframe_height.py")


@pytest.fixture(scope="session")
Expand All @@ -36,7 +34,7 @@ def go_to_app(page: Page, streamlit_app: StreamlitRunner):


def test_should_render_template_check_container_size(page: Page):
expect(page.get_by_text("Test PDF Viewer using legacy iframe")).to_be_visible()
expect(page.get_by_text("Test PDF Viewer using legacy iframe with specified height")).to_be_visible()

iframe_component = page.locator('iframe[title="streamlit_pdf_viewer.streamlit_pdf_viewer"]').nth(0)
expect(iframe_component).to_be_visible()
Expand Down
Loading

0 comments on commit a988ef2

Please sign in to comment.