diff --git a/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/Autocomplete_JS_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/Autocomplete_JS_spec.ts index 7f12158472..5e0710d0f9 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/Autocomplete_JS_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Autocomplete/Autocomplete_JS_spec.ts @@ -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}", diff --git a/app/client/cypress/e2e/Regression/ClientSide/FormNativeToRawTests/MongoConversion_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/FormNativeToRawTests/MongoConversion_spec.ts index 9cd3a6724b..b7ce20e710 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/FormNativeToRawTests/MongoConversion_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/FormNativeToRawTests/MongoConversion_spec.ts @@ -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", diff --git a/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js b/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js index 368f82a21d..7416b85cc0 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/IDE/MaintainContext&Focus_spec.js @@ -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"); diff --git a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/EvaluatedValuePopUp_spec.ts b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/EvaluatedValuePopUp_spec.ts index 002a347be2..68fd42fed5 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/EvaluatedValuePopUp_spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/EvaluatedValuePopUp_spec.ts @@ -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 diff --git a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.js b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.js index aada107e7b..08fbe348cf 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.js +++ b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.js @@ -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, { diff --git a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.ts b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.ts index bb438baf9e..c8c368cce4 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.ts +++ b/app/client/cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.ts @@ -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, { diff --git a/app/client/cypress/e2e/Sanity/Datasources/MockDBs_Spec.ts b/app/client/cypress/e2e/Sanity/Datasources/MockDBs_Spec.ts index 5c0bb8a964..496593f464 100644 --- a/app/client/cypress/e2e/Sanity/Datasources/MockDBs_Spec.ts +++ b/app/client/cypress/e2e/Sanity/Datasources/MockDBs_Spec.ts @@ -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 diff --git a/app/client/cypress/locators/FormControl.json b/app/client/cypress/locators/FormControl.json index 5b9637d97b..97cda15377 100644 --- a/app/client/cypress/locators/FormControl.json +++ b/app/client/cypress/locators/FormControl.json @@ -48,4 +48,4 @@ "s3ReadFileDataType": ".t--actionConfiguration\\.formData\\.read\\.dataType\\.data", "postgreSqlBody": ".t--actionConfiguration\\.body", "rawBody": ".t--actionConfiguration\\.formData\\.body\\.data" -} +} \ No newline at end of file diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index 0f1a646497..1380083b22 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -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, + }); + } } diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/aggregate.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/aggregate.json index aef7c1f8da..323f7f760c 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/aggregate.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/aggregate.json @@ -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" + } + } + } + } } ] }, diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/count.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/count.json index c270dea774..3ba1921cbb 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/count.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/count.json @@ -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" + } + } + } + } } ] }, diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/delete.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/delete.json index 15163e26c1..947275bcdf 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/delete.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/delete.json @@ -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" + } + } + } + } } ] }, diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/distinct.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/distinct.json index 49e2f0d507..98c5b51adc 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/distinct.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/distinct.json @@ -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" + } + } + } + } } ] }, diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/find.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/find.json index 917d518132..741a778852 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/find.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/find.json @@ -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" + } + } + } + } } ] }, diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/insert.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/insert.json index b7d38c990a..e70f7f903b 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/insert.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/insert.json @@ -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" + } + } + } + } } ] }, diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/update.json b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/update.json index a16b8057a6..4b2f60228d 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/update.json +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/resources/editor/update.json @@ -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" + } + } + } + } } ] },