Skip to content

Commit

Permalink
Merge pull request #193 from cloudsufi/Wrangler_import_e2e
Browse files Browse the repository at this point in the history
Wrangler Import e2e Steps
  • Loading branch information
Aryan-Verma committed Aug 11, 2023
2 parents 4ec16f7 + 7d801b5 commit 0330990
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ public static void waitTillConnectionDataLoadingCompletes(long timeoutInSeconds)

/**
* Select data row for connection
*
* <p>
* Based on the connection type - table with rows containing data (i.e.bucket, dataset, table, directory names etc.)
* will be displayed.
* To select data for the connection use this method with its name as parameter.
* Example : For GCS pass actual bucket name as parameter.
*/
private static void selectConnectionDataRow(String dataRow) {
waitTillConnectionDataLoadingCompletes (ConstantsUtil.DEFAULT_TIMEOUT_SECONDS);
waitTillConnectionDataLoadingCompletes(ConstantsUtil.DEFAULT_TIMEOUT_SECONDS);
ElementHelper.sendKeys(CdfConnectionLocators.searchDirectoryInput, dataRow);
WaitHelper.waitForTextToBePresentInElementValue(CdfConnectionLocators.searchDirectoryInput, dataRow);
int attempts = 0;
Expand All @@ -146,15 +146,13 @@ private static void selectConnectionDataRow(String dataRow) {

/**
* Select data for connection using name
*
* <p>
* Example :
* For GCS, table with bucket names will be displayed.
* To select bucket for the connection use this method with bucket name as parameter.
*
* Once bucket name is selected - in next table all directories inside bucket will be displayed.
* To select directory use this method with directory name as parameter.
*
*
* @param dataName If dataName is present in {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} as a key
* then actual dataName to select is fetched from it
* else dataName used as it is.
Expand All @@ -169,7 +167,7 @@ public static void selectConnectionDataWithName(String dataName) {

/**
* Select data rows for connection traversing through directories using provided path
*
* <p>
* Example GCS dataPath: "testdata/GCS_CSV_TEST.csv"
* First "testdata" directory inside bucket will be selected
* and then in next datatable, file "GCS_CSV_TEST.csv" will be selected.
Expand All @@ -191,11 +189,11 @@ public static void selectConnectionDataWithPath(String dataPath) {

/**
* Click SELECT button inside connection data row using name
*
* <p>
* Example :
* For BQ, table with dataset names will be displayed.
* To click on SELECT button of dataset row use this method with dataset name as parameter.
*
* <p>
* Once SELECT button is clicked, steps to select source/target BQ table will be skipped.
*
* @param dataName If dataName is present in {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} as a key
Expand Down Expand Up @@ -331,7 +329,7 @@ public static void verifyConnectionIsNotPresent(String connectionType, String co
ConstantsUtil.DEFAULT_TIMEOUT_SECONDS);
Assert.assertTrue("Connection " + connectionName + " should not be present"
, !ElementHelper.isElementDisplayed(CdfConnectionLocators.locatorOfConnection(connectionType,
actualConnectionName), 5));
actualConnectionName), 5));
}

/**
Expand Down
33 changes: 31 additions & 2 deletions src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.cdap.e2e.utils.AssertionHelper;
import io.cdap.e2e.utils.ConstantsUtil;
import io.cdap.e2e.utils.ElementHelper;
import io.cdap.e2e.utils.FileImportUtil;
import io.cdap.e2e.utils.SeleniumDriver;
import io.cdap.e2e.utils.SeleniumHelper;
import io.cdap.e2e.utils.WaitHelper;
Expand All @@ -31,6 +32,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URISyntaxException;

/**
* Represents Cdf Studio Page Actions
*/
Expand Down Expand Up @@ -280,6 +283,7 @@ public static void clickPreviewLogsButton() {

/**
* Verify the Pipeline Preview Run's status in logs
*
* @param status
*/
public static void verifyPipelinePreviewStatusInLogs(String status) {
Expand Down Expand Up @@ -498,11 +502,36 @@ public static void closeStatusBanner() {

/**
* Click on the element and move.
*
* @param pluginName plugin title.
* @param xOffset horizontal move offset.
* @param yOffset vertical move offset.
* @param xOffset horizontal move offset.
* @param yOffset vertical move offset.
*/
public static void movePlugin(String pluginName, int xOffset, int yOffset) {
ElementHelper.dragAndDropByOffset(CdfStudioLocators.locatePluginNodeInCanvas(pluginName), xOffset, yOffset);
}

/**
* Click on the Upload Button
*/
public static void clickOnAddEntityButton() {
ElementHelper.clickOnElement(CdfStudioLocators.addEntityButton);
}

/**
* Clicks on the "Fix All" button if displayed.
*/
public static void clickOnFixAllButtonIfDisplayed() {
ElementHelper.clickIfDisplayed(CdfStudioLocators.fixAllButton());
}

/**
* Imports a pipeline from the specified file path.
* @param filePath The path to the file containing the pipeline to be imported.
**/
public static void importPipeline(String filePath) throws URISyntaxException {
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.importPipelineButton);
FileImportUtil.uploadFile(CdfStudioLocators.importPipelineInputTag(), filePath);
clickOnFixAllButtonIfDisplayed();
}
}
15 changes: 15 additions & 0 deletions src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,19 @@ public static By locatorOfLoadingSpinnerOnValidateButton() {
@Deprecated
@FindBy(how = How.XPATH, using = "//*[@data-cy='plugin-validation-error-msg']")
public static WebElement pluginValidationErrorMsg;

@FindBy(how = How.XPATH, using = "//img[@id='resource-center-btn']")
public static WebElement addEntityButton;

@FindBy(how = How.XPATH, using = "//*[@id='import-pipeline']")
public static WebElement importPipelineButton;

public static By fixAllButton() {
return By.xpath("//button[@data-cy='fix-all-btn']");
}

public static WebElement importPipelineInputTag() {
return SeleniumDriver.getDriver().findElement(By.xpath
("//input[@id='resource-center-import-pipeline']"));
}
}
37 changes: 37 additions & 0 deletions src/main/java/io/cdap/e2e/utils/FileImportUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright © 2022 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 io.cdap.e2e.utils;

import io.cdap.e2e.pages.locators.CdfStudioLocators;
import org.openqa.selenium.WebElement;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

/**
* File Import Util
*/
public class FileImportUtil {

public static void uploadFile(WebElement uploadButtonLocator, String filePath) throws URISyntaxException {
Path resourcePath = Paths.get(Objects.requireNonNull
(CdfStudioLocators.class.getResource("/" + filePath)).toURI());
uploadButtonLocator.sendKeys(resourcePath.toString());
}
}
17 changes: 17 additions & 0 deletions src/main/java/stepsdesign/PipelineSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -715,4 +716,20 @@ public void waitTillTheReviewAssessmentPageIsLoadedInReplication() {
public void waitTillTheConfigureAdvancedPropertiesPageIsLoadedInReplication() {
CdfPluginPropertiesActions.waitTillTheConfigureAdvancedPropertiesPageLoaded();
}

@Then("Click on the Plus Green Button to import the pipelines")
public void clickOnPlusGreenButton () {
CdfStudioActions.clickOnAddEntityButton();
}

@Then("Select the file for importing the pipeline for the plugin {string}")
public void selectFileForImport(String path) throws URISyntaxException {
CdfStudioActions.importPipeline(PluginPropertyUtils.pluginProp(path));
}

@Then("Rename the pipeline")
public void renameThePipeline() {
pipelineName = "TestPipeline-" + RandomStringUtils.randomAlphanumeric(10);
CdfStudioActions.fillPipelineNameAndSave(pipelineName);
}
}

0 comments on commit 0330990

Please sign in to comment.