fix: prevent temporary update of sub-path value in store object (#14847)

* support paths as keys in storevalue

* add cypresstests

* StoreValue added deploy mode verification

* Adding array input [boolean, string, number]

* store number too

* Added bug id to title

* Added dot object array & SelectJSFunctionToExecute

* propPane.UpdateFieldValue() update

* updated UpdatePropertyFieldValue

* JS toasts handling

* JSOnload spec fix

* JsOnload toast appearances fix

* support paths as keys in storevalue

* add cypresstests

* StoreValue added deploy mode verification

* Adding array input [boolean, string, number]

* store number too

* Added bug id to title

* Added dot object array & SelectJSFunctionToExecute

* propPane.UpdateFieldValue() update

* updated UpdatePropertyFieldValue

* JS toasts handling

* JSOnload spec fix

* JsOnload toast appearances fix

* prevent modification of storeValue path in temporary store

* Add cypress tests for case where storeValue key is a path

* remove redundant import of lodash

* Modify cypress tests

* update cypress tests

* Store fix revert

* revert

* Actions revert

* revert redundant change

* removed additional button- from script

* JsOnPage load script fix

* validate toast fixes

Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
This commit is contained in:
Favour Ohanekwu 2022-07-01 06:26:57 +01:00 committed by GitHub
parent cc3b10c9a6
commit 11f8684e7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 276 additions and 121 deletions

View File

@ -119,7 +119,7 @@ describe("AForce - Community Issues page validations", function() {
}); });
it("4. Change Default selected row in table and verify", () => { it("4. Change Default selected row in table and verify", () => {
jsEditor.EnterJSContext("Default Selected Row", "1"); propPane.UpdatePropertyFieldValue("Default Selected Row", "1");
deployMode.DeployApp(); deployMode.DeployApp();
table.WaitUntilTableLoad(); table.WaitUntilTableLoad();
table.AssertPageNumber(1); table.AssertPageNumber(1);

View File

@ -1,15 +1,23 @@
import { ObjectsRegistry } from "../../../../support/Objects/Registry"; import { ObjectsRegistry } from "../../../../support/Objects/Registry";
const { AggregateHelper: agHelper, JSEditor: jsEditor } = ObjectsRegistry; const {
AggregateHelper: agHelper,
EntityExplorer: ee,
JSEditor: jsEditor,
CommonLocators: locator,
DeployMode: deployMode,
PropertyPane: propPane,
} = ObjectsRegistry;
describe("storeValue Action test", () => { describe("storeValue Action test", () => {
before(() => { before(() => {
// ee.DragDropWidgetNVerify("buttonwidget", 100, 100);
ee.NavigateToSwitcher("explorer");
}); });
it("1. Bug 14653: Running consecutive storeValue actions and await", function() { it("1. Bug 14653: Running consecutive storeValue actions and await", function() {
const jsObjectBody = `export default { const jsObjectBody = `export default {
myFun1: () => { storeTest: () => {
let values = let values =
[ [
storeValue('val1', 'number 1'), storeValue('val1', 'number 1'),
@ -33,15 +41,162 @@ describe("storeValue Action test", () => {
toRun: false, toRun: false,
shouldCreateNewJSObj: true, shouldCreateNewJSObj: true,
}); });
agHelper.WaitUntilToastDisappear('created successfully')
agHelper.GetNClick(jsEditor._runButton); ee.SelectEntityByName("Button1", "WIDGETS");
agHelper.ValidateToastMessage( propPane.UpdatePropertyFieldValue("Label", "StoreTest");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"storeTest",
);
});
deployMode.DeployApp();
agHelper.ClickButton("StoreTest");
agHelper.WaitUntilToastDisappear(
JSON.stringify({ JSON.stringify({
val1: "number 1", val1: "number 1",
val2: "number 2", val2: "number 2",
val3: "number 3", val3: "number 3",
val4: "number 4", val4: "number 4",
}), 2 }),
); );
deployMode.NavigateBacktoEditor();
});
it("2. Bug 14827 : Accepts paths as keys and doesn't update paths in store but creates a new field with path as key", function() {
const DEFAULT_STUDENT_OBJECT = {
details: { isTopper: true, name: "Abhah", grade: 1 },
};
const MODIFIED_STUDENT_OBJECT = {
details: { isTopper: false, name: "Alia", grade: 3 },
};
const JS_OBJECT_BODY = `export default {
storePathTest: async ()=> {
await storeValue("student", ${JSON.stringify(
DEFAULT_STUDENT_OBJECT,
)}, false)
await showAlert(JSON.stringify(appsmith.store.student));
await storeValue("student.details.name", "Annah", false);
await showAlert(appsmith.store.student.details.name);
await showAlert(appsmith.store["student.details.name"]);
},
modifyStorePathTest: async ()=>{
await storeValue("student",${JSON.stringify(
MODIFIED_STUDENT_OBJECT,
)} , false)
await showAlert(JSON.stringify(appsmith.store.student));
await storeValue("student.details.isTopper", true, false);
await showAlert(appsmith.store.student.details.isTopper.toString());
await showAlert(appsmith.store["student.details.isTopper"].toString());
}
}
`;
// Create js object
jsEditor.CreateJSObject(JS_OBJECT_BODY, {
paste: true,
completeReplace: true,
toRun: false,
shouldCreateNewJSObj: true,
});
// Button1
ee.SelectEntityByName("Button1", "WIDGETS");
propPane.UpdatePropertyFieldValue("Label", "StorePathTest");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"storePathTest",
);
});
// Button 2
ee.DragDropWidgetNVerify("buttonwidget", 100, 200);
ee.SelectEntityByName("Button2", "WIDGETS");
propPane.UpdatePropertyFieldValue("Label", "modifyStorePathTest");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"modifyStorePathTest",
);
});
deployMode.DeployApp();
agHelper.ClickButton("StorePathTest");
agHelper.ValidateToastMessage(JSON.stringify(DEFAULT_STUDENT_OBJECT), 0, 1);
agHelper.ValidateToastMessage(DEFAULT_STUDENT_OBJECT.details.name, 1, 2);
agHelper.WaitUntilToastDisappear("Annah", 2, 3);
agHelper.ClickButton("modifyStorePathTest");
agHelper.ValidateToastMessage(
JSON.stringify(MODIFIED_STUDENT_OBJECT.details),
0,
1,
);
agHelper.ValidateToastMessage(
`${MODIFIED_STUDENT_OBJECT.details.isTopper}`,
1,
2,
);
agHelper.WaitUntilToastDisappear(`true`, 2, 3);
deployMode.NavigateBacktoEditor();
});
it("3. Bug 14827 : Accepts paths as keys and doesn't update paths in store but creates a new field with path as key - object keys", function() {
const TEST_OBJECT = { a: 1, two: {} };
const JS_OBJECT_BODY = `export default {
setStore: async () => {
await storeValue("test", ${JSON.stringify(TEST_OBJECT)}, false);
await showAlert(JSON.stringify(appsmith.store.test));
await storeValue("test.two",{"b":2}, false);
await showAlert(JSON.stringify(appsmith.store.test.two));
await showAlert(JSON.stringify(appsmith.store["test.two"]));
},
showStore: () => {
showAlert(JSON.stringify(appsmith.store.test));}
}`;
// create js object
jsEditor.CreateJSObject(JS_OBJECT_BODY, {
paste: true,
completeReplace: true,
toRun: false,
shouldCreateNewJSObj: true,
});
ee.SelectEntityByName("Button1", "WIDGETS");
propPane.UpdatePropertyFieldValue("Label", "SetStore");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"setStore",
);
});
ee.SelectEntityByName("Button2", "WIDGETS");
propPane.UpdatePropertyFieldValue("Label", "ShowStore");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"showStore",
);
});
deployMode.DeployApp();
agHelper.ClickButton("SetStore");
agHelper.ValidateToastMessage(JSON.stringify(TEST_OBJECT), 0, 1);
agHelper.ValidateToastMessage(JSON.stringify(TEST_OBJECT.two), 1, 2);
agHelper.WaitUntilToastDisappear(`{"b":2}`, 2, 3);
agHelper.ClickButton("ShowStore");
agHelper.ValidateToastMessage(JSON.stringify(TEST_OBJECT), 0);
deployMode.NavigateBacktoEditor();
}); });
}); });

