diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-11-29 23:54:09 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-02 18:04:23 +0000 |
commit | 2ee91ebd9cf0ed14e9dfc93d2172ebe22ac3a5b3 (patch) | |
tree | 2e9ab413f4170ec9af9057d90a32dd02d1823503 /bitbake | |
parent | 715898cb9a2688957120d0286dc136db1298f9de (diff) | |
download | poky-2ee91ebd9cf0ed14e9dfc93d2172ebe22ac3a5b3.tar.gz |
bitbake: toaster/tests: Override table edit columns TestCase from image recipe page
Better handle TestCase of table edit column feature
(Bitbake rev: 6adc708a1520f8c947f9c40fdc88ebe2b51ecc97)
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/functional/test_project_page.py | 130 |
1 files changed, 130 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 3edf967a2c..f1eb9cfa87 100644 --- a/bitbake/lib/toaster/tests/functional/test_project_page.py +++ b/bitbake/lib/toaster/tests/functional/test_project_page.py | |||
@@ -8,8 +8,10 @@ | |||
8 | 8 | ||
9 | import pytest | 9 | import pytest |
10 | from django.urls import reverse | 10 | from django.urls import reverse |
11 | from django.utils import timezone | ||
11 | from selenium.webdriver.support.select import Select | 12 | from selenium.webdriver.support.select import Select |
12 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase | 13 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase |
14 | from orm.models import Build, Project, Target | ||
13 | from selenium.webdriver.common.by import By | 15 | from selenium.webdriver.common.by import By |
14 | 16 | ||
15 | 17 | ||
@@ -55,6 +57,134 @@ class TestProjectPage(SeleniumFunctionalTestCase): | |||
55 | 57 | ||
56 | self.driver.find_element(By.ID, "create-project-button").click() | 58 | self.driver.find_element(By.ID, "create-project-button").click() |
57 | 59 | ||
60 | def _get_create_builds(self, **kwargs): | ||
61 | """ Create a build and return the build object """ | ||
62 | # parameters for builds to associate with the projects | ||
63 | now = timezone.now() | ||
64 | release = '3' | ||
65 | project_name = 'projectmaster' | ||
66 | self._create_test_new_project( | ||
67 | project_name+"2", | ||
68 | release, | ||
69 | False, | ||
70 | ) | ||
71 | |||
72 | self.project1_build_success = { | ||
73 | 'project': Project.objects.get(id=1), | ||
74 | 'started_on': now, | ||
75 | 'completed_on': now, | ||
76 | 'outcome': Build.SUCCEEDED | ||
77 | } | ||
78 | |||
79 | self.project1_build_failure = { | ||
80 | 'project': Project.objects.get(id=1), | ||
81 | 'started_on': now, | ||
82 | 'completed_on': now, | ||
83 | 'outcome': Build.FAILED | ||
84 | } | ||
85 | build1 = Build.objects.create(**self.project1_build_success) | ||
86 | build2 = Build.objects.create(**self.project1_build_failure) | ||
87 | |||
88 | # add some targets to these builds so they have recipe links | ||
89 | # (and so we can find the row in the ToasterTable corresponding to | ||
90 | # a particular build) | ||
91 | Target.objects.create(build=build1, target='foo') | ||
92 | Target.objects.create(build=build2, target='bar') | ||
93 | |||
94 | if kwargs: | ||
95 | # Create kwargs.get('success') builds with success status with target | ||
96 | # and kwargs.get('failure') builds with failure status with target | ||
97 | for i in range(kwargs.get('success', 0)): | ||
98 | now = timezone.now() | ||
99 | self.project1_build_success['started_on'] = now | ||
100 | self.project1_build_success[ | ||
101 | 'completed_on'] = now - timezone.timedelta(days=i) | ||
102 | build = Build.objects.create(**self.project1_build_success) | ||
103 | Target.objects.create(build=build, | ||
104 | target=f'{i}_success_recipe', | ||
105 | task=f'{i}_success_task') | ||
106 | |||
107 | for i in range(kwargs.get('failure', 0)): | ||
108 | now = timezone.now() | ||
109 | self.project1_build_failure['started_on'] = now | ||
110 | self.project1_build_failure[ | ||
111 | 'completed_on'] = now - timezone.timedelta(days=i) | ||
112 | build = Build.objects.create(**self.project1_build_failure) | ||
113 | Target.objects.create(build=build, | ||
114 | target=f'{i}_fail_recipe', | ||
115 | task=f'{i}_fail_task') | ||
116 | return build1, build2 | ||
117 | |||
118 | def _mixin_test_table_edit_column( | ||
119 | self, | ||
120 | table_id, | ||
121 | edit_btn_id, | ||
122 | list_check_box_id: list | ||
123 | ): | ||
124 | # Check edit column | ||
125 | edit_column = self.find(f'#{edit_btn_id}') | ||
126 | self.assertTrue(edit_column.is_displayed()) | ||
127 | edit_column.click() | ||
128 | # Check dropdown is visible | ||
129 | self.wait_until_visible('ul.dropdown-menu.editcol') | ||
130 | for check_box_id in list_check_box_id: | ||
131 | # Check that we can hide/show table column | ||
132 | check_box = self.find(f'#{check_box_id}') | ||
133 | th_class = str(check_box_id).replace('checkbox-', '') | ||
134 | if check_box.is_selected(): | ||
135 | # check if column is visible in table | ||
136 | self.assertTrue( | ||
137 | self.find( | ||
138 | f'#{table_id} thead th.{th_class}' | ||
139 | ).is_displayed(), | ||
140 | f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" | ||
141 | ) | ||
142 | check_box.click() | ||
143 | # check if column is hidden in table | ||
144 | self.assertFalse( | ||
145 | self.find( | ||
146 | f'#{table_id} thead th.{th_class}' | ||
147 | ).is_displayed(), | ||
148 | f"The {th_class} column is unchecked in EditColumn dropdown, but it's visible in table" | ||
149 | ) | ||
150 | else: | ||
151 | # check if column is hidden in table | ||
152 | self.assertFalse( | ||
153 | self.find( | ||
154 | f'#{table_id} thead th.{th_class}' | ||
155 | ).is_displayed(), | ||
156 | f"The {th_class} column is unchecked in EditColumn dropdown, but it's visible in table" | ||
157 | ) | ||
158 | check_box.click() | ||
159 | # check if column is visible in table | ||
160 | self.assertTrue( | ||
161 | self.find( | ||
162 | f'#{table_id} thead th.{th_class}' | ||
163 | ).is_displayed(), | ||
164 | f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" | ||
165 | ) | ||
166 | |||
167 | def test_image_recipe_editColumn(self): | ||
168 | """ Test the edit column feature in image recipe table on project page """ | ||
169 | self._get_create_builds(success=10, failure=10) | ||
170 | |||
171 | url = reverse('projectimagerecipes', args=(1,)) | ||
172 | self.get(url) | ||
173 | self.wait_until_present('#imagerecipestable tbody tr') | ||
174 | |||
175 | column_list = [ | ||
176 | 'get_description_or_summary', 'layer_version__get_vcs_reference', | ||
177 | 'layer_version__layer__name', 'license', 'recipe-file', 'section', | ||
178 | 'version' | ||
179 | ] | ||
180 | |||
181 | # Check that we can hide the edit column | ||
182 | self._mixin_test_table_edit_column( | ||
183 | 'imagerecipestable', | ||
184 | 'edit-columns-button', | ||
185 | [f'checkbox-{column}' for column in column_list] | ||
186 | ) | ||
187 | |||
58 | def test_page_header_on_project_page(self): | 188 | def test_page_header_on_project_page(self): |
59 | """ Check page header in project page: | 189 | """ Check page header in project page: |
60 | - AT LEFT -> Logo of Yocto project, displayed, clickable | 190 | - AT LEFT -> Logo of Yocto project, displayed, clickable |