Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions src/main/java/io/cdap/e2e/pages/actions/CdfSysAdminActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
package io.cdap.e2e.pages.actions;

import io.cdap.e2e.pages.locators.CdfSysAdminLocators;
import io.cdap.e2e.utils.AssertionHelper;
import io.cdap.e2e.utils.ConstantsUtil;
import io.cdap.e2e.utils.ElementHelper;
import io.cdap.e2e.utils.PluginPropertyUtils;
import io.cdap.e2e.utils.SeleniumHelper;
import io.cdap.e2e.utils.WaitHelper;
import org.junit.Assert;
import org.openqa.selenium.support.ui.Select;
import org.slf4j.Logger;
Expand Down Expand Up @@ -77,4 +81,101 @@ public static void verifySuccess() {
}
Assert.assertTrue(checkParam);
}

/**
* Check whether Namespace created successfully
*/
public static void namespaceCreatedSuccessMessage() {
WaitHelper.waitForElementToBeDisplayed(CdfSysAdminLocators.locateNameSpaceSuccessMessage,
ConstantsUtil.DEFAULT_TIMEOUT_SECONDS);
}

/**
* Click on Switch button to switch to created Namespace
*/
public static void clickOnSwitchToButton() {
ElementHelper.clickOnElement(CdfSysAdminLocators.switchToCreatedNamespace);
}

/**
* Click on close button to close the Namespace window
*/
public static void clickOnCloseIconOnNamespaceWindow() {
ElementHelper.clickOnElement(CdfSysAdminLocators.closeNamespaceWindow);
}

/**
* Check whether created Namespace is displayed in System Admin's Namespace tab
*
* @param namespaceName any specific title created
*/
public static void verifyCreatedNamespaceIsDisplayed(String namespaceName) {
WaitHelper.waitForElementToBeDisplayed(CdfSysAdminLocators.namespaceAdded
(PluginPropertyUtils.pluginProp(namespaceName)));
AssertionHelper.verifyElementDisplayed(CdfSysAdminLocators.
namespaceAdded(PluginPropertyUtils.pluginProp(namespaceName)));
}

/**
* Click on Make HTTP calls
*/
public static void clickOnMakeHttpCalls() {
ElementHelper.clickOnElement(CdfSysAdminLocators.makeHttpCall);
}

/**
* Click on EDIT button to add Namespace preferences
*/
public static void clickOnEditNamespacePreference() {
ElementHelper.clickOnElement(CdfSysAdminLocators.editPreferencesButton);
}

/**
* Click on Hamburger Menu
*/
public static void clickOnHamburgerMenu() {
ElementHelper.clickOnElement(CdfSysAdminLocators.hamburgerMenu);
}

/**
* Select the type of tab from hamburger menu list
*
* @param listName @data-cy attribute value from menu list. If Provisioner is present in
* {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy is
* fetched from it else Provisioner is used as it is.
*/
public static void selectHamburgerMenuList(String listName) {
String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute(
listName);
if (pluginPropertyDataCyAttribute == null) {
pluginPropertyDataCyAttribute = listName;
}
ElementHelper.clickOnElement(
CdfSysAdminLocators.locateMenuLink(pluginPropertyDataCyAttribute));
}

/**
* Click on Namespace tab links
*
* @param tabName @data-cy attribute value of tabName. If tabName is present in
* {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE}
* then its data-cy is fetched from it else tabName is used
* as it is.
* @param nameSpaceName Actual nameSpaceName is fetched from {@link
* ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} else nameSpaceName param is used as it is
*/
public static void clickOnNameSpaceAdminTabs(String tabName, String nameSpaceName) {
ElementHelper.clickOnElement(
CdfSysAdminLocators.nameSpaceModules(tabName, PluginPropertyUtils.pluginProp(nameSpaceName)));
}

/**
* Select the request method from drop down
*
* @param requestMethod any specific value
*/
public static void selectRequestDropdownOption(String requestMethod) {
Select selectRequestMethod = new Select(CdfSysAdminLocators.requestMethod);
selectRequestMethod.selectByVisibleText(PluginPropertyUtils.pluginProp(requestMethod));
}
}
42 changes: 42 additions & 0 deletions src/main/java/io/cdap/e2e/pages/locators/CdfSysAdminLocators.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.cdap.e2e.pages.locators;

