From 3338ccfb38a060b7f2e0036c1b31e24eaa31756c Mon Sep 17 00:00:00 2001 From: aribeiro Date: Thu, 4 Mar 2021 11:49:00 +0000 Subject: Add new ui integration test flow New flows for onboarding VNF`s and CNF`s, download and verify if the onboarded package is present Issue-ID: SDC-3507 Signed-off-by: aribeiro Change-Id: Ie53c9ef4ef739d72fa78d3e14511d4107ee7a12a --- .../data/providers/OnboardingDataProviders.java | 24 +++ .../ci/tests/datatypes/enums/XnfTypeEnum.java | 1 + .../ci/tests/utils/general/FileHandling.java | 5 +- .../execute/sanity/EtsiOnboardVnfCnfUiTests.java | 182 +++++++++++++++++++++ .../ci/tests/execute/sanity/OnboardingFlowsUi.java | 6 +- .../sdc/frontend/ci/tests/flow/CreateVlmFlow.java | 126 ++++++++++++++ .../sdc/frontend/ci/tests/flow/CreateVspFlow.java | 4 +- .../ci/tests/flow/DownloadToscaCsarFlow.java | 77 +++++++++ .../sdc/frontend/ci/tests/pages/ComponentPage.java | 51 ++++++ .../frontend/ci/tests/pages/OnboardHomePage.java | 21 ++- .../frontend/ci/tests/pages/TopNavComponent.java | 11 +- .../frontend/ci/tests/pages/VlmCreationModal.java | 122 ++++++++++++++ .../frontend/ci/tests/pages/VlmOverviewPage.java | 100 +++++++++++ .../frontend/ci/tests/pages/VlmSubmitModal.java | 74 +++++++++ .../frontend/ci/tests/pages/VspCommitModal.java | 6 +- .../sdc/frontend/ci/tests/pages/home/HomePage.java | 4 + .../ci/tests/utilities/GeneralUIUtils.java | 2 +- .../frontend/ci/tests/utilities/LoaderHelper.java | 6 +- .../ci/tests/utilities/NotificationComponent.java | 16 +- .../test/resources/Files/ETSI/ETSI-CNF-SAMPLE.csar | Bin 0 -> 21234 bytes .../test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar | Bin 0 -> 2229 bytes .../ci/testSuites/frontend/onapUiSanity.xml | 6 + 22 files changed, 819 insertions(+), 25 deletions(-) create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVlmFlow.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadToscaCsarFlow.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmCreationModal.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmOverviewPage.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmSubmitModal.java create mode 100644 integration-tests/src/test/resources/Files/ETSI/ETSI-CNF-SAMPLE.csar create mode 100644 integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar (limited to 'integration-tests/src/test') diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java index 88b1a661b9..7f8c018c8f 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; import org.onap.sdc.backend.ci.tests.utils.general.FileHandling; @@ -114,6 +115,29 @@ public final class OnboardingDataProviders { return parametersArray; } + @DataProvider(name = "etsiVnfCnfOnboardPackages", parallel = true) + private static Object[][] etsiVnf() { + final List vnfPackageFileNameList = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.ETSI); + if (CollectionUtils.isEmpty(vnfPackageFileNameList)) { + fail("Could not create etsiSingleVnfCnf datasource"); + } + final String etsiVnfPackageName = "ETSI-VNF-SAMPLE.csar"; + final String etsiCnfPackageName = "ETSI-CNF-SAMPLE.csar"; + final List etsiPackages = vnfPackageFileNameList.stream() + .filter(packageName -> packageName.equals(etsiVnfPackageName) || packageName.equals(etsiCnfPackageName)) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(etsiPackages) || etsiPackages.size() < 2) { + fail(String.format("Could not create etsiSingleVnfCnf datasource, one of the package '%s' was not found", + etsiPackages)); + } + + final String folderPath = FileHandling.getXnfRepositoryPath(XnfTypeEnum.ETSI); + final Object[][] parametersArray = new Object[2][]; + parametersArray[0] = new Object[]{folderPath, etsiPackages.get(0)}; + parametersArray[1] = new Object[]{folderPath, etsiPackages.get(1)}; + return parametersArray; + } + private static Object[][] provideData(final List fileNamesFromFolder, final String folderPath) { final Object[][] parametersArray = new Object[fileNamesFromFolder.size()][]; int index = 0; diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/XnfTypeEnum.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/XnfTypeEnum.java index 0ee3e65944..b27e7e308b 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/XnfTypeEnum.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/XnfTypeEnum.java @@ -22,6 +22,7 @@ package org.onap.sdc.backend.ci.tests.datatypes.enums; public enum XnfTypeEnum { + ETSI ("ETSI"), VNF ("VNF"), PNF ("PNF"), CNF ("CNF"); diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java index d4191d7738..17331e8d64 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java @@ -135,7 +135,8 @@ public class FileHandling { private static EnumMap XNF_REPOSITORY_PATHS_MAP = new EnumMap<>(Map.of( XnfTypeEnum.PNF, getPnfRepositoryPath(), XnfTypeEnum.CNF, getCnfRepositoryPath(), - XnfTypeEnum.VNF, getVnfRepositoryPath() + XnfTypeEnum.VNF, getVnfRepositoryPath(), + XnfTypeEnum.ETSI, getEtsiRepositoryPath() )); public static String getVnfRepositoryPath() { @@ -150,6 +151,8 @@ public class FileHandling { return getFilePath("CNFs"); } + private static String getEtsiRepositoryPath() { return getFilePath("ETSI"); } + public static String getXnfRepositoryPath(XnfTypeEnum xnfTypeEnum) { return XNF_REPOSITORY_PATHS_MAP.get(xnfTypeEnum); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java new file mode 100644 index 0000000000..55b4f535db --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java @@ -0,0 +1,182 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.execute.sanity; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.fail; + +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.Status; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.Assertions; +import org.onap.sdc.backend.ci.tests.data.providers.OnboardingDataProviders; +import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; +import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; +import org.onap.sdc.frontend.ci.tests.exception.UnzipException; +import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; +import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest; +import org.onap.sdc.frontend.ci.tests.flow.CreateResourceFromVspFlow; +import org.onap.sdc.frontend.ci.tests.flow.CreateVlmFlow; +import org.onap.sdc.frontend.ci.tests.flow.CreateVspFlow; +import org.onap.sdc.frontend.ci.tests.flow.DownloadToscaCsarFlow; +import org.onap.sdc.frontend.ci.tests.flow.ImportVspFlow; +import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; +import org.onap.sdc.frontend.ci.tests.pages.ResourceLeftSideMenu; +import org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent; +import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; +import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; +import org.openqa.selenium.WebDriver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class EtsiOnboardVnfCnfUiTests extends SetupCDTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(EtsiOnboardVnfCnfUiTests.class); + + private WebDriver webDriver; + private TopNavComponent topNavComponent; + + @BeforeMethod + public void init() { + webDriver = DriverFactory.getDriver(); + topNavComponent = new TopNavComponent(webDriver); + } + + @Test + public void createVlm() { + final ExtentTest extendTest = getExtendTest(); + extendTest.log(Status.INFO, String.format("Starting flow to create a VLM")); + final CreateVlmFlow createVlmFlow = new CreateVlmFlow(webDriver); + createVlmFlow.run(); + } + + @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "etsiVnfCnfOnboardPackages") + public void onboardEtsiVnfCnfFlow(final String rootFolder, final String vnfFile) { + setLog(vnfFile); + final String resourceName = ElementFactory.addRandomSuffixToName(ElementFactory.getResourcePrefix()); + runOnboardEtsiVnfCnf(resourceName, rootFolder, vnfFile); + } + + /** + * Runs ETSI onboarding VNF/CNF UI flow + * + * @param resourceName VSP name + * @param rootFolder VNF/CNF package location + * @param vnfCnfFile file to be onboarded + */ + public void runOnboardEtsiVnfCnf(final String resourceName, final String rootFolder, final String vnfCnfFile) { + final ExtentTest extendTest = getExtendTest(); + extendTest.log(Status.INFO, + String.format("Creating VSP '%s' by onboarding ETSI VNF/CNF package '%s'", resourceName, vnfCnfFile)); + final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, resourceName, vnfCnfFile, rootFolder); + createVspFlow.run(topNavComponent); + + extendTest.log(Status.INFO, String.format("Importing VSP '%s'", resourceName)); + final ImportVspFlow importVspFlow = new ImportVspFlow(webDriver, resourceName); + + extendTest.log(Status.INFO, "Creating ResourceCreatePage"); + final ResourceCreatePage resourceCreatePage = importVspFlow.run() + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage")); + + extendTest.log(Status.INFO, String.format("Onboarding '%s' package", vnfCnfFile)); + final CreateResourceFromVspFlow createResourceFlow = new CreateResourceFromVspFlow(webDriver, resourceName); + createResourceFlow.run(resourceCreatePage); + extendTest.log(Status.INFO, String.format("Successfully onboarded the package '%s'", vnfCnfFile)); + + extendTest.log(Status.INFO, "Loading Component Page"); + final ComponentPage componentPage = loadComponentPage(); + extendTest.log(Status.INFO, "Downloading Tosca CSAR generated"); + final DownloadToscaCsarFlow downloadToscaCsarFlow = downloadToscaCsar(componentPage); + final ToscaArtifactsPage toscaArtifactsPage = downloadToscaCsarFlow.getLandedPage() + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ToscaArtifactsPage")); + assertThat("No artifact download was found", toscaArtifactsPage.getDownloadedArtifactList(), not(empty())); + extendTest.log(Status.INFO, "Tosca CSAR was successfully downloaded"); + + final String downloadedCsarName = toscaArtifactsPage.getDownloadedArtifactList().get(0); + extendTest.log(Status.INFO, String + .format("Verifying if the onboarded package is included in the downloaded csar '%s'", downloadedCsarName)); + verifyOnboardedPackage(downloadedCsarName); + } + + /** + * Loads Component Page + * + * @return ComponentPage + */ + private ComponentPage loadComponentPage() { + final ResourceLeftSideMenu resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver); + resourceLeftSideMenu.isLoaded(); + final ResourceWorkspaceTopBarComponent workspaceTopBarComponent = new ResourceWorkspaceTopBarComponent( + webDriver); + workspaceTopBarComponent.isLoaded(); + final ComponentPage componentPage = Optional + .of(new ComponentPage(webDriver, topNavComponent, resourceLeftSideMenu, workspaceTopBarComponent)) + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ComponentPage")); + componentPage.isLoaded(); + return componentPage; + } + + /** + * Download the generated packag + * + * @return DownloadToscaCsarFlow + */ + private DownloadToscaCsarFlow downloadToscaCsar(final ComponentPage componentPage) { + final DownloadToscaCsarFlow downloadToscaCsarFlow = new DownloadToscaCsarFlow(webDriver); + downloadToscaCsarFlow.run(componentPage); + return downloadToscaCsarFlow; + } + + /** + * Verifies if the onboarded package is included in the downloaded csar + * + * @param downloadedCsarName downloaded csar package name + */ + private void verifyOnboardedPackage(final String downloadedCsarName) { + final String downloadFolderPath = getConfig().getDownloadAutomationFolder(); + final Map filesFromZip; + try { + filesFromZip = FileHandling.getFilesFromZip(downloadFolderPath, downloadedCsarName); + final java.util.Optional etsiPackageEntryOpt = + filesFromZip.keySet().stream().filter(s -> s.startsWith("Artifacts/Deployment/ETSI_PACKAGE")) + .findFirst(); + if (etsiPackageEntryOpt.isEmpty()) { + Assertions.fail("Could not find the Onboarded Package in Artifacts/Deployment/ETSI_PACKAGE"); + } + } catch (final UnzipException e) { + final String errorMsg = "Could not unzip the downloaded csar package"; + LOGGER.info(errorMsg, e); + fail(String.format("%s Error: %s", errorMsg, e.getMessage())); + } + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java index cf562c766f..693302aca1 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java @@ -52,7 +52,6 @@ import org.onap.sdc.frontend.ci.tests.dataProvider.OnbordingDataProviders; import org.onap.sdc.frontend.ci.tests.datatypes.CanvasElement; import org.onap.sdc.frontend.ci.tests.datatypes.CanvasManager; import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum; -import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest; @@ -113,12 +112,14 @@ public class OnboardingFlowsUi extends SetupCDTest { protected static String filePath = FileHandling.getVnfRepositoryPath(); private Boolean makeDistributionValue; + private WebDriver webDriver; @Parameters({"makeDistribution"}) @BeforeMethod public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) { LOGGER.debug("makeDistribution parameter is '{}'", makeDistributionReadValue); makeDistributionValue = Boolean.valueOf(makeDistributionReadValue); + webDriver = DriverFactory.getDriver(); } @Test @@ -388,8 +389,7 @@ public class OnboardingFlowsUi extends SetupCDTest { extendTest.log(Status.INFO, String.format("Creating VSP '%s' by onboarding package '%s' with software version '%s'", - resourceName, pnfFile, swVersionsToString) - ); + resourceName, pnfFile, swVersionsToString)); final WebDriver webDriver = DriverFactory.getDriver(); final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, resourceName, pnfFile, rootFolder); createVspFlow.run(new TopNavComponent(webDriver)); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVlmFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVlmFlow.java new file mode 100644 index 0000000000..c40205c331 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVlmFlow.java @@ -0,0 +1,126 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.flow; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import com.aventstack.extentreports.Status; +import java.util.Optional; +import org.apache.commons.lang.RandomStringUtils; +import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.frontend.ci.tests.pages.OnboardHomePage; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; +import org.onap.sdc.frontend.ci.tests.pages.VlmCreationModal; +import org.onap.sdc.frontend.ci.tests.pages.VlmOverviewPage; +import org.onap.sdc.frontend.ci.tests.pages.home.HomePage; +import org.openqa.selenium.WebDriver; + +public class CreateVlmFlow extends AbstractUiTestFlow { + + private HomePage homePage; + + public CreateVlmFlow(WebDriver webDriver) { + super(webDriver); + } + + @Override + public Optional run(PageObject... pageObjects) { + final TopNavComponent topNavComponent = getParameter(pageObjects, TopNavComponent.class) + .orElse(new TopNavComponent(webDriver)); + extendTest.log(Status.INFO, "Accessing the Onboard Home Page to create a VLM"); + topNavComponent.isLoaded(); + final OnboardHomePage onboardHomePage = goToOnboardHomePage(topNavComponent); + final VlmOverviewPage vlmOverviewPage = createNewVlm(onboardHomePage); + submitVlm(vlmOverviewPage); + goToHomePage(topNavComponent); + return Optional.empty(); + } + + @Override + public Optional getLandedPage() { + return Optional.ofNullable(homePage); + } + + /** + * Goes to the onboard home page by clicking in the onboard tab in the top nav component. + * + * @param topNavComponent the top nav component + * @return the onboard home page + */ + private OnboardHomePage goToOnboardHomePage(final TopNavComponent topNavComponent) { + final OnboardHomePage onboardHomePage = topNavComponent.clickOnOnboard(); + onboardHomePage.isLoaded(); + ExtentTestActions.takeScreenshot(Status.INFO, "onboard-homepage", "Onboard homepage is loaded"); + return onboardHomePage; + } + + /** + * Creates a new VLM in the onboard home page. + * + * @param onboardHomePage the onboard home page representation + * @return the Vendor License Model Overview page + */ + private VlmOverviewPage createNewVlm(final OnboardHomePage onboardHomePage) { + final String vendorName = new StringBuilder("CiVlm").append(RandomStringUtils.randomAlphabetic(5)).toString(); + extendTest.log(Status.INFO, "Creating a new VLM"); + final VlmCreationModal vlmCreationModal = onboardHomePage.clickOnCreateNewVlm(); + vlmCreationModal.isLoaded(); + vlmCreationModal.fillCreationForm(vendorName, "My New VLM"); + ExtentTestActions.takeScreenshot(Status.INFO, "vlm-creation-form", + "Creating VLM with given information"); + final VlmOverviewPage vlmOverviewPage = vlmCreationModal.clickOnCreate(); + vlmOverviewPage.isLoaded(); + extendTest.log(Status.INFO, String.format("VLM with vendor name '%s' created", vendorName)); + final String actualVendorName = vlmOverviewPage.getVendorName(); + assertThat(String.format("Should be in the Vendor License Model '%s' page", vendorName), + actualVendorName, is(vendorName)); + return vlmOverviewPage; + } + + /** + * Submits the VLM through the software product view. + * + * @param vlmOverviewPage the Vendor Licence Overview page + */ + private void submitVlm(final VlmOverviewPage vlmOverviewPage) { + extendTest.log(Status.INFO, "Checking if the VLM Overview page is loaded."); + ExtentTestActions.takeScreenshot(Status.INFO, "vlm-overview-page-loaded", "The first VLM version was submitted"); + vlmOverviewPage.overviewScreenIsLoaded(); + extendTest.log(Status.INFO, "Submitting the first VLM version."); + vlmOverviewPage.submit(); + ExtentTestActions.takeScreenshot(Status.INFO, "vlm-submitted", "The first VLM version was submitted"); + } + + /** + * Go to the system home page through the top nav menu. + * + * @param topNavComponent the top nav component + */ + private void goToHomePage(final TopNavComponent topNavComponent) { + extendTest.log(Status.INFO, "Accessing the Home page"); + topNavComponent.isLoaded(); + homePage = topNavComponent.clickOnHome(); + homePage.isLoaded(); + ExtentTestActions.takeScreenshot(Status.INFO, "home-is-loaded", "The Home page is loaded."); + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java index 1da45b5397..614dc1a2af 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java @@ -31,7 +31,6 @@ import org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding; import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; import org.onap.sdc.frontend.ci.tests.pages.VspCreationModal; import org.onap.sdc.frontend.ci.tests.pages.home.HomePage; -import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebDriver; /** @@ -140,8 +139,7 @@ public class CreateVspFlow extends AbstractUiTestFlow { private void goToHomePage(final TopNavComponent topNavComponent) { extendTest.log(Status.INFO, "Accessing the Home page to import the created VSP"); topNavComponent.isLoaded(); - homePage = topNavComponent.clickOnHome(); - GeneralUIUtils.ultimateWait(); + this.homePage = topNavComponent.clickOnHome(); homePage.isLoaded(); ExtentTestActions.takeScreenshot(Status.INFO, "home-is-loaded", "The Home page is loaded."); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadToscaCsarFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadToscaCsarFlow.java new file mode 100644 index 0000000000..d785c1f3c5 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadToscaCsarFlow.java @@ -0,0 +1,77 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.flow; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +import com.aventstack.extentreports.Status; +import java.io.File; +import java.time.Duration; +import java.util.Optional; +import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; +import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.FluentWait; + +/** + * UI Flow for downloading Tosca CSAR from a component + */ +public class DownloadToscaCsarFlow extends AbstractUiTestFlow { + + private ToscaArtifactsPage toscaArtifactsPage; + + public DownloadToscaCsarFlow(final WebDriver webDriver) { + super(webDriver); + } + + @Override + public Optional run(final PageObject... pageObjects) { + final ComponentPage componentPage = findParameter(pageObjects, ComponentPage.class); + toscaArtifactsPage = componentPage.goToToscaArtifacts(); + toscaArtifactsPage.isLoaded(); + toscaArtifactsPage.clickOnDownload("Tosca Model"); + + final File downloadedCsar = waitAndGetDownloadedCsar(); + assertThat("The downloaded CSAR should exist", downloadedCsar, is(notNullValue())); + assertThat("The downloaded CSAR should exist", downloadedCsar.exists(), is(true)); + toscaArtifactsPage.addToDownloadedArtifactList(downloadedCsar.getName()); + ExtentTestActions.takeScreenshot(Status.INFO, "tosca-csar-downloaded", "TOSCA CSAR Downloaded"); + + return Optional.of(toscaArtifactsPage); + } + + @Override + public Optional getLandedPage() { + return Optional.ofNullable(toscaArtifactsPage); + } + + private File waitAndGetDownloadedCsar() { + final FluentWait fluentWait = new FluentWait<>("") + .withTimeout(Duration.ofSeconds(5)).pollingEvery(Duration.ofSeconds(1)); + fluentWait.until(s -> FileHandling.getLastModifiedFileNameFromDir() != null); + return FileHandling.getLastModifiedFileNameFromDir(); + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java new file mode 100644 index 0000000000..13ab884c70 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.pages; + +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; +import org.openqa.selenium.WebDriver; + +public class ComponentPage extends AbstractPageObject { + + private final TopNavComponent topNavComponent; + private final ResourceLeftSideMenu resourceLeftSideMenu; + private final ResourceWorkspaceTopBarComponent workspaceTopBarComponent; + + public ComponentPage(final WebDriver webDriver, final TopNavComponent topNavComponent, + final ResourceLeftSideMenu resourceLeftSideMenu, + final ResourceWorkspaceTopBarComponent workspaceTopBarComponent) { + super(webDriver); + this.topNavComponent = topNavComponent; + this.resourceLeftSideMenu = resourceLeftSideMenu; + this.workspaceTopBarComponent = workspaceTopBarComponent; + } + + @Override + public void isLoaded() { + topNavComponent.isLoaded(); + resourceLeftSideMenu.isLoaded(); + workspaceTopBarComponent.isLoaded(); + } + + public ToscaArtifactsPage goToToscaArtifacts() { + return resourceLeftSideMenu.clickOnToscaArtifactsMenuItem(); + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java index cd3e34d36e..70af5cdeaa 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java @@ -19,6 +19,7 @@ package org.onap.sdc.frontend.ci.tests.pages; + import lombok.AllArgsConstructor; import lombok.Getter; import org.openqa.selenium.By; @@ -33,6 +34,7 @@ public class OnboardHomePage extends AbstractPageObject { private final OnboardHeaderComponent onboardHeaderComponent; private WebElement createNewVspBtn; + private WebElement createNewVlmBtn; public OnboardHomePage(final WebDriver webDriver, final OnboardHeaderComponent onboardHeaderComponent) { @@ -45,7 +47,8 @@ public class OnboardHomePage extends AbstractPageObject { onboardHeaderComponent.isLoaded(); createNewVspBtn = getWait() .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ADD_NEW_VSP_BTN.getXpath()))); - getWait() + + createNewVlmBtn = getWait() .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ADD_NEW_VLM_BTN.getXpath()))); } @@ -55,17 +58,31 @@ public class OnboardHomePage extends AbstractPageObject { * @return returns the next vsp creation page object */ public VspCreationModal clickOnCreateNewVsp() { + waitForElementInvisibility(By.xpath(XpathSelector.ONBOARDING_LOADER_DIV.getXpath())); createNewVspBtn.click(); return new VspCreationModal(webDriver); } + + /** + * Clicks on the button create new vlm. + * + * @return returns the next vlm creation page object + */ + public VlmCreationModal clickOnCreateNewVlm() { + waitForElementInvisibility(By.xpath(XpathSelector.ONBOARDING_LOADER_DIV.getXpath())); + createNewVlmBtn.click(); + return new VlmCreationModal(webDriver); + } + /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ @AllArgsConstructor private enum XpathSelector { ADD_NEW_VSP_BTN("catalog-add-new-vsp", "//div[@data-test-id='%s']"), - ADD_NEW_VLM_BTN("catalog-add-new-vlm", "//div[@data-test-id='%s']"); + ADD_NEW_VLM_BTN("catalog-add-new-vlm", "//div[@data-test-id='%s']"), + ONBOARDING_LOADER_DIV("onboarding-loader-backdrop","//div[@class='%s']"); @Getter private final String id; diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java index 33deabbae0..7eb15bbded 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java @@ -76,10 +76,11 @@ public class TopNavComponent extends AbstractPageObject { public boolean isHomeSelected() { final By homeLinkLocator = By.xpath(XpathSelector.MAIN_MENU_LINK_HOME.getXpath()); - final WebElement homeLinkElement = waitForElementVisibility(homeLinkLocator); + final WebElement homeLinkElement = waitToBeClickable(homeLinkLocator); final WebElement homeLinkParentElement = homeLinkElement.findElement(By.xpath("./..")); - final String aClass = homeLinkParentElement.getAttribute("class"); - return "selected".equals(aClass); + final String homeLinkClass = homeLinkParentElement.getAttribute("class"); + LOGGER.debug(String.format("Home link class '%s'", homeLinkClass)); + return homeLinkClass != null && homeLinkClass.contains("selected"); } /** @@ -116,6 +117,7 @@ public class TopNavComponent extends AbstractPageObject { * @return the next page object */ public OnboardHomePage clickOnOnboard() { + waitForElementInvisibility(By.xpath(XpathSelector.SDC_LOADER_BACKGROUND.getXpath())); wrappingElement.findElement(By.xpath(XpathSelector.MAIN_MENU_ONBOARD_BTN.getXpath())).click(); return new OnboardHomePage(DriverFactory.getDriver(), new OnboardHeaderComponent(DriverFactory.getDriver())); } @@ -146,7 +148,8 @@ public class TopNavComponent extends AbstractPageObject { MAIN_MENU_LINK_HOME("main-menu-button-home", "//*[@data-tests-id='%s']"), ARROW_DROPDOWN("triangle-dropdown", "//li[contains(@class, '%s')]"), MAIN_MENU_ONBOARD_BTN("main-menu-button-onboard", "//a[@data-tests-id='%s']"), - REPOSITORY_ICON("repository-icon", "//*[@data-tests-id='%s']"); + REPOSITORY_ICON("repository-icon", "//*[@data-tests-id='%s']"), + SDC_LOADER_BACKGROUND("sdc-loader-global-wrapper sdc-loader-background", "//div[@class='%s']"); @Getter private final String id; diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmCreationModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmCreationModal.java new file mode 100644 index 0000000000..13c0236ad8 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmCreationModal.java @@ -0,0 +1,122 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.pages; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Handles the VLM Creation Modal UI actions + */ +public class VlmCreationModal extends AbstractPageObject { + + private static final Logger LOGGER = LoggerFactory.getLogger(VlmCreationModal.class); + + private WebElement wrappingElement; + + public VlmCreationModal(final WebDriver webDriver) { + super(webDriver); + timeoutInSeconds = 5; + } + + @Override + public void isLoaded() { + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_XPATH.getXpath()); + wrappingElement = waitForElementVisibility(XpathSelector.MODAL_XPATH.getXpath()); + } + + /** + * Fills VLM mandatory entries + * @param vendorName the VLM vendor name + * @param description the VLM description + */ + public void fillCreationForm(final String vendorName, final String description) { + fillVendorName(vendorName); + fillDescription(description); + } + + /** + * Fills the VLM Vendor Name field + * @param vendorName the VLM vendor name + */ + private void fillVendorName(final String vendorName) { + setInputValue(XpathSelector.VENDOR_NAME_TXT, vendorName); + } + + /** + * Fills the VLM description field. + * + * @param description the VLM description + */ + public void fillDescription(final String description) { + setInputValue(XpathSelector.DESCRIPTION_TXT, description); + } + + /** + * Sets input value to the given Xpath + * @param inputTestId the Xpath selected + * @param value the value + */ + private void setInputValue(final XpathSelector inputTestId, final String value) { + findSubElement(wrappingElement, By.xpath(inputTestId.getXpath())).sendKeys(value); + } + + /** + * Clicks on the create button. + * @return the next page object + */ + public VlmOverviewPage clickOnCreate() { + clickElement(XpathSelector.CREATE_BTN); + return new VlmOverviewPage(webDriver, new VlmSubmitModal(webDriver)); + } + + /** + * Clicks on the given Xpath element + * @param elementTestId the ui element + */ + private void clickElement(final XpathSelector elementTestId) { + wrappingElement.findElement(By.xpath(elementTestId.getXpath())).click(); + } + + /** + * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. + */ + @AllArgsConstructor + private enum XpathSelector { + MODAL_XPATH("license-model-modal", "//div[@class='%s']"), + VENDOR_NAME_TXT("vendor-name", "//*[@data-test-id='%s']"), + DESCRIPTION_TXT("vendor-description", "//*[@data-test-id='%s']"), + CREATE_BTN("form-submit-button", "//*[@data-test-id='%s']"); + + @Getter + private final String id; + private final String xpathFormat; + + public String getXpath() { + return String.format(xpathFormat, id); + } + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmOverviewPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmOverviewPage.java new file mode 100644 index 0000000000..ce3c26b215 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmOverviewPage.java @@ -0,0 +1,100 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.pages; + +import static org.hamcrest.MatcherAssert.assertThat; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.hamcrest.core.Is; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VlmOverviewPage extends AbstractPageObject { + + private static final Logger LOGGER = LoggerFactory.getLogger(VlmOverviewPage.class); + private static final String DIV_CLASS_XPATH_FORMAT = "//div[@class='%s']"; + private static final String DIV_DATA_TEST_ID_XPATH_FORMAT = "//div[@data-test-id='%s']"; + private final VlmSubmitModal vlmSubmitModal; + private WebElement wrappingElement; + + public VlmOverviewPage(final WebDriver webDriver, + final VlmSubmitModal vlmSubmitModal) { + super(webDriver); + this.vlmSubmitModal = vlmSubmitModal; + timeoutInSeconds = 10; + } + + @Override + public void isLoaded() { + wrappingElement = getWrappingElement(); + } + + public void overviewScreenIsLoaded() { + final String overviewPageXpath = String + .format("%s%s", VlmOverviewPage.XpathSelector.PAGE_MAIN_DIV.getXpath(), XpathSelector.OVERVIEW_PAGE.getXpath()); + waitForElementVisibility(By.xpath(overviewPageXpath)); + final WebElement selectedNavBarGroupItem = + findSubElement(wrappingElement, XpathSelector.SELECTED_NAV_BAR_GROUP_ITEM.getXpath()); + final String selectedNavBarGroupItemTestId = selectedNavBarGroupItem.getAttribute("data-test-id"); + assertThat("Overview page should be selected", selectedNavBarGroupItemTestId, + Is.is(XpathSelector.NAV_BAR_GROUP_ITEM_OVERVIEW.getId())); + } + + public String getVendorName() { + return wrappingElement.findElement(By.xpath(XpathSelector.NAV_BAR_GROUP_NAME_XPATH.getXpath())).getText(); + } + + public void submit() { + findSubElement(wrappingElement, XpathSelector.BNT_SUBMIT.getXpath()).click(); + vlmSubmitModal.isLoaded(); + vlmSubmitModal.confirmSuccess(); + } + + public WebElement getWrappingElement() { + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.PAGE_MAIN_DIV.getXpath()); + return waitForElementVisibility(XpathSelector.PAGE_MAIN_DIV.getXpath()); + } + + /** + * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. + */ + @AllArgsConstructor + private enum XpathSelector { + PAGE_MAIN_DIV("software-product-view", DIV_CLASS_XPATH_FORMAT), + NAV_BAR_GROUP_ITEM_OVERVIEW("navbar-group-item-LICENSE_MODEL_OVERVIEW", DIV_CLASS_XPATH_FORMAT), + BNT_SUBMIT("vc-submit-btn", DIV_DATA_TEST_ID_XPATH_FORMAT), + NAV_BAR_GROUP_NAME_XPATH("navbar-group-name", DIV_DATA_TEST_ID_XPATH_FORMAT), + SELECTED_NAV_BAR_GROUP_ITEM("navigation-group-item-name selected", DIV_CLASS_XPATH_FORMAT), + OVERVIEW_PAGE("license-model-overview", DIV_CLASS_XPATH_FORMAT); + + @Getter + private final String id; + private final String xpathFormat; + + public String getXpath() { + return String.format(xpathFormat, id); + } + + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmSubmitModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmSubmitModal.java new file mode 100644 index 0000000000..112ddc2b5f --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VlmSubmitModal.java @@ -0,0 +1,74 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.pages; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Handles the VLM Submit Modal UI actions + */ +public class VlmSubmitModal extends AbstractPageObject { + + private static final Logger LOGGER = LoggerFactory.getLogger(VlmSubmitModal.class); + + + public VlmSubmitModal(final WebDriver webDriver) { + super(webDriver); + } + + public void isLoaded() { + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_DIV.getXpath()); + waitForElementVisibility(XpathSelector.MODAL_DIV.getXpath()); + } + + /** + * Confirms the success of the modal submission. + */ + public void confirmSuccess() { + final WebElement successModal = waitForElementVisibility(XpathSelector.SUCCESS_MODAL_DIV.getXpath()); + successModal.findElement(By.xpath(XpathSelector.MODAL_CANCEL_BTN.getXpath())).click(); + } + + /** + * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. + */ + @AllArgsConstructor + private enum XpathSelector { + MODAL_DIV("sdc-modal", "//div[contains(@class, '%s')]"), + SUBMIT_BTN("vc-submit-btn", "//div[@data-test-id='%s']"), + SUCCESS_MODAL_DIV("sdc-modal-type-info", "//div[contains(@class, '%s')]"), + MODAL_CANCEL_BTN("sdc-modal-cancel-button", "//button[@data-test-id='%s']"); + + @Getter + private final String id; + private final String xpath; + + public String getXpath() { + return String.format(xpath, id); + } + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java index 5c1928cf36..bf57e099a2 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java @@ -21,11 +21,9 @@ package org.onap.sdc.frontend.ci.tests.pages; import lombok.AllArgsConstructor; import lombok.Getter; -import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,7 +59,6 @@ public class VspCommitModal extends AbstractPageObject { public void submit() { final WebElement commitAndSubmitBtn = wrappingElement.findElement(By.xpath(XpathSelector.COMMIT_AND_SUBMIT_BTN.getXpath())); commitAndSubmitBtn.click(); - GeneralUIUtils.ultimateWait(); confirmSuccess(); } @@ -69,8 +66,7 @@ public class VspCommitModal extends AbstractPageObject { * Confirms the success of the modal submission. */ private void confirmSuccess() { - final WebElement successModal = getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.SUCCESS_MODAL_DIV.getXpath()))); + final WebElement successModal = waitForElementVisibility(By.xpath(XpathSelector.SUCCESS_MODAL_DIV.getXpath()), 60); successModal.findElement(By.xpath(XpathSelector.MODAL_CANCEL_BTN.getXpath())).click(); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java index 563dd11452..7a0d7a1e6b 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java @@ -22,6 +22,7 @@ package org.onap.sdc.frontend.ci.tests.pages.home; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import java.time.Duration; import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; @@ -31,6 +32,7 @@ import org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent; import org.onap.sdc.frontend.ci.tests.pages.ServiceComponentPage; import org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage; import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; +import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -51,6 +53,8 @@ public class HomePage extends AbstractPageObject { @Override public void isLoaded() { + new Actions(webDriver).pause(Duration.ofSeconds(2)).perform(); + new LoaderHelper(webDriver).waitForLoaderInvisibility(5); waitToBeClickable(XpathSelector.HOME_RIGHT_CONTAINER.getXpath()); waitToBeClickable(XpathSelector.HOME_SIDE_BAR.getXpath()); topNavComponent.isLoaded(); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/GeneralUIUtils.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/GeneralUIUtils.java index 302edacacb..c0a829af64 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/GeneralUIUtils.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/GeneralUIUtils.java @@ -717,7 +717,7 @@ public final class GeneralUIUtils { getDriver().navigate().to(url); } - public static void refreshWebpage() throws Exception { + public static void refreshWebpage() { getExtendTest().log(Status.INFO, "Refreshing Webpage"); getDriver().navigate().refresh(); ultimateWait(); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java index d8f57db7e6..e5bfc2bbbb 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java @@ -25,7 +25,7 @@ import org.openqa.selenium.WebDriver; public class LoaderHelper extends AbstractPageObject { - private final By loaderLocator = By.xpath("//*[@data-tests-id='loader' or @class='tlv-loader']"); + private final By loaderLocator = By.xpath("//*[@data-tests-id='loader' or @class='tlv-loader' or @class='sdc-loader' or @class='sdc-loader-global-wrapper sdc-loader-background']"); public LoaderHelper(final WebDriver webDriver) { super(webDriver); @@ -36,6 +36,10 @@ public class LoaderHelper extends AbstractPageObject { waitForElementInvisibility(loaderLocator, timeout); } + public void waitForLoaderInvisibility(final int timeout) { + waitForElementInvisibility(loaderLocator, timeout); + } + @Override public void isLoaded() { diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java index 26db4828f7..2ffe658465 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java @@ -19,6 +19,7 @@ package org.onap.sdc.frontend.ci.tests.utilities; + import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; @@ -48,9 +49,14 @@ public class NotificationComponent extends AbstractPageObject { } private String getMessageXpath(final NotificationType notificationType) { + final String messageContainerPath = String + .format("%s%s", XpathSelector.MAIN_CONTAINER_DIV.getXpath(), XpathSelector.MESSAGE_CONTENT_DIV.getXpath()); if (notificationType == NotificationType.SUCCESS) { - return String.format("%s%s%s", XpathSelector.MAIN_CONTAINER_DIV.getXpath(), XpathSelector.MESSAGE_CONTENT_DIV.getXpath(), - XpathSelector.MESSAGE_SUCCESS_DIV.getXpath()); + return String.format("%s%s", messageContainerPath, XpathSelector.MESSAGE_SUCCESS_DIV.getXpath()); + } + + if (notificationType == NotificationType.CREATE_OR_UPDATE) { + return String.format("%s%s", messageContainerPath, XpathSelector.MESSAGE_CREATE_UPDATE_DIV.getXpath()); } LOGGER.warn("Xpath for NotificationType {} not yet implemented.", notificationType); @@ -66,8 +72,8 @@ public class NotificationComponent extends AbstractPageObject { private enum XpathSelector { MAIN_CONTAINER_DIV("notification-container", "//div[@class='%s']"), MESSAGE_CONTENT_DIV("msg-content", "//div[@class='%s']"), - MESSAGE_SUCCESS_DIV("message", - "//div[contains(@class, 'message') and (contains(text(),'successfully') or contains(text(), 'Successfully'))]"); + MESSAGE_SUCCESS_DIV("message", "//div[contains(@class, 'message') and (contains(text(),'successfully') or contains(text(), 'Successfully'))]"), + MESSAGE_CREATE_UPDATE_DIV("message", "//div[contains(@class, '%s') and (contains(text(), 'Create/Update') or contains(text(), 'created'))]"); @Getter private final String id; @@ -79,7 +85,7 @@ public class NotificationComponent extends AbstractPageObject { } public enum NotificationType { - SUCCESS; + SUCCESS, CREATE_OR_UPDATE; } } diff --git a/integration-tests/src/test/resources/Files/ETSI/ETSI-CNF-SAMPLE.csar b/integration-tests/src/test/resources/Files/ETSI/ETSI-CNF-SAMPLE.csar new file mode 100644 index 0000000000..841eddd84d Binary files /dev/null and b/integration-tests/src/test/resources/Files/ETSI/ETSI-CNF-SAMPLE.csar differ diff --git a/integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar b/integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar new file mode 100644 index 0000000000..10c7169ab9 Binary files /dev/null and b/integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar differ diff --git a/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml b/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml index 2cc0808076..78f9cdc197 100644 --- a/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml +++ b/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml @@ -31,6 +31,12 @@ + + + + + + -- cgit 1.2.3-korg