streamlit

Форк
0
/
st_plotly_chart_test.py 
63 строки · 2.3 Кб
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

16
import pytest
17
from playwright.sync_api import Page, expect
18

19
from e2e_playwright.conftest import ImageCompareFunction
20

21

22
# Only do chromium as this can create a lot of screenshots
23
# there should be no differences between chrome and safari and firefox
24
@pytest.mark.only_browser("chromium")
25
def test_plotly_has_consistent_visuals(
26
    themed_app: Page, assert_snapshot: ImageCompareFunction
27
):
28
    snapshot_names = [
29
        "st_plotly_chart-none-theme",
30
        "st_plotly_chart-streamlit-theme-use-container-width",
31
        "st_plotly_chart-candlestick-streamlit-theme",
32
        "st_plotly_chart-sunburst-custom-color",
33
        "st_plotly_chart-contour-heatmap-together",
34
        "st_plotly_chart-waterfall-chart-custom-height-and-width",
35
        "st_plotly_chart-ternary-chart",
36
        "st_plotly_chart-table-plot",
37
        "st_plotly_chart-electric-colorscale",
38
        "st_plotly_chart-discrete-sequence",
39
        "st_plotly_chart-layout-customization",
40
        "st_plotly_chart-template-customization",
41
        "st_plotly_chart-histogram-chart",
42
    ]
43
    expect(themed_app.locator(".stPlotlyChart")).to_have_count(16)
44
    for i, name in enumerate(snapshot_names):
45
        assert_snapshot(
46
            themed_app.locator(".stPlotlyChart").nth(i),
47
            name=name,
48
        )
49

50

51
def test_plotly_has_correct_visuals(
52
    themed_app: Page, assert_snapshot: ImageCompareFunction
53
):
54
    snapshot_names = [
55
        "st_plotly_chart-line-chart-specific-height-width",
56
        "st_plotly_chart-use-container-width-false-and-specified-height",
57
        "st_plotly_chart-none-theme-and-use-container-width",
58
    ]
59
    for i, name in enumerate(snapshot_names):
60
        assert_snapshot(
61
            themed_app.locator(".stPlotlyChart").nth(i),
62
            name=name,
63
        )
64

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

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

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

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