From b9cff7ad91f4e157fc2f65e28d00969a4434c09a Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sat, 9 Sep 2017 08:28:01 -0400 Subject: [PATCH] Fix another issue with sorting by owner for published histories Selenium test. Locally this never happens, but remotely sometimes when sorting by owner the histories are sorted by owner but not in the same order as the test was asserting. I would assume this is likely a postgres vs. sqlite difference - perhaps the former doesn't sort the rows by the order they were created within equal sort classifications (i.e. same owner) but the latter does. I've fixed this - the test should not have been asserting such a strong condition I don't think. --- .../test_published_histories_grid.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/selenium_tests/test_published_histories_grid.py b/test/selenium_tests/test_published_histories_grid.py index ebe4cd2316a..188a68b6eee 100644 --- a/test/selenium_tests/test_published_histories_grid.py +++ b/test/selenium_tests/test_published_histories_grid.py @@ -82,16 +82,14 @@ class HistoryGridTestCase(SeleniumTestCase): @selenium_test def test_history_grid_sort_by_name(self): self.navigate_to_published_histories_page() - sort_link = self.wait_for_selector('th#name-header > a') - sort_link.click() + self.wait_for_and_click_selector('th#name-header > a') self.assert_grid_histories_are([HISTORY1_NAME, HISTORY2_NAME, HISTORY3_NAME]) @selenium_test def test_history_grid_sort_by_owner(self): self.navigate_to_published_histories_page() - sort_link = self.wait_for_selector('th#username-header > a') - sort_link.click() - self.assert_grid_histories_are([HISTORY1_NAME, HISTORY3_NAME, HISTORY2_NAME]) + self.wait_for_and_click_selector('th#username-header > a') + self.assert_grid_histories_sorted_by_owner() @selenium_test def test_history_grid_tag_click(self): @@ -125,6 +123,15 @@ class HistoryGridTestCase(SeleniumTestCase): return names + @retry_assertion_during_transitions + def assert_grid_histories_sorted_by_owner(self): + histories = self.get_histories() + index_1, index_2, index_3 = [histories.index(n) for n in [HISTORY1_NAME, HISTORY2_NAME, HISTORY3_NAME]] + # 1 and 3 are owned by a owner whose username lexicographically + # precedes 2. So verify 1 and 3 come before 2. + assert index_1 < index_2 + assert index_3 < index_2 + @retry_assertion_during_transitions def assert_grid_histories_are(self, expected_histories, sort_matters=True): actual_histories = self.get_histories()