feat: added trigger for collection property editor, making it dd for mongo (#24213)

## Description
Added a dynamic trigger config to mongo editor json for each command to fetch the collections whenever the mongo action is opened and populate those in the dropdown to allow users ease in selecting the collection to run a query.
This commit is contained in:
Aman Agarwal 2023-06-14 12:16:09 +05:30 committed by GitHub
parent e644edabf8
commit dba06b1705
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 216 additions and 78 deletions

View File

@ -284,7 +284,7 @@ describe("Autocomplete tests", () => {
input.focus();
cy.wait(200);
cy.get(_.locators._codeMirrorTextArea)
.eq(1)
.eq(0)
.focus()
.type(
"{downArrow}{downArrow}{leftArrow}{leftArrow}{leftArrow}{leftArrow}",

View File

@ -7,10 +7,17 @@ describe("Mongo Form to Native conversion works", () => {
_.dataSources.CreateDataSource("Mongo", true, true);
_.dataSources.CreateQueryAfterDSSaved();
_.agHelper.TypeDynamicInputValueNValidate(
"listingAndReviews",
formControls.mongoCollection,
);
_.agHelper.ValidateNetworkStatus("@trigger");
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "listingAndReviews",
});
// _.dataSources.ValidateNSelectDropdown(
// "Collection",
// "",
// "listingAndReviews",
// );
_.agHelper.TypeDynamicInputValueNValidate(
"{beds : {$lte: 2}}",
@ -44,10 +51,13 @@ describe("Mongo Form to Native conversion works", () => {
"Find document(s)",
);
_.agHelper.TypeDynamicInputValueNValidate(
"modifyCollection",
formControls.mongoCollection,
);
cy.wait(500);
_.agHelper.EnterValue("modifyCollection", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
});
_.dataSources.ValidateNSelectDropdown(
"Commands",

View File

@ -82,10 +82,11 @@ describe("MaintainContext&Focus", function () {
_.entityExplorer.SelectEntityByName("Mongo_Query");
cy.wait(1000);
cy.updateCodeInput(
".t--actionConfiguration\\.formData\\.collection\\.data",
"TestCollection",
);
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "TestCollection",
});
cy.wait("@saveAction");
});
@ -135,11 +136,13 @@ describe("MaintainContext&Focus", function () {
".t--actionConfiguration\\.formData\\.bucket\\.data",
{ ch: 2, line: 0 },
);
_.entityExplorer.SelectEntityByName("Mongo_Query");
cy.assertCursorOnCodeInput(
".t--actionConfiguration\\.formData\\.collection\\.data",
);
// Removing as the Mongo collection is now converted to dropdown
// _.entityExplorer.SelectEntityByName("Mongo_Query");
// cy.assertCursorOnCodeInput(
// ".t--actionConfiguration\\.formData\\.collection\\.data",
// );
//Maintains focus on JS Objects
_.entityExplorer.SelectEntityByName("JSObject1");

View File

@ -6,9 +6,12 @@ describe("Ensures evaluated popup is viewable when dynamic bindings are present
_.dataSources.CreateDataSource("Mongo", true, true);
_.dataSources.CreateQueryAfterDSSaved();
// ordinary strings should not open evaluated value popup
_.agHelper.TypeDynamicInputValueNValidate(
_.agHelper.ValidateNetworkStatus("@trigger");
_.dataSources.ValidateNSelectDropdown(
"Collection",
"",
"listingAndReviews",
formControls.mongoCollection,
);
// object strings should not open evaluated value popup

View File

@ -69,15 +69,16 @@ describe("Validate Mongo query commands", function () {
//cy.xpath(queryLocators.findDocs).should("exist"); //Verifying update is success or below line
//cy.expect(queryLocators.findDocs).to.exist;
_.agHelper.ValidateNetworkStatus("@trigger");
cy.ValidateAndSelectDropdownOption(
formControls.commandDropdown,
"Find document(s)",
);
_.agHelper.EnterValue("listingAndReviews", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "listingAndReviews",
});
_.dataSources.RunQuery();
_.dataSources.CheckResponseRecordsCount(10);
@ -138,15 +139,16 @@ describe("Validate Mongo query commands", function () {
it("3. Validate Count command & Run and then delete the query", function () {
cy.NavigateToActiveDSQueryPane(datasourceName);
_.agHelper.ValidateNetworkStatus("@trigger");
cy.ValidateAndSelectDropdownOption(
formControls.commandDropdown,
"Find document(s)",
"Count",
);
_.agHelper.EnterValue("listingAndReviews", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "listingAndReviews",
});
_.dataSources.RunQuery();
_.agHelper.EnterValue("{guests_included : {$gte: 2}}", {
@ -166,15 +168,16 @@ describe("Validate Mongo query commands", function () {
it("4. Validate Distinct command & Run and then delete the query", function () {
cy.NavigateToActiveDSQueryPane(datasourceName);
_.agHelper.ValidateNetworkStatus("@trigger");
cy.ValidateAndSelectDropdownOption(
formControls.commandDropdown,
"Find document(s)",
"Distinct",
);
_.agHelper.EnterValue("listingAndReviews", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "listingAndReviews",
});
_.agHelper.EnterValue("{price : {$gte: 100}}", {
propFieldName: "",
@ -198,15 +201,16 @@ describe("Validate Mongo query commands", function () {
it("5. Validate Aggregate command & Run and then delete the query", function () {
cy.NavigateToActiveDSQueryPane(datasourceName);
_.agHelper.ValidateNetworkStatus("@trigger");
cy.ValidateAndSelectDropdownOption(
formControls.commandDropdown,
"Find document(s)",
"Aggregate",
);
_.agHelper.EnterValue("listingAndReviews", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "listingAndReviews",
});
_.agHelper.EnterValue(`[{ $project: { count: { $size:"$amenities" }}}]`, {
propFieldName: "",
@ -285,18 +289,19 @@ describe("Validate Mongo query commands", function () {
let id;
_.entityExplorer.ExpandCollapseEntity("Datasources");
_.entityExplorer.ExpandCollapseEntity(`${datasourceName}`);
// div[text()='listingAndReviews']/ancestor::div/following-sibling::div/div[contains(@class, 'entity-context-menu')]//span[text()='Add']",
cy.get("[data-testid='t--entity-item-listingAndReviews']")
.find(".t--template-menu-trigger")
.click({ force: true });
cy.get(".ads-v2-menu__menu-item").contains("Find").click().wait(100); //wait for Find form to open
cy.EvaluatFieldValue(formControls.mongoCollection).then((colData) => {
let localcolData = colData.replace("{", "").replace("}", "");
cy.log("Collection value is fieldData: " + localcolData);
cy.wrap(localcolData).as("colData");
});
cy.get(`${formControls.mongoCollection} .rc-select-selection-item`)
.then(($field) => {
return cy.wrap($field).invoke("text");
})
.then((val) => {
cy.wrap(val).as("colData");
});
cy.EvaluatFieldValue(formControls.mongoFindQuery).then((queryData) => {
let localqueryData = queryData.replace("{", "").replace("}", "");
id = localqueryData;
@ -384,6 +389,8 @@ describe("Validate Mongo query commands", function () {
cy.NavigateToActiveDSQueryPane(dbName);
});
_.agHelper.ValidateNetworkStatus("@trigger");
_.dataSources.SetQueryTimeout(30000);
cy.ValidateAndSelectDropdownOption(
formControls.commandDropdown,
@ -395,10 +402,10 @@ describe("Validate Mongo query commands", function () {
{"_id":2, "Från" :"Joann" , "Frõ" :"Active", "Leverantör":"De Bolster", "Frö":"Sallad - Oakleaf 'Salad Bowl'"},
{"_id":3, "Från" :"Olivia" , "Frõ" :"Active", "Leverantör":"De Bolster", "Frö":"Sallad - Oakleaf 'Red Salad Bowl'"}]`;
_.agHelper.EnterValue("NonAsciiTest", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "NonAsciiTest",
});
_.agHelper.EnterValue(nonAsciiDoc, {

View File

@ -268,16 +268,18 @@ describe("Validate Mongo Query Pane Validations", () => {
_.dataSources.NavigateFromActiveDS(dsName, true);
_.agHelper.ValidateNetworkStatus("@trigger");
_.dataSources.ValidateNSelectDropdown(
"Commands",
"Find document(s)",
"Insert document(s)",
);
_.agHelper.EnterValue("AuthorNAwards", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "AuthorNAwards",
});
_.agHelper.EnterValue(authorNAwardsArray, {
@ -730,6 +732,8 @@ describe("Validate Mongo Query Pane Validations", () => {
_.dataSources.NavigateFromActiveDS(dsName, true);
_.agHelper.ValidateNetworkStatus("@trigger");
_.dataSources.ValidateNSelectDropdown(
"Commands",
"Find document(s)",
@ -737,10 +741,10 @@ describe("Validate Mongo Query Pane Validations", () => {
);
_.agHelper.RenameWithInPane("InsertBirthNDeath");
_.agHelper.EnterValue("BirthNDeath", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
_.dataSources.EnterJSContext({
fieldProperty: _.dataSources._mongoCollectionPath,
fieldLabel: "Collection",
fieldValue: "BirthNDeath",
});
_.agHelper.EnterValue(birthNDeathArray, {

View File

@ -9,12 +9,9 @@ describe(
_.dataSources.CreateMockDB("Movies").then((mockDBName) => {
dsName = mockDBName;
_.dataSources.CreateQueryFromActiveTab(mockDBName, false);
_.agHelper.ValidateNetworkStatus("@trigger");
_.dataSources.ValidateNSelectDropdown("Commands", "Find document(s)");
_.agHelper.EnterValue("movies", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
});
_.dataSources.ValidateNSelectDropdown("Collection", "", "movies");
_.dataSources.RunQueryNVerifyResponseViews(10, false);
_.dataSources.NavigateToActiveTab();
_.agHelper
@ -25,11 +22,7 @@ describe(
_.entityExplorer.CreateNewDsQuery(mockDBName);
_.dataSources.ValidateNSelectDropdown("Commands", "Find document(s)");
_.agHelper.EnterValue("movies", {
propFieldName: "",
directInput: false,
inputFieldName: "Collection",
});
_.dataSources.ValidateNSelectDropdown("Collection", "", "movies");
_.dataSources.RunQueryNVerifyResponseViews(10, false);
_.dataSources.NavigateToActiveTab();
_.agHelper

View File

@ -48,4 +48,4 @@
"s3ReadFileDataType": ".t--actionConfiguration\\.formData\\.read\\.dataType\\.data",
"postgreSqlBody": ".t--actionConfiguration\\.body",
"rawBody": ".t--actionConfiguration\\.formData\\.body\\.data"
}
}

View File

@ -204,6 +204,9 @@ export class DataSources {
public _datasourceModalDoNotSave = ".t--datasource-modal-do-not-save";
public _cancelEditDatasourceButton = ".t--cancel-edit-datasource";
public _urlInputControl = "input[name='url']";
public _mongoCollectionPath = "t--actionConfiguration.formData.collection";
private _getJSONswitchLocator = (fieldLocator: string) =>
`[data-testid='${fieldLocator}.data-JS']`;
_nestedWhereClauseKey = (index: number) =>
".t--actionConfiguration\\.formData\\.where\\.data\\.children\\[" +
index +
@ -1320,4 +1323,21 @@ export class DataSources {
break;
}
}
public EnterJSContext({
fieldLabel,
fieldProperty,
fieldValue,
}: {
fieldProperty: string;
fieldValue: string;
fieldLabel: string;
}) {
this.agHelper.GetNClick(this._getJSONswitchLocator(fieldProperty));
this.agHelper.EnterValue(fieldValue, {
propFieldName: "",
directInput: false,
inputFieldName: fieldLabel,
});
}
}

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},

View File

@ -12,8 +12,22 @@
{
"label": "Collection",
"configProperty": "actionConfiguration.formData.collection.data",
"controlType": "QUERY_DYNAMIC_INPUT_TEXT",
"evaluationSubstitutionType": "TEMPLATE"
"controlType": "DROP_DOWN",
"evaluationSubstitutionType": "TEMPLATE",
"propertyName": "get_collections",
"fetchOptionsConditionally": true,
"alternateViewTypes": ["json"],
"conditionals": {
"fetchDynamicValues": {
"condition": "{{true}}",
"config": {
"params": {
"requestType": "_GET_STRUCTURE",
"displayType": "DROP_DOWN"
}
}
}
}
}
]
},