View File

@ -4,7 +4,8 @@ let agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, jsEditor = ObjectsRegistry.JSEditor,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
describe("Validate JSObjects binding to Input widget", () => { describe("Validate JSObjects binding to Input widget", () => {
before(() => { before(() => {
@ -40,7 +41,7 @@ describe("Validate JSObjects binding to Input widget", () => {
.should("equal", "Hello"); //Before mapping JSObject value of input .should("equal", "Hello"); //Before mapping JSObject value of input
cy.get("@jsObjName").then((jsObjName) => { cy.get("@jsObjName").then((jsObjName) => {
jsOjbNameReceived = jsObjName; jsOjbNameReceived = jsObjName;
jsEditor.EnterJSContext("Default Text", "{{" + jsObjName + ".myFun1()}}"); propPane.UpdatePropertyFieldValue("Default Text", "{{" + jsObjName + ".myFun1()}}");
}); });
cy.get(locator._inputWidget) cy.get(locator._inputWidget)
.last() .last()

View File

@ -7,7 +7,8 @@ let agHelper = ObjectsRegistry.AggregateHelper,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
apiPage = ObjectsRegistry.ApiPage, apiPage = ObjectsRegistry.ApiPage,
table = ObjectsRegistry.Table, table = ObjectsRegistry.Table,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
describe("Validate JSObj binding to Table widget", () => { describe("Validate JSObj binding to Table widget", () => {
before(() => { before(() => {
@ -43,7 +44,7 @@ describe("Validate JSObj binding to Table widget", () => {
it("2. Validate the Api data is updated on List widget + Bug 12438", function() { it("2. Validate the Api data is updated on List widget + Bug 12438", function() {
ee.SelectEntityByName("List1", "WIDGETS"); ee.SelectEntityByName("List1", "WIDGETS");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Items", "Items",
(("{{" + jsName) as string) + ".myFun1()}}", (("{{" + jsName) as string) + ".myFun1()}}",
); );
@ -75,7 +76,7 @@ describe("Validate JSObj binding to Table widget", () => {
it("3. Validate the List widget + Bug 12438 ", function() { it("3. Validate the List widget + Bug 12438 ", function() {
ee.SelectEntityByName("List1", "WIDGETS"); ee.SelectEntityByName("List1", "WIDGETS");
jsEditor.EnterJSContext("Item Spacing (px)", "50"); propPane.UpdatePropertyFieldValue("Item Spacing (px)", "50");
cy.get(locator._textWidget).should("have.length", 6); cy.get(locator._textWidget).should("have.length", 6);
deployMode.DeployApp(locator._textWidgetInDeployed); deployMode.DeployApp(locator._textWidgetInDeployed);
agHelper.AssertElementLength(locator._textWidgetInDeployed, 6); agHelper.AssertElementLength(locator._textWidgetInDeployed, 6);

View File

@ -3,7 +3,7 @@ import { ObjectsRegistry } from "../../../../support/Objects/Registry"
let dataSet: any; let dataSet: any;
let agHelper = ObjectsRegistry.AggregateHelper, let agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -21,13 +21,13 @@ describe("Loadash basic test with input Widget", () => {
it("1. Input widget test with default value for atob method", () => { it("1. Input widget test with default value for atob method", () => {
ee.SelectEntityByName("Input1", 'WIDGETS') ee.SelectEntityByName("Input1", 'WIDGETS')
jsEditor.EnterJSContext("Default Text", dataSet.defaultInputBinding + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.defaultInputBinding + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
}); });
it("2. Input widget test with default value for btoa method", function () { it("2. Input widget test with default value for btoa method", function () {
ee.SelectEntityByName("Input2") ee.SelectEntityByName("Input2")
jsEditor.EnterJSContext("Default Text", dataSet.loadashInput + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.loadashInput + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
}); });

View File

@ -3,7 +3,7 @@ import { ObjectsRegistry } from "../../../../support/Objects/Registry"
let dataSet: any; let dataSet: any;
let agHelper = ObjectsRegistry.AggregateHelper, let agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -21,13 +21,13 @@ describe("Validate basic binding of Input widget to Input widget", () => {
it("1. Input widget test with default value from another Input widget", () => { it("1. Input widget test with default value from another Input widget", () => {
ee.SelectEntityByName("Input1", 'WIDGETS') ee.SelectEntityByName("Input1", 'WIDGETS')
jsEditor.EnterJSContext("Default Text", dataSet.defaultInputBinding + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.defaultInputBinding + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
}); });
it("2. Binding second input widget with first input widget and validating", function () { it("2. Binding second input widget with first input widget and validating", function () {
ee.SelectEntityByName("Input2") ee.SelectEntityByName("Input2")
jsEditor.EnterJSContext("Default Text", dataSet.momentInput + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.momentInput + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
}); });

View File

@ -5,7 +5,8 @@ let agHelper = ObjectsRegistry.AggregateHelper,
jsEditor = ObjectsRegistry.JSEditor, jsEditor = ObjectsRegistry.JSEditor,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
apiPage = ObjectsRegistry.ApiPage, apiPage = ObjectsRegistry.ApiPage,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
describe("Validate basic Promises", () => { describe("Validate basic Promises", () => {
it("1. Verify storeValue via .then via direct Promises", () => { it("1. Verify storeValue via .then via direct Promises", () => {
@ -111,7 +112,7 @@ describe("Validate basic Promises", () => {
true, true,
); );
ee.SelectEntityByName("Image1"); ee.SelectEntityByName("Image1");
jsEditor.EnterJSContext("Image", `{{Christmas.data}}`, true); propPane.UpdatePropertyFieldValue("Image", `{{Christmas.data}}`);
agHelper.ValidateToastMessage( agHelper.ValidateToastMessage(
"will be executed automatically on page load", "will be executed automatically on page load",
); );
@ -184,7 +185,7 @@ return InspiringQuotes.run().then((res) => { showAlert("Today's quote for " + us
"GetAnime", "GetAnime",
); );
ee.SelectEntityByName("List1", "WIDGETS"); ee.SelectEntityByName("List1", "WIDGETS");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Items", "Items",
`[{ `[{
"name": {{ GetAnime.data.results[0].title }}, "name": {{ GetAnime.data.results[0].title }},
@ -200,9 +201,7 @@ return InspiringQuotes.run().then((res) => { showAlert("Today's quote for " + us
"name": {{ GetAnime.data.results[2].title }}, "name": {{ GetAnime.data.results[2].title }},
"img": {{ GetAnime.data.results[2].image_url }}, "img": {{ GetAnime.data.results[2].image_url }},
"synopsis": {{ GetAnime.data.results[2].synopsis }} "synopsis": {{ GetAnime.data.results[2].synopsis }}
}]`, }]`);
true,
);
agHelper.ValidateToastMessage( agHelper.ValidateToastMessage(
"will be executed automatically on page load", "will be executed automatically on page load",
); //Validating 'Run API on Page Load' is set once api response is mapped ); //Validating 'Run API on Page Load' is set once api response is mapped

View File

@ -3,7 +3,7 @@ import { ObjectsRegistry } from "../../../../support/Objects/Registry"
let dataSet: any; let dataSet: any;
let agHelper = ObjectsRegistry.AggregateHelper, let agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -21,14 +21,14 @@ describe("Validate basic binding of Input widget to Input widget", () => {
it("1. Input widget test with default value for atob method", () => { it("1. Input widget test with default value for atob method", () => {
ee.SelectEntityByName("Input1", 'WIDGETS') ee.SelectEntityByName("Input1", 'WIDGETS')
jsEditor.EnterJSContext("Default Text", dataSet.atobInput + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.atobInput + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
cy.get(locator._inputWidget).first().invoke("attr", "value").should("equal", 'A');//Before mapping JSObject value of input cy.get(locator._inputWidget).first().invoke("attr", "value").should("equal", 'A');//Before mapping JSObject value of input
}); });
it("2. Input widget test with default value for btoa method", function () { it("2. Input widget test with default value for btoa method", function () {
ee.SelectEntityByName("Input2") ee.SelectEntityByName("Input2")
jsEditor.EnterJSContext("Default Text", dataSet.btoaInput + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.btoaInput + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
cy.get(locator._inputWidget).last().invoke("attr", "value").should("equal", 'QQ==');//Before mapping JSObject value of input cy.get(locator._inputWidget).last().invoke("attr", "value").should("equal", 'QQ==');//Before mapping JSObject value of input
}); });

View File

@ -56,16 +56,16 @@ describe("[Bug]: The data from the query does not show up on the widget #14299",
); );
ee.SelectEntityByName("Table1"); ee.SelectEntityByName("Table1");
jsEditor.EnterJSContext("Table Data", `{{JSObject1.runAstros.data}}`); propPane.UpdatePropertyFieldValue("Table Data", `{{JSObject1.runAstros.data}}`);
ee.SelectEntityByName("DatePicker1"); ee.SelectEntityByName("DatePicker1");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Default Date", "Default Date",
`{{moment(Table1.selectedRow.date_of_death)}}`, `{{moment(Table1.selectedRow.date_of_death)}}`,
); );
ee.SelectEntityByName("Text1"); ee.SelectEntityByName("Text1");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Text", "Text",
`Date: {{moment(Table1.selectedRow.date_of_death).toString()}}`, `Date: {{moment(Table1.selectedRow.date_of_death).toString()}}`,
); );

View File

@ -3,7 +3,7 @@ import { ObjectsRegistry } from "../../../../support/Objects/Registry"
let dataSet: any, dsl: any; let dataSet: any, dsl: any;
let agHelper = ObjectsRegistry.AggregateHelper, let agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -22,13 +22,13 @@ describe("Input widget test with default value from chart datapoint", () => {
it("1. Chart widget - Input widget test with default value from another Input widget", () => { it("1. Chart widget - Input widget test with default value from another Input widget", () => {
ee.SelectEntityByName("Input1", 'WIDGETS') ee.SelectEntityByName("Input1", 'WIDGETS')
jsEditor.EnterJSContext("Default Text", dataSet.bindChartData + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.bindChartData + "}}");
agHelper.ValidateNetworkStatus('@updateLayout') agHelper.ValidateNetworkStatus('@updateLayout')
ee.SelectEntityByName("Chart1") ee.SelectEntityByName("Chart1")
agHelper.SelectPropertiesDropDown("ondatapointclick", "Show message") agHelper.SelectPropertiesDropDown("ondatapointclick", "Show message")
agHelper.EnterActionValue("Message", dataSet.bindingDataPoint) agHelper.EnterActionValue("Message", dataSet.bindingDataPoint)
ee.SelectEntityByName("Input2") ee.SelectEntityByName("Input2")
jsEditor.EnterJSContext("Default Text", dataSet.bindingSeriesTitle + "}}"); propPane.UpdatePropertyFieldValue("Default Text", dataSet.bindingSeriesTitle + "}}");
deployMode.DeployApp() deployMode.DeployApp()
agHelper.Sleep(1500)//waiting for chart to load! agHelper.Sleep(1500)//waiting for chart to load!
agHelper.GetNClick("//*[local-name()='rect']", 13) agHelper.GetNClick("//*[local-name()='rect']", 13)

View File

@ -3,7 +3,7 @@ import { ObjectsRegistry } from "../../../../support/Objects/Registry";
let dataSet: any; let dataSet: any;
const agHelper = ObjectsRegistry.AggregateHelper, const agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
table = ObjectsRegistry.Table, table = ObjectsRegistry.Table,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -16,16 +16,15 @@ describe("Verify various Table property bugs", function () {
it("1. Adding Data to Table Widget", function () { it("1. Adding Data to Table Widget", function () {
ee.DragDropWidgetNVerify("tablewidget", 250, 250); ee.DragDropWidgetNVerify("tablewidget", 250, 250);
jsEditor.EnterJSContext("Table Data", JSON.stringify(dataSet.TableURLColumnType)); propPane.UpdatePropertyFieldValue("Table Data", JSON.stringify(dataSet.TableURLColumnType));
agHelper.ValidateNetworkStatus("@updateLayout", 200); agHelper.ValidateNetworkStatus("@updateLayout", 200);
cy.get('body').type("{esc}"); cy.get('body').type("{esc}");
}); });
it("2. Bug 13299 - Verify Display Text does not contain garbage value for URL column type when empty", function () { it("2. Bug 13299 - Verify Display Text does not contain garbage value for URL column type when empty", function () {
table.ChangeColumnType('image', 'URL') table.ChangeColumnType('image', 'URL')
jsEditor.EnterJSContext("Display Text", propPane.UpdatePropertyFieldValue("Display Text",
`{{currentRow.image.toString().includes('7') ? currentRow.image.toString().split('full/')[1] : "" }}`, `{{currentRow.image.toString().includes('7') ? currentRow.image.toString().split('full/')[1] : "" }}`)
true)
deployMode.DeployApp() deployMode.DeployApp()
@ -58,9 +57,8 @@ describe("Verify various Table property bugs", function () {
ee.SelectEntityByName("Table1", 'WIDGETS') ee.SelectEntityByName("Table1", 'WIDGETS')
agHelper.GetNClick(table._columnSettings('image')) agHelper.GetNClick(table._columnSettings('image'))
jsEditor.EnterJSContext("Display Text", propPane.UpdatePropertyFieldValue("Display Text",
`{{currentRow.image.toString().includes('7') ? currentRow.image.toString().split('full/')[1] : null }}`, `{{currentRow.image.toString().includes('7') ? currentRow.image.toString().split('full/')[1] : null }}`)
true)
deployMode.DeployApp() deployMode.DeployApp()
@ -91,9 +89,8 @@ describe("Verify various Table property bugs", function () {
ee.SelectEntityByName("Table1", 'WIDGETS') ee.SelectEntityByName("Table1", 'WIDGETS')
agHelper.GetNClick(table._columnSettings('image')) agHelper.GetNClick(table._columnSettings('image'))
jsEditor.EnterJSContext("Display Text", propPane.UpdatePropertyFieldValue("Display Text",
`{{currentRow.image.toString().includes('7') ? currentRow.image.toString().split('full/')[1] : undefined }}`, `{{currentRow.image.toString().includes('7') ? currentRow.image.toString().split('full/')[1] : undefined }}`)
true)
deployMode.DeployApp() deployMode.DeployApp()

View File

@ -3,7 +3,7 @@ import { ObjectsRegistry } from "../../../../support/Objects/Registry";
let dataSet: any; let dataSet: any;
const agHelper = ObjectsRegistry.AggregateHelper, const agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
table = ObjectsRegistry.Table, table = ObjectsRegistry.Table,
homePage = ObjectsRegistry.HomePage, homePage = ObjectsRegistry.HomePage,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -17,7 +17,7 @@ describe("Verify various Table_Filter combinations", function () {
it("1. Adding Data to Table Widget", function () { it("1. Adding Data to Table Widget", function () {
ee.DragDropWidgetNVerify("tablewidget", 250, 250); ee.DragDropWidgetNVerify("tablewidget", 250, 250);
jsEditor.EnterJSContext("Table Data", JSON.stringify(dataSet.TableInput)); propPane.UpdatePropertyFieldValue("Table Data", JSON.stringify(dataSet.TableInput));
agHelper.ValidateNetworkStatus("@updateLayout", 200); agHelper.ValidateNetworkStatus("@updateLayout", 200);
cy.get('body').type("{esc}"); cy.get('body').type("{esc}");
deployMode.DeployApp() deployMode.DeployApp()

View File

@ -5,7 +5,8 @@ let agHelper = ObjectsRegistry.AggregateHelper,
jsEditor = ObjectsRegistry.JSEditor, jsEditor = ObjectsRegistry.JSEditor,
apiPage = ObjectsRegistry.ApiPage, apiPage = ObjectsRegistry.ApiPage,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
describe("Validate API request body panel", () => { describe("Validate API request body panel", () => {
it("1. Check whether input and type dropdown selector exist when multi-part is selected", () => { it("1. Check whether input and type dropdown selector exist when multi-part is selected", () => {
@ -127,7 +128,7 @@ describe("Validate API request body panel", () => {
); );
ee.SelectEntityByName("Image1"); ee.SelectEntityByName("Image1");
jsEditor.EnterJSContext("Image", "{{CloudinaryUploadApi.data.url}}"); propPane.UpdatePropertyFieldValue("Image", "{{CloudinaryUploadApi.data.url}}");
ee.SelectEntityByName("CloudinaryUploadApi", "QUERIES/JS"); ee.SelectEntityByName("CloudinaryUploadApi", "QUERIES/JS");

View File

@ -9,8 +9,7 @@ let agHelper = ObjectsRegistry.AggregateHelper,
homePage = ObjectsRegistry.HomePage, homePage = ObjectsRegistry.HomePage,
dataSources = ObjectsRegistry.DataSources, dataSources = ObjectsRegistry.DataSources,
propPane = ObjectsRegistry.PropertyPane, propPane = ObjectsRegistry.PropertyPane,
deployMode = ObjectsRegistry.DeployMode, deployMode = ObjectsRegistry.DeployMode;
jsEditor = ObjectsRegistry.JSEditor;
describe("Validate MySQL Generate CRUD with JSON Form", () => { describe("Validate MySQL Generate CRUD with JSON Form", () => {
before(() => { before(() => {
@ -693,7 +692,7 @@ describe("Validate MySQL Generate CRUD with JSON Form", () => {
function updatingStoreJSONPropertyFileds() { function updatingStoreJSONPropertyFileds() {
propPane.ChangeJsonFormFieldType("Store Status", "Radio Group"); propPane.ChangeJsonFormFieldType("Store Status", "Radio Group");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Options", "Options",
`[{ `[{
"label": "Active", "label": "Active",

View File

@ -9,8 +9,7 @@ let agHelper = ObjectsRegistry.AggregateHelper,
homePage = ObjectsRegistry.HomePage, homePage = ObjectsRegistry.HomePage,
dataSources = ObjectsRegistry.DataSources, dataSources = ObjectsRegistry.DataSources,
propPane = ObjectsRegistry.PropertyPane, propPane = ObjectsRegistry.PropertyPane,
deployMode = ObjectsRegistry.DeployMode, deployMode = ObjectsRegistry.DeployMode;
jsEditor = ObjectsRegistry.JSEditor;
describe("Validate Postgres Generate CRUD with JSON Form", () => { describe("Validate Postgres Generate CRUD with JSON Form", () => {
before(() => { before(() => {
@ -803,7 +802,7 @@ describe("Validate Postgres Generate CRUD with JSON Form", () => {
propPane.NavigateBackToPropertyPane(); propPane.NavigateBackToPropertyPane();
propPane.ChangeJsonFormFieldType("Vessel Type", "Select"); propPane.ChangeJsonFormFieldType("Vessel Type", "Select");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Options", "Options",
`{{["Cargo", "Pleasure Craft", "Passenger", "Fishing", "Special Craft"].map(item=> {return { `{{["Cargo", "Pleasure Craft", "Passenger", "Fishing", "Special Craft"].map(item=> {return {
label: item, label: item,
@ -813,9 +812,9 @@ describe("Validate Postgres Generate CRUD with JSON Form", () => {
propPane.NavigateBackToPropertyPane(); propPane.NavigateBackToPropertyPane();
propPane.OpenJsonFormFieldSettings("Timezone"); propPane.OpenJsonFormFieldSettings("Timezone");
jsEditor.EnterJSContext("Min", "-10"); propPane.UpdatePropertyFieldValue("Min", "-10");
jsEditor.EnterJSContext("Max", "10"); propPane.UpdatePropertyFieldValue("Max", "10");
jsEditor.EnterJSContext("Error Message", "Not a valid timezone!"); propPane.UpdatePropertyFieldValue("Error Message", "Not a valid timezone!");
propPane.NavigateBackToPropertyPane(); propPane.NavigateBackToPropertyPane();
propPane.ChangeJsonFormFieldType("Eta Updated", "Datepicker"); propPane.ChangeJsonFormFieldType("Eta Updated", "Datepicker");

View File

@ -6,7 +6,8 @@ const jsEditor = ObjectsRegistry.JSEditor,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
table = ObjectsRegistry.Table, table = ObjectsRegistry.Table,
agHelper = ObjectsRegistry.AggregateHelper, agHelper = ObjectsRegistry.AggregateHelper,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
let onPageLoadAndConfirmExecuteFunctionsLength: number, let onPageLoadAndConfirmExecuteFunctionsLength: number,
getJSObject: any, getJSObject: any,
@ -172,9 +173,8 @@ describe("JS Function Execution", function() {
toRun: false, toRun: false,
shouldCreateNewJSObj: true, shouldCreateNewJSObj: true,
}); });
// Assert presence of toast message // Assert presence of toast message
agHelper.ValidateToastMessage(invalidJSObjectStartToastMessage); agHelper.WaitUntilToastDisappear(invalidJSObjectStartToastMessage);
// Assert presence of lint error at the start line // Assert presence of lint error at the start line
cy.get(locator._lintErrorElement) cy.get(locator._lintErrorElement)
@ -283,7 +283,7 @@ describe("JS Function Execution", function() {
cy.get("@jsObjName").then((jsObjName) => { cy.get("@jsObjName").then((jsObjName) => {
ee.SelectEntityByName("Table1", "WIDGETS"); ee.SelectEntityByName("Table1", "WIDGETS");
jsEditor.EnterJSContext("Table Data", `{{${jsObjName}.largeData}}`); propPane.UpdatePropertyFieldValue("Table Data", `{{${jsObjName}.largeData}}`);
}); });
// Deploy App and test that table loads properly // Deploy App and test that table loads properly
@ -338,7 +338,6 @@ describe("JS Function Execution", function() {
toRun: false, toRun: false,
shouldCreateNewJSObj: true, shouldCreateNewJSObj: true,
}); });
agHelper.WaitUntilToastDisappear("created successfully");
// change sync function name and test that cyclic dependency is not created // change sync function name and test that cyclic dependency is not created
jsEditor.EditJSObj(syncJSCodeWithRenamedFunction1); jsEditor.EditJSObj(syncJSCodeWithRenamedFunction1);
@ -352,7 +351,6 @@ describe("JS Function Execution", function() {
toRun: false, toRun: false,
shouldCreateNewJSObj: true, shouldCreateNewJSObj: true,
}); });
agHelper.WaitUntilToastDisappear("created successfully");
// change async function name and test that cyclic dependency is not created // change async function name and test that cyclic dependency is not created
jsEditor.EditJSObj(asyncJSCodeWithRenamedFunction1); jsEditor.EditJSObj(asyncJSCodeWithRenamedFunction1);
agHelper.AssertElementAbsence(locator._toastMsg); agHelper.AssertElementAbsence(locator._toastMsg);

View File

@ -9,7 +9,8 @@ const agHelper = ObjectsRegistry.AggregateHelper,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
homePage = ObjectsRegistry.HomePage, homePage = ObjectsRegistry.HomePage,
apiPage = ObjectsRegistry.ApiPage, apiPage = ObjectsRegistry.ApiPage,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
describe("JSObjects OnLoad Actions tests", function() { describe("JSObjects OnLoad Actions tests", function() {
before(() => { before(() => {
@ -55,7 +56,7 @@ describe("JSObjects OnLoad Actions tests", function() {
".getId.data}}", ".getId.data}}",
); );
ee.SelectEntityByName("Table1", "WIDGETS"); ee.SelectEntityByName("Table1", "WIDGETS");
jsEditor.EnterJSContext("Table Data", "{{GetUser.data}}"); propPane.UpdatePropertyFieldValue("Table Data", "{{GetUser.data}}");
agHelper.ValidateToastMessage( agHelper.ValidateToastMessage(
(("[" + jsName) as string) + (("[" + jsName) as string) +
".getId, GetUser] will be executed automatically on page load", ".getId, GetUser] will be executed automatically on page load",
@ -275,7 +276,7 @@ describe("JSObjects OnLoad Actions tests", function() {
// cy.get(locator._toastMsg).contains(regex) // cy.get(locator._toastMsg).contains(regex)
ee.SelectEntityByName("Input1", "WIDGETS"); ee.SelectEntityByName("Input1", "WIDGETS");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Default Text", "Default Text",
"{{" + jsObjName + ".callQuotes.data}}", "{{" + jsObjName + ".callQuotes.data}}",
); );
@ -285,12 +286,14 @@ describe("JSObjects OnLoad Actions tests", function() {
.and("contain", jsName as string) .and("contain", jsName as string)
.and("contain", "will be executed automatically on page load"); .and("contain", "will be executed automatically on page load");
agHelper.WaitUntilToastDisappear("Quotes");
ee.SelectEntityByName("Input2"); ee.SelectEntityByName("Input2");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Default Text", "Default Text",
"{{" + jsObjName + ".callTrump.data.message}}", "{{" + jsObjName + ".callTrump.data.message}}",
); );
agHelper.ValidateToastMessage( agHelper.WaitUntilToastDisappear(
(("[" + jsName) as string) + (("[" + jsName) as string) +
".callTrump] will be executed automatically on page load", ".callTrump] will be executed automatically on page load",
); );
@ -300,19 +303,19 @@ describe("JSObjects OnLoad Actions tests", function() {
//One Quotes confirmation - for API true //One Quotes confirmation - for API true
agHelper.AssertElementVisible(jsEditor._dialogBody("Quotes")); agHelper.AssertElementVisible(jsEditor._dialogBody("Quotes"));
agHelper.ClickButton("No"); agHelper.ClickButton("No");
agHelper.ValidateToastMessage('The action "Quotes" has failed'); agHelper.WaitUntilToastDisappear('The action "Quotes" has failed');
//Another for API called via JS callQuotes() //Another for API called via JS callQuotes()
agHelper.AssertElementVisible(jsEditor._dialogBody("Quotes")); agHelper.AssertElementVisible(jsEditor._dialogBody("Quotes"));
agHelper.ClickButton("No"); agHelper.ClickButton("No");
agHelper.ValidateToastMessage('The action "Quotes" has failed'); //agHelper.WaitUntilToastDisappear('The action "Quotes" has failed');No toast appears!
//Confirmation - first JSObj then API //Confirmation - first JSObj then API
agHelper.AssertElementVisible( agHelper.AssertElementVisible(
jsEditor._dialogBody((jsName as string) + ".callTrump"), jsEditor._dialogBody((jsName as string) + ".callTrump"),
); );
agHelper.ClickButton("No"); agHelper.ClickButton("No");
agHelper.ValidateToastMessage( agHelper.WaitUntilToastDisappear(
"Failed to execute actions during page load", "Failed to execute actions during page load",
); //When Confirmation is NO validate error toast! ); //When Confirmation is NO validate error toast!
agHelper.AssertElementAbsence(jsEditor._dialogBody("WhatTrumpThinks")); //Since JS call is NO, dependent API confirmation should not appear agHelper.AssertElementAbsence(jsEditor._dialogBody("WhatTrumpThinks")); //Since JS call is NO, dependent API confirmation should not appear
@ -468,7 +471,7 @@ describe("JSObjects OnLoad Actions tests", function() {
//jsEditor.EnableDisableAsyncFuncSettings("callCountry", false, true); Bug # 13826 //jsEditor.EnableDisableAsyncFuncSettings("callCountry", false, true); Bug # 13826
ee.SelectEntityByName("Select1", "WIDGETS"); ee.SelectEntityByName("Select1", "WIDGETS");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Options", "Options",
`{{ getCitiesList.data.map((row) => { `{{ getCitiesList.data.map((row) => {
return { label: row.city, value: row.city } return { label: row.city, value: row.city }
@ -505,7 +508,7 @@ describe("JSObjects OnLoad Actions tests", function() {
// agHelper.GetNClick(locator._dropDownValue("callBooks")); // agHelper.GetNClick(locator._dropDownValue("callBooks"));
ee.SelectEntityByName("JSONForm1"); ee.SelectEntityByName("JSONForm1");
jsEditor.EnterJSContext("Source Data", "{{getBooks.data}}"); propPane.UpdatePropertyFieldValue("Source Data", "{{getBooks.data}}");
//this toast is not coming due to existing JSON date errors but its made true at API //this toast is not coming due to existing JSON date errors but its made true at API
//agHelper.ValidateToastMessage("[getBooks] will be executed automatically on page load"); //agHelper.ValidateToastMessage("[getBooks] will be executed automatically on page load");
}); });

View File

@ -4,7 +4,7 @@ let dsl: any;
const agHelper = ObjectsRegistry.AggregateHelper, const agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
apiPage = ObjectsRegistry.ApiPage, apiPage = ObjectsRegistry.ApiPage,
jsEditor = ObjectsRegistry.JSEditor, propPane = ObjectsRegistry.PropertyPane,
locator = ObjectsRegistry.CommonLocators, locator = ObjectsRegistry.CommonLocators,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode;
@ -63,28 +63,22 @@ describe("Layout OnLoad Actions tests", function() {
//Adding dependency in right order matters! //Adding dependency in right order matters!
ee.ExpandCollapseEntity("WIDGETS"); ee.ExpandCollapseEntity("WIDGETS");
ee.SelectEntityByName("Image1"); ee.SelectEntityByName("Image1");
jsEditor.EnterJSContext("Image", `{{RandomFlora.data}}`, true); propPane.UpdatePropertyFieldValue("Image", `{{RandomFlora.data}}`);
ee.SelectEntityByName("Image2"); ee.SelectEntityByName("Image2");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Image", "Image",
`{{RandomUser.data.results[0].picture.large}}`, `{{RandomUser.data.results[0].picture.large}}`);
true,
);
ee.SelectEntityByName("Text1"); ee.SelectEntityByName("Text1");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Text", "Text",
`{{InspiringQuotes.data.quote.body}}\n--\n{{InspiringQuotes.data.quote.author}}\n`, `{{InspiringQuotes.data.quote.body}}\n--\n{{InspiringQuotes.data.quote.author}}\n`);
true,
);
ee.SelectEntityByName("Text2"); ee.SelectEntityByName("Text2");
jsEditor.EnterJSContext( propPane.UpdatePropertyFieldValue(
"Text", "Text",
`Hi, here is {{RandomUser.data.results[0].name.first}} & I'm {{RandomUser.data.results[0].dob.age}}'yo\nI live in {{RandomUser.data.results[0].location.country}}\nMy Suggestion : {{Suggestions.data.activity}}\n\nI'm {{Genderize.data.gender}}`, `Hi, here is {{RandomUser.data.results[0].name.first}} & I'm {{RandomUser.data.results[0].dob.age}}'yo\nI live in {{RandomUser.data.results[0].location.country}}\nMy Suggestion : {{Suggestions.data.activity}}\n\nI'm {{Genderize.data.gender}}`);
true,
);
// cy.url().then((url) => { // cy.url().then((url) => {
// const pageid = url.split("/")[4]?.split("-").pop(); // const pageid = url.split("/")[4]?.split("-").pop();

View File

@ -8,7 +8,8 @@ let agHelper = ObjectsRegistry.AggregateHelper,
ee = ObjectsRegistry.EntityExplorer, ee = ObjectsRegistry.EntityExplorer,
table = ObjectsRegistry.Table, table = ObjectsRegistry.Table,
apiPage = ObjectsRegistry.ApiPage, apiPage = ObjectsRegistry.ApiPage,
deployMode = ObjectsRegistry.DeployMode; deployMode = ObjectsRegistry.DeployMode,
propPane = ObjectsRegistry.PropertyPane;
describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", () => { describe("[Bug] - 10784 - Passing params from JS to SQL query should not break", () => {
before(() => { before(() => {
@ -54,7 +55,7 @@ describe("[Bug] - 10784 - Passing params from JS to SQL query should not break",
); );
}); });
ee.SelectEntityByName("Table1"); ee.SelectEntityByName("Table1");
jsEditor.EnterJSContext("Table Data", "{{ParamsTest.data}}"); propPane.UpdatePropertyFieldValue("Table Data", "{{ParamsTest.data}}");
ee.SelectEntityByName("ParamsTest", "QUERIES/JS"); ee.SelectEntityByName("ParamsTest", "QUERIES/JS");
apiPage.ToggleOnPageLoadRun(false); //Bug 12476 apiPage.ToggleOnPageLoadRun(false); //Bug 12476

View File

@ -45,7 +45,7 @@ export class CommonLocators {
_entityNameEditing = (entityNameinLeftSidebar: string) => "//span[text()='" + entityNameinLeftSidebar + "']/parent::div[contains(@class, 't--entity-name editing')]/input" _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" _jsToggle = (controlToToggle: string) => ".t--property-control-" + controlToToggle + " .t--js-toggle"
_spanButton = (btnVisibleText: string) => "//span[text()='" + btnVisibleText + "']/parent::button" _spanButton = (btnVisibleText: string) => "//span[text()='" + btnVisibleText + "']/parent::button"
_selectPropDropdown = (ddName: string) => "//div[contains(@class, 't--property-control-" + ddName + "')]//button[contains(@class, 't--open-dropdown-Select-Action')]" _selectPropDropdown = (ddName: string) => "//div[contains(@class, 't--property-control-" + ddName.replace(/ +/g, "").toLowerCase() + "')]//button[contains(@class, 't--open-dropdown-Select-Action')]"
_dropDownValue = (dropdownOption: string) => ".single-select:contains('" + dropdownOption + "')" _dropDownValue = (dropdownOption: string) => ".single-select:contains('" + dropdownOption + "')"
_selectOptionValue = (dropdownOption: string) => ".menu-item-link:contains('" + dropdownOption + "')" _selectOptionValue = (dropdownOption: string) => ".menu-item-link:contains('" + dropdownOption + "')"
_selectedDropdownValue = "//button[contains(@class, 'select-button')]/span[@class='bp3-button-text']" _selectedDropdownValue = "//button[contains(@class, 'select-button')]/span[@class='bp3-button-text']"

View File

@ -110,9 +110,10 @@ export class AggregateHelper {
}); });
} }
public ValidateToastMessage(text: string, length = 1) { public ValidateToastMessage(text: string, index = 0, length = 1) {
cy.get(this.locator._toastMsg).should("have.length.at.least", length);
cy.get(this.locator._toastMsg) cy.get(this.locator._toastMsg)
.should("have.length", length) .eq(index)
.should("contain.text", text); .should("contain.text", text);
} }
@ -138,7 +139,8 @@ export class AggregateHelper {
}); });
} }
public WaitUntilToastDisappear(msgToCheckforDisappearance: string | "") { public WaitUntilToastDisappear(msgToCheckforDisappearance: string | "", index = 0 , length = 1) {
this.ValidateToastMessage(msgToCheckforDisappearance, index, length);
cy.waitUntil(() => cy.get(this.locator._toastMsg), { cy.waitUntil(() => cy.get(this.locator._toastMsg), {
errorMsg: msgToCheckforDisappearance + " did not disappear", errorMsg: msgToCheckforDisappearance + " did not disappear",
timeout: 5000, timeout: 5000,
@ -511,6 +513,7 @@ export class AggregateHelper {
if (action == "Delete") { if (action == "Delete") {
!jsDelete && this.ValidateNetworkStatus("@deleteAction"); !jsDelete && this.ValidateNetworkStatus("@deleteAction");
jsDelete && this.ValidateNetworkStatus("@deleteJSCollection"); jsDelete && this.ValidateNetworkStatus("@deleteJSCollection");
jsDelete && this.WaitUntilToastDisappear("deleted successfully");
} }
} }
@ -528,14 +531,7 @@ export class AggregateHelper {
options: IEnterValue = DEFAULT_ENTERVALUE_OPTIONS, options: IEnterValue = DEFAULT_ENTERVALUE_OPTIONS,
) { ) {
const { directInput, inputFieldName, propFieldName } = options; const { directInput, inputFieldName, propFieldName } = options;
if (propFieldName && directInput && !inputFieldName) {
if (propFieldName && !directInput && !inputFieldName) {
cy.xpath(this.locator._existingFieldTextByName(propFieldName)).then(
($field: any) => {
this.UpdateCodeInput($field, valueToEnter);
},
);
} else if (propFieldName && directInput && !inputFieldName) {
cy.get(propFieldName).then(($field: any) => { cy.get(propFieldName).then(($field: any) => {
this.UpdateCodeInput($field, valueToEnter); this.UpdateCodeInput($field, valueToEnter);
}); });

View File

@ -51,6 +51,7 @@ export class EntityExplorer {
entityNameinLeftSidebar: string, entityNameinLeftSidebar: string,
section: "WIDGETS" | "QUERIES/JS" | "DATASOURCES" | "" = "", section: "WIDGETS" | "QUERIES/JS" | "DATASOURCES" | "" = "",
) { ) {
this.NavigateToSwitcher("explorer");
if (section) this.ExpandCollapseEntity(section); //to expand respective section if (section) this.ExpandCollapseEntity(section); //to expand respective section
cy.xpath(this._entityNameInExplorer(entityNameinLeftSidebar)) cy.xpath(this._entityNameInExplorer(entityNameinLeftSidebar))
.last() .last()

View File

@ -17,6 +17,7 @@ export class JSEditor {
public agHelper = ObjectsRegistry.AggregateHelper; public agHelper = ObjectsRegistry.AggregateHelper;
public locator = ObjectsRegistry.CommonLocators; public locator = ObjectsRegistry.CommonLocators;
public ee = ObjectsRegistry.EntityExplorer; public ee = ObjectsRegistry.EntityExplorer;
public propPane = ObjectsRegistry.PropertyPane;
//#region Element locators //#region Element locators
_runButton = "button.run-js-action"; _runButton = "button.run-js-action";
@ -109,7 +110,7 @@ export class JSEditor {
cy.get(this._jsObjTxt).should("not.exist"); cy.get(this._jsObjTxt).should("not.exist");
//cy.waitUntil(() => cy.get(this.locator._toastMsg).should('not.be.visible')) // fails sometimes //cy.waitUntil(() => cy.get(this.locator._toastMsg).should('not.be.visible')) // fails sometimes
//this.agHelper.WaitUntilToastDisappear('created successfully') this.agHelper.WaitUntilToastDisappear("created successfully"); //to not hinder with other toast msgs!
this.agHelper.Sleep(); this.agHelper.Sleep();
} }
@ -153,22 +154,19 @@ export class JSEditor {
} else { } else {
input.type(JSCode, { input.type(JSCode, {
parseSpecialCharSequences: false, parseSpecialCharSequences: false,
delay: 150, delay: 100,
force: true, force: true,
}); });
} }
}); });
this.agHelper.AssertAutoSave(); //Ample wait due to open bug # 10284 this.agHelper.AssertAutoSave(); //Ample wait due to open bug # 10284
//this.agHelper.Sleep(5000)//Ample wait due to open bug # 10284
if (toRun) { if (toRun) {
//clicking 1 times & waits for 3 second for result to be populated! //clicking 1 times & waits for 2 second for result to be populated!
Cypress._.times(1, () => { Cypress._.times(1, () => {
cy.get(this._runButton) this.agHelper.GetNClick(this._runButton);
.first() this.agHelper.Sleep(2000);
.click()
.wait(3000);
}); });
cy.get(this.locator._empty).should("not.exist"); cy.get(this.locator._empty).should("not.exist");
} }
@ -191,7 +189,6 @@ export class JSEditor {
value: string, value: string,
paste = true, paste = true,
toToggleOnJS = false, toToggleOnJS = false,
notField = false,
) { ) {
if (toToggleOnJS) { if (toToggleOnJS) {
cy.get(this.locator._jsToggle(endp.replace(/ +/g, "").toLowerCase())) cy.get(this.locator._jsToggle(endp.replace(/ +/g, "").toLowerCase()))
@ -216,11 +213,7 @@ export class JSEditor {
// .type("{del}", { force: true }); // .type("{del}", { force: true });
if (paste) { if (paste) {
this.agHelper.EnterValue(value, { this.propPane.UpdatePropertyFieldValue(endp, value);
propFieldName: endp,
directInput: notField,
inputFieldName: "",
});
} else { } else {
cy.get( cy.get(
this.locator._propertyControl + this.locator._propertyControl +

View File

@ -19,7 +19,6 @@ type filedTypeValues =
export class PropertyPane { export class PropertyPane {
private agHelper = ObjectsRegistry.AggregateHelper; private agHelper = ObjectsRegistry.AggregateHelper;
private jsEditor = ObjectsRegistry.JSEditor;
private locator = ObjectsRegistry.CommonLocators; private locator = ObjectsRegistry.CommonLocators;
_fieldConfig = (fieldName: string) => _fieldConfig = (fieldName: string) =>
@ -72,7 +71,7 @@ export class PropertyPane {
public ChangeTheme(newTheme: string) { public ChangeTheme(newTheme: string) {
this.agHelper.GetNClick(this._changeThemeBtn, 0, true); this.agHelper.GetNClick(this._changeThemeBtn, 0, true);
this.agHelper.GetNClick(this._themeCard(newTheme)); this.agHelper.GetNClick(this._themeCard(newTheme));
this.agHelper.ValidateToastMessage("Theme " + newTheme + " Applied"); this.agHelper.WaitUntilToastDisappear("Theme " + newTheme + " Applied");
} }
public ChangeColor( public ChangeColor(
@ -109,9 +108,9 @@ export class PropertyPane {
.GetText(this.locator._existingActualValueByName("Property Name")) .GetText(this.locator._existingActualValueByName("Property Name"))
.then(($propName) => { .then(($propName) => {
placeHolderText = "{{sourceData." + $propName + "}}"; placeHolderText = "{{sourceData." + $propName + "}}";
this.jsEditor.EnterJSContext("Placeholder", placeHolderText); this.UpdatePropertyFieldValue("Placeholder", placeHolderText);
}); });
this.jsEditor.EnterJSContext("Default Value", ""); this.UpdatePropertyFieldValue("Default Value", "");
this.NavigateBackToPropertyPane(); this.NavigateBackToPropertyPane();
}); });
} }
@ -128,4 +127,22 @@ export class PropertyPane {
} }
this.agHelper.AssertAutoSave(); this.agHelper.AssertAutoSave();
} }
public SelectJSFunctionToExecute(
eventName: string,
jsName: string,
funcName: string,
) {
this.agHelper.SelectPropertiesDropDown(eventName, "Execute a JS function");
this.agHelper.GetNClick(this.locator._dropDownValue(jsName), 0, true);
this.agHelper.GetNClick(this.locator._dropDownValue(funcName), 0, true);
this.agHelper.AssertAutoSave();
}
public UpdatePropertyFieldValue(propFieldName: string, valueToEnter: string) {
cy.xpath(this.locator._existingFieldTextByName(propFieldName)).then(
($field: any) => {
this.agHelper.UpdateCodeInput($field, valueToEnter);
});
}
} }

View File

@ -77,7 +77,7 @@ const DATA_TREE_FUNCTIONS: Record<
}, },
storeValue: function(key: string, value: string, persist = true) { storeValue: function(key: string, value: string, persist = true) {
// momentarily store this value in local state to support loops // momentarily store this value in local state to support loops
_.set(self, `appsmith.store[${key}]`, value); _.set(self, ["appsmith", "store", key], value);
return { return {
type: ActionTriggerType.STORE_VALUE, type: ActionTriggerType.STORE_VALUE,
payload: { payload: {