mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-31 20:51:26 +00:00
revamped user listing selenium tests (#2583)
This commit is contained in:
parent
b9ec9bea88
commit
dc4f7d7f98
@ -27,6 +27,7 @@ const CheckBoxDropDownList = ({
|
||||
<>
|
||||
<button
|
||||
className="tw-z-10 tw-fixed tw-inset-0 tw-h-full tw-w-full tw-bg-black tw-opacity-0"
|
||||
data-testid="close-dropdown"
|
||||
onClick={() => setIsOpen && setIsOpen(false)}
|
||||
/>
|
||||
<div
|
||||
@ -53,6 +54,7 @@ const CheckBoxDropDownList = ({
|
||||
/>
|
||||
<p
|
||||
className="tw-inline-block tw-truncate tw-w-52 tw-align-middle"
|
||||
data-testid={item.name as string}
|
||||
title={item.name as string}>
|
||||
{item.name}
|
||||
</p>
|
||||
|
@ -0,0 +1,62 @@
|
||||
package org.openmetadata.catalog.selenium.objectRepository;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
public class UserPage {
|
||||
WebDriver webDriver;
|
||||
|
||||
public UserPage(WebDriver webDriver) {
|
||||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
By rolesList = By.cssSelector("[data-testid='menu-button'][id='menu-button-User']");
|
||||
By selectUser = By.xpath("//div[@data-testid='data-container']//p");
|
||||
By userFilterCount = By.xpath("//button[@data-testid='users']//span[@data-testid='filter-count']");
|
||||
By adminFilterCount = By.xpath("//button[@data-testid='assets'][1]//span[@data-testid='filter-count']");
|
||||
By userListSearchBar = By.cssSelector("[data-testid='searchbar']");
|
||||
By userListSearchResult =
|
||||
By.xpath("//div[@data-testid='user-card-container']/div[@data-testid='user-card-container']");
|
||||
By closeCheckBoxDropDown = By.cssSelector("[data-testid='close-dropdown']");
|
||||
|
||||
public By headerSettingsMenu(String menuItem) {
|
||||
return By.cssSelector("[data-testid='menu-item-" + menuItem + "']");
|
||||
}
|
||||
|
||||
public By rolesList() {
|
||||
return rolesList;
|
||||
}
|
||||
|
||||
public By selectRole(String role) {
|
||||
return By.cssSelector("[data-testid='" + role + "']");
|
||||
}
|
||||
|
||||
public By selectUser() {
|
||||
return selectUser;
|
||||
}
|
||||
|
||||
public By userFilterCount() {
|
||||
return userFilterCount;
|
||||
}
|
||||
|
||||
public By adminFilterCount() {
|
||||
return adminFilterCount;
|
||||
}
|
||||
|
||||
public By userPageTab(int index) {
|
||||
return By.xpath("//button[@data-testid='assets'][" + index + "]");
|
||||
}
|
||||
|
||||
public By userListSearchBar() {
|
||||
return userListSearchBar;
|
||||
}
|
||||
|
||||
public By userListSearchResult() {
|
||||
return userListSearchResult;
|
||||
}
|
||||
|
||||
public WebElement closeCheckBoxDropDown() {
|
||||
return webDriver.findElement(closeCheckBoxDropDown);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.catalog.selenium.pages.users;
|
||||
|
||||
import com.github.javafaker.Faker;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@ -10,8 +9,11 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.openmetadata.catalog.selenium.events.Events;
|
||||
import org.openmetadata.catalog.selenium.objectRepository.DashboardServicePage;
|
||||
import org.openmetadata.catalog.selenium.objectRepository.DatabaseServicePage;
|
||||
import org.openmetadata.catalog.selenium.objectRepository.TagsPage;
|
||||
import org.openmetadata.catalog.selenium.objectRepository.UserPage;
|
||||
import org.openmetadata.catalog.selenium.properties.Property;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
@ -24,14 +26,14 @@ import org.testng.Assert;
|
||||
public class UsersPageTest {
|
||||
|
||||
static WebDriver webDriver;
|
||||
static TagsPage tagsPage;
|
||||
static DatabaseServicePage databaseServicePage;
|
||||
static DashboardServicePage dashboardServicePage;
|
||||
static UserPage userPage;
|
||||
static Actions actions;
|
||||
static Faker faker = new Faker();
|
||||
static String tagCategoryDisplayName = faker.name().firstName();
|
||||
static String enterDescription = "//div[@data-testid='enterDescription']/div/div[2]/div/div/div/div/div/div";
|
||||
static WebDriverWait wait;
|
||||
Integer waitTime = Property.getInstance().getSleepTime();
|
||||
static String url = Property.getInstance().getURL();
|
||||
static String urlTag = "/api/v1/tags/";
|
||||
String webDriverInstance = Property.getInstance().getWebDriver();
|
||||
String webDriverPath = Property.getInstance().getWebDriverPath();
|
||||
|
||||
@ -42,6 +44,10 @@ public class UsersPageTest {
|
||||
options.addArguments("--headless");
|
||||
options.addArguments("--window-size=1280,800");
|
||||
webDriver = new ChromeDriver(options);
|
||||
tagsPage = new TagsPage(webDriver);
|
||||
databaseServicePage = new DatabaseServicePage(webDriver);
|
||||
dashboardServicePage = new DashboardServicePage(webDriver);
|
||||
userPage = new UserPage(webDriver);
|
||||
actions = new Actions(webDriver);
|
||||
wait = new WebDriverWait(webDriver, Duration.ofSeconds(30));
|
||||
webDriver.manage().window().maximize();
|
||||
@ -49,9 +55,9 @@ public class UsersPageTest {
|
||||
}
|
||||
|
||||
public void openUsersPage() throws InterruptedException {
|
||||
Events.click(webDriver, By.cssSelector("[data-testid='closeWhatsNew']")); // Close What's new
|
||||
Events.click(webDriver, By.cssSelector("[data-testid='menu-button'][id='menu-button-Settings']")); // Setting
|
||||
Events.click(webDriver, By.cssSelector("[data-testid='menu-item-Users']")); // Setting/Users
|
||||
Events.click(webDriver, tagsPage.closeWhatsNew()); // Close What's new
|
||||
Events.click(webDriver, tagsPage.headerSettings()); // Setting
|
||||
Events.click(webDriver, userPage.headerSettingsMenu("Users"));
|
||||
Thread.sleep(waitTime);
|
||||
}
|
||||
|
||||
@ -59,20 +65,20 @@ public class UsersPageTest {
|
||||
@Order(1)
|
||||
public void addAdminCheckCountCheck() throws InterruptedException {
|
||||
openUsersPage();
|
||||
Events.click(webDriver, By.xpath("//*[text()[contains(.,'" + "Cloud_Infra" + "')]] "));
|
||||
Events.click(webDriver, By.xpath("//div[@data-testid='data-container']//p"));
|
||||
Events.click(webDriver, By.cssSelector("[data-testid='saveButton']"));
|
||||
Object afterUsersCount =
|
||||
webDriver
|
||||
.findElement(By.xpath("//button[@data-testid='users']//span[@data-testid='filter-count']"))
|
||||
.getAttribute("innerHTML");
|
||||
Events.click(webDriver, tagsPage.containsText("Cloud_Infra"));
|
||||
Events.click(webDriver, userPage.selectUser());
|
||||
Thread.sleep(2000);
|
||||
Events.click(webDriver, userPage.rolesList());
|
||||
Events.click(webDriver, userPage.selectRole("Admin"));
|
||||
actions.moveToElement(userPage.closeCheckBoxDropDown(), 100, 200);
|
||||
actions.click();
|
||||
actions.perform();
|
||||
Events.click(webDriver, tagsPage.descriptionSaveButton());
|
||||
Thread.sleep(1000);
|
||||
Object afterUsersCount = webDriver.findElement(userPage.userFilterCount()).getAttribute("innerHTML");
|
||||
Thread.sleep(1000);
|
||||
Assert.assertEquals(afterUsersCount, "14");
|
||||
Object afterAdminCount =
|
||||
webDriver
|
||||
.findElement(By.xpath("//button[@data-testid='assets'][1]//span[@data-testid='filter-count']"))
|
||||
.getAttribute("innerHTML");
|
||||
Thread.sleep(1000);
|
||||
Object afterAdminCount = webDriver.findElement(userPage.adminFilterCount()).getAttribute("innerHTML");
|
||||
Assert.assertEquals(afterAdminCount, "1");
|
||||
}
|
||||
|
||||
@ -80,21 +86,21 @@ public class UsersPageTest {
|
||||
@Order(2)
|
||||
public void removeAdminCheckCountCheck() throws InterruptedException {
|
||||
openUsersPage();
|
||||
Events.click(webDriver, By.xpath("//*[text()[contains(.,'" + "Cloud_Infra" + "')]] "));
|
||||
Events.click(webDriver, By.cssSelector("[data-testid='assets']"));
|
||||
Events.click(webDriver, By.xpath("//div[@data-testid='data-container']//p"));
|
||||
Events.click(webDriver, By.cssSelector("[data-testid='saveButton']"));
|
||||
Object afterAdminCount =
|
||||
webDriver
|
||||
.findElement(By.xpath("//button[@data-testid='assets'][1]//span[@data-testid='filter-count']"))
|
||||
.getAttribute("innerHTML");
|
||||
Events.click(webDriver, tagsPage.containsText("Cloud_Infra"));
|
||||
Events.click(webDriver, userPage.userPageTab(1));
|
||||
Events.click(webDriver, userPage.selectUser());
|
||||
Events.click(webDriver, userPage.rolesList());
|
||||
Events.click(webDriver, userPage.selectRole("Admin"));
|
||||
actions.moveToElement(userPage.closeCheckBoxDropDown(), 100, 200);
|
||||
actions.click();
|
||||
actions.perform();
|
||||
// Events.click(webDriver, tagsPage.containsText("aaron_johnson0@gmail.com"));
|
||||
Events.click(webDriver, tagsPage.descriptionSaveButton());
|
||||
Thread.sleep(1000);
|
||||
Object afterAdminCount = webDriver.findElement(userPage.adminFilterCount()).getAttribute("innerHTML");
|
||||
Thread.sleep(1000);
|
||||
Assert.assertEquals(afterAdminCount, "0");
|
||||
Object afterUsersCount =
|
||||
webDriver
|
||||
.findElement(By.xpath("//button[@data-testid='users']//span[@data-testid='filter-count']"))
|
||||
.getAttribute("innerHTML");
|
||||
Thread.sleep(1000);
|
||||
Object afterUsersCount = webDriver.findElement(userPage.userFilterCount()).getAttribute("innerHTML");
|
||||
Assert.assertEquals(afterUsersCount, "15");
|
||||
}
|
||||
|
||||
@ -102,12 +108,9 @@ public class UsersPageTest {
|
||||
@Order(3)
|
||||
public void caseSensitiveSearchCheck() throws InterruptedException {
|
||||
openUsersPage();
|
||||
Events.sendKeys(webDriver, By.cssSelector("[data-testid='searchbar']"), "AaR");
|
||||
Events.sendKeys(webDriver, userPage.userListSearchBar(), "AaR");
|
||||
Thread.sleep(4000);
|
||||
Object userResultsCount =
|
||||
webDriver
|
||||
.findElements(By.xpath("//div[@data-testid='user-card-container']/div[@data-testid='user-card-container']"))
|
||||
.size();
|
||||
Object userResultsCount = webDriver.findElements(userPage.userListSearchResult()).size();
|
||||
Assert.assertEquals(userResultsCount, 3);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user