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. 111
      scripts/cypress/integration/common/8a_webhook.js

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

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

Loading…
Cancel
Save