diff options
| -rw-r--r-- | bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py b/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py index 598a805540..2dfc120d83 100644 --- a/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py +++ b/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py | |||
| @@ -8,10 +8,12 @@ | |||
| 8 | 8 | ||
| 9 | from time import sleep | 9 | from time import sleep |
| 10 | import pytest | 10 | import pytest |
| 11 | from django.utils import timezone | ||
| 11 | from django.urls import reverse | 12 | from django.urls import reverse |
| 12 | from selenium.webdriver import Keys | 13 | from selenium.webdriver import Keys |
| 13 | from selenium.webdriver.support.select import Select | 14 | from selenium.webdriver.support.select import Select |
| 14 | from selenium.common.exceptions import NoSuchElementException | 15 | from selenium.common.exceptions import NoSuchElementException |
| 16 | from orm.models import Build, Project, Target | ||
| 15 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase | 17 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase |
| 16 | from selenium.webdriver.common.by import By | 18 | from selenium.webdriver.common.by import By |
| 17 | 19 | ||
| @@ -112,6 +114,64 @@ class TestProjectConfigTab(SeleniumFunctionalTestCase): | |||
| 112 | config_nav = self.find('#config-nav') | 114 | config_nav = self.find('#config-nav') |
| 113 | return config_nav.find_elements(By.TAG_NAME, 'li')[index] | 115 | return config_nav.find_elements(By.TAG_NAME, 'li')[index] |
| 114 | 116 | ||
| 117 | def _get_create_builds(self, **kwargs): | ||
| 118 | """ Create a build and return the build object """ | ||
| 119 | # parameters for builds to associate with the projects | ||
| 120 | now = timezone.now() | ||
| 121 | release = '3' | ||
| 122 | project_name = 'projectmaster' | ||
| 123 | self._create_test_new_project( | ||
| 124 | project_name+"2", | ||
| 125 | release, | ||
| 126 | False, | ||
| 127 | ) | ||
| 128 | |||
| 129 | self.project1_build_success = { | ||
| 130 | 'project': Project.objects.get(id=1), | ||
| 131 | 'started_on': now, | ||
| 132 | 'completed_on': now, | ||
| 133 | 'outcome': Build.SUCCEEDED | ||
| 134 | } | ||
| 135 | |||
| 136 | self.project1_build_failure = { | ||
| 137 | 'project': Project.objects.get(id=1), | ||
| 138 | 'started_on': now, | ||
| 139 | 'completed_on': now, | ||
| 140 | 'outcome': Build.FAILED | ||
| 141 | } | ||
| 142 | build1 = Build.objects.create(**self.project1_build_success) | ||
| 143 | build2 = Build.objects.create(**self.project1_build_failure) | ||
| 144 | |||
| 145 | # add some targets to these builds so they have recipe links | ||
| 146 | # (and so we can find the row in the ToasterTable corresponding to | ||
| 147 | # a particular build) | ||
| 148 | Target.objects.create(build=build1, target='foo') | ||
| 149 | Target.objects.create(build=build2, target='bar') | ||
| 150 | |||
| 151 | if kwargs: | ||
| 152 | # Create kwargs.get('success') builds with success status with target | ||
| 153 | # and kwargs.get('failure') builds with failure status with target | ||
| 154 | for i in range(kwargs.get('success', 0)): | ||
| 155 | now = timezone.now() | ||
| 156 | self.project1_build_success['started_on'] = now | ||
| 157 | self.project1_build_success[ | ||
| 158 | 'completed_on'] = now - timezone.timedelta(days=i) | ||
| 159 | build = Build.objects.create(**self.project1_build_success) | ||
| 160 | Target.objects.create(build=build, | ||
| 161 | target=f'{i}_success_recipe', | ||
| 162 | task=f'{i}_success_task') | ||
| 163 | |||
| 164 | for i in range(kwargs.get('failure', 0)): | ||
| 165 | now = timezone.now() | ||
| 166 | self.project1_build_failure['started_on'] = now | ||
| 167 | self.project1_build_failure[ | ||
| 168 | 'completed_on'] = now - timezone.timedelta(days=i) | ||
| 169 | build = Build.objects.create(**self.project1_build_failure) | ||
| 170 | Target.objects.create(build=build, | ||
| 171 | target=f'{i}_fail_recipe', | ||
| 172 | task=f'{i}_fail_task') | ||
| 173 | return build1, build2 | ||
| 174 | |||
| 115 | def test_project_config_nav(self): | 175 | def test_project_config_nav(self): |
| 116 | """ Test project config tab navigation: | 176 | """ Test project config tab navigation: |
| 117 | - Check if the menu is displayed and contains the right elements: | 177 | - Check if the menu is displayed and contains the right elements: |
| @@ -421,3 +481,64 @@ class TestProjectConfigTab(SeleniumFunctionalTestCase): | |||
| 421 | '//div[@id="latest-builds"]/div' | 481 | '//div[@id="latest-builds"]/div' |
| 422 | ) | 482 | ) |
| 423 | self.assertTrue(len(lastest_builds) > 0) | 483 | self.assertTrue(len(lastest_builds) > 0) |
| 484 | |||
| 485 | def test_image_recipe_editColumn(self): | ||
| 486 | """ Test the edit column feature in image recipe table on project page """ | ||
| 487 | self._get_create_builds(success=10, failure=10) | ||
| 488 | |||
| 489 | def test_edit_column(check_box_id): | ||
| 490 | # Check that we can hide/show table column | ||
| 491 | check_box = self.find(f'#{check_box_id}') | ||
| 492 | th_class = str(check_box_id).replace('checkbox-', '') | ||
| 493 | if check_box.is_selected(): | ||
| 494 | # check if column is visible in table | ||
| 495 | self.assertTrue( | ||
| 496 | self.find( | ||
| 497 | f'#imagerecipestable thead th.{th_class}' | ||
| 498 | ).is_displayed(), | ||
| 499 | f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" | ||
| 500 | ) | ||
| 501 | check_box.click() | ||
| 502 | # check if column is hidden in table | ||
| 503 | self.assertFalse( | ||
| 504 | self.find( | ||
| 505 | f'#imagerecipestable thead th.{th_class}' | ||
| 506 | ).is_displayed(), | ||
| 507 | f"The {th_class} column is unchecked in EditColumn dropdown, but it's visible in table" | ||
| 508 | ) | ||
| 509 | else: | ||
| 510 | # check if column is hidden in table | ||
| 511 | self.assertFalse( | ||
| 512 | self.find( | ||
| 513 | f'#imagerecipestable thead th.{th_class}' | ||
| 514 | ).is_displayed(), | ||
| 515 | f"The {th_class} column is unchecked in EditColumn dropdown, but it's visible in table" | ||
| 516 | ) | ||
| 517 | check_box.click() | ||
| 518 | # check if column is visible in table | ||
| 519 | self.assertTrue( | ||
| 520 | self.find( | ||
| 521 | f'#imagerecipestable thead th.{th_class}' | ||
| 522 | ).is_displayed(), | ||
| 523 | f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" | ||
| 524 | ) | ||
| 525 | |||
| 526 | url = reverse('projectimagerecipes', args=(1,)) | ||
| 527 | self.get(url) | ||
| 528 | self.wait_until_present('#imagerecipestable tbody tr') | ||
| 529 | |||
| 530 | # Check edit column | ||
| 531 | edit_column = self.find('#edit-columns-button') | ||
| 532 | self.assertTrue(edit_column.is_displayed()) | ||
| 533 | edit_column.click() | ||
| 534 | # Check dropdown is visible | ||
| 535 | self.wait_until_visible('ul.dropdown-menu.editcol') | ||
| 536 | |||
| 537 | # Check that we can hide the edit column | ||
| 538 | test_edit_column('checkbox-get_description_or_summary') | ||
| 539 | test_edit_column('checkbox-layer_version__get_vcs_reference') | ||
| 540 | test_edit_column('checkbox-layer_version__layer__name') | ||
| 541 | test_edit_column('checkbox-license') | ||
| 542 | test_edit_column('checkbox-recipe-file') | ||
| 543 | test_edit_column('checkbox-section') | ||
| 544 | test_edit_column('checkbox-version') | ||
