[E2E] add switch task case (#8180)
* fix switch bug * add switch e2e test * add switch workflow * pre task option * selectPreTask id * update * switch task e2e * naming optimization Co-authored-by: caishunfeng <534328519@qq.com>
This commit is contained in:
parent
480492db73
commit
fc9a31f813
|
|
@ -85,6 +85,8 @@ jobs:
|
|||
class: org.apache.dolphinscheduler.e2e.cases.TokenE2ETest
|
||||
- name: Workflow
|
||||
class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
|
||||
- name: WorkflowForSwitch
|
||||
class: org.apache.dolphinscheduler.e2e.cases.WorkflowSwitchE2ETest
|
||||
- name: FileManage
|
||||
class: org.apache.dolphinscheduler.e2e.cases.FileManageE2ETest
|
||||
- name: UdfManage
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ public class SwitchParameters extends AbstractParameters {
|
|||
List<String> nextNodeList = new ArrayList<>();
|
||||
nextNodeList.add(String.valueOf(nextNode));
|
||||
this.nextNode = nextNodeList;
|
||||
} else if (nextNode instanceof Number) {
|
||||
List<String> nextNodeList = new ArrayList<>();
|
||||
nextNodeList.add(nextNode.toString());
|
||||
this.nextNode = nextNodeList;
|
||||
} else {
|
||||
this.nextNode = (ArrayList) nextNode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* Licensed to Apache Software Foundation (ASF) under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Apache Software Foundation (ASF) licenses this file to you 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 org.apache.dolphinscheduler.e2e.cases;
|
||||
|
||||
import org.apache.dolphinscheduler.e2e.core.DolphinScheduler;
|
||||
import org.apache.dolphinscheduler.e2e.pages.LoginPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.ProjectDetailPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.ProjectPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.TaskInstanceTab;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowDefinitionTab;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm.TaskType;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab.Row;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.ShellTaskForm;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SwitchTaskForm;
|
||||
import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.security.TenantPage;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml")
|
||||
class WorkflowSwitchE2ETest {
|
||||
private static final String project = "test-workflow-1";
|
||||
private static final String workflow = "test-workflow-1";
|
||||
private static final String ifBranchName = "key==1";
|
||||
private static final String elseBranchName = "key!=1";
|
||||
|
||||
private static final String tenant = System.getProperty("user.name");
|
||||
|
||||
private static RemoteWebDriver browser;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
new LoginPage(browser)
|
||||
.login("admin", "dolphinscheduler123")
|
||||
.goToNav(SecurityPage.class)
|
||||
.goToTab(TenantPage.class)
|
||||
.create(tenant)
|
||||
.goToNav(ProjectPage.class)
|
||||
.create(project)
|
||||
;
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void cleanup() {
|
||||
new NavBarPage(browser)
|
||||
.goToNav(ProjectPage.class)
|
||||
.goTo(project)
|
||||
.goToTab(WorkflowDefinitionTab.class)
|
||||
.cancelPublishAll()
|
||||
.deleteAll()
|
||||
;
|
||||
new NavBarPage(browser)
|
||||
.goToNav(ProjectPage.class)
|
||||
.delete(project)
|
||||
.goToNav(SecurityPage.class)
|
||||
.goToTab(TenantPage.class)
|
||||
.delete(tenant)
|
||||
;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testCreateSwitchWorkflow() {
|
||||
|
||||
final WorkflowDefinitionTab workflowDefinitionPage =
|
||||
new ProjectPage(browser)
|
||||
.goTo(project)
|
||||
.goToTab(WorkflowDefinitionTab.class);
|
||||
|
||||
WorkflowForm workflowForm = workflowDefinitionPage.createWorkflow();
|
||||
|
||||
workflowForm.<ShellTaskForm> addTask(TaskType.SHELL)
|
||||
.script("echo ${today}\necho ${global_param}\n")
|
||||
.name("pre-task")
|
||||
.submit();
|
||||
|
||||
SwitchTaskForm switchTaskForm = workflowForm.addTask(TaskType.SWITCH);
|
||||
switchTaskForm.preTask("pre-task")
|
||||
.name("switch")
|
||||
.submit();
|
||||
|
||||
workflowForm.<ShellTaskForm>addTask(TaskType.SHELL)
|
||||
.script("echo ${key}")
|
||||
.preTask("switch")
|
||||
.name(ifBranchName)
|
||||
.submit();
|
||||
|
||||
workflowForm.<ShellTaskForm>addTask(TaskType.SHELL)
|
||||
.script("echo ${key}")
|
||||
.preTask("switch")
|
||||
.name(elseBranchName)
|
||||
.submit();
|
||||
|
||||
// format dag
|
||||
workflowForm.formatDAG().confirm();
|
||||
|
||||
// add branch for switch task
|
||||
workflowForm.getTask("switch");
|
||||
switchTaskForm.addIfBranch("${key}==1", ifBranchName);
|
||||
switchTaskForm.elseBranch(elseBranchName);
|
||||
switchTaskForm.submit();
|
||||
|
||||
workflowForm.submit()
|
||||
.name(workflow)
|
||||
.tenant(tenant)
|
||||
.addGlobalParam("key", "1")
|
||||
.submit();
|
||||
|
||||
await().untilAsserted(() -> assertThat(
|
||||
workflowDefinitionPage.workflowList()
|
||||
).anyMatch(it -> it.getText().contains(workflow)));
|
||||
|
||||
workflowDefinitionPage.publish(workflow);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void testRunWorkflow() {
|
||||
final ProjectDetailPage projectPage =
|
||||
new ProjectPage(browser)
|
||||
.goToNav(ProjectPage.class)
|
||||
.goTo(project);
|
||||
|
||||
projectPage
|
||||
.goToTab(WorkflowInstanceTab.class)
|
||||
.deleteAll();
|
||||
|
||||
projectPage
|
||||
.goToTab(WorkflowDefinitionTab.class)
|
||||
.run(workflow)
|
||||
.submit();
|
||||
|
||||
await().untilAsserted(() -> {
|
||||
browser.navigate().refresh();
|
||||
|
||||
final Row row = projectPage
|
||||
.goToTab(WorkflowInstanceTab.class)
|
||||
.instances()
|
||||
.iterator()
|
||||
.next();
|
||||
|
||||
assertThat(row.isSuccess()).isTrue();
|
||||
assertThat(row.executionTime()).isEqualTo(1);
|
||||
});
|
||||
|
||||
// check task for switch
|
||||
List<TaskInstanceTab.Row> taskInstances = projectPage
|
||||
.goToTab(TaskInstanceTab.class)
|
||||
.instances();
|
||||
|
||||
await().untilAsserted(() -> {
|
||||
assertThat(taskInstances.size()).isEqualTo(3);
|
||||
assertThat(taskInstances.stream().filter(row -> row.name().contains(ifBranchName)).count()).isEqualTo(1);
|
||||
assertThat(taskInstances.stream().noneMatch(row -> row.name().contains(elseBranchName))).isTrue();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
package org.apache.dolphinscheduler.e2e.pages.project;
|
||||
|
||||
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.TaskInstanceTab;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowDefinitionTab;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab;
|
||||
|
||||
|
|
@ -35,6 +36,8 @@ public final class ProjectDetailPage extends NavBarPage {
|
|||
private WebElement menuProcessDefinition;
|
||||
@FindBy(className = "tab-process-instance")
|
||||
private WebElement menuProcessInstances;
|
||||
@FindBy(className = "tab-task-instance")
|
||||
private WebElement menuTaskInstances;
|
||||
|
||||
public ProjectDetailPage(RemoteWebDriver driver) {
|
||||
super(driver);
|
||||
|
|
@ -49,6 +52,10 @@ public final class ProjectDetailPage extends NavBarPage {
|
|||
menuProcessInstances().click();
|
||||
return tab.cast(new WorkflowInstanceTab(driver));
|
||||
}
|
||||
if (tab == TaskInstanceTab.class) {
|
||||
menuTaskInstances().click();
|
||||
return tab.cast(new TaskInstanceTab(driver));
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Unknown tab: " + tab.getName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.dolphinscheduler.e2e.pages.project.workflow;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.ProjectDetailPage;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.FindBys;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public final class TaskInstanceTab extends NavBarPage implements ProjectDetailPage.Tab {
|
||||
@FindBy(className = "items-task-instances")
|
||||
private List<WebElement> instanceList;
|
||||
|
||||
public TaskInstanceTab(RemoteWebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
public List<Row> instances() {
|
||||
return instanceList()
|
||||
.stream()
|
||||
.filter(WebElement::isDisplayed)
|
||||
.map(Row::new)
|
||||
.filter(row -> !row.name().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public static class Row {
|
||||
private final WebElement row;
|
||||
|
||||
public String state() {
|
||||
return row.findElement(By.className("task-instance-state")).getText();
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return row.findElement(By.className("task-instance-name")).getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,11 +23,14 @@ import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.ShellTaskForm
|
|||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SubWorkflowTaskForm;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SwitchTaskForm;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
|
|
@ -35,12 +38,18 @@ import com.google.common.io.Resources;
|
|||
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@Getter
|
||||
public final class WorkflowForm {
|
||||
private final WebDriver driver;
|
||||
private final WorkflowSaveDialog saveForm;
|
||||
private final WorkflowFormatDialog formatDialog;
|
||||
|
||||
@FindBy(className = "graph-format")
|
||||
private WebElement formatBtn;
|
||||
|
||||
@FindBy(id = "btnSave")
|
||||
private WebElement buttonSave;
|
||||
|
|
@ -48,6 +57,7 @@ public final class WorkflowForm {
|
|||
public WorkflowForm(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
this.saveForm = new WorkflowSaveDialog(this);
|
||||
this.formatDialog = new WorkflowFormatDialog(this);
|
||||
|
||||
PageFactory.initElements(driver, this);
|
||||
}
|
||||
|
|
@ -60,7 +70,7 @@ public final class WorkflowForm {
|
|||
|
||||
final JavascriptExecutor js = (JavascriptExecutor) driver;
|
||||
final String dragAndDrop = String.join("\n",
|
||||
Resources.readLines(Resources.getResource("dragAndDrop.js"), StandardCharsets.UTF_8));
|
||||
Resources.readLines(Resources.getResource("dragAndDrop.js"), StandardCharsets.UTF_8));
|
||||
js.executeScript(dragAndDrop, task, canvas);
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -68,18 +78,42 @@ public final class WorkflowForm {
|
|||
return (T) new ShellTaskForm(this);
|
||||
case SUB_PROCESS:
|
||||
return (T) new SubWorkflowTaskForm(this);
|
||||
case SWITCH:
|
||||
return (T) new SwitchTaskForm(this);
|
||||
}
|
||||
throw new UnsupportedOperationException("Unknown task type");
|
||||
}
|
||||
|
||||
public WebElement getTask(String taskName) {
|
||||
List<WebElement> tasks = new WebDriverWait(driver, 10)
|
||||
.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("svg > g > g[class^='x6-graph-svg-stage'] > g[data-shape^='dag-task']")));
|
||||
|
||||
WebElement task = tasks.stream()
|
||||
.filter(t -> t.getText().contains(taskName))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("No such task: " + taskName));
|
||||
|
||||
Actions action = new Actions(driver);
|
||||
action.doubleClick(task).build().perform();
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
public WorkflowSaveDialog submit() {
|
||||
buttonSave().click();
|
||||
|
||||
return new WorkflowSaveDialog(this);
|
||||
}
|
||||
|
||||
public WorkflowFormatDialog formatDAG() {
|
||||
formatBtn.click();
|
||||
|
||||
return new WorkflowFormatDialog(this);
|
||||
}
|
||||
|
||||
public enum TaskType {
|
||||
SHELL,
|
||||
SUB_PROCESS,
|
||||
SWITCH,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.dolphinscheduler.e2e.pages.project.workflow;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.FindBys;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
import org.openqa.selenium.support.pagefactory.ByChained;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
public final class WorkflowFormatDialog {
|
||||
private final WebDriver driver;
|
||||
private final WorkflowForm parent;
|
||||
|
||||
@FindBys({
|
||||
@FindBy(className = "el-dialog__wrapper"),
|
||||
@FindBy(className = "el-button--primary"),
|
||||
})
|
||||
private List<WebElement> buttonConfirm;
|
||||
|
||||
public WorkflowFormatDialog(WorkflowForm parent) {
|
||||
this.parent = parent;
|
||||
this.driver = parent.driver();
|
||||
|
||||
PageFactory.initElements(driver, this);
|
||||
}
|
||||
|
||||
public WorkflowForm confirm() {
|
||||
buttonConfirm()
|
||||
.stream()
|
||||
.filter(WebElement::isDisplayed)
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("No confirm button when confirm"))
|
||||
.click();
|
||||
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.FindBys;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public final class SwitchTaskForm extends TaskNodeForm {
|
||||
|
||||
@FindBy(id = "btnAddIfBranch")
|
||||
private WebElement buttonAddBranch;
|
||||
|
||||
@FindBys({
|
||||
@FindBy(className = "switch-task"),
|
||||
@FindBy(className = "switch-else"),
|
||||
@FindBy(className = "el-input__inner")
|
||||
})
|
||||
private WebElement inputElseBranch;
|
||||
|
||||
public SwitchTaskForm(WorkflowForm parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
public SwitchTaskForm elseBranch(String elseBranchName) {
|
||||
((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", inputElseBranch());
|
||||
|
||||
final By optionsLocator = By.className("option-else-branches");
|
||||
|
||||
new WebDriverWait(parent().driver(), 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
|
||||
|
||||
List<WebElement> webElements = parent().driver().findElements(optionsLocator);
|
||||
webElements.stream()
|
||||
.filter(it -> it.getText().contains(elseBranchName))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("No such else branch: " + elseBranchName))
|
||||
.click();
|
||||
|
||||
inputNodeName().click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public SwitchTaskForm addIfBranch(String switchScript, String ifBranchName) {
|
||||
((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", buttonAddBranch);
|
||||
|
||||
SwitchTaskIfBranch switchTaskIfBranch = new SwitchTaskIfBranch(this);
|
||||
switchTaskIfBranch.codeEditor().content(switchScript);
|
||||
|
||||
((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", switchTaskIfBranch.inputIfBranch());
|
||||
|
||||
final By optionsLocator = By.className("option-if-branches");
|
||||
|
||||
new WebDriverWait(parent().driver(), 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
|
||||
|
||||
List<WebElement> webElements = parent().driver().findElements(optionsLocator);
|
||||
webElements.stream()
|
||||
.filter(it -> it.getText().contains(ifBranchName))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("No such if branch: " + ifBranchName))
|
||||
.click();
|
||||
|
||||
inputNodeName().click();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.FindBys;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
@Getter
|
||||
public final class SwitchTaskIfBranch {
|
||||
private final WebDriver driver;
|
||||
private final SwitchTaskForm parent;
|
||||
|
||||
private final CodeEditor codeEditor;
|
||||
|
||||
@FindBys({
|
||||
@FindBy(className = "switch-task"),
|
||||
@FindBy(className = "switch-list"),
|
||||
@FindBy(className = "el-input")
|
||||
})
|
||||
private WebElement inputIfBranch;
|
||||
|
||||
public SwitchTaskIfBranch(SwitchTaskForm parent) {
|
||||
this.parent = parent;
|
||||
this.driver = parent.parent().driver();
|
||||
|
||||
this.codeEditor = new CodeEditor(driver);
|
||||
|
||||
PageFactory.initElements(driver, this);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,12 +22,15 @@ package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
|
|||
import lombok.Getter;
|
||||
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.FindBys;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
import org.openqa.selenium.support.pagefactory.ByChained;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
|
@ -49,6 +52,12 @@ public abstract class TaskNodeForm {
|
|||
})
|
||||
private List<WebElement> inputParamVal;
|
||||
|
||||
@FindBys({
|
||||
@FindBy(className = "pre_tasks-model"),
|
||||
@FindBy(tagName = "input"),
|
||||
})
|
||||
private WebElement selectPreTasks;
|
||||
|
||||
private final WorkflowForm parent;
|
||||
|
||||
TaskNodeForm(WorkflowForm parent) {
|
||||
|
|
@ -84,6 +93,26 @@ public abstract class TaskNodeForm {
|
|||
return this;
|
||||
}
|
||||
|
||||
public TaskNodeForm preTask(String preTaskName) {
|
||||
((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", selectPreTasks);
|
||||
|
||||
final By optionsLocator = By.className("option-pre-tasks");
|
||||
|
||||
new WebDriverWait(parent.driver(), 10)
|
||||
.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
|
||||
|
||||
List<WebElement> webElements = parent.driver().findElements(optionsLocator);
|
||||
webElements.stream()
|
||||
.filter(it -> it.getText().contains(preTaskName))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("No such task: " + preTaskName))
|
||||
.click();
|
||||
|
||||
inputNodeName().click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public WorkflowForm submit() {
|
||||
buttonSubmit.click();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
<div slot="text">{{ $t("Pre tasks") }}</div>
|
||||
<div slot="content">
|
||||
<el-select
|
||||
id="selectPreTask"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
multiple
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
>
|
||||
<el-option
|
||||
v-for="task in options"
|
||||
class="option-pre-tasks"
|
||||
:key="task.code"
|
||||
:value="task.code"
|
||||
:label="task.name"
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<a href="javascript:"
|
||||
@click="!isDetails && _addDep()"
|
||||
class="add-dep">
|
||||
<em v-if="!isLoading" class="el-icon-circle-plus-outline" :class="_isDetails" data-toggle="tooltip" :title="$t('Add')"></em>
|
||||
<em v-if="!isLoading" id="btnAddIfBranch" class="el-icon-circle-plus-outline" :class="_isDetails" data-toggle="tooltip" :title="$t('Add')"></em>
|
||||
<em v-if="isLoading" class="el-icon-loading as as-spin" data-toggle="tooltip" :title="$t('Add')"></em>
|
||||
</a>
|
||||
</div>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
</label>
|
||||
<span class="text-b" style="padding-left: 0">{{$t('Branch flow')}}</span>
|
||||
<el-select style="width: 157px;" size="small" v-model="el.nextNode" clearable :disabled="isDetails">
|
||||
<el-option v-for="item in postTasks" :key="item.code" :value="item.code" :label="item.name"></el-option>
|
||||
<el-option class="option-if-branches" v-for="item in postTasks" :key="item.code" :value="item.code" :label="item.name"></el-option>
|
||||
</el-select>
|
||||
<span class="operation">
|
||||
<a href="javascript:" class="delete" @click="!isDetails && _removeDep(index)" v-if="index === (dependItemList.length - 1)">
|
||||
|
|
@ -51,9 +51,9 @@
|
|||
</m-list-box>
|
||||
<m-list-box>
|
||||
<div slot="text">{{$t('Branch flow')}}</div>
|
||||
<div slot="content">
|
||||
<div slot="content" class="switch-else">
|
||||
<el-select style="width: 157px;" size="small" v-model="nextNode" clearable :disabled="isDetails">
|
||||
<el-option v-for="item in postTasks" :key="item.code" :value="item.code" :label="item.name"></el-option>
|
||||
<el-option class="option-else-branches" v-for="item in postTasks" :key="item.code" :value="item.code" :label="item.name"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</m-list-box>
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
<template>
|
||||
<div class="list-model">
|
||||
<div class="table-box">
|
||||
<el-table :data="list" size="mini" style="width: 100%">
|
||||
<el-table :data="list" size="mini" style="width: 100%" row-class-name="items-task-instances">
|
||||
<el-table-column prop="id" :label="$t('#')" width="50"></el-table-column>
|
||||
<el-table-column prop="name" :label="$t('Name')"></el-table-column>
|
||||
<el-table-column prop="name" :label="$t('Name')" class-name="task-instance-name"></el-table-column>
|
||||
<el-table-column :label="$t('Process Instance')" min-width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-popover trigger="hover" placement="top">
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column prop="executorName" :label="$t('Executor')"></el-table-column>
|
||||
<el-table-column prop="taskType" :label="$t('Node Type')"></el-table-column>
|
||||
<el-table-column :label="$t('State')" width="50">
|
||||
<el-table-column :label="$t('State')" width="50" class-name="task-instance-state">
|
||||
<template slot-scope="scope">
|
||||
<span v-html="_rtState(scope.row.state)" style="cursor: pointer;"></span>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ const menu = {
|
|||
name: `${i18n.$t('Task Instance')}`,
|
||||
path: 'task-instance',
|
||||
id: 2,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
classNames: 'tab-task-instance'
|
||||
},
|
||||
{
|
||||
name: `${i18n.$t('Task record')}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue