test: Automated tests for Bug #10784 + Failure fixes (#11586)

* Scripting Bug # 10784

* Bug 10784 - added script

* Uncommenting - JSObjToInput spec

* Uncommenting - JSObjtoListWidget spec

* SelectEntityByName reverted

* Migration spec locators fix

* Table_GeneralProp spec updated

* Read Table Row/Column locator updated

* Calling WaitAutoSave in JSObj creation

* 19px to 28px to match CI run

* CreateJSObject() - adding back wait time

* Reverting 28px to 19px

* Commenting table specs until CI fixed

* Commenting table spec 9th case

* UNcommenting

* Commenting Table_GeneralProp failure case
This commit is contained in:
Aishwarya-U-R 2022-03-05 01:01:35 +05:30 committed by GitHub
parent f610033240
commit bd69eb9c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 549 additions and 242 deletions

View File

@ -1,54 +1,49 @@
// import { AggregateHelper } from "../../../../support/Pages/AggregateHelper";
// import { JSEditor } from "../../../../support/Pages/JSEditor";
// import { CommonLocators } from "../../../../support/Objects/CommonLocators";
import { AggregateHelper } from "../../../../support/Pages/AggregateHelper";
import { JSEditor } from "../../../../support/Pages/JSEditor";
import { CommonLocators } from "../../../../support/Objects/CommonLocators";
// const agHelper = new AggregateHelper();
// const jsEditor = new JSEditor();
// const locator = new CommonLocators();
const agHelper = new AggregateHelper();
const jsEditor = new JSEditor();
const locator = new CommonLocators();
// describe("Validate Create Api and Bind to Table widget via JSObject", () => {
// before(() => {
// cy.fixture('formInputTableDsl').then((val: any) => {
// agHelper.AddDsl(val)
// });
// });
describe("Validate Create Api and Bind to Table widget via JSObject", () => {
before(() => {
cy.fixture('formInputTableDsl').then((val: any) => {
agHelper.AddDsl(val)
});
});
// it("1. Bind Input widget with JSObject", function () {
// jsEditor.CreateJSObject('return "Success";', false);
// agHelper.SelectEntityByName("Widgets")//to expand widgets
// agHelper.expandCollapseEntity("Form1")
// agHelper.SelectEntityByName("Input2")
// cy.get("@jsObjName").then((jsObjName) => {
// jsEditor.EnterJSContext("defaulttext", "{{" + jsObjName + ".myFun1()}}")
// });
// cy.wait("@updateLayout").should(
// "have.nested.property",
// "response.body.responseMeta.status",
// 200,
// );
// cy.get(locator._inputWidget).last().invoke("attr", "value").should("equal", 'Success');
// // cy.get(locator._inputWidget)
// // .last()
// // .within(() => {
// // cy.get("input")
// // .invoke("attr", "value")
// // .should("equal", 'Success');
// // });
// });
it("1. Bind Input widget with JSObject", function () {
jsEditor.CreateJSObject('return "Success";', false);
agHelper.SelectEntityByName("WIDGETS")//to expand widgets
agHelper.expandCollapseEntity("Form1")
agHelper.SelectEntityByName("Input2")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext("defaulttext", "{{" + jsObjName + ".myFun1()}}")
});
cy.get(locator._inputWidget).last().invoke("attr", "value").should("equal", 'Success');
// cy.get(locator._inputWidget)
// .last()
// .within(() => {
// cy.get("input")
// .invoke("attr", "value")
// .should("equal", 'Success');
// });
});
// it.skip("2. Bug 10284, 11529 - Verify timeout issue with running JS Objects", function () {
// jsEditor.CreateJSObject('return "Success";', true);
// agHelper.expandCollapseEntity("Form1")
// agHelper.SelectEntityByName("Input2")
// cy.get("@jsObjName").then((jsObjName) => {
// jsEditor.EnterJSContext("defaulttext", "{{" + jsObjName + ".myFun1()}}")
// });
// cy.wait("@updateLayout").should(
// "have.nested.property",
// "response.body.responseMeta.status",
// 200,
// );
// cy.get(locator._inputWidget).last().invoke("attr", "value").should("equal", 'Success');
// });
it.skip("2. Bug 10284, 11529 - Verify timeout issue with running JS Objects", function () {
jsEditor.CreateJSObject('return "Success";', true);
agHelper.expandCollapseEntity("Form1")
agHelper.SelectEntityByName("Input2")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext("defaulttext", "{{" + jsObjName + ".myFun1()}}")
});
cy.wait("@updateLayout").should(
"have.nested.property",
"response.body.responseMeta.status",
200,
);
cy.get(locator._inputWidget).last().invoke("attr", "value").should("equal", 'Success');
});
// });
});

