streamlit

Форк
0
/
host_config_test.py 
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

15
from playwright.sync_api import Page, Route, expect
16

17
from e2e_playwright.conftest import ImageCompareFunction, wait_for_app_loaded
18

19

20
def handle_route_hostconfig_disable_fullscreen(route: Route) -> None:
21
    response = route.fetch()
22
    body = response.json()
23
    body["disableFullscreenMode"] = True
24
    route.fulfill(
25
        # Pass all fields from the response.
26
        response=response,
27
        # Override response body.
28
        json=body,
29
    )
30

31

32
def test_disable_fullscreen(
33
    page: Page, app_port: int, assert_snapshot: ImageCompareFunction
34
):
35
    """Test that fullscreen mode is disabled for elements when set via host-config"""
36
    page.route("**/_stcore/host-config", handle_route_hostconfig_disable_fullscreen)
37
    page.goto(f"http://localhost:{app_port}")
38
    wait_for_app_loaded(page)
39

40
    # check that the image does not have the fullscreen button
41
    expect(page.get_by_test_id("StyledFullScreenButton")).to_have_count(0)
42

43
    # Test that the toolbar is not shown when hovering over a dataframe
44
    dataframe_element = page.get_by_test_id("stDataFrame").nth(0)
45
    dataframe_toolbar = dataframe_element.get_by_test_id("stElementToolbar")
46

47
    # Hover over dataframe
48
    dataframe_element.hover()
49
    # Check that it is visible (expect waits)
50
    expect(dataframe_toolbar).to_have_css("opacity", "1")
51
    # Take a snapshot
52
    assert_snapshot(
53
        dataframe_toolbar, name="host_config-dataframe_disabled_fullscreen_mode"
54
    )
55

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.