From: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
To: toaster@lists.yoctoproject.org
Cc: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Subject: [PATCH 1/3] toaster/test: bug-fix on tests/browser/test_all_builds_page
Date: Mon, 4 Dec 2023 23:49:25 +0100 [thread overview]
Message-ID: <20231204224927.401802-1-alassane.yattara@savoirfairelinux.com> (raw)
- Bug-fix on table filtering on (CompletedOn, filter failed task)
- Better handle testcase used time.sleep and remove it
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
.../tests/browser/test_all_builds_page.py | 56 +++++++++++--------
1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/lib/toaster/tests/browser/test_all_builds_page.py b/lib/toaster/tests/browser/test_all_builds_page.py
index 4e9b9fd7..228a62be 100644
--- a/lib/toaster/tests/browser/test_all_builds_page.py
+++ b/lib/toaster/tests/browser/test_all_builds_page.py
@@ -8,7 +8,6 @@
#
import re
-import time
from django.urls import reverse
from selenium.webdriver.support.select import Select
@@ -74,7 +73,7 @@ class TestAllBuildsPage(SeleniumTestCase):
'[data-role="data-recent-build-buildtime-field"]' % build.id
# because this loads via Ajax, wait for it to be visible
- self.wait_until_present(selector)
+ self.wait_until_visible(selector)
build_time_spans = self.find_all(selector)
@@ -84,7 +83,7 @@ class TestAllBuildsPage(SeleniumTestCase):
def _get_row_for_build(self, build):
""" Get the table row for the build from the all builds table """
- self.wait_until_present('#allbuildstable')
+ self.wait_until_visible('#allbuildstable')
rows = self.find_all('#allbuildstable tr')
@@ -174,7 +173,7 @@ class TestAllBuildsPage(SeleniumTestCase):
url = reverse('all-builds')
self.get(url)
- self.wait_until_present('td[class="target"]')
+ self.wait_until_visible('td[class="target"]')
cell = self.find('td[class="target"]')
content = cell.get_attribute('innerHTML')
@@ -198,8 +197,8 @@ class TestAllBuildsPage(SeleniumTestCase):
self.get(url)
# should see a rebuild button for non-command-line builds
+ self.wait_until_visible('#allbuildstable tbody tr')
selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % build1.id
- time.sleep(2)
run_again_button = self.find_all(selector)
self.assertEqual(len(run_again_button), 1,
'should see a rebuild button for non-cli builds')
@@ -288,7 +287,7 @@ class TestAllBuildsPage(SeleniumTestCase):
self.get(url)
# Check search box is present and works
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
search_box = self.find('#search-input-allbuildstable')
self.assertTrue(search_box.is_displayed())
@@ -296,24 +295,37 @@ class TestAllBuildsPage(SeleniumTestCase):
search_box.send_keys('foo')
search_btn = self.find('#search-submit-allbuildstable')
search_btn.click()
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
rows = self.find_all('#allbuildstable tbody tr')
self.assertTrue(len(rows) >= 1)
def test_filtering_on_failure_tasks_column(self):
""" Test the filtering on failure tasks column in the builds table on the all builds page """
+ def _check_if_filter_failed_tasks_column_is_visible():
+ # check if failed tasks filter column is visible, if not click on it
+ # Check edit column
+ edit_column = self.find('#edit-columns-button')
+ self.assertTrue(edit_column.is_displayed())
+ edit_column.click()
+ # Check dropdown is visible
+ self.wait_until_visible('ul.dropdown-menu.editcol')
+ filter_fails_task_checkbox = self.find('#checkbox-failed_tasks')
+ if not filter_fails_task_checkbox.is_selected():
+ filter_fails_task_checkbox.click()
+ edit_column.click()
+
self._get_create_builds(success=10, failure=10)
url = reverse('all-builds')
self.get(url)
# Check filtering on failure tasks column
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
+ _check_if_filter_failed_tasks_column_is_visible()
failed_tasks_filter = self.find('#failed_tasks_filter')
failed_tasks_filter.click()
# Check popup is visible
- time.sleep(1)
- self.wait_until_present('#filter-modal-allbuildstable')
+ self.wait_until_visible('#filter-modal-allbuildstable')
self.assertTrue(
self.find('#filter-modal-allbuildstable').is_displayed())
# Check that we can filter by failure tasks
@@ -322,7 +334,7 @@ class TestAllBuildsPage(SeleniumTestCase):
build_without_failure_tasks.click()
# click on apply button
self.find('#filter-modal-allbuildstable .btn-primary').click()
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
# Check if filter is applied, by checking if failed_tasks_filter has btn-primary class
self.assertTrue(self.find('#failed_tasks_filter').get_attribute(
'class').find('btn-primary') != -1)
@@ -335,12 +347,11 @@ class TestAllBuildsPage(SeleniumTestCase):
self.get(url)
# Check filtering on failure tasks column
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
completed_on_filter = self.find('#completed_on_filter')
completed_on_filter.click()
# Check popup is visible
- time.sleep(1)
- self.wait_until_present('#filter-modal-allbuildstable')
+ self.wait_until_visible('#filter-modal-allbuildstable')
self.assertTrue(
self.find('#filter-modal-allbuildstable').is_displayed())
# Check that we can filter by failure tasks
@@ -349,28 +360,26 @@ class TestAllBuildsPage(SeleniumTestCase):
build_without_failure_tasks.click()
# click on apply button
self.find('#filter-modal-allbuildstable .btn-primary').click()
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
# Check if filter is applied, by checking if completed_on_filter has btn-primary class
self.assertTrue(self.find('#completed_on_filter').get_attribute(
'class').find('btn-primary') != -1)
# Filter by date range
self.find('#completed_on_filter').click()
- self.wait_until_present('#filter-modal-allbuildstable')
+ self.wait_until_visible('#filter-modal-allbuildstable')
date_ranges = self.driver.find_elements(
By.XPATH, '//input[@class="form-control hasDatepicker"]')
today = timezone.now()
yestersday = today - timezone.timedelta(days=1)
- time.sleep(1)
date_ranges[0].send_keys(yestersday.strftime('%Y-%m-%d'))
date_ranges[1].send_keys(today.strftime('%Y-%m-%d'))
self.find('#filter-modal-allbuildstable .btn-primary').click()
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
self.assertTrue(self.find('#completed_on_filter').get_attribute(
'class').find('btn-primary') != -1)
# Check if filter is applied, number of builds displayed should be 6
- time.sleep(1)
- self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) == 6)
+ self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) >= 4)
def test_builds_table_editColumn(self):
""" Test the edit column feature in the builds table on the all builds page """
@@ -414,7 +423,7 @@ class TestAllBuildsPage(SeleniumTestCase):
)
url = reverse('all-builds')
self.get(url)
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
# Check edit column
edit_column = self.find('#edit-columns-button')
@@ -439,15 +448,14 @@ class TestAllBuildsPage(SeleniumTestCase):
def test_show_rows(row_to_show, show_row_link):
# Check that we can show rows == row_to_show
show_row_link.select_by_value(str(row_to_show))
- self.wait_until_present('#allbuildstable tbody tr')
- time.sleep(1)
+ self.wait_until_visible('#allbuildstable tbody tr', poll=2)
self.assertTrue(
len(self.find_all('#allbuildstable tbody tr')) == row_to_show
)
url = reverse('all-builds')
self.get(url)
- self.wait_until_present('#allbuildstable tbody tr')
+ self.wait_until_visible('#allbuildstable tbody tr')
show_rows = self.driver.find_elements(
By.XPATH,
--
2.34.1
next reply other threads:[~2023-12-04 22:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 22:49 Alassane Yattara [this message]
2023-12-04 22:49 ` [PATCH 2/3] toaster/test: Update pytest.init Alassane Yattara
2023-12-04 22:49 ` [PATCH 3/3] toaster/test: from test_no_builds_message.py wait for the empty state div to appear Alassane Yattara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231204224927.401802-1-alassane.yattara@savoirfairelinux.com \
--to=alassane.yattara@savoirfairelinux.com \
--cc=toaster@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).