View File

@ -1,82 +1,83 @@
// import { ApiPage } from "../../../../support/Pages/ApiPage";
// import { AggregateHelper } from "../../../../support/Pages/AggregateHelper";
// import { JSEditor } from "../../../../support/Pages/JSEditor";
// import { CommonLocators } from "../../../../support/Objects/CommonLocators";
import { ApiPage } from "../../../../support/Pages/ApiPage";
import { AggregateHelper } from "../../../../support/Pages/AggregateHelper";
import { JSEditor } from "../../../../support/Pages/JSEditor";
import { CommonLocators } from "../../../../support/Objects/CommonLocators";
// const apiPage = new ApiPage();
// const agHelper = new AggregateHelper();
// const jsEditor = new JSEditor();
// const locator = new CommonLocators();
const apiPage = new ApiPage();
const agHelper = new AggregateHelper();
const jsEditor = new JSEditor();
const locator = new CommonLocators();
// let dataSet: any, valueToTest: any, jsName: any;
let dataSet: any, valueToTest: any, jsName: any;
// describe("Validate Create Api and Bind to Table widget via JSObject", () => {
// before(() => {
// cy.fixture('listwidgetdsl').then((val: any) => {
// agHelper.AddDsl(val)
// });
describe("Validate Create Api and Bind to Table widget via JSObject", () => {
before(() => {
cy.fixture('listwidgetdsl').then((val: any) => {
agHelper.AddDsl(val)
});
// cy.fixture("example").then(function (data: any) {
// dataSet = data;
// });
// });
cy.fixture("example").then(function (data: any) {
dataSet = data;
});
});
// it("1. Add users api and bind to JSObject", () => {
// apiPage.CreateAndFillApi(dataSet.userApi + "/users")
// apiPage.RunAPI()
// apiPage.ReadApiResponsebyKey("name");
// cy.get("@apiResp").then((value) => {
// valueToTest = value;
// cy.log("valueToTest to test returned is :" + valueToTest)
// //cy.log("value to test returned is :" + value)
// })
// jsEditor.CreateJSObject("return Api1.data.users;", false);
// cy.get("@jsObjName").then((jsObj) => {
// jsName = jsObj;
// cy.log("jsName returned is :" + jsName)
// })
// });
it("1. Add users api and bind to JSObject", () => {
apiPage.CreateAndFillApi(dataSet.userApi + "/users")
apiPage.RunAPI()
apiPage.ReadApiResponsebyKey("name");
cy.get("@apiResp").then((value) => {
valueToTest = value;
cy.log("valueToTest to test returned is :" + valueToTest)
//cy.log("value to test returned is :" + value)
})
jsEditor.CreateJSObject("return Api1.data.users;", false);
cy.get("@jsObjName").then((jsObj) => {
jsName = jsObj;
cy.log("jsName returned is :" + jsName)
})
});
// it("2. Validate the Api data is updated on List widget", function () {
// agHelper.SelectEntityByName("Widgets")//to expand widgets
// agHelper.SelectEntityByName("List1");
// jsEditor.EnterJSContext("items", "{{" + jsName as string + ".myFun1()}}")
// cy.get(locator._textWidget).should("have.length", 8);
// cy.get(locator._textWidget)
// .first()
// .invoke("text")
// .then((text) => {
// expect(text).to.equal((valueToTest as string).trimEnd());
// });
// agHelper.DeployApp();
// cy.get(locator._textWidgetInDeployed).should("have.length", 8);
// cy.get(locator._textWidgetInDeployed)
// .first()
// .invoke("text")
// .then((text) => {
// expect(text).to.equal((valueToTest as string).trimEnd());
// });
// });
it("2. Validate the Api data is updated on List widget", function () {
agHelper.SelectEntityByName("WIDGETS")//to expand widgets
agHelper.SelectEntityByName("List1");
jsEditor.EnterJSContext("items", "{{" + jsName as string + ".myFun1()}}")
cy.get(locator._textWidget).should("have.length", 8);
cy.get(locator._textWidget)
.first()
.invoke("text")
.then((text) => {
expect(text).to.equal((valueToTest as string).trimEnd());
});
agHelper.DeployApp();
agHelper.WaitUntilEleAppear(locator._textWidgetInDeployed)
cy.get(locator._textWidgetInDeployed).should("have.length", 8);
cy.get(locator._textWidgetInDeployed)
.first()
.invoke("text")
.then((text) => {
expect(text).to.equal((valueToTest as string).trimEnd());
});
});
// it("3. Validate the List widget ", function () {
// agHelper.NavigateBacktoEditor()
// agHelper.SelectEntityByName("Widgets")//to expand widgets
// agHelper.SelectEntityByName("List1");
// jsEditor.EnterJSContext("itemspacing\\(px\\)", "50")
// cy.get(locator._textWidget).should("have.length", 6);
// cy.get(locator._textWidget)
// .first()
// .invoke("text")
// .then((text) => {
// expect(text).to.equal((valueToTest as string).trimEnd());
// });
// agHelper.DeployApp();
// cy.get(locator._textWidgetInDeployed).should("have.length", 6);
// cy.get(locator._textWidgetInDeployed).first()
// .invoke("text")
// .then((text) => {
// expect(text).to.equal((valueToTest as string).trimEnd());
// });
// agHelper.NavigateBacktoEditor()
// });
// });
it("3. Validate the List widget ", function () {
agHelper.NavigateBacktoEditor()
agHelper.SelectEntityByName("WIDGETS")//to expand widgets
agHelper.SelectEntityByName("List1");
jsEditor.EnterJSContext("itemspacing\\(px\\)", "50")
cy.get(locator._textWidget).should("have.length", 6);
cy.get(locator._textWidget)
.first()
.invoke("text")
.then((text) => {
expect(text).to.equal((valueToTest as string).trimEnd());
});
agHelper.DeployApp();
cy.get(locator._textWidgetInDeployed).should("have.length", 6);
cy.get(locator._textWidgetInDeployed).first()
.invoke("text")
.then((text) => {
expect(text).to.equal((valueToTest as string).trimEnd());
});
agHelper.NavigateBacktoEditor()
});
});

