Browse Source

test: webhook- add wait for webhook to get triggered

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3655/head
Raju Udava 2 years ago
parent
commit
fbceea976b
  1. 113
      scripts/cypress/integration/common/8a_webhook.js

113
scripts/cypress/integration/common/8a_webhook.js

@ -6,8 +6,11 @@ import { loginPage } from "../../support/page_objects/navigation";
let hookPath = "http://localhost:9090/hook";
function createWebhook(hook, test) {
cy.get('.nc-actions-menu-btn').should('exist').click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-title-content').contains('Webhooks').click()
cy.get(".nc-actions-menu-btn").should("exist").click();
cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-title-content")
.contains("Webhooks")
.click();
// cy.get(".nc-btn-webhook").should("exist").click();
cy.get(".nc-btn-create-webhook").should("exist").click();
@ -23,35 +26,45 @@ function createWebhook(hook, test) {
cy.get(".nc-input-hook-header-key")
.should("exist")
.click()
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
.type('{downarrow}')
cy.getActiveSelection('.nc-dropdown-webhook-header').find('.ant-select-item-option-content').contains('Content-Type').should('exist').click();
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}");
cy.getActiveSelection(".nc-dropdown-webhook-header")
.find(".ant-select-item-option-content")
.contains("Content-Type")
.should("exist")
.click();
cy.get("input.nc-input-hook-header-value")
.should("exist")
.clear({ force: true })
.type("application/json", { force: true });
cy.get('.nc-hook-header-tab-checkbox').find('input.ant-checkbox-input').should('exist').click();
cy.get(".nc-hook-header-tab-checkbox")
.find("input.ant-checkbox-input")
.should("exist")
.click();
// common routine for both create & modify to configure hook
configureWebhook(hook, test);
}
function deleteWebhook(index) {
cy.get('.nc-actions-menu-btn').should('exist').click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-title-content').contains('Webhooks').click()
cy.get(".nc-actions-menu-btn").should("exist").click();
cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-title-content")
.contains("Webhooks")
.click();
cy.get(".nc-hook-delete-icon").eq(index).click({ force: true });
cy.toastWait("Hook deleted successfully");
@ -59,8 +72,11 @@ function deleteWebhook(index) {
}
function openWebhook(index) {
cy.get('.nc-actions-menu-btn').should('exist').click();
cy.getActiveMenu(".nc-dropdown-actions-menu").find('.ant-dropdown-menu-title-content').contains('Webhooks').click()
cy.get(".nc-actions-menu-btn").should("exist").click();
cy.getActiveMenu(".nc-dropdown-actions-menu")
.find(".ant-dropdown-menu-title-content")
.contains("Webhooks")
.click();
cy.get(".nc-hook").eq(index).click({ force: true });
}
@ -78,7 +94,7 @@ function configureWebhook(hook, test) {
if (hook?.event) {
cy.get(".nc-text-field-hook-event").should("exist").click();
cy.getActiveSelection('.nc-dropdown-webhook-event')
cy.getActiveSelection(".nc-dropdown-webhook-event")
.find(`.ant-select-item`)
.contains(hook.event)
.should("exist")
@ -93,9 +109,7 @@ function configureWebhook(hook, test) {
}
if (hook?.deleteCondition === true) {
cy.get(".nc-filter-item-remove-btn")
.should("exist")
.click({ force: true });
cy.get(".nc-filter-item-remove-btn").should("exist").click({ force: true });
}
if (hook?.condition) {
@ -106,26 +120,26 @@ function configureWebhook(hook, test) {
.contains("Add Filter")
.click();
cy.get(".nc-filter-field-select")
cy.get(".nc-filter-field-select").should("exist").last().click();
cy.get(".ant-select-dropdown:visible")
.should("exist")
.last()
.click()
cy.get('.ant-select-dropdown:visible')
.should('exist')
.find(`.ant-select-item`)
.contains(new RegExp("^" + hook.condition.column + "$", "g"))
.should('exist')
.should("exist")
.click();
cy.wait(1000);
cy.get(".nc-filter-operation-select").should("exist").last().click();
cy.get('.ant-select-dropdown:visible')
.should('exist')
cy.get(".ant-select-dropdown:visible")
.should("exist")
.find(`.ant-select-item`)
.contains(hook.condition.operator)
.should('exist')
.should("exist")
.click();
if (hook.condition.operator != "is null" && hook.condition.operator != "is not null") {
if (
hook.condition.operator != "is null" &&
hook.condition.operator != "is not null"
) {
cy.get(".nc-filter-value-select")
.should("exist")
.last()
@ -160,13 +174,16 @@ function addNewRow(index, cellValue) {
cy.get(".nc-add-new-row-btn:visible").should("exist");
cy.get(".nc-add-new-row-btn").click();
cy.wait(1000);
cy.get(".nc-expand-col-Title").find(".nc-cell > input").first().type(cellValue);
cy.getActiveDrawer('.nc-drawer-expanded-form')
cy.get(".nc-expand-col-Title")
.find(".nc-cell > input")
.first()
.type(cellValue);
cy.getActiveDrawer(".nc-drawer-expanded-form")
.find(".ant-btn-primary")
.click();
cy.toastWait("updated successfully");
cy.getActiveDrawer('.nc-drawer-expanded-form')
cy.getActiveDrawer(".nc-drawer-expanded-form")
.find(".ant-btn")
.contains("Cancel")
.click();
@ -175,29 +192,33 @@ function addNewRow(index, cellValue) {
function updateRow(index, cellValue) {
cy.get(".nc-row-expand")
.eq(index-1)
.eq(index - 1)
.click({ force: true });
cy.get(".nc-expand-col-Title").find(".nc-cell > input")
cy.get(".nc-expand-col-Title")
.find(".nc-cell > input")
.should("exist")
.first()
.clear()
.type(cellValue);
cy.getActiveDrawer('.nc-drawer-expanded-form')
cy.getActiveDrawer(".nc-drawer-expanded-form")
.find("button")
.contains("Save row")
.click({ force: true });
// partial toast message
cy.toastWait("updated successfully");
cy.getActiveDrawer('.nc-drawer-expanded-form')
cy.getActiveDrawer(".nc-drawer-expanded-form")
.find("button")
.contains("Cancel")
.click({ force: true });
}
function verifyHookTrigger(count, lastValue) {
// allow message to be received
cy.wait(500);
cy.request("http://localhost:9090/hook/count").then((msg) => {
cy.log(msg.body);
expect(msg.body).to.equal(count);
@ -211,15 +232,13 @@ function verifyHookTrigger(count, lastValue) {
}
function deleteRow(index) {
mainPage
.getCell("Title", index)
.rightclick();
mainPage.getCell("Title", index).rightclick();
// delete row
cy.getActiveMenu(".nc-dropdown-grid-context-menu")
.find('.ant-dropdown-menu-item:contains("Delete Row")')
.first()
.click({ force: true });
.click();
}
export const genTest = (apiType, dbType) => {
@ -237,7 +256,7 @@ export const genTest = (apiType, dbType) => {
afterEach(() => {
cy.saveLocalStorage();
})
});
after(() => {
cy.restoreLocalStorage();

Loading…
Cancel
Save