From patchwork Wed Nov 29 22:53:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 35378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 419F8C10DC2 for ; Wed, 29 Nov 2023 22:53:58 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.57399.1701298435965646035 for ; Wed, 29 Nov 2023 14:53:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=RNCOgU47; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 58F9B9C3679 for ; Wed, 29 Nov 2023 17:53:55 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id 7M-3hKDdcWGa; Wed, 29 Nov 2023 17:53:54 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B0A139C3DF2; Wed, 29 Nov 2023 17:53:54 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com B0A139C3DF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1701298434; bh=Gu7LSjTMRIutt2pVoYpNGcgYEgMPM5NyOuXX8kEY7oA=; h=From:To:Date:Message-Id:MIME-Version; b=RNCOgU47eZ6R0lLHdbH1a1/XkNvaGcXVgAdHJ3dj11svWSpicIJHAye+/LaEUaH2f /L8IymdN8NRsuM1yyuBPKhgYSRU3bliWryanF1QFl8qR3HHHembh6uu1VmDuWHfpxM 2EkvHvrVoe1eQdl1YGqE0148tgoObNMBs0SstHIEHWZ9donFBus6S4RXEN1HhS6wl5 aplCxEqVMZKWz6IA2KTa0TJUhd7U4prT9aLy/BPriw4cKj4oAriJlJMEbNoGfUAOIu zaQ1EKAMmxLhWWaZY1VjwcrNt4q+YDad7yPKMV8K66W5/ODu+skR2+5xttv4i6pPRs ywZ2v1/MPNgLg== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id LU8NgOwSCNZr; Wed, 29 Nov 2023 17:53:54 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 283F89C2797; Wed, 29 Nov 2023 17:53:54 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH 3/9] toaster/test: Test software recipe page Date: Wed, 29 Nov 2023 23:53:34 +0100 Message-Id: <20231129225340.477401-3-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129225340.477401-1-alassane.yattara@savoirfairelinux.com> References: <20231129225340.477401-1-alassane.yattara@savoirfairelinux.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 29 Nov 2023 22:53:58 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/6026 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) Signed-off-by: Alassane Yattara --- .../tests/functional/test_project_page.py | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/lib/toaster/tests/functional/test_project_page.py b/lib/toaster/tests/functional/test_project_page.py index f1eb9cfa..28f1fcb6 100644 --- a/lib/toaster/tests/functional/test_project_page.py +++ b/lib/toaster/tests/functional/test_project_page.py @@ -7,9 +7,11 @@ # import pytest +from time import sleep from django.urls import reverse from django.utils import timezone from selenium.webdriver.support.select import Select +from selenium.common.exceptions import NoSuchElementException from tests.functional.functional_helpers import SeleniumFunctionalTestCase from orm.models import Build, Project, Target from selenium.webdriver.common.by import By @@ -164,6 +166,70 @@ class TestProjectPage(SeleniumFunctionalTestCase): f"The {th_class} column is checked in EditColumn dropdown, but it's not visible in table" ) + def _get_config_nav_item(self, index): + config_nav = self.find('#config-nav') + return config_nav.find_elements(By.TAG_NAME, 'li')[index] + + def _navigate_to_config_nav(self, nav_id, nav_index): + # navigate to the project page + url = reverse("project", args=(1,)) + self.get(url) + self.wait_until_visible('#config-nav') + # click on "Software recipe" tab + soft_recipe = self._get_config_nav_item(nav_index) + soft_recipe.click() + self.wait_until_visible(f'#{nav_id}') + + def _mixin_test_table_show_rows(self, table_selector, **kwargs): + """ Test the show rows feature in the builds table on the all builds page """ + 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_visible(f'#{table_selector} tbody tr', poll=2) + self.assertTrue( + len(self.find_all(f'#{table_selector} tbody tr')) == row_to_show + ) + self.wait_until_present(f'#{table_selector} tbody tr') + show_rows = self.driver.find_elements( + By.XPATH, + f'//select[@class="form-control pagesize-{table_selector}"]' + ) + rows_to_show = [10, 25, 50, 100, 150] + to_skip = kwargs.get('to_skip', []) + # Check show rows + for show_row_link in show_rows: + show_row_link = Select(show_row_link) + for row_to_show in rows_to_show: + if row_to_show not in to_skip: + test_show_rows(row_to_show, show_row_link) + + def _wait_until_build(self, state): + while True: + try: + last_build_state = self.driver.find_element( + By.XPATH, + '//*[@id="latest-builds"]/div[1]//div[@class="build-state"]', + ) + build_state = last_build_state.get_attribute( + 'data-build-state') + state_text = state.lower().split() + if any(x in str(build_state).lower() for x in state_text): + break + except NoSuchElementException: + continue + sleep(1) + + def _mixin_test_table_search_input(self, **kwargs): + input_selector, input_text, searchBtn_selector, table_selector, *_ = kwargs.values() + # Test search input + self.wait_until_visible(f'#{input_selector}') + recipe_input = self.find(f'#{input_selector}') + recipe_input.send_keys(input_text) + self.find(f'#{searchBtn_selector}').click() + self.wait_until_visible(f'#{table_selector} tbody tr') + rows = self.find_all(f'#{table_selector} tbody tr') + self.assertTrue(len(rows) > 0) + def test_image_recipe_editColumn(self): """ Test the edit column feature in image recipe table on project page """ self._get_create_builds(success=10, failure=10) @@ -375,3 +441,55 @@ class TestProjectPage(SeleniumFunctionalTestCase): self.assertTrue( 'core-image-minimal' in str(last_build.text) ) + + def test_softwareRecipe_page(self): + """ 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) + """ + self._navigate_to_config_nav('softwarerecipestable', 4) + # check title "Compatible software recipes" is displayed + self.assertTrue("Compatible software recipes" in self.get_page_source()) + # Test search input + self._mixin_test_table_search_input( + input_selector='search-input-softwarerecipestable', + input_text='busybox', + searchBtn_selector='search-submit-softwarerecipestable', + table_selector='softwarerecipestable' + ) + # check "build recipe" button works + rows = self.find_all('#softwarerecipestable tbody tr') + image_to_build = rows[0] + build_btn = image_to_build.find_element( + By.XPATH, + '//td[@class="add-del-layers"]' + ) + build_btn.click() + self._wait_until_build('parsing starting cloning') + lastest_builds = self.driver.find_elements( + By.XPATH, + '//div[@id="latest-builds"]/div' + ) + self.assertTrue(len(lastest_builds) > 0) + + # check software recipe table feature(show/hide column, pagination) + self._navigate_to_config_nav('softwarerecipestable', 4) + column_list = [ + 'get_description_or_summary', + 'layer_version__get_vcs_reference', + 'layer_version__layer__name', + 'license', + 'recipe-file', + 'section', + 'version', + ] + self._mixin_test_table_edit_column( + 'softwarerecipestable', + 'edit-columns-button', + [f'checkbox-{column}' for column in column_list] + ) + self._navigate_to_config_nav('softwarerecipestable', 4) + # check show rows(pagination) + self._mixin_test_table_show_rows(table_selector='softwarerecipestable')