diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-12-05 01:54:09 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-06 22:28:03 +0000 |
commit | 2d1f6c055d9ffc115fff2fc40e386d52e4b1bfc5 (patch) | |
tree | 594dbf535695980fca9699b41eba199464fb2c58 /bitbake/lib/toaster | |
parent | 0f4fe4f7630b45228bcbb893f08a86e00109296c (diff) | |
download | poky-2d1f6c055d9ffc115fff2fc40e386d52e4b1bfc5.tar.gz |
bitbake: toaster/test: bug-fix on tests/browser/test_all_builds_page
- Bug-fix on table filtering on (CompletedOn, filter failed task)
- Better handle testcase used time.sleep and remove it
(Bitbake rev: 03a8657dd377f87be08dd149ec507d153cb10a07)
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r-- | bitbake/lib/toaster/tests/browser/test_all_builds_page.py | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py index 4e9b9fd760..228a62be7d 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py | |||
@@ -8,7 +8,6 @@ | |||
8 | # | 8 | # |
9 | 9 | ||
10 | import re | 10 | import re |
11 | import time | ||
12 | 11 | ||
13 | from django.urls import reverse | 12 | from django.urls import reverse |
14 | from selenium.webdriver.support.select import Select | 13 | from selenium.webdriver.support.select import Select |
@@ -74,7 +73,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
74 | '[data-role="data-recent-build-buildtime-field"]' % build.id | 73 | '[data-role="data-recent-build-buildtime-field"]' % build.id |
75 | 74 | ||
76 | # because this loads via Ajax, wait for it to be visible | 75 | # because this loads via Ajax, wait for it to be visible |
77 | self.wait_until_present(selector) | 76 | self.wait_until_visible(selector) |
78 | 77 | ||
79 | build_time_spans = self.find_all(selector) | 78 | build_time_spans = self.find_all(selector) |
80 | 79 | ||
@@ -84,7 +83,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
84 | 83 | ||
85 | def _get_row_for_build(self, build): | 84 | def _get_row_for_build(self, build): |
86 | """ Get the table row for the build from the all builds table """ | 85 | """ Get the table row for the build from the all builds table """ |
87 | self.wait_until_present('#allbuildstable') | 86 | self.wait_until_visible('#allbuildstable') |
88 | 87 | ||
89 | rows = self.find_all('#allbuildstable tr') | 88 | rows = self.find_all('#allbuildstable tr') |
90 | 89 | ||
@@ -174,7 +173,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
174 | 173 | ||
175 | url = reverse('all-builds') | 174 | url = reverse('all-builds') |
176 | self.get(url) | 175 | self.get(url) |
177 | self.wait_until_present('td[class="target"]') | 176 | self.wait_until_visible('td[class="target"]') |
178 | 177 | ||
179 | cell = self.find('td[class="target"]') | 178 | cell = self.find('td[class="target"]') |
180 | content = cell.get_attribute('innerHTML') | 179 | content = cell.get_attribute('innerHTML') |
@@ -198,8 +197,8 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
198 | self.get(url) | 197 | self.get(url) |
199 | 198 | ||
200 | # should see a rebuild button for non-command-line builds | 199 | # should see a rebuild button for non-command-line builds |
200 | self.wait_until_visible('#allbuildstable tbody tr') | ||
201 | selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % build1.id | 201 | selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % build1.id |
202 | time.sleep(2) | ||
203 | run_again_button = self.find_all(selector) | 202 | run_again_button = self.find_all(selector) |
204 | self.assertEqual(len(run_again_button), 1, | 203 | self.assertEqual(len(run_again_button), 1, |
205 | 'should see a rebuild button for non-cli builds') | 204 | 'should see a rebuild button for non-cli builds') |
@@ -288,7 +287,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
288 | self.get(url) | 287 | self.get(url) |
289 | 288 | ||
290 | # Check search box is present and works | 289 | # Check search box is present and works |
291 | self.wait_until_present('#allbuildstable tbody tr') | 290 | self.wait_until_visible('#allbuildstable tbody tr') |
292 | search_box = self.find('#search-input-allbuildstable') | 291 | search_box = self.find('#search-input-allbuildstable') |
293 | self.assertTrue(search_box.is_displayed()) | 292 | self.assertTrue(search_box.is_displayed()) |
294 | 293 | ||
@@ -296,24 +295,37 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
296 | search_box.send_keys('foo') | 295 | search_box.send_keys('foo') |
297 | search_btn = self.find('#search-submit-allbuildstable') | 296 | search_btn = self.find('#search-submit-allbuildstable') |
298 | search_btn.click() | 297 | search_btn.click() |
299 | self.wait_until_present('#allbuildstable tbody tr') | 298 | self.wait_until_visible('#allbuildstable tbody tr') |
300 | rows = self.find_all('#allbuildstable tbody tr') | 299 | rows = self.find_all('#allbuildstable tbody tr') |
301 | self.assertTrue(len(rows) >= 1) | 300 | self.assertTrue(len(rows) >= 1) |
302 | 301 | ||
303 | def test_filtering_on_failure_tasks_column(self): | 302 | def test_filtering_on_failure_tasks_column(self): |
304 | """ Test the filtering on failure tasks column in the builds table on the all builds page """ | 303 | """ Test the filtering on failure tasks column in the builds table on the all builds page """ |
304 | def _check_if_filter_failed_tasks_column_is_visible(): | ||
305 | # check if failed tasks filter column is visible, if not click on it | ||
306 | # Check edit column | ||
307 | edit_column = self.find('#edit-columns-button') | ||
308 | self.assertTrue(edit_column.is_displayed()) | ||
309 | edit_column.click() | ||
310 | # Check dropdown is visible | ||
311 | self.wait_until_visible('ul.dropdown-menu.editcol') | ||
312 | filter_fails_task_checkbox = self.find('#checkbox-failed_tasks') | ||
313 | if not filter_fails_task_checkbox.is_selected(): | ||
314 | filter_fails_task_checkbox.click() | ||
315 | edit_column.click() | ||
316 | |||
305 | self._get_create_builds(success=10, failure=10) | 317 | self._get_create_builds(success=10, failure=10) |
306 | 318 | ||
307 | url = reverse('all-builds') | 319 | url = reverse('all-builds') |
308 | self.get(url) | 320 | self.get(url) |
309 | 321 | ||
310 | # Check filtering on failure tasks column | 322 | # Check filtering on failure tasks column |
311 | self.wait_until_present('#allbuildstable tbody tr') | 323 | self.wait_until_visible('#allbuildstable tbody tr') |
324 | _check_if_filter_failed_tasks_column_is_visible() | ||
312 | failed_tasks_filter = self.find('#failed_tasks_filter') | 325 | failed_tasks_filter = self.find('#failed_tasks_filter') |
313 | failed_tasks_filter.click() | 326 | failed_tasks_filter.click() |
314 | # Check popup is visible | 327 | # Check popup is visible |
315 | time.sleep(1) | 328 | self.wait_until_visible('#filter-modal-allbuildstable') |
316 | self.wait_until_present('#filter-modal-allbuildstable') | ||
317 | self.assertTrue( | 329 | self.assertTrue( |
318 | self.find('#filter-modal-allbuildstable').is_displayed()) | 330 | self.find('#filter-modal-allbuildstable').is_displayed()) |
319 | # Check that we can filter by failure tasks | 331 | # Check that we can filter by failure tasks |
@@ -322,7 +334,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
322 | build_without_failure_tasks.click() | 334 | build_without_failure_tasks.click() |
323 | # click on apply button | 335 | # click on apply button |
324 | self.find('#filter-modal-allbuildstable .btn-primary').click() | 336 | self.find('#filter-modal-allbuildstable .btn-primary').click() |
325 | self.wait_until_present('#allbuildstable tbody tr') | 337 | self.wait_until_visible('#allbuildstable tbody tr') |
326 | # Check if filter is applied, by checking if failed_tasks_filter has btn-primary class | 338 | # Check if filter is applied, by checking if failed_tasks_filter has btn-primary class |
327 | self.assertTrue(self.find('#failed_tasks_filter').get_attribute( | 339 | self.assertTrue(self.find('#failed_tasks_filter').get_attribute( |
328 | 'class').find('btn-primary') != -1) | 340 | 'class').find('btn-primary') != -1) |
@@ -335,12 +347,11 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
335 | self.get(url) | 347 | self.get(url) |
336 | 348 | ||
337 | # Check filtering on failure tasks column | 349 | # Check filtering on failure tasks column |
338 | self.wait_until_present('#allbuildstable tbody tr') | 350 | self.wait_until_visible('#allbuildstable tbody tr') |
339 | completed_on_filter = self.find('#completed_on_filter') | 351 | completed_on_filter = self.find('#completed_on_filter') |
340 | completed_on_filter.click() | 352 | completed_on_filter.click() |
341 | # Check popup is visible | 353 | # Check popup is visible |
342 | time.sleep(1) | 354 | self.wait_until_visible('#filter-modal-allbuildstable') |
343 | self.wait_until_present('#filter-modal-allbuildstable') | ||
344 | self.assertTrue( | 355 | self.assertTrue( |
345 | self.find('#filter-modal-allbuildstable').is_displayed()) | 356 | self.find('#filter-modal-allbuildstable').is_displayed()) |
346 | # Check that we can filter by failure tasks | 357 | # Check that we can filter by failure tasks |
@@ -349,28 +360,26 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
349 | build_without_failure_tasks.click() | 360 | build_without_failure_tasks.click() |
350 | # click on apply button | 361 | # click on apply button |
351 | self.find('#filter-modal-allbuildstable .btn-primary').click() | 362 | self.find('#filter-modal-allbuildstable .btn-primary').click() |
352 | self.wait_until_present('#allbuildstable tbody tr') | 363 | self.wait_until_visible('#allbuildstable tbody tr') |
353 | # Check if filter is applied, by checking if completed_on_filter has btn-primary class | 364 | # Check if filter is applied, by checking if completed_on_filter has btn-primary class |
354 | self.assertTrue(self.find('#completed_on_filter').get_attribute( | 365 | self.assertTrue(self.find('#completed_on_filter').get_attribute( |
355 | 'class').find('btn-primary') != -1) | 366 | 'class').find('btn-primary') != -1) |
356 | 367 | ||
357 | # Filter by date range | 368 | # Filter by date range |
358 | self.find('#completed_on_filter').click() | 369 | self.find('#completed_on_filter').click() |
359 | self.wait_until_present('#filter-modal-allbuildstable') | 370 | self.wait_until_visible('#filter-modal-allbuildstable') |
360 | date_ranges = self.driver.find_elements( | 371 | date_ranges = self.driver.find_elements( |
361 | By.XPATH, '//input[@class="form-control hasDatepicker"]') | 372 | By.XPATH, '//input[@class="form-control hasDatepicker"]') |
362 | today = timezone.now() | 373 | today = timezone.now() |
363 | yestersday = today - timezone.timedelta(days=1) | 374 | yestersday = today - timezone.timedelta(days=1) |
364 | time.sleep(1) | ||
365 | date_ranges[0].send_keys(yestersday.strftime('%Y-%m-%d')) | 375 | date_ranges[0].send_keys(yestersday.strftime('%Y-%m-%d')) |
366 | date_ranges[1].send_keys(today.strftime('%Y-%m-%d')) | 376 | date_ranges[1].send_keys(today.strftime('%Y-%m-%d')) |
367 | self.find('#filter-modal-allbuildstable .btn-primary').click() | 377 | self.find('#filter-modal-allbuildstable .btn-primary').click() |
368 | self.wait_until_present('#allbuildstable tbody tr') | 378 | self.wait_until_visible('#allbuildstable tbody tr') |
369 | self.assertTrue(self.find('#completed_on_filter').get_attribute( | 379 | self.assertTrue(self.find('#completed_on_filter').get_attribute( |
370 | 'class').find('btn-primary') != -1) | 380 | 'class').find('btn-primary') != -1) |
371 | # Check if filter is applied, number of builds displayed should be 6 | 381 | # Check if filter is applied, number of builds displayed should be 6 |
372 | time.sleep(1) | 382 | self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) >= 4) |
373 | self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) == 6) | ||
374 | 383 | ||
375 | def test_builds_table_editColumn(self): | 384 | def test_builds_table_editColumn(self): |
376 | """ Test the edit column feature in the builds table on the all builds page """ | 385 | """ Test the edit column feature in the builds table on the all builds page """ |
@@ -414,7 +423,7 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
414 | ) | 423 | ) |
415 | url = reverse('all-builds') | 424 | url = reverse('all-builds') |
416 | self.get(url) | 425 | self.get(url) |
417 | self.wait_until_present('#allbuildstable tbody tr') | 426 | self.wait_until_visible('#allbuildstable tbody tr') |
418 | 427 | ||
419 | # Check edit column | 428 | # Check edit column |
420 | edit_column = self.find('#edit-columns-button') | 429 | edit_column = self.find('#edit-columns-button') |
@@ -439,15 +448,14 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
439 | def test_show_rows(row_to_show, show_row_link): | 448 | def test_show_rows(row_to_show, show_row_link): |
440 | # Check that we can show rows == row_to_show | 449 | # Check that we can show rows == row_to_show |
441 | show_row_link.select_by_value(str(row_to_show)) | 450 | show_row_link.select_by_value(str(row_to_show)) |
442 | self.wait_until_present('#allbuildstable tbody tr') | 451 | self.wait_until_visible('#allbuildstable tbody tr', poll=2) |
443 | time.sleep(1) | ||
444 | self.assertTrue( | 452 | self.assertTrue( |
445 | len(self.find_all('#allbuildstable tbody tr')) == row_to_show | 453 | len(self.find_all('#allbuildstable tbody tr')) == row_to_show |
446 | ) | 454 | ) |
447 | 455 | ||
448 | url = reverse('all-builds') | 456 | url = reverse('all-builds') |
449 | self.get(url) | 457 | self.get(url) |
450 | self.wait_until_present('#allbuildstable tbody tr') | 458 | self.wait_until_visible('#allbuildstable tbody tr') |
451 | 459 | ||
452 | show_rows = self.driver.find_elements( | 460 | show_rows = self.driver.find_elements( |
453 | By.XPATH, | 461 | By.XPATH, |