-
Notifications
You must be signed in to change notification settings - Fork 876
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
Adding Webhooks selenium tests #2911
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a80e29
Adding Webhooks selenium tests
c20bf21
Adding java checkstyle
babd177
Changed assertions based on comments
b84041f
Merge branch 'main' into WebHooks-page-test
694b73d
Added @RequiredArgsConstructor
071c09c
Adding java checkstyle
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...etadata-ui/src/test/java/org/openmetadata/catalog/selenium/objectRepository/Webhooks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.openmetadata.catalog.selenium.objectRepository; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class Webhooks { | ||
WebDriver webDriver; | ||
|
||
public Webhooks(WebDriver webDriver) { | ||
this.webDriver = webDriver; | ||
} | ||
|
||
By webhookLink = By.linkText("Webhooks"); | ||
By addWebhook = By.xpath("//button[@data-testid='add-webhook-button']"); | ||
By name = By.xpath("//input[@data-testid='name']"); | ||
By descriptionBox = By.xpath("//div[@class='notranslate public-DraftEditor-content']"); | ||
By endpoint = By.xpath("//input[@data-testid='endpoint-url']"); | ||
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]"); | ||
|
||
public By getToast() { | ||
return toast; | ||
} | ||
|
||
public By checkWebhook() { | ||
return checkWebhook; | ||
} | ||
|
||
public By getSaveWebhook() { | ||
return saveWebhook; | ||
} | ||
|
||
public By allEntities() { | ||
return allEntities; | ||
} | ||
|
||
public By getEntityCreatedMenu() { | ||
return entityCreatedMenu; | ||
} | ||
|
||
public By checkbox() { | ||
return checkbox; | ||
} | ||
|
||
public By getEndpoint() { | ||
return endpoint; | ||
} | ||
|
||
public By getDescriptionBox() { | ||
return descriptionBox; | ||
} | ||
|
||
public By name() { | ||
return name; | ||
} | ||
|
||
public By webhookLink() { | ||
return webhookLink; | ||
} | ||
|
||
public By addWebhook() { | ||
return addWebhook; | ||
} | ||
} |
168 changes: 168 additions & 0 deletions
168
...a-ui/src/test/java/org/openmetadata/catalog/selenium/pages/Webhooks/WebhooksPageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package org.openmetadata.catalog.selenium.pages.Webhooks; | ||
|
||
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.Test; | ||
import org.openmetadata.catalog.selenium.events.*; | ||
import org.openmetadata.catalog.selenium.objectRepository.*; | ||
import org.openmetadata.catalog.selenium.properties.*; | ||
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; | ||
|
||
public class WebhooksPageTest { | ||
|
||
static WebDriver webDriver; | ||
static Common common; | ||
static Webhooks webhooks; | ||
static String url = Property.getInstance().getURL(); | ||
static Faker faker = new Faker(); | ||
static Actions actions; | ||
static WebDriverWait wait; | ||
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(); | ||
common = new Common(webDriver); | ||
webhooks = new Webhooks(webDriver); | ||
actions = new Actions(webDriver); | ||
wait = new WebDriverWait(webDriver, Duration.ofSeconds(30)); | ||
webDriver.manage().window().maximize(); | ||
webDriver.get(url); | ||
} | ||
|
||
@Test | ||
void openWebHookPage() { | ||
Events.click(webDriver, common.closeWhatsNew()); // Close What's new | ||
Events.click(webDriver, common.headerSettings()); // Setting | ||
Events.click(webDriver, webhooks.webhookLink()); | ||
} | ||
|
||
@Test | ||
void addWebHook() throws InterruptedException { | ||
String name = faker.name().name(); | ||
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); | ||
openWebHookPage(); | ||
Events.click(webDriver, webhooks.addWebhook()); | ||
Events.sendKeys(webDriver, webhooks.name(), name); | ||
Events.click(webDriver, webhooks.getDescriptionBox()); | ||
Events.sendKeys(webDriver, webhooks.getDescriptionBox(), "test"); | ||
Events.sendKeys(webDriver, webhooks.getEndpoint(), "test.com"); | ||
Events.click(webDriver, webhooks.checkbox()); | ||
Thread.sleep(waitTime); | ||
Events.click(webDriver, webhooks.getEntityCreatedMenu()); | ||
Events.click(webDriver, webhooks.allEntities()); | ||
actions.click(); | ||
actions.perform(); | ||
Events.click(webDriver, webhooks.getSaveWebhook()); | ||
WebElement checkName = webDriver.findElement(webhooks.checkWebhook()); | ||
Assert.assertTrue(checkName.isDisplayed()); | ||
Assert.assertEquals(checkName.getText(), name); | ||
} | ||
|
||
@Test | ||
void checkDuplicateWebhookName() { | ||
String name = faker.name().name(); | ||
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); | ||
openWebHookPage(); | ||
for (int i = 0; i < 2; i++) { | ||
Events.click(webDriver, webhooks.addWebhook()); | ||
Events.sendKeys(webDriver, webhooks.name(), name); | ||
Events.click(webDriver, webhooks.getDescriptionBox()); | ||
Events.sendKeys(webDriver, webhooks.getDescriptionBox(), "test"); | ||
Events.sendKeys(webDriver, webhooks.getEndpoint(), "test.com"); | ||
Events.click(webDriver, webhooks.checkbox()); | ||
Events.click(webDriver, webhooks.getEntityCreatedMenu()); | ||
Events.click(webDriver, webhooks.allEntities()); | ||
actions.click(); | ||
actions.perform(); | ||
Events.click(webDriver, webhooks.getSaveWebhook()); | ||
} | ||
WebElement errorMessage = webDriver.findElement(webhooks.getToast()); | ||
Assert.assertTrue(errorMessage.isDisplayed()); | ||
Assert.assertEquals(errorMessage.getText(), "Request failed with status code 409"); | ||
} | ||
|
||
@Test | ||
void checkBlankName() throws InterruptedException { | ||
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); | ||
openWebHookPage(); | ||
Events.click(webDriver, webhooks.addWebhook()); | ||
Events.sendKeys(webDriver, webhooks.name(), ""); | ||
Events.click(webDriver, webhooks.getDescriptionBox()); | ||
Events.sendKeys(webDriver, webhooks.getDescriptionBox(), "test"); | ||
Events.sendKeys(webDriver, webhooks.getEndpoint(), "test.com"); | ||
Events.click(webDriver, webhooks.checkbox()); | ||
Thread.sleep(waitTime); | ||
Events.click(webDriver, webhooks.getEntityCreatedMenu()); | ||
Events.click(webDriver, webhooks.allEntities()); | ||
actions.click(); | ||
actions.perform(); | ||
Events.click(webDriver, webhooks.getSaveWebhook()); | ||
WebElement errorMessage = webDriver.findElement(common.errorMessage()); | ||
Assert.assertTrue(errorMessage.isDisplayed()); | ||
Assert.assertEquals(errorMessage.getText(), "Webhook name is required."); | ||
} | ||
|
||
@Test | ||
void checkBlankEndpoint() { | ||
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); | ||
openWebHookPage(); | ||
Events.click(webDriver, webhooks.addWebhook()); | ||
Events.sendKeys(webDriver, webhooks.name(), "test"); | ||
Events.click(webDriver, webhooks.getDescriptionBox()); | ||
Events.sendKeys(webDriver, webhooks.getDescriptionBox(), "test"); | ||
Events.sendKeys(webDriver, webhooks.getEndpoint(), ""); | ||
Events.click(webDriver, webhooks.checkbox()); | ||
Events.click(webDriver, webhooks.getEntityCreatedMenu()); | ||
Events.click(webDriver, webhooks.allEntities()); | ||
actions.click(); | ||
actions.perform(); | ||
Events.click(webDriver, webhooks.getSaveWebhook()); | ||
WebElement errorMessage = webDriver.findElement(common.errorMessage()); | ||
Assert.assertTrue(errorMessage.isDisplayed()); | ||
Assert.assertEquals(errorMessage.getText(), "Webhook endpoint is required."); | ||
} | ||
|
||
@Test | ||
void checkBlankEntityCheckbox() { | ||
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); | ||
openWebHookPage(); | ||
Events.click(webDriver, webhooks.addWebhook()); | ||
Events.sendKeys(webDriver, webhooks.name(), "test"); | ||
Events.click(webDriver, webhooks.getDescriptionBox()); | ||
Events.sendKeys(webDriver, webhooks.getDescriptionBox(), "test"); | ||
Events.sendKeys(webDriver, webhooks.getEndpoint(), "test.com"); | ||
Events.click(webDriver, webhooks.getSaveWebhook()); | ||
WebElement errorMessage = webDriver.findElement(common.errorMessage()); | ||
Assert.assertTrue(errorMessage.isDisplayed()); | ||
Assert.assertEquals(errorMessage.getText(), "Webhook event filters are required."); | ||
} | ||
|
||
@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(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use lombok RequiredArgsConstructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated lombok @requiredargsconstructor