streamlit
54 строки · 2.0 Кб
1# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from playwright.sync_api import Page, Route, expect
16
17from e2e_playwright.conftest import ImageCompareFunction, wait_for_app_loaded
18
19
20def handle_route_hostconfig_disable_fullscreen(route: Route) -> None:
21response = route.fetch()
22body = response.json()
23body["disableFullscreenMode"] = True
24route.fulfill(
25# Pass all fields from the response.
26response=response,
27# Override response body.
28json=body,
29)
30
31
32def test_disable_fullscreen(
33page: Page, app_port: int, assert_snapshot: ImageCompareFunction
34):
35"""Test that fullscreen mode is disabled for elements when set via host-config"""
36page.route("**/_stcore/host-config", handle_route_hostconfig_disable_fullscreen)
37page.goto(f"http://localhost:{app_port}")
38wait_for_app_loaded(page)
39
40# check that the image does not have the fullscreen button
41expect(page.get_by_test_id("StyledFullScreenButton")).to_have_count(0)
42
43# Test that the toolbar is not shown when hovering over a dataframe
44dataframe_element = page.get_by_test_id("stDataFrame").nth(0)
45dataframe_toolbar = dataframe_element.get_by_test_id("stElementToolbar")
46
47# Hover over dataframe
48dataframe_element.hover()
49# Check that it is visible (expect waits)
50expect(dataframe_toolbar).to_have_css("opacity", "1")
51# Take a snapshot
52assert_snapshot(
53dataframe_toolbar, name="host_config-dataframe_disabled_fullscreen_mode"
54)
55