diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-11-29 23:54:10 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-02 18:04:23 +0000 |
commit | 9f78fee273316602b2db5e25720c1747edb25df1 (patch) | |
tree | 6628cec8904cfa11a8c20e769a24d366f45374fc /bitbake/lib/toaster/tests | |
parent | 2ee91ebd9cf0ed14e9dfc93d2172ebe22ac3a5b3 (diff) | |
download | poky-9f78fee273316602b2db5e25720c1747edb25df1.tar.gz |
bitbake: toaster/tests: Test software recipe page
Test software recipe page
- Check title "Compatible software recipes" is displayed
- Check search input
- Check "build recipe" button works
- Check software recipe table feature(show/hide column, pagination)
(Bitbake rev: b9c8c77d73d19bd4ddf9b6e90b0aa71f92d36993)
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/tests')
-rw-r--r-- | bitbake/lib/toaster/tests/functional/test_project_page.py | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/tests/functional/test_project_page.py b/bitbake/lib/toaster/tests/functional/test_project_page.py index f1eb9cfa87..28f1fcb68b 100644 --- a/bitbake/lib/toaster/tests/functional/test_project_page.py +++ b/bitbake/lib/toaster/tests/functional/test_project_page.py | |||
@@ -7,9 +7,11 @@ | |||
7 | # | 7 | # |
8 | 8 | ||
9 | import pytest | 9 | import pytest |
10 | from time import sleep | ||
10 | from django.urls import reverse | 11 | from django.urls import reverse |
11 | from django.utils import timezone | 12 | from django.utils import timezone |
12 | from selenium.webdriver.support.select import Select | 13 | from selenium.webdriver.support.select import Select |
14 | from selenium.common.exceptions import NoSuchElementException | ||
13 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase | 15 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase |
14 | from orm.models import Build, Project, Target | 16 | from orm.models import Build, Project, Target |
15 | from selenium.webdriver.common.by import By | 17 | from selenium.webdriver.common.by import By |
@@ -164,6 +166,70 @@ class TestProjectPage(SeleniumFunctionalTestCase): | |||
164 | f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" | 166 | f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" |
165 | ) | 167 | ) |
166 | 168 | ||
169 | def _get_config_nav_item(self, index): | ||
170 | config_nav = self.find('#config-nav') | ||
171 | return config_nav.find_elements(By.TAG_NAME, 'li')[index] | ||
172 | |||
173 | def _navigate_to_config_nav(self, nav_id, nav_index): | ||
174 | # navigate to the project page | ||
175 | url = reverse("project", args=(1,)) | ||
176 | self.get(url) | ||
177 | self.wait_until_visible('#config-nav') | ||
178 | # click on "Software recipe" tab | ||
179 | soft_recipe = self._get_config_nav_item(nav_index) | ||
180 | soft_recipe.click() | ||
181 | self.wait_until_visible(f'#{nav_id}') | ||
182 | |||
183 | def _mixin_test_table_show_rows(self, table_selector, **kwargs): | ||
184 | """ Test the show rows feature in the builds table on the all builds page """ | ||
185 | def test_show_rows(row_to_show, show_row_link): | ||
186 | # Check that we can show rows == row_to_show | ||
187 | show_row_link.select_by_value(str(row_to_show)) | ||
188 | self.wait_until_visible(f'#{table_selector} tbody tr', poll=2) | ||
189 | self.assertTrue( | ||
190 | len(self.find_all(f'#{table_selector} tbody tr')) == row_to_show | ||
191 | ) | ||
192 | self.wait_until_present(f'#{table_selector} tbody tr') | ||
193 | show_rows = self.driver.find_elements( | ||
194 | By.XPATH, | ||
195 | f'//select[@class="form-control pagesize-{table_selector}"]' | ||
196 | ) | ||
197 | rows_to_show = [10, 25, 50, 100, 150] | ||
198 | to_skip = kwargs.get('to_skip', []) | ||
199 | # Check show rows | ||
200 | for show_row_link in show_rows: | ||
201 | show_row_link = Select(show_row_link) | ||
202 | for row_to_show in rows_to_show: | ||
203 | if row_to_show not in to_skip: | ||
204 | test_show_rows(row_to_show, show_row_link) | ||
205 | |||
206 | def _wait_until_build(self, state): | ||
207 | while True: | ||
208 | try: | ||
209 | last_build_state = self.driver.find_element( | ||
210 | By.XPATH, | ||
211 | '//*[@id="latest-builds"]/div[1]//div[@class="build-state"]', | ||
212 | ) | ||
213 | build_state = last_build_state.get_attribute( | ||
214 | 'data-build-state') | ||
215 | state_text = state.lower().split() | ||
216 | if any(x in str(build_state).lower() for x in state_text): | ||
217 | break | ||
218 | except NoSuchElementException: | ||
219 | continue | ||
220 | sleep(1) | ||
221 | |||
222 | def _mixin_test_table_search_input(self, **kwargs): | ||
223 | input_selector, input_text, searchBtn_selector, table_selector, *_ = kwargs.values() | ||
224 | # Test search input | ||
225 | self.wait_until_visible(f'#{input_selector}') | ||
226 | recipe_input = self.find(f'#{input_selector}') | ||
227 | recipe_input.send_keys(input_text) | ||
228 | self.find(f'#{searchBtn_selector}').click() | ||
229 | self.wait_until_visible(f'#{table_selector} tbody tr') | ||
230 | rows = self.find_all(f'#{table_selector} tbody tr') | ||
231 | self.assertTrue(len(rows) > 0) | ||
232 | |||
167 | def test_image_recipe_editColumn(self): | 233 | def test_image_recipe_editColumn(self): |
168 | """ Test the edit column feature in image recipe table on project page """ | 234 | """ Test the edit column feature in image recipe table on project page """ |
169 | self._get_create_builds(success=10, failure=10) | 235 | self._get_create_builds(success=10, failure=10) |
@@ -375,3 +441,55 @@ class TestProjectPage(SeleniumFunctionalTestCase): | |||
375 | self.assertTrue( | 441 | self.assertTrue( |
376 | 'core-image-minimal' in str(last_build.text) | 442 | 'core-image-minimal' in str(last_build.text) |
377 | ) | 443 | ) |
444 | |||
445 | def test_softwareRecipe_page(self): | ||
446 | """ Test software recipe page | ||
447 | - Check title "Compatible software recipes" is displayed | ||
448 | - Check search input | ||
449 | - Check "build recipe" button works | ||
450 | - Check software recipe table feature(show/hide column, pagination) | ||
451 | """ | ||
452 | self._navigate_to_config_nav('softwarerecipestable', 4) | ||
453 | # check title "Compatible software recipes" is displayed | ||
454 | self.assertTrue("Compatible software recipes" in self.get_page_source()) | ||
455 | # Test search input | ||
456 | self._mixin_test_table_search_input( | ||
457 | input_selector='search-input-softwarerecipestable', | ||
458 | input_text='busybox', | ||
459 | searchBtn_selector='search-submit-softwarerecipestable', | ||
460 | table_selector='softwarerecipestable' | ||
461 | ) | ||
462 | # check "build recipe" button works | ||
463 | rows = self.find_all('#softwarerecipestable tbody tr') | ||
464 | image_to_build = rows[0] | ||
465 | build_btn = image_to_build.find_element( | ||
466 | By.XPATH, | ||
467 | '//td[@class="add-del-layers"]' | ||
468 | ) | ||
469 | build_btn.click() | ||
470 | self._wait_until_build('parsing starting cloning') | ||
471 | lastest_builds = self.driver.find_elements( | ||
472 | By.XPATH, | ||
473 | '//div[@id="latest-builds"]/div' | ||
474 | ) | ||
475 | self.assertTrue(len(lastest_builds) > 0) | ||
476 | |||
477 | # check software recipe table feature(show/hide column, pagination) | ||
478 | self._navigate_to_config_nav('softwarerecipestable', 4) | ||
479 | column_list = [ | ||
480 | 'get_description_or_summary', | ||
481 | 'layer_version__get_vcs_reference', | ||
482 | 'layer_version__layer__name', | ||
483 | 'license', | ||
484 | 'recipe-file', | ||
485 | 'section', | ||
486 | 'version', | ||
487 | ] | ||
488 | self._mixin_test_table_edit_column( | ||
489 | 'softwarerecipestable', | ||
490 | 'edit-columns-button', | ||
491 | [f'checkbox-{column}' for column in column_list] | ||
492 | ) | ||
493 | self._navigate_to_config_nav('softwarerecipestable', 4) | ||
494 | # check show rows(pagination) | ||
495 | self._mixin_test_table_show_rows(table_selector='softwarerecipestable') | ||