zzzk1 commented on code in PR #3899:
URL: 
https://github.com/apache/incubator-streampark/pull/3899#discussion_r1685216017


##########
streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/setting/AlarmPage.java:
##########
@@ -0,0 +1,330 @@
+/*
+ * 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.streampark.e2e.pages.setting;
+
+import org.apache.streampark.e2e.pages.common.Constants;
+import org.apache.streampark.e2e.pages.common.NavBarPage;
+import org.apache.streampark.e2e.pages.setting.entity.AlarmPageDingTalk;
+import org.apache.streampark.e2e.pages.setting.entity.AlarmPageEmail;
+import org.apache.streampark.e2e.pages.setting.entity.AlarmPageLark;
+import org.apache.streampark.e2e.pages.setting.entity.AlarmPageSMS;
+import org.apache.streampark.e2e.pages.setting.entity.AlarmPageWeChat;
+import org.apache.streampark.e2e.pages.setting.entity.FaultAlert;
+
+import lombok.Getter;
+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 org.openqa.selenium.support.ui.WebDriverWait;
+
+import java.util.List;
+
+@Getter
+public class AlarmPage extends NavBarPage implements SettingPage.Tab {
+
+    public AlarmPage(RemoteWebDriver driver) {
+        super(driver);
+    }
+
+    private final CreateAlarmForm createAlarmForm = new CreateAlarmForm();
+
+    @FindBy(xpath = "//span[contains(., 'Alarms 
Setting')]/..//button[contains(@class, 'ant-btn-dashed')]/span[contains(text(), 
'Add New')]")
+    private WebElement buttonCreateAlarm;
+
+    @FindBy(xpath = "//div[@class='ant-row']")
+    private List<WebElement> alarmList;
+
+    @FindBy(className = "ant-form-item-explain-error")
+    private List<WebElement> errorMessageList;
+
+    @FindBy(xpath = "//button[contains(text(), 'Submit')]")
+    private WebElement errorMessageConfirmButton;
+
+    @FindBy(xpath = "//button[contains(@class, 'ant-btn')]/span[contains(., 
'Yes')]")
+    private WebElement deleteConfirmButton;
+
+    public AlarmPage createAlarm(String alertName, String alertType, 
FaultAlert faultAlert) {
+        waitForPageLoading();
+
+        new WebDriverWait(driver, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION)
+            .until(ExpectedConditions.elementToBeClickable(buttonCreateAlarm));
+
+        buttonCreateAlarm.click();
+        createAlarmForm.inputAlertName().sendKeys(alertName);
+
+        createFaultAlert(alertType, faultAlert);
+        createAlarmForm.buttonSubmit().click();
+
+        return this;
+    }
+
+    public AlarmPage editAlarm(String alertName, String alertType, FaultAlert 
faultAlert) {
+        waitForPageLoading();
+
+        alarmList().stream()
+            // Filter out cards containing a specific alertName.
+            .filter(card -> {
+                WebElement titleElement = new WebDriverWait(driver, 
Constants.DEFAULT_WEBDRIVER_WAIT_DURATION)
+                    .until(ExpectedConditions.visibilityOf(card
+                        
.findElement(By.xpath(".//div[@class='ant-card-head']//div[@class='ant-card-head-title']"))));
+                return titleElement.getText().contains(alertName);
+            })
+            // Find the eligible cards and click the edit button.
+            .flatMap(card -> {
+                List<WebElement> editButtons = card.findElements(By.xpath(
+                    ".//button[.//span[contains(@class, 'anticon') and 
contains(@class, 'anticon-edit')]]"));
+
+                // Make sure the button is loaded.
+                new WebDriverWait(driver, 
Constants.DEFAULT_WEBDRIVER_WAIT_DURATION)
+                    
.until(ExpectedConditions.visibilityOfAllElements(editButtons));
+
+                return editButtons.stream();
+            })
+            .filter(WebElement::isDisplayed)
+            .findFirst()
+            .orElseThrow(() -> new RuntimeException("No edit button found for 
alarm: " + alertName))
+            .click();
+
+        // todo: edit alert type
+        // createFaultAlert(alertType, faultAlert);

Review Comment:
   I will finish this part as soon as possible.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to