* [PATCH 1/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects
@ 2023-11-21 13:47 Alassane Yattara
2023-11-21 13:47 ` [PATCH 2/3] " Alassane Yattara
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alassane Yattara @ 2023-11-21 13:47 UTC (permalink / raw)
To: toaster; +Cc: Alassane Yattara
Test the search box in the all project table on the all projects page
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
.../tests/browser/test_all_projects_page.py | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/toaster/tests/browser/test_all_projects_page.py b/lib/toaster/tests/browser/test_all_projects_page.py
index 3389d323..db25e723 100644
--- a/lib/toaster/tests/browser/test_all_projects_page.py
+++ b/lib/toaster/tests/browser/test_all_projects_page.py
@@ -8,9 +8,11 @@
#
import re
+import time
from django.urls import reverse
from django.utils import timezone
+from selenium.webdriver.support.select import Select
from tests.browser.selenium_helpers import SeleniumTestCase
from orm.models import BitbakeVersion, Release, Project, Build
@@ -37,6 +39,17 @@ class TestAllProjectsPage(SeleniumTestCase):
self.release = None
+ def _create_projects(self, nb_project=10):
+ projects = []
+ for i in range(1, nb_project + 1):
+ projects.append(
+ Project(
+ name='test project {}'.format(i),
+ release=self.release,
+ )
+ )
+ Project.objects.bulk_create(projects)
+
def _add_build_to_default_project(self):
""" Add a build to the default project (not used in all tests) """
now = timezone.now()
@@ -205,3 +218,24 @@ class TestAllProjectsPage(SeleniumTestCase):
expected_url = reverse('project', args=(self.project.id,))
msg = 'link on project name should point to configuration but was %s' % link_url
self.assertTrue(link_url.endswith(expected_url), msg)
+
+ def test_allProject_table_search_box(self):
+ """ Test the search box in the all project table on the all projects page """
+ self._create_projects()
+
+ url = reverse('all-projects')
+ self.get(url)
+
+ # Chseck search box is present and works
+ self.wait_until_present('#projectstable tbody tr')
+ search_box = self.find('#search-input-projectstable')
+ self.assertTrue(search_box.is_displayed())
+
+ # Check that we can search for a project by project name
+ search_box.send_keys('test project 10')
+ search_btn = self.find('#search-submit-projectstable')
+ search_btn.click()
+ self.wait_until_present('#projectstable tbody tr')
+ time.sleep(1)
+ rows = self.find_all('#projectstable tbody tr')
+ self.assertTrue(len(rows) == 1)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects
2023-11-21 13:47 [PATCH 1/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects Alassane Yattara
@ 2023-11-21 13:47 ` Alassane Yattara
2023-11-21 13:47 ` [PATCH 3/3] " Alassane Yattara
2023-11-23 12:10 ` [Toaster] [PATCH 1/3] " Richard Purdie
2 siblings, 0 replies; 4+ messages in thread
From: Alassane Yattara @ 2023-11-21 13:47 UTC (permalink / raw)
To: toaster; +Cc: Alassane Yattara
Test the edit column feature in the projects table on the all projects page
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
.../tests/browser/test_all_projects_page.py | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/lib/toaster/tests/browser/test_all_projects_page.py b/lib/toaster/tests/browser/test_all_projects_page.py
index db25e723..2b1d8cc1 100644
--- a/lib/toaster/tests/browser/test_all_projects_page.py
+++ b/lib/toaster/tests/browser/test_all_projects_page.py
@@ -239,3 +239,61 @@ class TestAllProjectsPage(SeleniumTestCase):
time.sleep(1)
rows = self.find_all('#projectstable tbody tr')
self.assertTrue(len(rows) == 1)
+
+ def test_allProject_table_editColumn(self):
+ """ Test the edit column feature in the projects table on the all projects page """
+ self._create_projects()
+
+ def test_edit_column(check_box_id):
+ # Check that we can hide/show table column
+ check_box = self.find(f'#{check_box_id}')
+ th_class = str(check_box_id).replace('checkbox-', '')
+ if check_box.is_selected():
+ # check if column is visible in table
+ self.assertTrue(
+ self.find(
+ f'#projectstable thead th.{th_class}'
+ ).is_displayed(),
+ f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table"
+ )
+ check_box.click()
+ # check if column is hidden in table
+ self.assertFalse(
+ self.find(
+ f'#projectstable thead th.{th_class}'
+ ).is_displayed(),
+ f"The {th_class} column is unchecked in EditColumn dropdown, but it's visible in table"
+ )
+ else:
+ # check if column is hidden in table
+ self.assertFalse(
+ self.find(
+ f'#projectstable thead th.{th_class}'
+ ).is_displayed(),
+ f"The {th_class} column is unchecked in EditColumn dropdown, but it's visible in table"
+ )
+ check_box.click()
+ # check if column is visible in table
+ self.assertTrue(
+ self.find(
+ f'#projectstable thead th.{th_class}'
+ ).is_displayed(),
+ f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table"
+ )
+ url = reverse('all-projects')
+ self.get(url)
+ self.wait_until_present('#projectstable tbody tr')
+
+ # Check edit column
+ edit_column = self.find('#edit-columns-button')
+ self.assertTrue(edit_column.is_displayed())
+ edit_column.click()
+ # Check dropdown is visible
+ self.wait_until_visible('ul.dropdown-menu.editcol')
+
+ # Check that we can hide the edit column
+ test_edit_column('checkbox-errors')
+ test_edit_column('checkbox-image_files')
+ test_edit_column('checkbox-last_build_outcome')
+ test_edit_column('checkbox-recipe_name')
+ test_edit_column('checkbox-warnings')
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects
2023-11-21 13:47 [PATCH 1/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects Alassane Yattara
2023-11-21 13:47 ` [PATCH 2/3] " Alassane Yattara
@ 2023-11-21 13:47 ` Alassane Yattara
2023-11-23 12:10 ` [Toaster] [PATCH 1/3] " Richard Purdie
2 siblings, 0 replies; 4+ messages in thread
From: Alassane Yattara @ 2023-11-21 13:47 UTC (permalink / raw)
To: toaster; +Cc: Alassane Yattara
Test the show rows feature in the projects table on the all projects page
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
.../tests/browser/test_all_projects_page.py | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/toaster/tests/browser/test_all_projects_page.py b/lib/toaster/tests/browser/test_all_projects_page.py
index 2b1d8cc1..a880dbcc 100644
--- a/lib/toaster/tests/browser/test_all_projects_page.py
+++ b/lib/toaster/tests/browser/test_all_projects_page.py
@@ -297,3 +297,37 @@ class TestAllProjectsPage(SeleniumTestCase):
test_edit_column('checkbox-last_build_outcome')
test_edit_column('checkbox-recipe_name')
test_edit_column('checkbox-warnings')
+
+ def test_allProject_table_show_rows(self):
+ """ Test the show rows feature in the projects table on the all projects page """
+ self._create_projects(nb_project=200)
+
+ def test_show_rows(row_to_show, show_row_link):
+ # Check that we can show rows == row_to_show
+ show_row_link.select_by_value(str(row_to_show))
+ self.wait_until_present('#projectstable tbody tr')
+ sleep_time = 1
+ if row_to_show == 150:
+ # wait more time for 150 rows
+ sleep_time = 2
+ time.sleep(sleep_time)
+ self.assertTrue(
+ len(self.find_all('#projectstable tbody tr')) == row_to_show
+ )
+
+ url = reverse('all-projects')
+ self.get(url)
+ self.wait_until_present('#projectstable tbody tr')
+
+ show_rows = self.driver.find_elements(
+ By.XPATH,
+ '//select[@class="form-control pagesize-projectstable"]'
+ )
+ # Check show rows
+ for show_row_link in show_rows:
+ show_row_link = Select(show_row_link)
+ test_show_rows(10, show_row_link)
+ test_show_rows(25, show_row_link)
+ test_show_rows(50, show_row_link)
+ test_show_rows(100, show_row_link)
+ test_show_rows(150, show_row_link)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Toaster] [PATCH 1/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects
2023-11-21 13:47 [PATCH 1/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects Alassane Yattara
2023-11-21 13:47 ` [PATCH 2/3] " Alassane Yattara
2023-11-21 13:47 ` [PATCH 3/3] " Alassane Yattara
@ 2023-11-23 12:10 ` Richard Purdie
2 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2023-11-23 12:10 UTC (permalink / raw)
To: Alassane Yattara, toaster, bitbake-devel
Hi Alassane,
On Tue, 2023-11-21 at 14:47 +0100, Alassane Yattara wrote:
>
> @@ -205,3 +218,24 @@ class TestAllProjectsPage(SeleniumTestCase):
> expected_url = reverse('project', args=(self.project.id,))
> msg = 'link on project name should point to configuration but was %s' % link_url
> self.assertTrue(link_url.endswith(expected_url), msg)
> +
> + def test_allProject_table_search_box(self):
> + """ Test the search box in the all project table on the all projects page """
> + self._create_projects()
> +
> + url = reverse('all-projects')
> + self.get(url)
> +
> + # Chseck search box is present and works
> + self.wait_until_present('#projectstable tbody tr')
> + search_box = self.find('#search-input-projectstable')
> + self.assertTrue(search_box.is_displayed())
> +
> + # Check that we can search for a project by project name
> + search_box.send_keys('test project 10')
> + search_btn = self.find('#search-submit-projectstable')
> + search_btn.click()
> + self.wait_until_present('#projectstable tbody tr')
> + time.sleep(1)
> + rows = self.find_all('#projectstable tbody tr')
> + self.assertTrue(len(rows) == 1)
I've merged these with some tweaks to the commit messages, basically
changing "Toaster:" to "toaster/tests:" and "->" to "-" to make things
more consistent with our other commits.
The time.sleep() calls in these tests worry me a bit as the values are
a little arbitrary. I noticed one does have to increase the timeout
depending on how much work is being done. Does the test framework not
have a better way to handle this such as a settle function or something
similar? I'm thinking this could be fixed in a follow up commit.
Cheers,
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-23 12:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21 13:47 [PATCH 1/3] Toaster: Toaster: Write UI TestCase -> Visualize all projects Alassane Yattara
2023-11-21 13:47 ` [PATCH 2/3] " Alassane Yattara
2023-11-21 13:47 ` [PATCH 3/3] " Alassane Yattara
2023-11-23 12:10 ` [Toaster] [PATCH 1/3] " Richard Purdie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).