mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-24 14:08:45 +00:00
Added selenium tests for glossary page (#3546)
* added glossary selenium tests * glossary tests * minor change * reverting minor change * addressing stylecheck * adding chrome option * removing commented code
This commit is contained in:
parent
2eccd711f1
commit
4b7358dfbf
@ -19,4 +19,4 @@ webDriver = webdriver.chrome.driver
|
||||
webDriverPath = src/test/resources/drivers/linux/chromedriver
|
||||
|
||||
# Enter Time In Milliseconds
|
||||
waitTime = 700
|
||||
waitTime = 2000
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import classNames from 'classnames';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { EditorContentRef, FormattedUsersData } from 'Models';
|
||||
@ -30,7 +31,6 @@ import Loader from '../Loader/Loader';
|
||||
import ReviewerModal from '../Modals/ReviewerModal/ReviewerModal.component';
|
||||
import Tags from '../tags/tags';
|
||||
import { AddGlossaryProps } from './AddGlossary.interface';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
|
||||
const Field = ({ children }: { children: React.ReactNode }) => {
|
||||
return <div className="tw-mt-4">{children}</div>;
|
||||
@ -225,6 +225,7 @@ const AddGlossary = ({
|
||||
<p className="w-form-label tw-mr-3">Reviewers: </p>
|
||||
<Button
|
||||
className="tw-h-5 tw-px-2"
|
||||
data-testid="add-reviewers"
|
||||
size="x-small"
|
||||
theme="primary"
|
||||
variant="contained"
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import classNames from 'classnames';
|
||||
import { cloneDeep, isEmpty, isUndefined } from 'lodash';
|
||||
import {
|
||||
@ -37,7 +38,6 @@ import RelatedTermsModal from '../Modals/RelatedTermsModal/RelatedTermsModal';
|
||||
import ReviewerModal from '../Modals/ReviewerModal/ReviewerModal.component';
|
||||
import Tags from '../tags/tags';
|
||||
import { AddGlossaryTermProps } from './AddGlossaryTerm.interface';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
|
||||
const Field = ({
|
||||
children,
|
||||
@ -447,6 +447,7 @@ const AddGlossaryTerm = ({
|
||||
<p className="w-form-label tw-mr-3">Reviewers </p>
|
||||
<Button
|
||||
className="tw-h-5 tw-px-2"
|
||||
data-testid="add-reviewers"
|
||||
size="x-small"
|
||||
theme="primary"
|
||||
variant="contained"
|
||||
|
||||
@ -191,7 +191,7 @@ const GlossaryDetails = ({ isHasAccess, glossary, updateGlossary }: props) => {
|
||||
className={classNames('tw-h-8 tw-rounded tw-mr-1', {
|
||||
'tw-opacity-40': isHasAccess,
|
||||
})}
|
||||
data-testid="add-new-tag-button"
|
||||
data-testid="add-new-reviewer"
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="contained"
|
||||
|
||||
@ -304,7 +304,7 @@ const GlossaryTermsV1 = ({
|
||||
className={classNames('tw-h-8 tw-rounded', {
|
||||
'tw-opacity-40': isHasAccess,
|
||||
})}
|
||||
data-testid="add-new-tag-button"
|
||||
data-testid="add-new-reviewer"
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="contained"
|
||||
|
||||
@ -86,6 +86,10 @@ public class Common {
|
||||
By headerSettingsTeams = By.cssSelector("[data-testid='menu-item-Teams']");
|
||||
By viewMore = By.xpath("//div[@data-testid='filter-containers-2']/p]");
|
||||
By home = By.cssSelector("[data-testid='image']");
|
||||
By saveWebhook = By.xpath("//button[@data-testid='save-webhook']");
|
||||
By reviewCount = By.cssSelector("[data-testid='user-card-container']");
|
||||
By tagsCount = By.xpath("(//div[@data-testid='tags']/div)");
|
||||
By addGlossaryReviewer = By.cssSelector("[data-testid='add-new-reviewer']");
|
||||
|
||||
public List<WebElement> versionRadioButton() {
|
||||
return webDriver.findElements(versionRadioButton);
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package org.openmetadata.catalog.selenium.objectRepository;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class GlossaryPage {
|
||||
@Nonnull WebDriver webDriver;
|
||||
|
||||
By addGlossaryButton = By.cssSelector("[data-testid='add-webhook-button']");
|
||||
By addReviewerButton = By.cssSelector("[data-testid='add-reviewers']");
|
||||
By editGlossaryTag = By.xpath("//div[@data-testid='tag-container']//img[@data-testid='image']");
|
||||
By addTerm = By.cssSelector("[title='Add term']");
|
||||
|
||||
public By checkboxAddUser(int index) {
|
||||
return By.xpath(
|
||||
"(//div[@data-testid='user-card-container']//input[@data-testid='checkboxAddUser'])[" + index + "]");
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,6 @@ public class Webhooks {
|
||||
By checkbox = By.xpath("//input[@data-testid='checkbox']");
|
||||
By entityCreatedMenu = By.xpath("(//button[@id='menu-button-select entities'])[1]");
|
||||
By allEntities = By.xpath("(//input[@type='checkbox'])[2]");
|
||||
By saveWebhook = By.xpath("//button[@data-testid='save-webhook']");
|
||||
By checkWebhook = By.xpath("//button[@data-testid='webhook-link']");
|
||||
By toast = By.xpath("(//div[@data-testid='toast']/div)[2]");
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class WebhooksPageTest {
|
||||
Events.click(webDriver, webhooks.allEntities());
|
||||
actions.click();
|
||||
actions.perform();
|
||||
Events.click(webDriver, webhooks.saveWebhook());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
Thread.sleep(2000);
|
||||
WebElement checkName = wait.until(ExpectedConditions.presenceOfElementLocated(webhooks.checkWebhook()));
|
||||
Assert.assertTrue(checkName.isDisplayed());
|
||||
@ -100,7 +100,7 @@ public class WebhooksPageTest {
|
||||
Events.click(webDriver, webhooks.allEntities());
|
||||
actions.click();
|
||||
actions.perform();
|
||||
Events.click(webDriver, webhooks.saveWebhook());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
WebElement errorMessage = webDriver.findElement(webhooks.toast());
|
||||
@ -124,7 +124,7 @@ public class WebhooksPageTest {
|
||||
Events.click(webDriver, webhooks.allEntities());
|
||||
actions.click();
|
||||
actions.perform();
|
||||
Events.click(webDriver, webhooks.saveWebhook());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
WebElement errorMessage = webDriver.findElement(common.errorMessage());
|
||||
Assert.assertTrue(errorMessage.isDisplayed());
|
||||
Assert.assertEquals(errorMessage.getText(), "Webhook name is required.");
|
||||
@ -145,7 +145,7 @@ public class WebhooksPageTest {
|
||||
Events.click(webDriver, webhooks.allEntities());
|
||||
actions.click();
|
||||
actions.perform();
|
||||
Events.click(webDriver, webhooks.saveWebhook());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
WebElement errorMessage = webDriver.findElement(common.errorMessage());
|
||||
Assert.assertTrue(errorMessage.isDisplayed());
|
||||
Assert.assertEquals(errorMessage.getText(), "Webhook endpoint is required.");
|
||||
@ -161,7 +161,7 @@ public class WebhooksPageTest {
|
||||
Events.click(webDriver, webhooks.descriptionBox());
|
||||
Events.sendKeys(webDriver, webhooks.descriptionBox(), "test");
|
||||
Events.sendKeys(webDriver, webhooks.endpoint(), "https://www.test.com");
|
||||
Events.click(webDriver, webhooks.saveWebhook());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
WebElement errorMessage = webDriver.findElement(common.errorMessage());
|
||||
Assert.assertTrue(errorMessage.isDisplayed());
|
||||
Assert.assertEquals(errorMessage.getText(), "Webhook event filters are required.");
|
||||
|
||||
@ -0,0 +1,284 @@
|
||||
package org.openmetadata.catalog.selenium.pages.glossary;
|
||||
|
||||
import com.github.javafaker.Faker;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
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.Common;
|
||||
import org.openmetadata.catalog.selenium.objectRepository.GlossaryPage;
|
||||
import org.openmetadata.catalog.selenium.properties.Property;
|
||||
import org.openqa.selenium.NoSuchElementException;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
import org.testng.Assert;
|
||||
|
||||
@Order(21)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class GlossaryPageTest {
|
||||
|
||||
static WebDriver webDriver;
|
||||
static Common common;
|
||||
static GlossaryPage glossary;
|
||||
static String url = Property.getInstance().getURL();
|
||||
static Faker faker = new Faker();
|
||||
static Actions actions;
|
||||
static WebDriverWait wait;
|
||||
static String glossaryName = faker.name().firstName();
|
||||
static String termName = faker.name().firstName();
|
||||
Integer waitTime = Property.getInstance().getSleepTime();
|
||||
String webDriverInstance = Property.getInstance().getWebDriver();
|
||||
String webDriverPath = Property.getInstance().getWebDriverPath();
|
||||
|
||||
@BeforeEach
|
||||
public void openMetadataWindow() {
|
||||
System.setProperty(webDriverInstance, webDriverPath);
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.addArguments("--headless");
|
||||
options.addArguments("--window-size=1280,800");
|
||||
webDriver = new ChromeDriver(options);
|
||||
common = new Common(webDriver);
|
||||
glossary = new GlossaryPage(webDriver);
|
||||
actions = new Actions(webDriver);
|
||||
wait = new WebDriverWait(webDriver, Duration.ofSeconds(30));
|
||||
webDriver.manage().window().maximize();
|
||||
webDriver.get(url);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void openGlossaryPage() throws InterruptedException {
|
||||
Events.click(webDriver, common.closeWhatsNew()); // Close What's new
|
||||
Events.click(webDriver, common.headerSettings()); // Setting
|
||||
Events.click(webDriver, common.headerSettingsMenu("Glossaries"));
|
||||
Thread.sleep(waitTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void addGlossary() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
try {
|
||||
WebElement addGlossaryButton = webDriver.findElement(common.addTagCategory());
|
||||
if (addGlossaryButton.isDisplayed()) {
|
||||
Events.click(webDriver, common.addTagCategory());
|
||||
}
|
||||
} catch (NoSuchElementException e) {
|
||||
Events.click(webDriver, glossary.addGlossaryButton());
|
||||
}
|
||||
Events.sendKeys(webDriver, common.displayName(), glossaryName);
|
||||
Events.click(webDriver, common.descriptionBoldButton());
|
||||
Events.sendKeys(webDriver, common.addDescriptionString(), faker.address().toString());
|
||||
Events.click(webDriver, common.addDescriptionString());
|
||||
Events.sendEnter(webDriver, common.addDescriptionString());
|
||||
Events.click(webDriver, common.descriptionItalicButton());
|
||||
Events.sendKeys(webDriver, common.addDescriptionString(), faker.address().toString());
|
||||
Events.click(webDriver, common.addDescriptionString());
|
||||
Events.sendEnter(webDriver, common.addDescriptionString());
|
||||
Events.click(webDriver, common.descriptionLinkButton());
|
||||
Events.sendKeys(webDriver, common.addDescriptionString(), faker.address().toString());
|
||||
Events.click(webDriver, glossary.addReviewerButton());
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
Events.click(webDriver, glossary.checkboxAddUser(i));
|
||||
}
|
||||
Events.click(webDriver, common.descriptionSaveButton());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void addTagToGlossary() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(glossaryName));
|
||||
Events.click(webDriver, common.breadCrumbTags());
|
||||
Events.click(webDriver, common.enterAssociatedTagName());
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
Events.sendKeys(webDriver, common.enterAssociatedTagName(), "P");
|
||||
Events.click(webDriver, common.tagListItem());
|
||||
}
|
||||
Events.click(webDriver, common.saveAssociatedTag());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.tagsCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void addReviewer() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(glossaryName));
|
||||
Events.click(webDriver, common.addGlossaryReviewer());
|
||||
Events.click(webDriver, glossary.checkboxAddUser(4));
|
||||
Events.click(webDriver, common.descriptionSaveButton());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "4");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deleteGlossaryReviewer() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(glossaryName));
|
||||
Thread.sleep(waitTime);
|
||||
actions.moveToElement(webDriver.findElement(common.removeAssociatedTag())).perform();
|
||||
Events.click(webDriver, common.removeAssociatedTag());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void removeAddedTagsToGlossary() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(glossaryName));
|
||||
Events.click(webDriver, glossary.editGlossaryTag());
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Events.click(webDriver, common.removeAssociatedTag());
|
||||
}
|
||||
Events.click(webDriver, common.saveAssociatedTag());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.tagsCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void removeAddedReviewers() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(glossaryName));
|
||||
Events.click(webDriver, common.addGlossaryReviewer());
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
Events.click(webDriver, glossary.checkboxAddUser(i));
|
||||
}
|
||||
Events.click(webDriver, common.descriptionSaveButton());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void addGlossaryTerm() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(glossaryName));
|
||||
Events.click(webDriver, common.addTagButton());
|
||||
Events.click(webDriver, common.selectUser());
|
||||
Events.sendKeys(webDriver, common.displayName(), termName);
|
||||
Events.click(webDriver, common.descriptionBoldButton());
|
||||
Events.sendKeys(webDriver, common.addDescriptionString(), faker.address().toString());
|
||||
Events.click(webDriver, common.addDescriptionString());
|
||||
Events.sendEnter(webDriver, common.addDescriptionString());
|
||||
Events.click(webDriver, common.descriptionItalicButton());
|
||||
Events.sendKeys(webDriver, common.addDescriptionString(), faker.address().toString());
|
||||
Events.click(webDriver, common.addDescriptionString());
|
||||
Events.sendEnter(webDriver, common.addDescriptionString());
|
||||
Events.click(webDriver, common.descriptionLinkButton());
|
||||
Events.sendKeys(webDriver, common.addDescriptionString(), faker.address().toString());
|
||||
Events.click(webDriver, glossary.addReviewerButton());
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
Events.click(webDriver, glossary.checkboxAddUser(i));
|
||||
}
|
||||
Events.click(webDriver, common.descriptionSaveButton());
|
||||
Events.click(webDriver, common.saveWebhook());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void addTagToTerm() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(termName));
|
||||
Events.click(webDriver, common.breadCrumbTags());
|
||||
Events.click(webDriver, common.enterAssociatedTagName());
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
Events.sendKeys(webDriver, common.enterAssociatedTagName(), "P");
|
||||
Events.click(webDriver, common.tagListItem());
|
||||
}
|
||||
Events.click(webDriver, common.saveAssociatedTag());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.tagsCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void addTermReviewer() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(termName));
|
||||
Events.click(webDriver, common.serviceDetailsTabs("reviewers"));
|
||||
Events.click(webDriver, common.addGlossaryReviewer());
|
||||
Events.click(webDriver, glossary.checkboxAddUser(3));
|
||||
Events.click(webDriver, common.descriptionSaveButton());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void deleteTermReviewer() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(termName));
|
||||
Events.click(webDriver, common.serviceDetailsTabs("reviewers"));
|
||||
Thread.sleep(waitTime);
|
||||
actions.moveToElement(webDriver.findElement(common.removeAssociatedTag())).perform();
|
||||
Events.click(webDriver, common.removeAssociatedTag());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void removeAddedReviewersToTerm() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(termName));
|
||||
Events.click(webDriver, common.serviceDetailsTabs("reviewers"));
|
||||
Events.click(webDriver, common.addGlossaryReviewer());
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
Events.click(webDriver, glossary.checkboxAddUser(i));
|
||||
}
|
||||
Events.click(webDriver, common.descriptionSaveButton());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void removeAddedTagsToTerm() throws InterruptedException {
|
||||
openGlossaryPage();
|
||||
Events.click(webDriver, common.containsText(termName));
|
||||
Events.click(webDriver, glossary.editGlossaryTag());
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Events.click(webDriver, common.removeAssociatedTag());
|
||||
}
|
||||
Events.click(webDriver, common.saveAssociatedTag());
|
||||
Thread.sleep(waitTime);
|
||||
Object reviewerCount = webDriver.findElements(common.tagsCount()).size();
|
||||
Assert.assertEquals(reviewerCount.toString(), "0");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void closeTabs() {
|
||||
ArrayList<String> tabs = new ArrayList<>(webDriver.getWindowHandles());
|
||||
String originalHandle = webDriver.getWindowHandle();
|
||||
for (String handle : webDriver.getWindowHandles()) {
|
||||
if (!handle.equals(originalHandle)) {
|
||||
webDriver.switchTo().window(handle);
|
||||
webDriver.close();
|
||||
}
|
||||
}
|
||||
webDriver.switchTo().window(tabs.get(0)).close();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user