Skip to content

Commit

Permalink
Fix flaky E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sissbruecker committed Mar 24, 2024
1 parent 9df80e0 commit 77e1525
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 17 additions & 3 deletions bookmarks/e2e/e2e_test_bookmark_page_bulk_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ def test_active_bookmarks_bulk_select_across(self):
with sync_playwright() as p:
self.open(reverse("bookmarks:index"), p)

bookmark_list = self.locate_bookmark_list()
self.locate_bulk_edit_toggle().click()
self.locate_bulk_edit_select_all().click()
self.locate_bulk_edit_select_across().click()

self.select_bulk_action("Delete")
self.locate_bulk_edit_bar().get_by_text("Execute").click()
self.locate_bulk_edit_bar().get_by_text("Confirm").click()
# Wait until bookmark list is updated (old reference becomes invisible)
expect(bookmark_list).not_to_be_visible()

self.assertEqual(
0,
Expand Down Expand Up @@ -74,13 +77,16 @@ def test_archived_bookmarks_bulk_select_across(self):
with sync_playwright() as p:
self.open(reverse("bookmarks:archived"), p)

bookmark_list = self.locate_bookmark_list()
self.locate_bulk_edit_toggle().click()
self.locate_bulk_edit_select_all().click()
self.locate_bulk_edit_select_across().click()

self.select_bulk_action("Delete")
self.locate_bulk_edit_bar().get_by_text("Execute").click()
self.locate_bulk_edit_bar().get_by_text("Confirm").click()
# Wait until bookmark list is updated (old reference becomes invisible)
expect(bookmark_list).not_to_be_visible()

self.assertEqual(
50,
Expand Down Expand Up @@ -109,13 +115,16 @@ def test_active_bookmarks_bulk_select_across_respects_query(self):
with sync_playwright() as p:
self.open(reverse("bookmarks:index") + "?q=foo", p)

bookmark_list = self.locate_bookmark_list()
self.locate_bulk_edit_toggle().click()
self.locate_bulk_edit_select_all().click()
self.locate_bulk_edit_select_across().click()

self.select_bulk_action("Delete")
self.locate_bulk_edit_bar().get_by_text("Execute").click()
self.locate_bulk_edit_bar().get_by_text("Confirm").click()
# Wait until bookmark list is updated (old reference becomes invisible)
expect(bookmark_list).not_to_be_visible()

self.assertEqual(
50,
Expand Down Expand Up @@ -144,13 +153,16 @@ def test_archived_bookmarks_bulk_select_across_respects_query(self):
with sync_playwright() as p:
self.open(reverse("bookmarks:archived") + "?q=foo", p)

bookmark_list = self.locate_bookmark_list()
self.locate_bulk_edit_toggle().click()
self.locate_bulk_edit_select_all().click()
self.locate_bulk_edit_select_across().click()

self.select_bulk_action("Delete")
self.locate_bulk_edit_bar().get_by_text("Execute").click()
self.locate_bulk_edit_bar().get_by_text("Confirm").click()
# Wait until bookmark list is updated (old reference becomes invisible)
expect(bookmark_list).not_to_be_visible()

self.assertEqual(
50,
Expand Down Expand Up @@ -269,14 +281,13 @@ def test_execute_resets_all_checkboxes(self):
url = reverse("bookmarks:index")
page = self.open(url, p)

bookmark_list = self.locate_bookmark_list()

# Select all bookmarks, enable select across
self.locate_bulk_edit_toggle().click()
self.locate_bulk_edit_select_all().click()
self.locate_bulk_edit_select_across().click()

# Get reference for bookmark list
bookmark_list = page.locator("ul[ld-bookmark-list]")

# Execute bulk action
self.select_bulk_action("Mark as unread")
self.locate_bulk_edit_bar().get_by_text("Execute").click()
Expand All @@ -302,6 +313,7 @@ def test_update_select_across_bookmark_count(self):
url = reverse("bookmarks:index")
self.open(url, p)

bookmark_list = self.locate_bookmark_list()
self.locate_bulk_edit_toggle().click()
self.locate_bulk_edit_select_all().click()

Expand All @@ -312,6 +324,8 @@ def test_update_select_across_bookmark_count(self):
self.select_bulk_action("Delete")
self.locate_bulk_edit_bar().get_by_text("Execute").click()
self.locate_bulk_edit_bar().get_by_text("Confirm").click()
# Wait until bookmark list is updated (old reference becomes invisible)
expect(bookmark_list).not_to_be_visible()

expect(self.locate_bulk_edit_select_all()).not_to_be_checked()
self.locate_bulk_edit_select_all().click()
Expand Down
3 changes: 3 additions & 0 deletions bookmarks/e2e/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def on_load(self):
def assertReloads(self, count: int):
self.assertEqual(self.num_loads, count)

def locate_bookmark_list(self):
return self.page.locator("ul[ld-bookmark-list]")

def locate_bookmark(self, title: str):
bookmark_tags = self.page.locator("li[ld-bookmark-item]")
return bookmark_tags.filter(has_text=title)
Expand Down

0 comments on commit 77e1525

Please sign in to comment.