streamlit

Форк
0
/
app_hotkeys_test.py 
51 строка · 1.9 Кб
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, expect
16

17

18
def test_shows_clear_cache_dialog_when_c_is_pressed(app: Page):
19
    app.keyboard.type("c")
20
    expect(app.get_by_role("dialog")).to_be_visible()
21
    expect(app.get_by_role("dialog")).to_have_text(
22
        """
23
Clear cachesAre you sure you want to clear the app's function caches?This will remove all cached entries from functions using @st.cache, @st.cache_data, and @st.cache_resource.CancelClear caches
24
    """
25
    )
26

27

28
modifier_keys = ["Control", "Meta"]
29

30

31
def test_does_not_show_clear_cache_when_modifier_c_is_pressed(app: Page):
32
    for key in modifier_keys:
33
        app.keyboard.press(f"{key}+c")
34
    expect(app.get_by_test_id("stClearCacheDialog")).not_to_be_visible()
35

36

37
def test_does_not_clear_cache_dialog_when_c_is_pressed_inside_text_input(app: Page):
38
    app.get_by_test_id("stTextInput").type("c")
39
    expect(app.get_by_test_id("stClearCacheDialog")).not_to_be_visible()
40

41

42
def test_reruns_when_r_is_pressed(app: Page):
43
    app.keyboard.type("r")
44
    expect(app.get_by_test_id("stStatusWidget")).to_be_visible()
45

46

47
def test_does_not_clear_cache_dialog_when_r_is_pressed_inside_text_input(
48
    app: Page,
49
):
50
    app.get_by_test_id("stTextInput").press("r")
51
    expect(app.get_by_test_id("stStatusWidget")).not_to_be_visible()
52

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

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

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

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