Browse Source

[E2E] Add the update test for tenant (#8282)

3.0.0/version-upgrade
QuakeWang 3 years ago committed by GitHub
parent
commit
fd38ef129b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TenantE2ETest.java
  2. 37
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TenantPage.java
  3. 4
      dolphinscheduler-ui/src/js/conf/home/pages/security/pages/tenement/_source/list.vue

20
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TenantE2ETest.java

@ -19,7 +19,6 @@
package org.apache.dolphinscheduler.e2e.cases; package org.apache.dolphinscheduler.e2e.cases;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
@ -38,6 +37,7 @@ import org.openqa.selenium.remote.RemoteWebDriver;
@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml")
class TenantE2ETest { class TenantE2ETest {
private static final String tenant = System.getProperty("user.name"); private static final String tenant = System.getProperty("user.name");
private static final String editDescription = "This is a test";
private static RemoteWebDriver browser; private static RemoteWebDriver browser;
@ -74,11 +74,27 @@ class TenantE2ETest {
.contains("already exists") .contains("already exists")
); );
page.createTenantForm().buttonCancel().click(); page.tenantForm().buttonCancel().click();
} }
@Test @Test
@Order(30) @Order(30)
void testUpdateTenant() {
TenantPage page = new TenantPage(browser);
page.update(tenant, editDescription);
await().untilAsserted(() -> {
browser.navigate().refresh();
assertThat(page.tenantList())
.as("Tenant list should contain newly-modified tenant")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains(tenant));
});
}
@Test
@Order(40)
void testDeleteTenant() { void testDeleteTenant() {
final TenantPage page = new TenantPage(browser); final TenantPage page = new TenantPage(browser);
page.delete(tenant); page.delete(tenant);

37
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TenantPage.java

@ -46,12 +46,17 @@ public final class TenantPage extends NavBarPage implements SecurityPage.Tab {
}) })
private WebElement buttonConfirm; private WebElement buttonConfirm;
private final CreateTenantForm createTenantForm; @FindBy(className = "tenantCode")
private WebElement tenantCode;
private final TenantForm tenantForm;
private final TenantForm editTenantForm;
public TenantPage(RemoteWebDriver driver) { public TenantPage(RemoteWebDriver driver) {
super(driver); super(driver);
createTenantForm = new CreateTenantForm(); tenantForm = new TenantForm();
editTenantForm = new TenantForm();
} }
public TenantPage create(String tenant) { public TenantPage create(String tenant) {
@ -60,9 +65,27 @@ public final class TenantPage extends NavBarPage implements SecurityPage.Tab {
public TenantPage create(String tenant, String description) { public TenantPage create(String tenant, String description) {
buttonCreateTenant().click(); buttonCreateTenant().click();
createTenantForm().inputTenantCode().sendKeys(tenant); tenantForm().inputTenantCode().sendKeys(tenant);
createTenantForm().inputDescription().sendKeys(description); tenantForm().inputDescription().sendKeys(description);
createTenantForm().buttonSubmit().click(); tenantForm().buttonSubmit().click();
return this;
}
public TenantPage update(String tenant, String description) {
tenantList().stream()
.filter(it -> it.findElement(By.className("tenantCode")).getAttribute("innerHTML").contains(tenant))
.flatMap(it -> it.findElements(By.className("edit")).stream())
.filter(WebElement::isDisplayed)
.findFirst()
.orElseThrow(() -> new RuntimeException("No edit button in tenant list"))
.click();
TenantForm editTenantForm = new TenantForm();
editTenantForm.inputDescription().clear();
editTenantForm.inputDescription().sendKeys(description);
editTenantForm.buttonSubmit().click();
return this; return this;
} }
@ -83,8 +106,8 @@ public final class TenantPage extends NavBarPage implements SecurityPage.Tab {
} }
@Getter @Getter
public class CreateTenantForm { public class TenantForm {
CreateTenantForm() { TenantForm() {
PageFactory.initElements(driver, this); PageFactory.initElements(driver, this);
} }

4
dolphinscheduler-ui/src/js/conf/home/pages/security/pages/tenement/_source/list.vue

@ -19,7 +19,7 @@
<div class="table-box"> <div class="table-box">
<el-table :data="list" size="mini" style="width: 100%" row-class-name="items"> <el-table :data="list" size="mini" style="width: 100%" row-class-name="items">
<el-table-column type="index" :label="$t('#')" width="50"></el-table-column> <el-table-column type="index" :label="$t('#')" width="50"></el-table-column>
<el-table-column prop="tenantCode" :label="$t('OS Tenant Code')" min-width="100"></el-table-column> <el-table-column prop="tenantCode" :label="$t('OS Tenant Code')" min-width="100" class-name="tenantCode"></el-table-column>
<el-table-column :label="$t('Description')" min-width="100"> <el-table-column :label="$t('Description')" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.description | filterNull}}</span> <span>{{scope.row.description | filterNull}}</span>
@ -39,7 +39,7 @@
<el-table-column :label="$t('Operation')" width="100"> <el-table-column :label="$t('Operation')" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip :content="$t('Edit')" placement="top"> <el-tooltip :content="$t('Edit')" placement="top">
<el-button type="primary" size="mini" icon="el-icon-edit-outline" @click="_edit(scope.row)" circle></el-button> <el-button type="primary" size="mini" icon="el-icon-edit-outline" @click="_edit(scope.row)" circle class="edit"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip :content="$t('Delete')" placement="top"> <el-tooltip :content="$t('Delete')" placement="top">
<el-button type="danger" size="mini" icon="el-icon-delete" circle></el-button> <el-button type="danger" size="mini" icon="el-icon-delete" circle></el-button>

Loading…
Cancel
Save