From patchwork Tue Nov 21 13:50:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 34959 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 28806C61D99 for ; Tue, 21 Nov 2023 13:51:00 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.40859.1700574655695789200 for ; Tue, 21 Nov 2023 05:50:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=WF3cD6i2; 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 069B79C2B49 for ; Tue, 21 Nov 2023 08:50: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 k6E-39YxNuGr; Tue, 21 Nov 2023 08:50:54 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 0F6269C3500; Tue, 21 Nov 2023 08:50:54 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 0F6269C3500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1700574654; bh=XFp2Aw4VEZK5wuJU830kvVCbytU6doqvSFaKcSnUNrY=; h=From:To:Date:Message-Id:MIME-Version; b=WF3cD6i2vRPzTpUJme69xozIqTcJphP7u4mYiyQ6ZbL3IlaexuUvtxBVcEc55wjeu nTQ2slDOA5xxwzO0nOhsedMxNb05p9v82bUWwdx01srCt88R63rpNz5cNPuNClHV8s NRNChpPxHg1/V/LYYQIjwxFotpz2H0nM5kglUmNsBf9TBJRGe5V3TC25yEyRPaFsqH oZUPcHUTYRDLkGK1Q3rtHKmfVs4VGq1A0rAV8sTHGTJbqJ/ibypmKn3uA7B7bOnaMz 7TR2MNkEMjCOrIjda2JG4R9fVAe2qiKl3Om6HLfoSWV60NZxOvGaxiMi6qfV994tug y3P5olLtW/7YQ== 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 gz0TPoO82Ii1; Tue, 21 Nov 2023 08:50:54 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 517819C366C; Tue, 21 Nov 2023 08:50:53 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH 6/7] Toaster: Write UI TestCase -> the edit column feature in image recipe Date: Tue, 21 Nov 2023 14:50:42 +0100 Message-Id: <20231121135043.105385-6-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121135043.105385-1-alassane.yattara@savoirfairelinux.com> References: <20231121135043.105385-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 ; Tue, 21 Nov 2023 13:51:00 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/6017 BUILD IMAGE RECIPES: toastergui/project/{id}/images/ Test the edit column feature in image recipe table on project page Signed-off-by: Alassane Yattara --- .../test_project_page_tab_config.py | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/lib/toaster/tests/functional/test_project_page_tab_config.py b/lib/toaster/tests/functional/test_project_page_tab_config.py index 598a8055..2dfc120d 100644 --- a/lib/toaster/tests/functional/test_project_page_tab_config.py +++ b/lib/toaster/tests/functional/test_project_page_tab_config.py @@ -8,10 +8,12 @@ from time import sleep import pytest +from django.utils import timezone from django.urls import reverse from selenium.webdriver import Keys from selenium.webdriver.support.select import Select from selenium.common.exceptions import NoSuchElementException +from orm.models import Build, Project, Target from tests.functional.functional_helpers import SeleniumFunctionalTestCase from selenium.webdriver.common.by import By @@ -112,6 +114,64 @@ class TestProjectConfigTab(SeleniumFunctionalTestCase): config_nav = self.find('#config-nav') return config_nav.find_elements(By.TAG_NAME, 'li')[index] + def _get_create_builds(self, **kwargs): + """ Create a build and return the build object """ + # parameters for builds to associate with the projects + now = timezone.now() + release = '3' + project_name = 'projectmaster' + self._create_test_new_project( + project_name+"2", + release, + False, + ) + + self.project1_build_success = { + 'project': Project.objects.get(id=1), + 'started_on': now, + 'completed_on': now, + 'outcome': Build.SUCCEEDED + } + + self.project1_build_failure = { + 'project': Project.objects.get(id=1), + 'started_on': now, + 'completed_on': now, + 'outcome': Build.FAILED + } + build1 = Build.objects.create(**self.project1_build_success) + build2 = Build.objects.create(**self.project1_build_failure) + + # add some targets to these builds so they have recipe links + # (and so we can find the row in the ToasterTable corresponding to + # a particular build) + Target.objects.create(build=build1, target='foo') + Target.objects.create(build=build2, target='bar') + + if kwargs: + # Create kwargs.get('success') builds with success status with target + # and kwargs.get('failure') builds with failure status with target + for i in range(kwargs.get('success', 0)): + now = timezone.now() + self.project1_build_success['started_on'] = now + self.project1_build_success[ + 'completed_on'] = now - timezone.timedelta(days=i) + build = Build.objects.create(**self.project1_build_success) + Target.objects.create(build=build, + target=f'{i}_success_recipe', + task=f'{i}_success_task') + + for i in range(kwargs.get('failure', 0)): + now = timezone.now() + self.project1_build_failure['started_on'] = now + self.project1_build_failure[ + 'completed_on'] = now - timezone.timedelta(days=i) + build = Build.objects.create(**self.project1_build_failure) + Target.objects.create(build=build, + target=f'{i}_fail_recipe', + task=f'{i}_fail_task') + return build1, build2 + def test_project_config_nav(self): """ Test project config tab navigation: - Check if the menu is displayed and contains the right elements: @@ -421,3 +481,64 @@ class TestProjectConfigTab(SeleniumFunctionalTestCase): '//div[@id="latest-builds"]/div' ) self.assertTrue(len(lastest_builds) > 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) + + 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'#imagerecipestable 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'#imagerecipestable 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'#imagerecipestable 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'#imagerecipestable 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('projectimagerecipes', args=(1,)) + self.get(url) + self.wait_until_present('#imagerecipestable 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-get_description_or_summary') + test_edit_column('checkbox-layer_version__get_vcs_reference') + test_edit_column('checkbox-layer_version__layer__name') + test_edit_column('checkbox-license') + test_edit_column('checkbox-recipe-file') + test_edit_column('checkbox-section') + test_edit_column('checkbox-version')