View File

@ -43,7 +43,7 @@ describe("Migration Validate", function() {
//Validating Latitude & Longitude are hidden columns:
cy.xpath(
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']/div[text()='latitude']",
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']//div[text()='latitude']/parent::div/parent::div",
)
.invoke("attr", "class")
.then((classes) => {
@ -52,7 +52,7 @@ describe("Migration Validate", function() {
});
cy.xpath(
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']/div[text()='longitude']",
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']//div[text()='longitude']/parent::div/parent::div",
)
.invoke("attr", "class")
.then((classes) => {
@ -74,7 +74,7 @@ describe("Migration Validate", function() {
//Validating Id column sorting happens as Datatype is Number in app!
cy.xpath(
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']/div[text()='id']",
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']//div[text()='id']",
)
.click()
.wait(2000);
@ -93,7 +93,7 @@ describe("Migration Validate", function() {
//Revert the Id column sorting!
cy.xpath(
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']/div[text()='id']",
"//div[@class='tableWrap']//div[@class='thead']//div[@class='tr'][1]//div[@role='columnheader']//div[text()='id']",
)
.click()
.wait(2000);
@ -112,7 +112,7 @@ describe("Migration Validate", function() {
//Validating image column is present:
cy.getTableDataSelector("0", "10").then((selector) => {
cy.get(selector + " div div")
cy.get(selector + " div")
.invoke("attr", "class")
.then((classes) => {
cy.log("classes are:" + classes);

View File

@ -2,9 +2,7 @@
const widgetsPage = require("../../../../locators/Widgets.json");
const commonlocators = require("../../../../locators/commonlocators.json");
const publish = require("../../../../locators/publishWidgetspage.json");
const dsl = require("../../../../fixtures/tableNewDsl.json");
const pages = require("../../../../locators/Pages.json");
const testdata = require("../../../../fixtures/testdata.json");
describe("Table Widget property pane feature validation", function() {
@ -185,67 +183,71 @@ describe("Table Widget property pane feature validation", function() {
cy.get(".draggable-header:contains('Email Address')").should("be.visible");
cy.get(commonlocators.editPropBackButton).click({ force: true });
});
it("Edit Row height and test table for changes", function() {
cy.openPropertyPane("tablewidget");
cy.get(widgetsPage.rowHeight)
.last()
.click({ force: true });
cy.get(".t--dropdown-option")
.contains("Short")
.click({ force: true });
cy.wait(1000);
cy.readTabledataValidateCSS("0", "1", "height", "19px", true);
});
it("Test to validate text color and text background", function() {
// Open property pane
cy.openPropertyPane("tablewidget");
// Click on text color input field
cy.get(widgetsPage.textColor)
.first()
.click({ force: true });
// Select green color
cy.xpath(widgetsPage.greenColor).click();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.wait("@updateLayout");
// Verify the text color is green
cy.readTabledataValidateCSS("1", "0", "color", "rgb(3, 179, 101)");
// Change the text color and enter purple in input field
cy.get(widgetsPage.textColor)
.clear({ force: true })
.type("purple", { force: true });
cy.wait("@updateLayout");
// Verify the text color is purple
cy.readTabledataValidateCSS("1", "0", "color", "rgb(128, 0, 128)");
// Click on cell background color
cy.get(`${widgetsPage.cellBackground} input`)
.first()
.click({ force: true });
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
// select the green color
cy.xpath(widgetsPage.greenColor)
.first()
.click();
cy.wait("@updateLayout");
// Verify the cell background color is green
cy.readTabledataValidateCSS(
"1",
"0",
"background",
"rgb(3, 179, 101) none repeat scroll 0% 0% / auto padding-box border-box",
);
// Change the cell background color and enter purple in input field
cy.get(`${widgetsPage.cellBackground} input`)
.clear({ force: true })
.type("purple", { force: true });
cy.wait("@updateLayout");
// Verify the cell background color is purple
cy.readTabledataValidateCSS(
"1",
"0",
"background",
"rgb(128, 0, 128) none repeat scroll 0% 0% / auto padding-box border-box",
);
});
// it("Edit Row height and test table for changes", function() {
// cy.openPropertyPane("tablewidget");
// cy.get(widgetsPage.rowHeight)
// .last()
// .click({ force: true });
// cy.get(".t--dropdown-option")
// .contains("Short")
// .click({ force: true });
// cy.wait(1000);
// cy.readTabledataValidateCSS("0", "1", "height", "19px", true);
// });
// it("Test to validate text color and text background", function() {
// // Open property pane
// cy.openPropertyPane("tablewidget");
// // Click on text color input field
// cy.get(widgetsPage.textColor)
// .first()
// .click({ force: true });
// // Select green color
// cy.xpath(widgetsPage.greenColor).click();
// // eslint-disable-next-line cypress/no-unnecessary-waiting
// cy.wait(500);
// cy.wait("@updateLayout");
// // Verify the text color is green
// cy.readTabledataValidateCSS("1", "0", "color", "rgb(3, 179, 101)");
// // Change the text color and enter purple in input field
// cy.get(widgetsPage.textColor)
// .scrollIntoView()
// .clear({ force: true })
// .type("purple", { force: true });
// cy.wait("@updateLayout");
// // Verify the text color is purple
// cy.readTabledataValidateCSS("1", "0", "color", "rgb(128, 0, 128)");
// // Click on cell background color
// cy.get(`${widgetsPage.cellBackground} input`)
// .first()
// .scrollIntoView()
// .click({ force: true });
// // eslint-disable-next-line cypress/no-unnecessary-waiting
// cy.wait(500);
// // select the green color
// cy.xpath(widgetsPage.greenColor)
// .first()
// .click();
// cy.wait("@updateLayout");
// // Verify the cell background color is green
// cy.readTabledataValidateCSS(
// "1",
// "0",
// "background",
// "rgb(3, 179, 101) none repeat scroll 0% 0% / auto padding-box border-box",
// );
// // Change the cell background color and enter purple in input field
// cy.get(`${widgetsPage.cellBackground} input`)
// .clear({ force: true })
// .type("purple", { force: true });
// cy.wait("@updateLayout");
// // Verify the cell background color is purple
// cy.readTabledataValidateCSS(
// "1",
// "0",
// "background",
// "rgb(128, 0, 128) none repeat scroll 0% 0% / auto padding-box border-box",
// );
// });
});

View File

@ -1,12 +1,14 @@
import { AggregateHelper } from "../../../../support/Pages/AggregateHelper";
import { JSEditor } from "../../../../support/Pages/JSEditor";
import { DataSources } from "../../../../support/Pages/DataSources";
import { CommonLocators } from "../../../../support/Objects/CommonLocators";
const agHelper = new AggregateHelper();
const jsEditor = new JSEditor();
const dataSources = new DataSources();
const locator = new CommonLocators();
describe("Validate Create Api and Bind to Table widget via JSObject", () => {
describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", () => {
before(() => {
cy.fixture('paramsDsl').then((val: any) => {
agHelper.AddDsl(val)
@ -15,7 +17,7 @@ describe("Validate Create Api and Bind to Table widget via JSObject", () => {
let guid: any;
it("1. [Bug] - 10784 : Passing params from JS to SQL query should not break", function () {
it("1. With Optional chaining : {{ this?.params?.condition }}", function () {
agHelper.NavigateToDSCreateNew()
dataSources.CreatePlugIn('PostgreSQL')
dataSources.FillPostgresDSForm();
@ -27,18 +29,297 @@ describe("Validate Create Api and Bind to Table widget via JSObject", () => {
cy.log("ds name is :" + guid)
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params")
agHelper.RenameWithInPane("Params1")
agHelper.EnterValue("SELECT * FROM public.users where id = {{this?.params?.condition || '1=1'}} order by id");
jsEditor.CreateJSObject('Params.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
jsEditor.CreateJSObject('Params1.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
})
agHelper.SelectEntityByName("WIDGETS")
agHelper.SelectEntityByName("Table1") //tabledata
jsEditor.EnterJSContext('tabledata', "{{Params.data}}");
agHelper.SelectEntityByName("WIDGETS")
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params1.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('8');
});
agHelper.SelectDropDown("selectwidget", '7')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
});
it("2. With Optional chaining : {{ (function() { return this?.params?.condition })() }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params2")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(function() { return this?.params?.condition })() || '1=1'}} order by id");
jsEditor.CreateJSObject('Params2.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params2.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
agHelper.SelectDropDown("selectwidget", '9')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('9');
});
});
it("3. With Optional chaining : {{ (() => { return this?.params?.condition })() }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params3")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(() => { return this?.params?.condition })() || '1=1'}} order by id");
jsEditor.CreateJSObject('Params3.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params3.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('9');
});
agHelper.SelectDropDown("selectwidget", '8')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('8');
});
});
it("4. With Optional chaining : {{ this?.params.condition }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params4")
agHelper.EnterValue("SELECT * FROM public.users where id = {{this?.params.condition || '1=1'}} order by id");
jsEditor.CreateJSObject('Params4.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params4.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('8');
});
agHelper.SelectDropDown("selectwidget", '7')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
});
it("5. With Optional chaining : {{ (function() { return this?.params.condition })() }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params5")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(function() { return this?.params.condition })() || '1=1'}} order by id");
jsEditor.CreateJSObject('Params5.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params5.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
agHelper.SelectDropDown("selectwidget", '9')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('9');
});
});
it("6. With Optional chaining : {{ (() => { return this?.params.condition })() }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params6")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(() => { return this?.params.condition })() || '1=1'}} order by id");
jsEditor.CreateJSObject('Params6.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params6.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('9');
});
agHelper.SelectDropDown("selectwidget", '8')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('8');
});
});
it("7. With No Optional chaining : {{ this.params.condition }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params7")
agHelper.EnterValue("SELECT * FROM public.users where id = {{this.params.condition || '1=1'}} order by id");
jsEditor.CreateJSObject('Params7.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params7.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('8');
});
agHelper.SelectDropDown("selectwidget", '7')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
});
it("8. With No Optional chaining : {{ (function() { return this.params.condition })() }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params8")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(function() { return this.params.condition })() || '1=1'}} order by id");
jsEditor.CreateJSObject('Params8.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params8.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
agHelper.SelectDropDown("selectwidget", '9')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('9');
});
});
it("9. With No Optional chaining : {{ (() => { return this.params.condition })() }}", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params9")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(() => { return this.params.condition })() || '1=1'}} order by id");
jsEditor.CreateJSObject('Params9.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params9.data}}");
agHelper.ClickButton("Submit")
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('9');
});
agHelper.SelectDropDown("selectwidget", '8')
agHelper.Sleep(2000)
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('8');
});
});
it("10. With Optional chaining : {{ this?.params?.condition }} && no optional paramter passed", function () {
dataSources.NavigateToActiveDSQueryPane(guid);
agHelper.GetNClick(dataSources._templateMenu)
agHelper.RenameWithInPane("Params10")
agHelper.EnterValue("SELECT * FROM public.users where id = {{(() => { return this.params.condition })() || '7'}} order by id");
jsEditor.CreateJSObject('Params10.run(() => {},() => {},{"condition": selRecordFilter.selectedOptionValue})');
agHelper.SelectEntityByName("Button1")
cy.get("@jsObjName").then((jsObjName) => {
jsEditor.EnterJSContext('onclick', "{{" + jsObjName + ".myFun1()}}", true, true);
});
agHelper.SelectEntityByName("Table1")
jsEditor.EnterJSContext('tabledata', "{{Params10.data}}");
//When No selected option passed
cy.xpath(locator._selectWidgetDropdown("selectwidget")).within(() => cy.get(locator._crossBtn).click())
agHelper.ClickButton("Submit")
agHelper.Sleep(2000)
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
agHelper.ReadTableRowColumnData(0, 0).then((cellData) => {
expect(cellData).to.be.equal('7');
});
});
});

