Skip to content

Commit

Permalink
add wait for async requests in tests (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Feb 12, 2025
1 parent 5994c5a commit 9e7df47
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion projectroles/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ def _get_project_row(self, project):
By.ID, f'sodar-pr-project-list-item-{project.sodar_uuid}'
)

def _wait_for_async_requests(self):
"""Wait for async requests to finish"""
WebDriverWait(self.selenium, self.wait_time).until_not(
ec.presence_of_element_located(
(By.XPATH, '//svg[@data-icon="mdi:loading"]')
)
)

def test_project_list_items(self):
"""Test visibility of project list items"""
expected = [
Expand Down Expand Up @@ -598,7 +606,7 @@ def test_project_list_items_anon(self):
self.selenium.get(self.build_selenium_url(self.url))
WebDriverWait(self.selenium, self.wait_time).until(
ec.presence_of_element_located(
(getattr(By, 'CLASS_NAME'), 'sodar-pr-project-list-item')
(By.CLASS_NAME, 'sodar-pr-project-list-item')
)
)
self.assertEqual(self._get_item_vis_count(), 2)
Expand Down Expand Up @@ -814,6 +822,7 @@ def test_project_list_title_public(self):
def test_project_list_custom_cols(self):
"""Test rendering custom columns"""
self.login_and_redirect(self.user_owner, self.url, **self.wait_kwargs)
self._wait_for_async_requests()
row = self._get_project_row(self.project)
cols = row.find_elements(By.CLASS_NAME, 'sodar-pr-project-list-custom')
self.assertEqual(len(cols), 2)
Expand All @@ -830,6 +839,7 @@ def test_project_list_custom_cols_category(self):
def test_project_list_role_col_owner(self):
"""Test rendering role column as owner"""
self.login_and_redirect(self.user_owner, self.url, **self.wait_kwargs)
self._wait_for_async_requests()
row = self._get_project_row(self.project)
col = row.find_element(By.CLASS_NAME, 'sodar-pr-project-list-role')
self.assertEqual(
Expand All @@ -849,6 +859,7 @@ def test_project_list_role_col_category_inherit(self):
"""Test rendering role column with inherited role"""
# Owner user has no role in parent category
self.login_and_redirect(self.user_owner, self.url, **self.wait_kwargs)
self._wait_for_async_requests()
row = self._get_project_row(self.category)
col = row.find_element(By.CLASS_NAME, 'sodar-pr-project-list-role')
self.assertEqual(
Expand Down

0 comments on commit 9e7df47

Please sign in to comment.