Skip to content

Commit

Permalink
Add some quick fixes for test flakiness (#90)
Browse files Browse the repository at this point in the history
* Add some flakiness quick fixes

* Add quick fixes to cookiecutter template

* Fix except
  • Loading branch information
lukasmasuch authored Feb 2, 2024
1 parent efd4e02 commit f82cd1f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_should_change_iframe_height(page: Page):

locator = page.locator('iframe[title="my_component\\.my_component"]').nth(1)

page.wait_for_timeout(1000)
init_frame_height = locator.bounding_box()['height']
assert init_frame_height != 0

Expand All @@ -75,12 +76,14 @@ def test_should_change_iframe_height(page: Page):

expect(frame.get_by_text("Streamlit Streamlit Streamlit")).to_be_visible()

page.wait_for_timeout(1000)
frame_height = locator.bounding_box()['height']
assert frame_height > init_frame_height

page.set_viewport_size({"width": 150, "height": 150})

expect(frame.get_by_text("Streamlit Streamlit Streamlit")).not_to_be_in_viewport()

page.wait_for_timeout(1000)
frame_height_after_viewport_change = locator.bounding_box()['height']
assert frame_height_after_viewport_change > frame_height
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ def test_should_render_selectable_data_table(page: Page):

first_row_checkbox.uncheck()
expect(root_checkbox).not_to_be_checked()
assert root_checkbox.get_attribute('data-indeterminate') == "true"
expect(root_checkbox).to_have_attribute('data-indeterminate', 'true')

for checkbox in none_root_checkboxes:
checkbox.uncheck()

expect(root_checkbox).not_to_be_checked()
assert root_checkbox.get_attribute('data-indeterminate') == 'false'
expect(root_checkbox).to_have_attribute('data-indeterminate', 'false')

for checkbox in none_root_checkboxes:
checkbox.check()

expect(root_checkbox).to_be_checked()
assert root_checkbox.get_attribute('data-indeterminate') == 'false'
expect(root_checkbox).to_have_attribute('data-indeterminate', 'false')
3 changes: 3 additions & 0 deletions template-reactless/e2e/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_should_change_iframe_height(page: Page):

locator = page.locator('iframe[title="my_component\\.my_component"]').nth(1)

page.wait_for_timeout(1000)
init_frame_height = locator.bounding_box()['height']
assert init_frame_height != 0

Expand All @@ -75,12 +76,14 @@ def test_should_change_iframe_height(page: Page):

expect(frame.get_by_text("Streamlit Streamlit Streamlit")).to_be_visible()

page.wait_for_timeout(1000)
frame_height = locator.bounding_box()['height']
assert frame_height > init_frame_height

page.set_viewport_size({"width": 150, "height": 150})

expect(frame.get_by_text("Streamlit Streamlit Streamlit")).not_to_be_in_viewport()

page.wait_for_timeout(1000)
frame_height_after_viewport_change = locator.bounding_box()['height']
assert frame_height_after_viewport_change > frame_height
3 changes: 3 additions & 0 deletions template/e2e/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_should_change_iframe_height(page: Page):

locator = page.locator('iframe[title="my_component\\.my_component"]').nth(1)

page.wait_for_timeout(1000)
init_frame_height = locator.bounding_box()['height']
assert init_frame_height != 0

Expand All @@ -75,12 +76,14 @@ def test_should_change_iframe_height(page: Page):

expect(frame.get_by_text("Streamlit Streamlit Streamlit")).to_be_visible()

page.wait_for_timeout(1000)
frame_height = locator.bounding_box()['height']
assert frame_height > init_frame_height

page.set_viewport_size({"width": 150, "height": 150})

expect(frame.get_by_text("Streamlit Streamlit Streamlit")).not_to_be_in_viewport()

page.wait_for_timeout(1000)
frame_height_after_viewport_change = locator.bounding_box()['height']
assert frame_height_after_viewport_change > frame_height

0 comments on commit f82cd1f

Please sign in to comment.