You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/01/19 11:01:32 UTC

[GitHub] [dolphinscheduler] kezhenxu94 commented on a change in pull request #8121: [E2E]add the alarm group page and the alarm instance page of the e2e case

kezhenxu94 commented on a change in pull request #8121:
URL: https://github.com/apache/dolphinscheduler/pull/8121#discussion_r787633108



##########
File path: dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/WarningInstancePage.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.pages.security;
+
+import lombok.Getter;
+import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
+import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowDefinitionTab;
+import org.openqa.selenium.support.ui.WebDriverWait;
+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 org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import java.util.List;
+
+@Getter
+public final class WarningInstancePage extends NavBarPage implements SecurityPage.Tab {
+    @FindBy(id = "btnCreateAlarmInstance")
+    private WebElement buttonCreateWarningInstance;
+
+    @FindBy(className = "items")
+    private List<WebElement> warningInstanceList;
+
+    @FindBys({
+        @FindBy(className = "el-popconfirm"),
+        @FindBy(className = "el-button--primary"),
+    })
+    private List<WebElement> buttonConfirm;
+
+    private final WarningInstanceForm createWarningInstanceForm = new WarningInstanceForm();
+    private final WarningInstanceForm editWarningInstanceForm = new WarningInstanceForm();
+    private final WarningInstanceForm alertPluginForm = new WarningInstanceForm();
+
+
+    public WarningInstancePage(RemoteWebDriver driver) {
+        super(driver);
+    }
+
+    public WarningInstancePage create(String alarmInstanceName, String alarmPluginName, String inputPluginContent, String keyword) {
+        buttonCreateWarningInstance().click();
+
+        createWarningInstanceForm().inputAlarmInstanceName().sendKeys(alarmInstanceName);
+        createWarningInstanceForm().selectAlarmPlugin().click();
+        SelectAlarmPlugin(alarmPluginName);
+        createWarningInstanceForm().inputWebhook().sendKeys(inputPluginContent);
+        createWarningInstanceForm().inputKeyword().sendKeys(keyword);
+        createWarningInstanceForm().radioNoEnableProxy().click();
+        createWarningInstanceForm().buttonSubmit().click();
+        return this;
+    }
+
+
+    public WarningInstancePage update(String warningInstanceName, String editWarningInstanceName) {
+        warningInstanceList()
+            .stream()
+            .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(warningInstanceName))
+            .flatMap(it -> it.findElements(By.className("edit")).stream())
+            .filter(WebElement::isDisplayed)
+            .findFirst()
+            .orElseThrow(() -> new RuntimeException("No edit button in alarmInstance list"))
+            .click();
+
+        editWarningInstanceForm().inputAlarmInstanceName().clear();
+        editWarningInstanceForm().inputAlarmInstanceName().sendKeys(editWarningInstanceName);
+        editWarningInstanceForm().buttonSubmit().click();
+
+        return this;
+    }
+
+    public WarningInstancePage delete(String WarningInstance) {
+        warningInstanceList()
+            .stream()
+            .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(WarningInstance))
+            .flatMap(it -> it.findElements(By.className("delete")).stream())
+            .filter(WebElement::isDisplayed)
+            .findFirst()
+            .orElseThrow(() -> new RuntimeException("No delete button in alarmInstance list"))
+            .click();
+
+        buttonConfirm()
+            .stream()
+            .filter(WebElement::isDisplayed)
+            .findFirst()
+            .orElseThrow(() -> new RuntimeException("No confirm button when deleting"))
+            .click();
+
+        return this;
+    }
+
+    public WarningInstancePage SelectAlarmPlugin(String alarmPluginName) {

Review comment:
       method names are usually camel-case with first letter lowercase 
   
   ```suggestion
       public WarningInstancePage selectAlarmPlugin(String alarmPluginName) {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org