From 02022e7f03d5643022448a0bdee6fdbcab924dcb Mon Sep 17 00:00:00 2001 From: Lukas Masuch Date: Sat, 6 Jan 2024 00:24:09 +0100 Subject: [PATCH] Reduce e2e test flakiness by using waiting methods (#7907) * Reduce graphviz e2e test flakiness * Fix other test * Fix test * Update frontend license audit * Fix audit scan * Fix link --- .../st_both_query_params_error_test.py | 2 +- e2e_playwright/st_graphviz_chart_test.py | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e_playwright/st_both_query_params_error_test.py b/e2e_playwright/st_both_query_params_error_test.py index 717d8fee14ab..4fe60fdc3f90 100644 --- a/e2e_playwright/st_both_query_params_error_test.py +++ b/e2e_playwright/st_both_query_params_error_test.py @@ -16,7 +16,7 @@ def test_query_params_exception_msg(app: Page): - assert app.get_by_test_id("stException") is not None + expect(app.get_by_test_id("stException")).to_be_visible() expect( app.get_by_text( "Using st.query_params together with either st.experimental_get_query_params or st.experimental_set_query_params is not supported. Please convert your app to only use st.query_params" diff --git a/e2e_playwright/st_graphviz_chart_test.py b/e2e_playwright/st_graphviz_chart_test.py index a3b6e4d1c219..13e58c7729d9 100644 --- a/e2e_playwright/st_graphviz_chart_test.py +++ b/e2e_playwright/st_graphviz_chart_test.py @@ -29,26 +29,26 @@ def click_fullscreen(app: Page): def test_initial_setup(app: Page): """Initial setup: ensure charts are loaded.""" - - wait_for_app_run(app) - title_count = len(app.locator(".stGraphVizChart > svg > g > title").all()) - assert title_count == 6 + expect(app.locator(".stGraphVizChart > svg > g > title")).to_have_count(6) def test_shows_left_and_right_graph(app: Page): """Test if it shows left and right graph.""" - left_text = app.locator(".stGraphVizChart > svg > g > title").nth(3).text_content() - right_text = app.locator(".stGraphVizChart > svg > g > title").nth(4).text_content() - assert "Left" in left_text and "Right" in right_text + expect(app.locator(".stGraphVizChart > svg > g > title").nth(3)).to_have_text( + "Left" + ) + expect(app.locator(".stGraphVizChart > svg > g > title").nth(4)).to_have_text( + "Right" + ) def test_first_graph_dimensions(app: Page): """Test the dimensions of the first graph.""" first_graph_svg = get_first_graph_svg(app) - assert first_graph_svg.get_attribute("width") == "79pt" - assert first_graph_svg.get_attribute("height") == "116pt" + expect(first_graph_svg).to_have_attribute("width", "79pt") + expect(first_graph_svg).to_have_attribute("height", "116pt") def test_first_graph_fullscreen(app: Page, assert_snapshot: ImageCompareFunction): @@ -84,8 +84,8 @@ def test_first_graph_after_exit_fullscreen( click_fullscreen(app) first_graph_svg = get_first_graph_svg(app) - assert first_graph_svg.get_attribute("width") == "79pt" - assert first_graph_svg.get_attribute("height") == "116pt" + expect(first_graph_svg).to_have_attribute("width", "79pt") + expect(first_graph_svg).to_have_attribute("height", "116pt") assert_snapshot(first_graph_svg, name="graphviz_after_exit_fullscreen")