forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting disableFullscreenMode dynamically (streamlit#8026)
Co-authored-by: Lukas Masuch <[email protected]>
- Loading branch information
1 parent
d884221
commit e8f5fa9
Showing
17 changed files
with
224 additions
and
110 deletions.
There are no files selected for viewing
Binary file added
BIN
+1.13 KB
...x/host_config_test/host_config-dataframe_disabled_fullscreen_mode[chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.08 KB
...ux/host_config_test/host_config-dataframe_disabled_fullscreen_mode[firefox].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.05 KB
...nux/host_config_test/host_config-dataframe_disabled_fullscreen_mode[webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
import streamlit as st | ||
|
||
# always generate the same data | ||
np.random.seed(0) | ||
|
||
st.image(np.repeat(0, 100).reshape(10, 10)) | ||
st.dataframe( | ||
pd.DataFrame(np.random.randint(0, 100, size=(100, 4)), columns=list("ABCD")) | ||
) |
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,54 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from playwright.sync_api import Page, Route, expect | ||
|
||
from e2e_playwright.conftest import ImageCompareFunction, wait_for_app_loaded | ||
|
||
|
||
def handle_route_hostconfig_disable_fullscreen(route: Route) -> None: | ||
response = route.fetch() | ||
body = response.json() | ||
body["disableFullscreenMode"] = True | ||
route.fulfill( | ||
# Pass all fields from the response. | ||
response=response, | ||
# Override response body. | ||
json=body, | ||
) | ||
|
||
|
||
def test_disable_fullscreen( | ||
page: Page, app_port: int, assert_snapshot: ImageCompareFunction | ||
): | ||
"""Test that fullscreen mode is disabled for elements when set via host-config""" | ||
page.route("**/_stcore/host-config", handle_route_hostconfig_disable_fullscreen) | ||
page.goto(f"http://localhost:{app_port}") | ||
wait_for_app_loaded(page) | ||
|
||
# check that the image does not have the fullscreen button | ||
expect(page.get_by_test_id("StyledFullScreenButton")).to_have_count(0) | ||
|
||
# Test that the toolbar is not shown when hovering over a dataframe | ||
dataframe_element = page.get_by_test_id("stDataFrame").nth(0) | ||
dataframe_toolbar = dataframe_element.get_by_test_id("stElementToolbar") | ||
|
||
# Hover over dataframe | ||
dataframe_element.hover() | ||
# Check that it is visible (expect waits) | ||
expect(dataframe_toolbar).to_have_css("opacity", "1") | ||
# Take a snapshot | ||
assert_snapshot( | ||
dataframe_toolbar, name="host_config-dataframe_disabled_fullscreen_mode" | ||
) |
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
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,19 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import numpy as np | ||
|
||
import streamlit as st | ||
|
||
st.image(np.repeat(0, 100).reshape(10, 10)) |
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,21 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
|
||
def test_fullscreen_button_exists(app: Page): | ||
"""Test that element has the fullscreen button.""" | ||
# check that the image has the fullscreen button | ||
expect(app.get_by_test_id("StyledFullScreenButton")).to_have_count(1) |
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
Oops, something went wrong.