diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-11-14 15:28:04 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-11-14 23:38:13 +0000 |
commit | 853deb8f75cc9bd31c7597ba7a57e02e64f78c90 (patch) | |
tree | d4816be5473ac45b3549d0a8dcf2427f65d4d649 | |
parent | 2d73d6148eba7dbda0d2c95415bc0d205d630237 (diff) | |
download | poky-853deb8f75cc9bd31c7597ba7a57e02e64f78c90.tar.gz |
bitbake: toaster/tests: Add UI TestCase to test filtering feature on 'completed_on' column
Test the filtering on completed_on column in the builds table on the all builds page
(Bitbake rev: bb459d5809ada703b551172c8dd3771565f80dec)
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/toaster/tests/browser/test_all_builds_page.py | 80 |
1 files changed, 78 insertions, 2 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 81498aa818..90dcdd9193 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py | |||
@@ -11,10 +11,10 @@ import re, time | |||
11 | 11 | ||
12 | from django.urls import reverse | 12 | from django.urls import reverse |
13 | from django.utils import timezone | 13 | from django.utils import timezone |
14 | from selenium.webdriver.remote.webdriver import WebElement | 14 | from bldcontrol.models import BuildRequest |
15 | from tests.browser.selenium_helpers import SeleniumTestCase | 15 | from tests.browser.selenium_helpers import SeleniumTestCase |
16 | 16 | ||
17 | from orm.models import BitbakeVersion, Release, Project, Build, Target | 17 | from orm.models import BitbakeVersion, Layer, Layer_Version, Recipe, Release, Project, Build, Target, Task |
18 | 18 | ||
19 | from selenium.webdriver.common.by import By | 19 | from selenium.webdriver.common.by import By |
20 | 20 | ||
@@ -118,17 +118,51 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
118 | # Create kwargs.get('success') builds with success status with target | 118 | # Create kwargs.get('success') builds with success status with target |
119 | # and kwargs.get('failure') builds with failure status with target | 119 | # and kwargs.get('failure') builds with failure status with target |
120 | for i in range(kwargs.get('success', 0)): | 120 | for i in range(kwargs.get('success', 0)): |
121 | now = timezone.now() | ||
122 | self.project1_build_success['started_on'] = now | ||
123 | self.project1_build_success[ | ||
124 | 'completed_on'] = now - timezone.timedelta(days=i) | ||
121 | build = Build.objects.create(**self.project1_build_success) | 125 | build = Build.objects.create(**self.project1_build_success) |
122 | Target.objects.create(build=build, | 126 | Target.objects.create(build=build, |
123 | target=f'{i}_success_recipe', | 127 | target=f'{i}_success_recipe', |
124 | task=f'{i}_success_task') | 128 | task=f'{i}_success_task') |
129 | |||
130 | self._set_buildRequest_and_task_on_build(build) | ||
125 | for i in range(kwargs.get('failure', 0)): | 131 | for i in range(kwargs.get('failure', 0)): |
132 | now = timezone.now() | ||
133 | self.project1_build_failure['started_on'] = now | ||
134 | self.project1_build_failure[ | ||
135 | 'completed_on'] = now - timezone.timedelta(days=i) | ||
126 | build = Build.objects.create(**self.project1_build_failure) | 136 | build = Build.objects.create(**self.project1_build_failure) |
127 | Target.objects.create(build=build, | 137 | Target.objects.create(build=build, |
128 | target=f'{i}_fail_recipe', | 138 | target=f'{i}_fail_recipe', |
129 | task=f'{i}_fail_task') | 139 | task=f'{i}_fail_task') |
140 | self._set_buildRequest_and_task_on_build(build) | ||
130 | return build1, build2 | 141 | return build1, build2 |
131 | 142 | ||
143 | def _create_recipe(self): | ||
144 | """ Add a recipe to the database and return it """ | ||
145 | layer = Layer.objects.create() | ||
146 | layer_version = Layer_Version.objects.create(layer=layer) | ||
147 | return Recipe.objects.create(name='recipe_foo', layer_version=layer_version) | ||
148 | |||
149 | def _set_buildRequest_and_task_on_build(self, build): | ||
150 | """ Set buildRequest and task on build """ | ||
151 | build.recipes_parsed = 1 | ||
152 | build.save() | ||
153 | buildRequest = BuildRequest.objects.create( | ||
154 | build=build, | ||
155 | project=self.project1, | ||
156 | state=BuildRequest.REQ_COMPLETED) | ||
157 | build.build_request = buildRequest | ||
158 | recipe = self._create_recipe() | ||
159 | task = Task.objects.create(build=build, | ||
160 | recipe=recipe, | ||
161 | task_name='task', | ||
162 | outcome=Task.OUTCOME_SUCCESS) | ||
163 | task.save() | ||
164 | build.save() | ||
165 | |||
132 | def test_show_tasks_with_suffix(self): | 166 | def test_show_tasks_with_suffix(self): |
133 | """ Task should be shown as suffix on build name """ | 167 | """ Task should be shown as suffix on build name """ |
134 | build = Build.objects.create(**self.project1_build_success) | 168 | build = Build.objects.create(**self.project1_build_success) |
@@ -286,3 +320,45 @@ class TestAllBuildsPage(SeleniumTestCase): | |||
286 | self.wait_until_present('#allbuildstable tbody tr') | 320 | self.wait_until_present('#allbuildstable tbody tr') |
287 | # Check if filter is applied, by checking if failed_tasks_filter has btn-primary class | 321 | # Check if filter is applied, by checking if failed_tasks_filter has btn-primary class |
288 | self.assertTrue(self.find('#failed_tasks_filter').get_attribute('class').find('btn-primary') != -1) | 322 | self.assertTrue(self.find('#failed_tasks_filter').get_attribute('class').find('btn-primary') != -1) |
323 | |||
324 | def test_filtering_on_completedOn_column(self): | ||
325 | """ Test the filtering on completed_on column in the builds table on the all builds page """ | ||
326 | self._get_create_builds(success=10, failure=10) | ||
327 | |||
328 | url = reverse('all-builds') | ||
329 | self.get(url) | ||
330 | |||
331 | # Check filtering on failure tasks column | ||
332 | self.wait_until_present('#allbuildstable tbody tr') | ||
333 | completed_on_filter = self.find('#completed_on_filter') | ||
334 | completed_on_filter.click() | ||
335 | # Check popup is visible | ||
336 | time.sleep(1) | ||
337 | self.wait_until_present('#filter-modal-allbuildstable') | ||
338 | self.assertTrue(self.find('#filter-modal-allbuildstable').is_displayed()) | ||
339 | # Check that we can filter by failure tasks | ||
340 | build_without_failure_tasks = self.find('#completed_on_filter\\:date_range') | ||
341 | build_without_failure_tasks.click() | ||
342 | # click on apply button | ||
343 | self.find('#filter-modal-allbuildstable .btn-primary').click() | ||
344 | self.wait_until_present('#allbuildstable tbody tr') | ||
345 | # 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) | ||
347 | |||
348 | # Filter by date range | ||
349 | self.find('#completed_on_filter').click() | ||
350 | self.wait_until_present('#filter-modal-allbuildstable') | ||
351 | date_ranges = self.driver.find_elements( | ||
352 | By.XPATH, '//input[@class="form-control hasDatepicker"]') | ||
353 | today = timezone.now() | ||
354 | yestersday = today - timezone.timedelta(days=1) | ||
355 | time.sleep(1) | ||
356 | date_ranges[0].send_keys(yestersday.strftime('%Y-%m-%d')) | ||
357 | date_ranges[1].send_keys(today.strftime('%Y-%m-%d')) | ||
358 | self.find('#filter-modal-allbuildstable .btn-primary').click() | ||
359 | self.wait_until_present('#allbuildstable tbody tr') | ||
360 | self.assertTrue(self.find('#completed_on_filter').get_attribute('class').find('btn-primary') != -1) | ||
361 | # Check if filter is applied, number of builds displayed should be 6 | ||
362 | time.sleep(1) | ||
363 | self.assertTrue(len(self.find_all('#allbuildstable tbody tr')) == 6) | ||
364 | |||