Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 38 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f3a5e00
fix test actions running
ch3yne Mar 14, 2024
4b1a35f
fix
ch3yne Mar 14, 2024
68f6432
fix check pagation
ch3yne Mar 14, 2024
57b3546
fix xpath
ch3yne Mar 14, 2024
067f364
fix merge
ch3yne Mar 14, 2024
fec9526
add wait
ch3yne Mar 14, 2024
4d8da1b
add sleep
ch3yne Mar 14, 2024
e4683f7
add wait text
ch3yne Mar 15, 2024
ffd64bf
add log error
ch3yne Mar 15, 2024
16558df
fix time type
ch3yne Mar 16, 2024
7312679
add simple docs
ch3yne Mar 17, 2024
e899fa3
define common methods
ch3yne Mar 18, 2024
4667856
moditied docs
ch3yne Mar 18, 2024
7d3bdb2
remove add parameter
ch3yne Mar 18, 2024
8d81e24
add link to catalogs page
ch3yne Mar 19, 2024
75aa403
improve methods
ch3yne Mar 19, 2024
e471698
fix missing data-refer from merged PR#2574
ch3yne Mar 19, 2024
de34e09
fix check metalake name link
ch3yne Mar 19, 2024
689827c
rename define sleep millis variable and move beforeEach test to Abstr…
ch3yne Mar 20, 2024
1dd65cf
add url assertion
ch3yne Mar 20, 2024
372111e
modified link to page validation
ch3yne Mar 20, 2024
a13c0a5
test link url
ch3yne Mar 20, 2024
8303b58
improve after test view details click close button
ch3yne Mar 20, 2024
5f39dbc
modified metalake link selector
ch3yne Mar 20, 2024
eebe715
add selenium wait
ch3yne Mar 20, 2024
e92c93c
modified metalake link selector
ch3yne Mar 20, 2024
3efd25f
move metalake name link define position
ch3yne Mar 20, 2024
1d779dd
add props no sandbox
ch3yne Mar 20, 2024
733224f
redefine metalake link
ch3yne Mar 20, 2024
9431d11
remove add arguments for test
ch3yne Mar 20, 2024
a1221d5
add log
ch3yne Mar 20, 2024
865e1c6
remove disabled
ch3yne Mar 20, 2024
1982bc1
LOG
ch3yne Mar 20, 2024
02d8727
add query
ch3yne Mar 20, 2024
6c64326
modified id to data-refer
ch3yne Mar 21, 2024
e56fb79
remove unnecessary function
ch3yne Mar 21, 2024
42665ea
remove argument no sandbox
ch3yne Mar 21, 2024
ad1b2a2
improve the suggestions
ch3yne Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/webui.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
:::
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,16 +16,19 @@
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
Expand All @@ -35,78 +38,79 @@ public void homePage() {
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);
}

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);
metalakePage.submitHandleMetalakeBtn.click();
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));
}
}
Loading
Loading