Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#2532][#2512] fix(IT): fix the web e2e test errors when running on the github actions (#2534)

CHEYNE5ceb2b82571d
diff --git a/docs/webui.md b/docs/webui.md
index 6205bc8bd9..8678352ced 100644
--- a/docs/webui.md
+++ b/docs/webui.md
@@ -295,3 +295,21 @@ Design draft preview:
| Catalog | _`View`_ ✔ / _`Create`_ ✔ / _`Edit`_ ✔ / _`Delete`_ ✔ |
| Schema | _`View`_ ✔ / _`Create`_ ✘ / _`Edit`_ ✘ / _`Delete`_ ✘ |
| Table | _`View`_ ✔ / _`Create`_ ✘ / _`Edit`_ ✘ / _`Delete`_ ✘ |
+
+## E2E test
+End-to-end testing for web frontends is conducted using the [Selenium](https://www.selenium.dev/documentation/) testing framework, which is Java-based.
+
+Test cases can be found in the project directory: `integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui`, where the `pages` directory is designated for storing definitions of frontend elements, among others.
+The root directory contains the actual steps for the test cases.
+
+:::tip
+ While writing test cases, running them in a local environment may not pose any issues.
+
+ However, due to the limited performance capabilities of GitHub Actions, scenarios involving delayed DOM loading—such as the time taken for a popup animation to open—can result in test failures.
+
+ To circumvent this issue, it is necessary to manually insert a delay operation, for instance, by adding such as `Thread.sleep(sleepTimeMillis)`.
+
+ This ensures that the test waits for the completion of the delay animation before proceeding with the next operation, thereby avoiding the problem.
+
+ It is advisable to utilize the [`waits`](https://www.selenium.dev/documentation/webdriver/waits/) methods inherent to Selenium as a substitute for `Thread.sleep()`.
+:::
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java
index a38caa2601..ea30919a52 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java
@@ -4,7 +4,7 @@
*/
package com.datastrato.gravitino.integration.test.web.ui;
-import com.datastrato.gravitino.integration.test.web.ui.Pages.MetalakePage;
+import com.datastrato.gravitino.integration.test.web.ui.pages.MetalakePage;
import com.datastrato.gravitino.integration.test.web.ui.utils.AbstractWebIT;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
@@ -16,16 +16,19 @@ import org.junit.jupiter.api.TestMethodOrder;
public class MetalakePageTest extends AbstractWebIT {
MetalakePage metalakePage = new MetalakePage();
+ String metalakeName = "metalake_name";
+ String editedMetalakeName = metalakeName + "_edited";
+
// Create a metalake by name, set the default comment and properties.
- public void createMetalakeAction(String name) {
- metalakePage.createMetalakeBtn.click();
+ public void createMetalakeAction(String name) throws InterruptedException {
+ clickAndWait(metalakePage.createMetalakeBtn);
metalakePage.setMetalakeNameField(name);
metalakePage.setMetalakeCommentField("metalake comment");
metalakePage.addMetalakePropsBtn.click();
metalakePage.setMetalakeProps(0, "key1", "value1");
metalakePage.addMetalakePropsBtn.click();
metalakePage.setMetalakeProps(1, "key2", "value2");
- metalakePage.submitHandleMetalakeBtn.click();
+ clickAndWait(metalakePage.submitHandleMetalakeBtn);
}
@Test
@@ -35,45 +38,48 @@ public class MetalakePageTest extends AbstractWebIT {
Assertions.assertEquals("Gravitino", title);
}
- // @Test
- // @Order(1)
- public void testCreateMetalake() {
- String name = "metalake_name";
- createMetalakeAction(name);
- Assertions.assertTrue(metalakePage.verifyCreateMetalake(name));
+ @Test
+ @Order(1)
+ public void testCreateMetalake() throws InterruptedException {
+ createMetalakeAction(metalakeName);
+ Assertions.assertTrue(metalakePage.verifyCreateMetalake(metalakeName));
}
- // @Test
- // @Order(2)
- public void testViewMetalakeDetails() {
- String name = "metalake_name";
- metalakePage.clickViewMetalakeBtn(name);
- Assertions.assertTrue(metalakePage.verifyShowMetalakeDetails(name));
+ @Test
+ @Order(2)
+ public void testViewMetalakeDetails() throws InterruptedException {
+ metalakePage.clickViewMetalakeBtn(metalakeName);
+ Assertions.assertTrue(metalakePage.verifyShowMetalakeDetails(metalakeName));
}
- // @Test
- // @Order(3)
+ @Test
+ @Order(3)
public void testEditMetalake() {
- metalakePage.clickEditMetalakeBtn("metalake_name");
- metalakePage.setMetalakeNameField("metalake_name_edited");
+ metalakePage.clickEditMetalakeBtn(metalakeName);
+ metalakePage.setMetalakeNameField(editedMetalakeName);
metalakePage.submitHandleMetalakeBtn.click();
- Assertions.assertTrue(metalakePage.verifyEditedMetalake("metalake_name_edited"));
+ Assertions.assertTrue(metalakePage.verifyEditedMetalake(editedMetalakeName));
}
- // @Test
- // @Order(4)
+ @Test
+ @Order(4)
public void testDeleteMetalake() {
- metalakePage.clickDeleteMetalakeBtn("metalake_name_edited");
+ metalakePage.clickDeleteMetalakeBtn(editedMetalakeName);
metalakePage.confirmDeleteBtn.click();
Assertions.assertTrue(metalakePage.verifyEmptyMetalake());
}
- // @Test
- // @Order(5)
- public void testCreateMultipleMetalakes() {
+ @Test
+ @Order(5)
+ public void testCreateMultipleMetalakes() throws InterruptedException {
int twoPagesCount = 11;
for (int i = 0; i < twoPagesCount; i++) {
+ try {
+ Thread.sleep(ACTION_SLEEP_MILLIS);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
String name = "metalake_" + (i + 1);
createMetalakeAction(name);
}
@@ -81,17 +87,17 @@ public class MetalakePageTest extends AbstractWebIT {
Assertions.assertTrue(metalakePage.verifyChangePagination());
}
- // @Test
- // @Order(6)
- public void testQueryMetalake() {
+ @Test
+ @Order(6)
+ public void testQueryMetalake() throws InterruptedException {
String name = "query";
createMetalakeAction(name);
Assertions.assertTrue(metalakePage.verifyQueryMetalake(name));
}
- // @Test
- // @Order(7)
- public void testCreateInvalidMetalake() {
+ @Test
+ @Order(7)
+ public void testCreateInvalidMetalake() throws InterruptedException {
String name = "1!@#$";
metalakePage.createMetalakeBtn.click();
metalakePage.setMetalakeNameField(name);
@@ -99,14 +105,12 @@ public class MetalakePageTest extends AbstractWebIT {
Assertions.assertTrue(metalakePage.checkIsErrorName());
}
- // https://github.com/datastrato/gravitino/issues/2512
- // @Test
- // @Order(7)
- // public void testLinkToCatalogsPage() {
- // String name = "a_link";
- // createMetalakeAction(true, name);
- // metalakePage.clickMetalakeLink(name);
- // metalakePage.waitLinkElementDisplayed(name);
- // Assertions.assertTrue(metalakePage.verifyLinkToCatalogsPage(name));
- // }
+ @Test
+ @Order(8)
+ public void testLinkToCatalogsPage() throws InterruptedException {
+ String name = "a_test_link";
+ createMetalakeAction(name);
+ metalakePage.clickMetalakeLink(name);
+ Assertions.assertTrue(metalakePage.verifyLinkToCatalogsPage(name));
+ }
}
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/Pages/MetalakePage.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java
similarity index 54%
rename from integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/Pages/MetalakePage.java
rename to integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java
index eba70953b0..36eb11ed61 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/Pages/MetalakePage.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java
@@ -3,7 +3,7 @@
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.integration.test.web.ui.Pages;
+package com.datastrato.gravitino.integration.test.web.ui.pages;
import com.datastrato.gravitino.integration.test.web.ui.utils.AbstractWebIT;
import java.util.List;
@@ -17,27 +17,32 @@ import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class MetalakePage extends AbstractWebIT {
-
@FindBy(
xpath =
"//div[contains(@class, 'MuiDataGrid-main')]//div[contains(@class, 'MuiDataGrid-virtualScroller')]//div[@role='rowgroup']")
public WebElement dataViewer;
- @FindBy(xpath = "//*[@id='createMetalakeBtn']")
+ @FindBy(xpath = "//div[@data-refer='metalake-table-grid']")
+ public WebElement metalakeTableGrid;
+
+ @FindBy(xpath = "//*[@data-refer='create-metalake-btn']")
public WebElement createMetalakeBtn;
- @FindBy(xpath = "//*[@id='metalakeNameField']")
+ @FindBy(xpath = "//*[@data-refer='metalake-name-field']")
public WebElement metalakeNameField;
- @FindBy(xpath = "//*[@id='metalakeCommentField']")
+ @FindBy(xpath = "//*[@data-refer='metalake-comment-field']")
public WebElement metalakeCommentField;
- @FindBy(xpath = "//*[@id='query-metalake']")
+ @FindBy(xpath = "//*[@data-refer='query-metalake']//input")
public WebElement queryMetalakeInput;
- @FindBy(xpath = "//*[@id='submitHandleMetalake']")
+ @FindBy(xpath = "//*[@data-refer='submit-handle-metalake']")
public WebElement submitHandleMetalakeBtn;
+ @FindBy(xpath = "//*[@data-refer='cancel-handle-metalake']")
+ public WebElement cancelHandleMetalakeBtn;
+
@FindBy(xpath = "//button[@data-refer='confirm-delete']")
public WebElement confirmDeleteBtn;
@@ -53,44 +58,50 @@ public class MetalakePage extends AbstractWebIT {
@FindBy(xpath = "//button[@data-refer='add-metalake-props']")
public WebElement addMetalakePropsBtn;
- @FindBy(xpath = "//button[@aria-label='Go to next page']")
+ @FindBy(xpath = "//div[@data-refer='metalake-table-grid']//button[@aria-label='Go to next page']")
public WebElement nextPageBtn;
- @FindBy(xpath = "//button[@aria-label='Go to previous page']")
+ @FindBy(
+ xpath = "//div[@data-refer='metalake-table-grid']//button[@aria-label='Go to previous page']")
public WebElement prevPageBtn;
+ @FindBy(xpath = "//a[@data-refer='metalake-name-link']")
+ public WebElement metalakeNameLink;
+
+ @FindBy(
+ xpath =
+ "//div[@data-refer='metalake-table-grid']//div[contains(@class, 'MuiDataGrid-overlay')]")
+ public WebElement metalakeTableWrapper;
+
public MetalakePage() {
PageFactory.initElements(driver, this);
}
- public WebElement findElementByXPath(String xpath) {
- return driver.findElement(By.xpath(xpath));
- }
-
- // ** comment for MetalakePageTest.java testLinkToCatalogsPage()
- // public WebElement findElementByLink(String name) {
- // String xpath = "//div[@data-field='name']//a[@href='/ui/metalakes?metalake=" + name + "']";
- //
- // return driver.findElement(By.xpath(xpath));
- // }
-
public void setMetalakeNameField(String nameField) {
- metalakeNameField.sendKeys(
+ WebElement metalakeNameFieldInput = metalakeNameField.findElement(By.tagName("input"));
+ metalakeNameFieldInput.sendKeys(
Keys.chord(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END), Keys.DELETE));
- metalakeNameField.clear();
- metalakeNameField.sendKeys(nameField);
+ metalakeNameFieldInput.clear();
+ metalakeNameFieldInput.sendKeys(nameField);
}
public void setMetalakeCommentField(String commentField) {
- metalakeCommentField.sendKeys(
+ WebElement metalakeCommentFieldInput = metalakeCommentField.findElement(By.tagName("textarea"));
+ metalakeCommentFieldInput.sendKeys(
Keys.chord(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END), Keys.DELETE));
- metalakeCommentField.clear();
- metalakeCommentField.sendKeys(commentField);
+ metalakeCommentFieldInput.clear();
+ metalakeCommentFieldInput.sendKeys(commentField);
}
- public void setQueryInput(String queryInput) {
- clearQueryInput();
- queryMetalakeInput.sendKeys(queryInput);
+ public void setQueryParams(String queryParams) {
+ try {
+ Thread.sleep(ACTION_SLEEP_MILLIS);
+ clearQueryInput();
+ queryMetalakeInput.sendKeys(queryParams);
+ Thread.sleep(ACTION_SLEEP_MILLIS);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
}
public void clearQueryInput() {
@@ -100,29 +111,42 @@ public class MetalakePage extends AbstractWebIT {
}
public void clickDeleteMetalakeBtn(String name) {
- String xpath = "//button[@data-refer='delete-metalake-" + name + "']";
- WebElement deleteMetalakeBtn = driver.findElement(By.xpath(xpath));
- deleteMetalakeBtn.click();
+ try {
+ String xpath = "//button[@data-refer='delete-metalake-" + name + "']";
+ clickAndWait(By.xpath(xpath));
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
}
public void clickViewMetalakeBtn(String name) {
- String xpath = "//button[@data-refer='view-metalake-" + name + "']";
- WebElement viewMetalakeBtn = driver.findElement(By.xpath(xpath));
- viewMetalakeBtn.click();
+ try {
+ String xpath = "//button[@data-refer='view-metalake-" + name + "']";
+ clickAndWait(By.xpath(xpath));
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
}
public void clickEditMetalakeBtn(String name) {
- String xpath = "//button[@data-refer='edit-metalake-" + name + "']";
- WebElement editMetalakeBtn = driver.findElement(By.xpath(xpath));
- editMetalakeBtn.click();
+ try {
+ String xpath = "//button[@data-refer='edit-metalake-" + name + "']";
+ clickAndWait(By.xpath(xpath));
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
}
public void clickMetalakeLink(String name) {
- String xpath = "//a[@href='/ui/metalakes?metalake=" + name + "']";
- WebElement metalakeLink = driver.findElement(By.xpath(xpath));
- WebDriverWait wait = new WebDriverWait(driver, 10);
- wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xpath)));
- metalakeLink.click();
+ try {
+ setQueryParams(name);
+ Thread.sleep(ACTION_SLEEP_MILLIS);
+ String xpath = "//a[@data-refer='metalake-link-" + name + "']";
+ WebElement metalakeLink = metalakeTableGrid.findElement(By.xpath(xpath));
+ clickAndWait(metalakeLink);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
}
public void setMetalakeProps(int index, String key, String value) {
@@ -137,36 +161,20 @@ public class MetalakePage extends AbstractWebIT {
valueInput.sendKeys(value);
}
- public boolean checkIsErrorName() {
- String xpath = "//div[@data-refer='metalake-name-field']";
- WebElement nameField = findElementByXPath(xpath);
- List<WebElement> errorText =
- nameField.findElements(By.xpath("//div[contains(@class, 'Mui-error')]"));
+ public boolean checkIsErrorName() throws InterruptedException {
+ try {
+ List<WebElement> errorText =
+ metalakeNameField.findElements(By.xpath("//div[contains(@class, 'Mui-error')]"));
- return !errorText.isEmpty();
+ return !errorText.isEmpty();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return false;
+ } finally {
+ clickAndWait(cancelHandleMetalakeBtn);
+ }
}
- // ** comment for MetalakePageTest.java testLinkToCatalogsPage()
- // public void waitLinkElementDisplayed(String name) {
- // int retry = 0;
- // int sleepTimeMillis = 1_000;
- //
- // while (retry++ < 5) {
- // try {
- // WebElement ele = findElementByLink(name);
- // Wait<WebDriver> wait =
- // new FluentWait<>(driver)
- // .withTimeout(Duration.ofSeconds(10))
- // .pollingEvery(Duration.ofMillis(300))
- // .ignoring(ElementNotInteractableException.class);
- // wait.until(d -> ele.isDisplayed());
- // Thread.sleep(sleepTimeMillis);
- // } catch (Exception e) {
- // LOG.error(e.getMessage(), e);
- // }
- // }
- // }
-
public boolean verifyCreateMetalake(String name) {
try {
// Get the created metalake row element from DataGrid by name.
@@ -198,7 +206,7 @@ public class MetalakePage extends AbstractWebIT {
}
}
- public boolean verifyShowMetalakeDetails(String name) {
+ public boolean verifyShowMetalakeDetails(String name) throws InterruptedException {
try {
// Check the drawer css property value
detailsDrawer.isDisplayed();
@@ -211,26 +219,32 @@ public class MetalakePage extends AbstractWebIT {
return isVisible && isText;
} catch (Exception e) {
+ LOG.error(e.getMessage(), e);
return false;
} finally {
- closeDetailsBtn.click();
+ clickAndWait(closeDetailsBtn);
}
}
public boolean verifyEmptyMetalake() {
- String xpath = "//div[contains(@class, 'MuiDataGrid-overlay')]";
- WebElement noMetalakeRows = driver.findElement(By.xpath(xpath));
+ try {
+ boolean isNoRows = waitShowText("No rows", metalakeTableWrapper);
+
+ if (!isNoRows) {
+ LOG.error(metalakeTableWrapper.getText(), metalakeTableWrapper);
+ return false;
+ }
- return Objects.equals(noMetalakeRows.getText(), "No rows");
+ return true;
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return false;
+ }
}
public boolean verifyChangePagination() {
try {
- if (!nextPageBtn.isEnabled()) {
- return false;
- }
- nextPageBtn.click();
-
+ clickAndWait(nextPageBtn);
// Check if the previous page button is available
return prevPageBtn.isEnabled() && performPrevPageAction();
} catch (Exception e) {
@@ -240,7 +254,7 @@ public class MetalakePage extends AbstractWebIT {
private boolean performPrevPageAction() {
try {
- prevPageBtn.click();
+ clickAndWait(prevPageBtn);
return true;
} catch (Exception e) {
return false;
@@ -249,9 +263,8 @@ public class MetalakePage extends AbstractWebIT {
public boolean verifyQueryMetalake(String name) {
try {
- setQueryInput(name);
+ setQueryParams(name);
List<WebElement> dataList = dataViewer.findElements(By.xpath(".//div[@data-field='name']"));
-
// Check if the text in the first row matches the search input
boolean isQueried = Objects.equals(dataList.get(0).getText(), name);
@@ -263,36 +276,27 @@ public class MetalakePage extends AbstractWebIT {
return false;
}
} catch (Exception e) {
+ LOG.error(e.getMessage(), e);
return false;
}
}
- // ** comment for MetalakePageTest.java testLinkToCatalogsPage()
- // public boolean verifyLinkToCatalogsPage(String name) {
- // int sleepTimeMillis = 1_000;
- // try {
- // Thread.sleep(sleepTimeMillis);
- // String xpath = "//a[@data-refer='metalake-name-link']";
- // WebElement nameLink = driver.findElement(By.xpath(xpath));
- //
- // Wait<WebDriver> wait =
- // new FluentWait<>(driver)
- // .withTimeout(Duration.ofSeconds(10))
- // .pollingEvery(Duration.ofMillis(300))
- // .ignoring(ElementNotInteractableException.class);
- // wait.until(d -> nameLink.isDisplayed());
- //
- // String url = driver.getCurrentUrl();
- // boolean isUrl = url.contains("/ui/metalakes?metalake=" + name);
- //
- // return nameLink.isDisplayed() && isUrl;
- // } catch (Exception e) {
- // return false;
- // } finally {
- // // Back to homepage
- // String xpath = "//*[@data-refer='back-home-btn']";
- // WebElement backHomeBtn = driver.findElement(By.xpath(xpath));
- // backHomeBtn.click();
- // }
- // }
+ public boolean verifyLinkToCatalogsPage(String name) {
+ try {
+ WebDriverWait wait = new WebDriverWait(driver, MAX_TIMEOUT);
+ wait.until(ExpectedConditions.visibilityOf(metalakeNameLink));
+ wait.until(ExpectedConditions.urlContains(metalakeNameLink.getAttribute("href")));
+
+ if (!driver.getCurrentUrl().contains(name)
+ || !metalakeNameLink.getAttribute("href").contains(name)) {
+ LOG.error("metalake name link is not match");
+ return false;
+ }
+
+ return true;
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return false;
+ }
+ }
}
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/AbstractWebIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/AbstractWebIT.java
index 5571d6045b..93f2757859 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/AbstractWebIT.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/AbstractWebIT.java
@@ -5,9 +5,24 @@
package com.datastrato.gravitino.integration.test.web.ui.utils;
import com.datastrato.gravitino.integration.test.util.AbstractIT;
+import com.google.common.base.Function;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.openqa.selenium.By;
+import org.openqa.selenium.ElementClickInterceptedException;
+import org.openqa.selenium.InvalidArgumentException;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.FluentWait;
+import org.openqa.selenium.support.ui.Wait;
+import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,7 +32,66 @@ public class AbstractWebIT extends AbstractIT {
protected static WebDriver driver;
// https://www.selenium.dev/documentation/webdriver/waits/#implicit-waits
- protected static final long MAX_IMPLICIT_WAIT = 10;
+ protected static final long MAX_IMPLICIT_WAIT = 30;
+ protected static final long MAX_TIMEOUT = 20;
+ protected static final long EACH_TEST_SLEEP_MILLIS = 1_000;
+ protected static final long ACTION_SLEEP_MILLIS = 1_000;
+
+ protected boolean waitShowText(final String text, final Object locator) {
+ try {
+ return text.equals(locatorElement(locator).getText());
+ } catch (TimeoutException e) {
+ return false;
+ }
+ }
+
+ protected WebElement pollingWait(final By locator, final long maxTimeout) {
+ Wait<WebDriver> wait =
+ new FluentWait<>(driver)
+ .withTimeout(Duration.of(maxTimeout, ChronoUnit.SECONDS))
+ .pollingEvery(Duration.of(1, ChronoUnit.SECONDS))
+ .ignoring(NoSuchElementException.class);
+
+ return wait.until((Function<WebDriver, WebElement>) driver -> driver.findElement(locator));
+ }
+
+ protected void clickAndWait(final Object locator) throws InterruptedException {
+ try {
+ // wait the element is available
+ WebDriverWait wait = new WebDriverWait(driver, MAX_TIMEOUT);
+ wait.until(ExpectedConditions.visibilityOf(locatorElement(locator)));
+ wait.until(ExpectedConditions.elementToBeClickable(locatorElement(locator)));
+
+ locatorElement(locator).click();
+ Thread.sleep(ACTION_SLEEP_MILLIS);
+ } catch (ElementClickInterceptedException e) {
+ // if the previous click did not effected then try clicking in another way
+ Actions action = new Actions(driver);
+ action.moveToElement(locatorElement(locator)).click().build().perform();
+ Thread.sleep(ACTION_SLEEP_MILLIS);
+ }
+ }
+
+ WebElement locatorElement(final Object locatorOrElement) {
+ WebElement element;
+ if (locatorOrElement instanceof By) {
+ element = pollingWait((By) locatorOrElement, MAX_IMPLICIT_WAIT);
+ } else if (locatorOrElement instanceof WebElement) {
+ element = (WebElement) locatorOrElement;
+ } else {
+ throw new InvalidArgumentException("The provided argument is neither a By nor a WebElement");
+ }
+ return element;
+ }
+
+ @BeforeEach
+ public void beforeEachTest() {
+ try {
+ Thread.sleep(EACH_TEST_SLEEP_MILLIS);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
@BeforeAll
public static void startUp() {
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/WebDriverManager.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/WebDriverManager.java
index 051d8bd2a3..dcf058e14a 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/WebDriverManager.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/utils/WebDriverManager.java
@@ -27,7 +27,7 @@ public class WebDriverManager {
// wait for webpage load compiled.
try {
- (new WebDriverWait(driver, AbstractWebIT.MAX_IMPLICIT_WAIT))
+ (new WebDriverWait(driver, AbstractWebIT.MAX_TIMEOUT))
.until(
d -> {
String gravitinoVersion = d.findElement(By.id("gravitino_version")).getText();
diff --git a/web/build.gradle.kts b/web/build.gradle.kts
index f522d9b050..04031e65ea 100644
--- a/web/build.gradle.kts
+++ b/web/build.gradle.kts
@@ -54,6 +54,7 @@ tasks {
clean {
delete(".node")
delete("build")
+ delete(".next")
delete("dist")
delete("node_modules")
delete("yarn-error.log")
diff --git a/web/src/app/metalakes/CreateMetalakeDialog.js b/web/src/app/metalakes/CreateMetalakeDialog.js
index 45b4adf5eb..6fcb417def 100644
--- a/web/src/app/metalakes/CreateMetalakeDialog.js
+++ b/web/src/app/metalakes/CreateMetalakeDialog.js
@@ -224,7 +224,6 @@ const CreateMetalakeDialog = props => {
render={({ field: { value, onChange } }) => (
<TextField
value={value}
- id='metalakeNameField'
data-refer='metalake-name-field'
label='Name'
onChange={onChange}
@@ -250,7 +249,7 @@ const CreateMetalakeDialog = props => {
render={({ field: { value, onChange } }) => (
<TextField
value={value}
- id='metalakeCommentField'
+ data-refer='metalake-comment-field'
label='Comment'
multiline
rows={2}
@@ -327,10 +326,16 @@ const CreateMetalakeDialog = props => {
</Grid>
</DialogContent>
<DialogActions className={' twc-px-5 md:twc-px-15 twc-pb-5 md:twc-pb-[12.5 0.25 rem]'}>
- <Button variant='contained' type='submit' id='submitHandleMetalake'>
+ <Button variant='contained' type='submit' data-refer='submit-handle-metalake'>
{typeText === 'Edit' ? 'Update' : typeText}
</Button>
- <Button variant='outlined' className={'twc-ml-1'} onClick={handleClose} type='reset'>
+ <Button
+ variant='outlined'
+ className={'twc-ml-1'}
+ onClick={handleClose}
+ type='reset'
+ data-refer='cancel-handle-metalake'
+ >
Cancel
</Button>
</DialogActions>
diff --git a/web/src/app/metalakes/TableBody.js b/web/src/app/metalakes/TableBody.js
index 2fe53f64ec..5abd1d51d7 100644
--- a/web/src/app/metalakes/TableBody.js
+++ b/web/src/app/metalakes/TableBody.js
@@ -109,6 +109,7 @@ const TableBody = props => {
textOverflow: 'ellipsis',
'&:hover': { color: 'primary.main', textDecoration: 'underline' }
}}
+ data-refer={`metalake-link-${name}`}
>
{name}
</Typography>
@@ -232,6 +233,7 @@ const TableBody = props => {
},
maxHeight: 'calc(100vh - 23.2rem)'
}}
+ data-refer='metalake-table-grid'
getRowId={row => row?.name}
rows={store.filteredMetalakes}
columns={columns}
diff --git a/web/src/app/metalakes/TableHeader.js b/web/src/app/metalakes/TableHeader.js
index e2d9c8edcb..b378b9b727 100644
--- a/web/src/app/metalakes/TableHeader.js
+++ b/web/src/app/metalakes/TableHeader.js
@@ -20,14 +20,14 @@ const TableHeader = props => {
<Box className={'twc-pr-5 twc-pb-4 twc-pt-4 twc-flex twc-flex-wrap twc-items-center twc-justify-end'}>
<Box className={'twc-flex twc-items-center twc-flex-1 twc-h-full'} id='filter-panel' />
<TextField
- id='query-metalake'
+ data-refer='query-metalake'
size='small'
value={value}
placeholder='Query Name'
onChange={e => handleFilter(e.target.value)}
/>
<Button
- id='createMetalakeBtn'
+ data-refer='create-metalake-btn'
className={'twc-ml-2'}
variant='contained'
color='primary'