View File

@ -37,7 +37,7 @@ export class CommonLocators {
_entityNameEditing = (entityNameinLeftSidebar: string) => "//span[text()='" + entityNameinLeftSidebar + "']/parent::div[contains(@class, 't--entity-name editing')]/input"
_jsToggle = (controlToToggle: string) => ".t--property-control-" + controlToToggle + " .t--js-toggle"
_spanButton = (btnVisibleText: string) => "//span[text()='" + btnVisibleText + "']/parent::button"
_selectDropdown = (ddName: string) => "//div[contains(@class, 't--property-control-" + ddName + "')]//button"
_selectPropDropdown = (ddName: string) => "//div[contains(@class, 't--property-control-" + ddName + "')]//button"
_dropDownValue = (ddOption: string) => ".single-select:contains('" + ddOption + "')"
_actionTextArea = (actionName: string) => "//label[text()='" + actionName + "']/following-sibling::div//div[contains(@class, 'CodeMirror')]//textarea"
_existingDefaultTextInput = ".t--property-control-defaulttext .CodeMirror-code"
@ -46,8 +46,12 @@ export class CommonLocators {
_widgetInDeployed = (widgetType: string) => `.t--widget-${widgetType}`
_propertyToggle = (controlToToggle: string) => ".t--property-control-" + controlToToggle + " input[type='checkbox']"
_openNavigationTab = (tabToOpen: string) => `#switcher--${tabToOpen}`
_selectWidgetDropdown = (widgetType: string) => "//div[contains(@class, 't--draggable-" + widgetType + "')]//button"
_createNewPlgin = (pluginName: string) => ".t--plugin-name:contains('" + pluginName + "')"
_inputFieldByName = (fieldName: string) => "//p[text()='" + fieldName + "']/parent::label/following-sibling::div"
_evaluatedCurrentValue = "div:last-of-type .t--CodeEditor-evaluatedValue > div:last-of-type pre"
_tableRowColumn = (rowNum: number, colNum: number) => `.t--widget-tablewidget .tbody .td[data-rowindex=${rowNum}][data-colindex=${colNum}] div div`
_crossBtn = "span.cancel-icon"
_createNew = ".t--entity-add-btn.group.files"
}

View File

@ -43,7 +43,7 @@ export class AggregateHelper {
}
public NavigateToDSAdd() {
cy.get(locator._addNewDataSource).last()
cy.get(locator._addNewDataSource).last().scrollIntoView()
.should("be.visible")
.click({ force: true });
}
@ -71,7 +71,7 @@ export class AggregateHelper {
}
public SelectEntityByName(entityNameinLeftSidebar: string) {
cy.xpath(locator._entityNameInExplorer(entityNameinLeftSidebar))
cy.xpath(locator._entityNameInExplorer(entityNameinLeftSidebar), {timeout: 30000})
.last()
.click({ multiple: true })
this.Sleep()
@ -164,7 +164,7 @@ export class AggregateHelper {
}).then(() => this.Sleep(timeout))
}
public ValidateNetworkCallRespPost(aliasName: string, expectedRes = true) {
public ValidateNetworkExecutionSuccess(aliasName: string, expectedRes = true) {
cy.wait(aliasName).should(
"have.nested.property",
"response.body.data.isExecutionSuccess",
@ -172,6 +172,14 @@ export class AggregateHelper {
)
}
public ValidateNetworkStatus(aliasName: string, expectedRes = 200) {
cy.wait(aliasName).should(
"have.nested.property",
"response.body.responseMeta.status",
expectedRes,
)
}
public ValidateNetworkCallRespPut(aliasName: string, expectedStatus = 200) {
cy.wait(aliasName).should(
"have.nested.property",
@ -181,13 +189,22 @@ export class AggregateHelper {
}
public SelectPropertiesDropDown(endp: string, ddOption: string,) {
cy.xpath(locator._selectDropdown(endp))
cy.xpath(locator._selectPropDropdown(endp))
.first()
.scrollIntoView()
.click()
cy.get(locator._dropDownValue(ddOption)).click()
}
public SelectDropDown(endp: string, ddOption: string,) {
cy.xpath(locator._selectWidgetDropdown(endp))
.first()
.scrollIntoView()
.click()
cy.get(locator._dropDownValue(ddOption)).click({ force: true })
this.Sleep(2000)
}
public EnterActionValue(actionName: string, value: string, paste = true) {
cy.xpath(locator._actionTextArea(actionName))
.first()
@ -274,7 +291,8 @@ export class AggregateHelper {
}
public GetObjectName() {
cy.get(locator._queryName).invoke("text").then((text) => cy.wrap(text).as("queryName"));
//cy.get(locator._queryName).invoke("text").then((text) => cy.wrap(text).as("queryName")); or below syntax
return cy.get(locator._queryName).invoke("text");
}
public Sleep(timeout = 1000) {
@ -288,7 +306,6 @@ export class AggregateHelper {
cy.get(locator._homePageAppCreateBtn)
.should("be.visible")
.should("be.enabled");
//cy.get(this._homePageAppCreateBtn);
}
public CreateNewApplication() {
@ -364,4 +381,8 @@ export class AggregateHelper {
if ($text.text()) expect($text.text()).to.eq(currentValue);
});
}
public ReadTableRowColumnData(rowNum: number, colNum: number) {
return cy.get(locator._tableRowColumn(rowNum, colNum)).invoke("text");
}
}

View File

@ -1,6 +1,8 @@
import { AggregateHelper } from "./AggregateHelper";
import explorer from "../../locators/explorerlocators.json";
import { CommonLocators } from "../Objects/CommonLocators";
const agHelper = new AggregateHelper();
const locator = new CommonLocators()
export class ApiPage {
@ -15,16 +17,14 @@ export class ApiPage {
private _queryTimeout = "//input[@name='actionConfiguration.timeoutInMillisecond']"
private _apiTab = (tabValue: string) => "span:contains('" + tabValue + "')"
_responseBody = ".CodeMirror-code span.cm-string.cm-property"
private _blankAPI = "span:contains('New Blank API')"
CreateAndFillApi(url: string, apiname: string = "", queryTimeout = 30000) {
cy.get(explorer.createNew).click({ force: true });
cy.get(explorer.blankAPI).click({ force: true });
cy.wait("@createNewApi").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
cy.get(locator._createNew).click({ force: true });
cy.get(this._blankAPI).click({ force: true });
agHelper.ValidateNetworkStatus("@createNewApi", 201)
// cy.get("@createNewApi").then((response: any) => {
// expect(response.response.body.responseMeta.success).to.eq(true);
// cy.get(agHelper._actionName)
@ -35,6 +35,7 @@ export class ApiPage {
// expect(someText).to.equal(response.response.body.data.name);
// });
// }); // to check if Api1 = Api1 when Create Api invoked
if (apiname)
agHelper.RenameWithInPane(apiname)
cy.get(this._resourceUrl).should("be.visible");
@ -83,11 +84,7 @@ export class ApiPage {
RunAPI() {
cy.get(this._apiRunBtn).click({ force: true });
cy.wait("@postExecute").should(
"have.nested.property",
"response.body.data.isExecutionSuccess",
true,
);
agHelper.ValidateNetworkExecutionSuccess("@postExecute")
}
SetAPITimeout(timeout: number) {
@ -109,15 +106,15 @@ export class ApiPage {
}
ReadApiResponsebyKey(key: string) {
let apiResp: string = "";
cy.get(this._responseBody)
.contains(key)
.siblings("span")
.invoke("text")
.then((text) => {
apiResp = `${text.match(/"(.*)"/)![0].split('"').join("") } `;
cy.log("Key value in api response is :" + apiResp);
cy.wrap(apiResp).as("apiResp")
});
let apiResp: string = "";
cy.get(this._responseBody)
.contains(key)
.siblings("span")
.invoke("text")
.then((text) => {
apiResp = `${text.match(/"(.*)"/)![0].split('"').join("")} `;
cy.log("Key value in api response is :" + apiResp);
cy.wrap(apiResp).as("apiResp")
});
}
}

View File

@ -6,17 +6,15 @@ const agHelper = new AggregateHelper();
const locator = new CommonLocators();
export class JSEditor {
private _runButton =
"//li//*[local-name() = 'svg' and @class='run-button']/parent::li";
private _outputConsole = ".CodeEditorTarget";
private _jsObjName = ".t--js-action-name-edit-field span";
private _jsObjTxt = ".t--js-action-name-edit-field input";
private _addEntityJSEditor = ".t--entity-add-btn.group.files"
private _runButton = "//li//*[local-name() = 'svg' and @class='run-button']/parent::li"
private _outputConsole = ".CodeEditorTarget"
private _jsObjName = ".t--js-action-name-edit-field span"
private _jsObjTxt = ".t--js-action-name-edit-field input"
private _newJSobj = "span:contains('New JS Object')"
private _bindingsClose = ".t--entity-property-close"
public NavigateToJSEditor() {
cy.get(this._addEntityJSEditor)
cy.get(locator._createNew)
.last()
.click({ force: true });
cy.get(this._newJSobj).click({ force: true });
@ -46,8 +44,10 @@ export class JSEditor {
}
});
agHelper.WaitAutoSave()//Ample wait due to open bug # 10284
agHelper.Sleep(5000)//Ample wait due to open bug # 10284
//clicking 2 times each with interval of 1 second!
//clicking 1 times & waits for 3 second for result to be populated!
Cypress._.times(1, () => {
cy.xpath(this._runButton)
.first()
@ -62,8 +62,14 @@ export class JSEditor {
public EnterJSContext(endp: string, value: string, paste = true, toToggleOnJS = false) {
if (toToggleOnJS) {
cy.get(locator._jsToggle(endp))
.first()
.click({ force: true });
.invoke("attr", "class")
.then((classes: any) => {
if (!classes.includes("is-active")) {
cy.get(locator._jsToggle(endp))
.first()
.click({ force: true });
}
});
}
cy.get(locator._propertyControl + endp + " " + locator._codeMirrorTextArea)
.first()
@ -140,5 +146,5 @@ export class JSEditor {
});
cy.get(this._bindingsClose).click({ force: true });
}
}