streamlit
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
16import pytest17from playwright.sync_api import Page, expect18
19from e2e_playwright.conftest import ImageCompareFunction20
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")25def test_plotly_has_consistent_visuals(26themed_app: Page, assert_snapshot: ImageCompareFunction27):28snapshot_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]43expect(themed_app.locator(".stPlotlyChart")).to_have_count(16)44for i, name in enumerate(snapshot_names):45assert_snapshot(46themed_app.locator(".stPlotlyChart").nth(i),47name=name,48)49
50
51def test_plotly_has_correct_visuals(52themed_app: Page, assert_snapshot: ImageCompareFunction53):54snapshot_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]59for i, name in enumerate(snapshot_names):60assert_snapshot(61themed_app.locator(".stPlotlyChart").nth(i),62name=name,63)64