diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-11-14 15:28:06 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-11-14 23:38:13 +0000 |
commit | 221a7b752fd59b9a7475fd2aae0f7eaefea5b20a (patch) | |
tree | 45463cf19c005b2047f58fc1d34f498f36eb47ac /bitbake | |
parent | b2db1c4e81df605eeee2b067d189ec131362523a (diff) | |
download | poky-221a7b752fd59b9a7475fd2aae0f7eaefea5b20a.tar.gz |
bitbake: toaster/tests: Add UI TestCase to test "show rows" feature, change displaying rows in table
Test the "show rows" feature in the builds table, on the all builds page
(Bitbake rev: 04c1c46d117b98ee6ccc351323edaf90ac1436c5)
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/tests/browser/test_all_builds_page.py | 64 |
1 files changed, 52 insertions, 12 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 bd2b479912..4e9b9fd760 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py | |||
@@ -7,9 +7,11 @@ | |||
7 | # SPDX-License-Identifier: GPL-2.0-only | 7 | # SPDX-License-Identifier: GPL-2.0-only |
8 | # | 8 | # |
9 | 9 | ||
10 | import re, time | 10 | import re |
11 | import time | ||
11 | 12 | ||
12 | from django.urls import reverse | 13 | from django.urls import reverse |
14 | from selenium.webdriver.support.select import Select | ||
13 | from django.utils import timezone | 15 | from django.utils import timezone |
14 | from bldcontrol.models import BuildRequest | 16 | from bldcontrol.models import BuildRequest |
15 | from tests.browser.selenium_helpers import SeleniumTestCase | 17 | from tests.browser.selenium_helpers import SeleniumTestCase |
@@ -151,13 +153,13 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
151 | build.recipes_parsed = 1 | 153 | build.recipes_parsed = 1 |
152 | build.save() | 154 | build.save() |
153 | buildRequest = BuildRequest.objects.create( | 155 | buildRequest = BuildRequest.objects.create( |
154 | build=build, | 156 | build=build, |
155 | project=self.project1, | 157 | project=self.project1, |
156 | state=BuildRequest.REQ_COMPLETED) | 158 | state=BuildRequest.REQ_COMPLETED) |
157 | build.build_request = buildRequest | 159 | build.build_request = buildRequest |
158 | recipe = self._create_recipe() | 160 | recipe = self._create_recipe() |
159 | task = Task.objects.create(build=build, | 161 | task = Task.objects.create(build=build, |
160 | recipe=recipe, | 162 | recipe=recipe, |
161 | task_name='task', | 163 | task_name='task', |
162 | outcome=Task.OUTCOME_SUCCESS) | 164 | outcome=Task.OUTCOME_SUCCESS) |
163 | task.save() | 165 | task.save() |
@@ -189,7 +191,8 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
189 | but should be shown for other builds | 191 | but should be shown for other builds |
190 | """ | 192 | """ |
191 | build1 = Build.objects.create(**self.project1_build_success) | 193 | build1 = Build.objects.create(**self.project1_build_success) |
192 | default_build = Build.objects.create(**self.default_project_build_success) | 194 | default_build = Build.objects.create( |
195 | **self.default_project_build_success) | ||
193 | 196 | ||
194 | url = reverse('all-builds') | 197 | url = reverse('all-builds') |
195 | self.get(url) | 198 | self.get(url) |
@@ -311,15 +314,18 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
311 | # Check popup is visible | 314 | # Check popup is visible |
312 | time.sleep(1) | 315 | time.sleep(1) |
313 | self.wait_until_present('#filter-modal-allbuildstable') | 316 | self.wait_until_present('#filter-modal-allbuildstable') |
314 | self.assertTrue(self.find('#filter-modal-allbuildstable').is_displayed()) | 317 | self.assertTrue( |
318 | self.find('#filter-modal-allbuildstable').is_displayed()) | ||
315 | # Check that we can filter by failure tasks | 319 | # Check that we can filter by failure tasks |
316 | build_without_failure_tasks = self.find('#failed_tasks_filter\\:without_failed_tasks') | 320 | build_without_failure_tasks = self.find( |
321 | '#failed_tasks_filter\\:without_failed_tasks') | ||
317 | build_without_failure_tasks.click() | 322 | build_without_failure_tasks.click() |
318 | # click on apply button | 323 | # click on apply button |
319 | self.find('#filter-modal-allbuildstable .btn-primary').click() | 324 | self.find('#filter-modal-allbuildstable .btn-primary').click() |
320 | self.wait_until_present('#allbuildstable tbody tr') | 325 | self.wait_until_present('#allbuildstable tbody tr') |
321 | # Check if filter is applied, by checking if failed_tasks_filter has btn-primary class | 326 | # Check if filter is applied, by checking if failed_tasks_filter has btn-primary class |
322 | self.assertTrue(self.find('#failed_tasks_filter').get_attribute('class').find('btn-primary') != -1) | 327 | self.assertTrue(self.find('#failed_tasks_filter').get_attribute( |
328 | 'class').find('btn-primary') != -1) | ||
323 | 329 | ||
324 | def test_filtering_on_completedOn_column(self): | 330 | def test_filtering_on_completedOn_column(self): |
325 | """ Test the filtering on completed_on column in the builds table on the all builds page """ | 331 | """ Test the filtering on completed_on column in the builds table on the all builds page """ |
@@ -335,16 +341,19 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
335 | # Check popup is visible | 341 | # Check popup is visible |
336 | time.sleep(1) | 342 | time.sleep(1) |
337 | self.wait_until_present('#filter-modal-allbuildstable') | 343 | self.wait_until_present('#filter-modal-allbuildstable') |
338 | self.assertTrue(self.find('#filter-modal-allbuildstable').is_displayed()) | 344 | self.assertTrue( |
345 | self.find('#filter-modal-allbuildstable').is_displayed()) | ||
339 | # Check that we can filter by failure tasks | 346 | # Check that we can filter by failure tasks |
340 | build_without_failure_tasks = self.find('#completed_on_filter\\:date_range') | 347 | build_without_failure_tasks = self.find( |
348 | '#completed_on_filter\\:date_range') | ||
341 | build_without_failure_tasks.click() | 349 | build_without_failure_tasks.click() |
342 | # click on apply button | 350 | # click on apply button |
343 | self.find('#filter-modal-allbuildstable .btn-primary').click() | 351 | self.find('#filter-modal-allbuildstable .btn-primary').click() |
344 | self.wait_until_present('#allbuildstable tbody tr') | 352 | self.wait_until_present('#allbuildstable tbody tr') |
345 | # Check if filter is applied, by checking if completed_on_filter has btn-primary class | 353 | # Check if filter is applied, by checking if completed_on_filter has btn-primary class |
346 | self.assertTrue(self.find('#completed_on_filter').get_attribute('class').find('btn-primary') != -1) | 354 | self.assertTrue(self.find('#completed_on_filter').get_attribute( |
347 | 355 | 'class').find('btn-primary') != -1) | |
356 | |||
348 | # Filter by date range | 357 | # Filter by date range |
349 | self.find('#completed_on_filter').click() | 358 | self.find('#completed_on_filter').click() |
350 | self.wait_until_present('#filter-modal-allbuildstable') | 359 | self.wait_until_present('#filter-modal-allbuildstable') |
@@ -357,7 +366,8 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
357 | date_ranges[1].send_keys(today.strftime('%Y-%m-%d')) | 366 | date_ranges[1].send_keys(today.strftime('%Y-%m-%d')) |
358 | self.find('#filter-modal-allbuildstable .btn-primary').click() | 367 | self.find('#filter-modal-allbuildstable .btn-primary').click() |
359 | self.wait_until_present('#allbuildstable tbody tr') | 368 | self.wait_until_present('#allbuildstable tbody tr') |
360 | self.assertTrue(self.find('#completed_on_filter').get_attribute('class').find('btn-primary') != -1) | 369 | self.assertTrue(self.find('#completed_on_filter').get_attribute( |
370 | 'class').find('btn-primary') != -1) | ||
361 | # Check if filter is applied, number of builds displayed should be 6 | 371 | # Check if filter is applied, number of builds displayed should be 6 |
362 | time.sleep(1) | 372 | time.sleep(1) |
363 | self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) == 6) | 373 | self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) == 6) |
@@ -421,3 +431,33 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
421 | test_edit_column('checkbox-started_on') | 431 | test_edit_column('checkbox-started_on') |
422 | test_edit_column('checkbox-time') | 432 | test_edit_column('checkbox-time') |
423 | test_edit_column('checkbox-warnings_no') | 433 | test_edit_column('checkbox-warnings_no') |
434 | |||
435 | def test_builds_table_show_rows(self): | ||
436 | """ Test the show rows feature in the builds table on the all builds page """ | ||
437 | self._get_create_builds(success=100, failure=100) | ||
438 | |||
439 | def test_show_rows(row_to_show, show_row_link): | ||
440 | # Check that we can show rows == row_to_show | ||
441 | show_row_link.select_by_value(str(row_to_show)) | ||
442 | self.wait_until_present('#allbuildstable tbody tr') | ||
443 | time.sleep(1) | ||
444 | self.assertTrue( | ||
445 | len(self.find_all('#allbuildstable tbody tr')) == row_to_show | ||
446 | ) | ||
447 | |||
448 | url = reverse('all-builds') | ||
449 | self.get(url) | ||
450 | self.wait_until_present('#allbuildstable tbody tr') | ||
451 | |||
452 | show_rows = self.driver.find_elements( | ||
453 | By.XPATH, | ||
454 | '//select[@class="form-control pagesize-allbuildstable"]' | ||
455 | ) | ||
456 | # Check show rows | ||
457 | for show_row_link in show_rows: | ||
458 | show_row_link = Select(show_row_link) | ||
459 | test_show_rows(10, show_row_link) | ||
460 | test_show_rows(25, show_row_link) | ||
461 | test_show_rows(50, show_row_link) | ||
462 | test_show_rows(100, show_row_link) | ||
463 | test_show_rows(150, show_row_link) | ||