import io.cdap.e2e.utils.SeleniumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
Expand Down Expand Up @@ -51,4 +53,44 @@ public class CdfSysAdminLocators {

@FindBy(how = How.XPATH, using = "//*[@data-cy='Clear All']")
public static WebElement clearAll;

@FindBy(how = How.XPATH, using = "//*[@data-cy='wizard-result-icon-close-btn']")
public static WebElement closeNamespaceWindow;

public static WebElement namespaceAdded(String nameSpace) {
String path = "//*[@href=\"/cdap/ns/" + nameSpace + "/details\"]";
return SeleniumDriver.getDriver().findElement(By.xpath(path));
}

@FindBy(how = How.XPATH, using = "//a[contains(text(), 'Switch to')]")
public static WebElement switchToCreatedNamespace;

@FindBy(how = How.XPATH, using = "//a[contains(text(), 'Go to homepage')]")
public static WebElement goToHomepage;

@FindBy(how = How.XPATH, using = "//span[contains(@title, 'Successfully created the namespace')] ")
public static WebElement locateNameSpaceSuccessMessage;

@FindBy(how = How.XPATH, using = "//span[contains(text(),'Edit')]")
public static WebElement editPreferencesButton;

@FindBy(how = How.XPATH, using = "//*[@data-cy='navbar-hamburger-icon']")
public static WebElement hamburgerMenu;

public static WebElement locateMenuLink(String menuLink) {
String xpath = "//*[@data-cy='navbar-" + menuLink + "-link']";
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
}

public static WebElement nameSpaceModules(String module, String nameSpace) {
String path = "//*[@href=\"/cdap/ns/" + nameSpace + "/details/" + module + "\"]";
return SeleniumDriver.getDriver().findElement(By.xpath(path));
}

public static By locateDropdownItem(String option) {
return By.xpath("//select//option[@value='" + option + "']");
}

@FindBy(how = How.XPATH, using = "//*[@data-cy='request-method-selector']")
public static WebElement requestMethod;
}
90 changes: 90 additions & 0 deletions src/main/java/stepsdesign/SysadminSteps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright © 2023 Cask Data, Inc.
*
* 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.
*/
package stepsdesign;

import io.cdap.e2e.pages.actions.CdfSysAdminActions;
import io.cdap.e2e.utils.CdfHelper;
import io.cucumber.java.en.Then;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* CDF sysadmin related step design.
*/
public class SysadminSteps implements CdfHelper {

private static final Logger logger = LoggerFactory.getLogger(SysadminSteps.class);

@Then("Verify the namespace created success message displayed on confirmation window")
public void verifyNamespaceCreatedSuccessMessageDisplayed() {
CdfSysAdminActions.namespaceCreatedSuccessMessage();
}

@Then("Verify the created namespace: {string} is displayed in Namespace tab")
public void verifyCreatedNamespaceIsDisplayed(String namespace) {
CdfSysAdminActions.verifyCreatedNamespaceIsDisplayed(namespace);
}

@Then("Click on close icon of successful namespace confirmation window")
public void closeWindowIcon() {
CdfSysAdminActions.clickOnCloseIconOnNamespaceWindow();
}

@Then("Click on Make HTTP calls from the System admin configuration page")
public void clickOnMakeHttpCalls() {
CdfSysAdminActions.clickOnMakeHttpCalls();
}

@Then("Click on send button")
public void clickOnSendButton() {
CdfSysAdminActions.sendRequest();
}

@Then("Verify the status code for success response")
public void verifyStatusCode() {
CdfSysAdminActions.verifySuccess();
}

@Then("Click on edit namespace preferences to set namespace preferences")
public void clickOnEditNameSpacePreferences() {
CdfSysAdminActions.clickOnEditNamespacePreference();
}

@Then("Click on the Hamburger menu on the left panel")
public static void clickOnTheHamburgerMenu() {
CdfSysAdminActions.clickOnHamburgerMenu();
}

@Then("Click {string} tab from Configuration page for {string} Namespace")
public void openNameSpaceAdminPageTabs(String tabName, String nameSpace) {
CdfSysAdminActions.clickOnNameSpaceAdminTabs(tabName, nameSpace);
}

@Then("Select navigation item: {string} from the Hamburger menu list")
public void selectNavigationItemFromMenu(String tabName) {
CdfSysAdminActions.selectHamburgerMenuList(tabName);
}

@Then("Click on the switch to namespace button")
public static void clickOnTheSwitchToButton() {
CdfSysAdminActions.clickOnSwitchToButton();
}

@Then("Select request dropdown property with option value: {string}")
public void selectDropdownPluginPropertyOptionValue(String option) {
CdfSysAdminActions.selectRequestDropdownOption(option);
}
}