diff --git a/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_EvaluatedValue_spec.ts b/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_EvaluatedValue_spec.ts new file mode 100644 index 0000000000..57813f9388 --- /dev/null +++ b/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_EvaluatedValue_spec.ts @@ -0,0 +1,10 @@ +import { ObjectsRegistry } from "../../../../support/Objects/Registry"; + +const apiPage = ObjectsRegistry.ApiPage; + +describe("Validate API URL Evaluated value", () => { + it("1. Check if url object does not crash App", () => { + apiPage.CreateApi("FirstAPI"); + apiPage.EnterURL(`{{{"key": "value"}}}`, true, `{"key":"value"}`); + }); +}); diff --git a/app/client/cypress/support/Pages/ApiPage.ts b/app/client/cypress/support/Pages/ApiPage.ts index d5bf3a03a6..cdfdcd9697 100644 --- a/app/client/cypress/support/Pages/ApiPage.ts +++ b/app/client/cypress/support/Pages/ApiPage.ts @@ -129,13 +129,17 @@ export class ApiPage { cy.get(this._apiRunBtn).should(query); } - EnterURL(url: string) { + EnterURL(url: string, validateEvaluatedValue = false, evaluatedValue = "") { this.agHelper.EnterValue(url, { propFieldName: this._resourceUrl, directInput: true, inputFieldName: "", }); this.agHelper.AssertAutoSave(); + + if (validateEvaluatedValue) { + this.agHelper.VerifyEvaluatedValue(evaluatedValue); + } } EnterHeader(hKey: string, hValue: string, index = 0) { diff --git a/app/client/src/components/editorComponents/form/fields/EmbeddedDatasourcePathField.tsx b/app/client/src/components/editorComponents/form/fields/EmbeddedDatasourcePathField.tsx index 9b3d7807d7..b1b172a2bf 100644 --- a/app/client/src/components/editorComponents/form/fields/EmbeddedDatasourcePathField.tsx +++ b/app/client/src/components/editorComponents/form/fields/EmbeddedDatasourcePathField.tsx @@ -57,6 +57,7 @@ import LazyCodeEditor from "components/editorComponents/LazyCodeEditor"; import { getCodeMirrorNamespaceFromEditor } from "utils/getCodeMirrorNamespace"; import { isDynamicValue } from "utils/DynamicBindingUtils"; import { DEFAULT_DATASOURCE_NAME } from "constants/ApiEditorConstants/ApiEditorConstants"; +import { isString } from "lodash"; type ReduxStateProps = { workspaceId: string; @@ -397,9 +398,14 @@ class EmbeddedDatasourcePathComponent extends React.Component< if ("ENTITY_TYPE" in entity && entity.ENTITY_TYPE === ENTITY_TYPE.ACTION) { let evaluatedPath = "path" in entity.config ? entity.config.path : ""; - if (evaluatedPath && evaluatedPath.indexOf("?") > -1) { - evaluatedPath = extractApiUrlPath(evaluatedPath); + if (evaluatedPath) { + if (isString(evaluatedPath) && evaluatedPath.indexOf("?") > -1) { + evaluatedPath = extractApiUrlPath(evaluatedPath); + } else { + evaluatedPath = JSON.stringify(evaluatedPath); + } } + const evaluatedQueryParameters = entity?.config?.queryParameters ?.filter((p: KeyValuePair) => !!p?.key) .map(