fix: Fix Evaluated value paths for objects (#24407)

This issue fixes the evaluated value for path fields that holds objects,
booleans or arrays.

#### PR fixes following issue(s)
Fixes #24397 

#### Type of change
> Please delete options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)

## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [x] Manual
- [ ] Jest
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [x] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
Ayangade Adeoluwa 2023-06-16 10:04:53 +01:00 committed by GitHub
parent f126f67010
commit 4c346def9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View File

@ -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"}`);
});
});

View File

@ -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) {

View File

@ -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(