diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-11-21 14:49:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-11-23 12:06:06 +0000 |
commit | 4ff7c528dd0e45a0474e3b6a391ea408ed30f23c (patch) | |
tree | 3b9f91daa628f88fb87baccb170edbcb8e378f26 /bitbake | |
parent | 26ac6923e23555d79423be0808f87c9091d30c6a (diff) | |
download | poky-4ff7c528dd0e45a0474e3b6a391ea408ed30f23c.tar.gz |
bitbake: toaster/tests: Add UI TestCase - Check project header contains right items
Check page header in project page:
- AT LEFT -> Logo of Yocto project, displayed, clickable
- "Toaster"+" Information icon", displayed, clickable
- "Server Icon" + "All builds", displayed, clickable
- "Directory Icon" + "All projects", displayed, clickable
- "Book Icon" + "Documentation", displayed, clickable
- AT RIGHT -> button "New project", displayed, clickable
(Bitbake rev: 5b2b8fe16e2adb45ca88165162c65c0f7f9a0755)
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 | 142 |
1 files changed, 142 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 new file mode 100644 index 0000000000..f77437f0af --- /dev/null +++ b/bitbake/lib/toaster/tests/functional/test_project_page.py | |||
@@ -0,0 +1,142 @@ | |||
1 | #! /usr/bin/env python3 # | ||
2 | # BitBake Toaster UI tests implementation | ||
3 | # | ||
4 | # Copyright (C) 2023 Savoir-faire Linux | ||
5 | # | ||
6 | # SPDX-License-Identifier: GPL-2.0-only | ||
7 | # | ||
8 | |||
9 | import pytest | ||
10 | from django.urls import reverse | ||
11 | from selenium.webdriver.support.select import Select | ||
12 | from tests.functional.functional_helpers import SeleniumFunctionalTestCase | ||
13 | from selenium.webdriver.common.by import By | ||
14 | |||
15 | |||
16 | @pytest.mark.django_db | ||
17 | class TestProjectPage(SeleniumFunctionalTestCase): | ||
18 | |||
19 | def setUp(self): | ||
20 | super().setUp() | ||
21 | release = '3' | ||
22 | project_name = 'projectmaster' | ||
23 | self._create_test_new_project( | ||
24 | project_name, | ||
25 | release, | ||
26 | False, | ||
27 | ) | ||
28 | |||
29 | def _create_test_new_project( | ||
30 | self, | ||
31 | project_name, | ||
32 | release, | ||
33 | merge_toaster_settings, | ||
34 | ): | ||
35 | """ Create/Test new project using: | ||
36 | - Project Name: Any string | ||
37 | - Release: Any string | ||
38 | - Merge Toaster settings: True or False | ||
39 | """ | ||
40 | self.get(reverse('newproject')) | ||
41 | self.driver.find_element(By.ID, | ||
42 | "new-project-name").send_keys(project_name) | ||
43 | |||
44 | select = Select(self.find('#projectversion')) | ||
45 | select.select_by_value(release) | ||
46 | |||
47 | # check merge toaster settings | ||
48 | checkbox = self.find('.checkbox-mergeattr') | ||
49 | if merge_toaster_settings: | ||
50 | if not checkbox.is_selected(): | ||
51 | checkbox.click() | ||
52 | else: | ||
53 | if checkbox.is_selected(): | ||
54 | checkbox.click() | ||
55 | |||
56 | self.driver.find_element(By.ID, "create-project-button").click() | ||
57 | |||
58 | def test_page_header_on_project_page(self): | ||
59 | """ Check page header in project page: | ||
60 | - AT LEFT -> Logo of Yocto project, displayed, clickable | ||
61 | - "Toaster"+" Information icon", displayed, clickable | ||
62 | - "Server Icon" + "All builds", displayed, clickable | ||
63 | - "Directory Icon" + "All projects", displayed, clickable | ||
64 | - "Book Icon" + "Documentation", displayed, clickable | ||
65 | - AT RIGHT -> button "New project", displayed, clickable | ||
66 | """ | ||
67 | # navigate to the project page | ||
68 | url = reverse("project", args=(1,)) | ||
69 | self.get(url) | ||
70 | |||
71 | # check page header | ||
72 | # AT LEFT -> Logo of Yocto project | ||
73 | logo = self.driver.find_element( | ||
74 | By.XPATH, | ||
75 | "//div[@class='toaster-navbar-brand']", | ||
76 | ) | ||
77 | logo_img = logo.find_element(By.TAG_NAME, 'img') | ||
78 | self.assertTrue(logo_img.is_displayed(), | ||
79 | 'Logo of Yocto project not found') | ||
80 | self.assertTrue( | ||
81 | '/static/img/logo.png' in str(logo_img.get_attribute('src')), | ||
82 | 'Logo of Yocto project not found' | ||
83 | ) | ||
84 | # "Toaster"+" Information icon", clickable | ||
85 | toaster = self.driver.find_element( | ||
86 | By.XPATH, | ||
87 | "//div[@class='toaster-navbar-brand']//a[@class='brand']", | ||
88 | ) | ||
89 | self.assertTrue(toaster.is_displayed(), 'Toaster not found') | ||
90 | self.assertTrue(toaster.text == 'Toaster') | ||
91 | info_sign = self.find('.glyphicon-info-sign') | ||
92 | self.assertTrue(info_sign.is_displayed()) | ||
93 | |||
94 | # "Server Icon" + "All builds" | ||
95 | all_builds = self.find('#navbar-all-builds') | ||
96 | all_builds_link = all_builds.find_element(By.TAG_NAME, 'a') | ||
97 | self.assertTrue("All builds" in all_builds_link.text) | ||
98 | self.assertTrue( | ||
99 | '/toastergui/builds/' in str(all_builds_link.get_attribute('href')) | ||
100 | ) | ||
101 | server_icon = all_builds.find_element(By.TAG_NAME, 'i') | ||
102 | self.assertTrue( | ||
103 | server_icon.get_attribute('class') == 'glyphicon glyphicon-tasks' | ||
104 | ) | ||
105 | self.assertTrue(server_icon.is_displayed()) | ||
106 | |||
107 | # "Directory Icon" + "All projects" | ||
108 | all_projects = self.find('#navbar-all-projects') | ||
109 | all_projects_link = all_projects.find_element(By.TAG_NAME, 'a') | ||
110 | self.assertTrue("All projects" in all_projects_link.text) | ||
111 | self.assertTrue( | ||
112 | '/toastergui/projects/' in str(all_projects_link.get_attribute( | ||
113 | 'href')) | ||
114 | ) | ||
115 | dir_icon = all_projects.find_element(By.TAG_NAME, 'i') | ||
116 | self.assertTrue( | ||
117 | dir_icon.get_attribute('class') == 'icon-folder-open' | ||
118 | ) | ||
119 | self.assertTrue(dir_icon.is_displayed()) | ||
120 | |||
121 | # "Book Icon" + "Documentation" | ||
122 | toaster_docs_link = self.find('#navbar-docs') | ||
123 | toaster_docs_link_link = toaster_docs_link.find_element(By.TAG_NAME, | ||
124 | 'a') | ||
125 | self.assertTrue("Documentation" in toaster_docs_link_link.text) | ||
126 | self.assertTrue( | ||
127 | toaster_docs_link_link.get_attribute('href') == 'http://docs.yoctoproject.org/toaster-manual/index.html#toaster-user-manual' | ||
128 | ) | ||
129 | book_icon = toaster_docs_link.find_element(By.TAG_NAME, 'i') | ||
130 | self.assertTrue( | ||
131 | book_icon.get_attribute('class') == 'glyphicon glyphicon-book' | ||
132 | ) | ||
133 | self.assertTrue(book_icon.is_displayed()) | ||
134 | |||
135 | # AT RIGHT -> button "New project" | ||
136 | new_project_button = self.find('#new-project-button') | ||
137 | self.assertTrue(new_project_button.is_displayed()) | ||
138 | self.assertTrue(new_project_button.text == 'New project') | ||
139 | new_project_button.click() | ||
140 | self.assertTrue( | ||
141 | '/toastergui/newproject/' in str(self.driver.current_url) | ||
142 | ) | ||