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