fix: empty query response on page load issue fixed (#28296)

## Description

When we bind a successfully running query to a widget, the query gets
executed on page load, so in such a case, we were able to see the query
in the widget, but when visiting query editor, response tab is empty.
This PR fixes that issue.

<img width="904" alt="Screenshot 2023-10-23 at 3 35 50 PM"
src="https://github.com/appsmithorg/appsmith/assets/30018882/b0244c87-d18f-4d8c-ad35-35cd1f4abfd6">


**Root Cause:**
In order to see the response in the response tab, we need to have action
config, execute API response and responseDisplayFormat to be present.
responseDisplayFormat denotes whether to show response in Table, Json or
Raw format.
This responseDisplayFormat gets set in `setDefaultActionDisplayFormat`
method. This property is set on action config object itself. This method
is called from execute `executePluginActionSaga` and
`executePluginActionSaga` is called from `executePageLoadAction`, so the
flow of actions looks as below:

- `executePageLoadAction`
      - `executePluginActionSaga`
              - `setDefaultActionDisplayFormat`

Once the responseDisplayFormat was set, `executePageLoadAction` was
again resetting the action config object in the redux store, thus
removing this responseDisplayFormat property and hence empty response
tab.

**Note: This bug is not a regression, it has existed from a long time.**

#### PR fixes following issue(s)
Fixes #28287 
#### Media
> A video or a GIF is preferred. when using Loom, don’t embed because it
looks like it’s a GIF. instead, just link to the video
>
>
#### Type of change
- 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
- [ ] JUnit
- [ ] Jest
- [x] 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
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] 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
- [ ] 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

Co-authored-by: “sneha122” <“sneha@appsmith.com”>
This commit is contained in:
sneha122 2023-10-26 15:09:00 +05:30 committed by GitHub
parent 70b3cf2a84
commit 881ac75ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 7 deletions

View File

@ -0,0 +1,45 @@
import {
dataSources,
agHelper,
entityExplorer,
propPane,
debuggerHelper,
} from "../../../../support/Objects/ObjectsCore";
let dsName: any;
let queryName: string;
describe("Bug 28287: Binding query to widget, check query response in query editor on page load", function () {
before("adds a text widget", () => {
agHelper.AddDsl("textDsl");
});
it("1. Create datasources", () => {
agHelper.GenerateUUID();
cy.get("@guid").then((uuid) => {
dataSources.CreateDataSource("Postgres");
cy.get("@dsName").then(($dsName) => {
dsName = $dsName;
});
queryName = `Query_${uuid}`;
dataSources.CreateQueryAfterDSSaved(
"SELECT * FROM users LIMIT 10",
queryName,
);
dataSources.ToggleUsePreparedStatement(false);
entityExplorer.SelectEntityByName("Text1");
propPane.TypeTextIntoField("Text", `{{${queryName}.data}}`);
agHelper.RefreshPage();
agHelper.Sleep(1000);
entityExplorer.SelectEntityByName(queryName, "Queries/JS");
debuggerHelper.ClickDebuggerIcon();
debuggerHelper.ClickResponseTab();
agHelper.AssertElementVisibility(dataSources._queryResponse("TABLE"));
});
});
});

View File

@ -1229,13 +1229,6 @@ function* executePageLoadAction(pageAction: PageAction) {
undefined,
pageAction.id,
);
yield put(
executePluginActionSuccess({
id: pageAction.id,
response: payload,
isPageLoad: true,
}),
);
yield put(
updateActionData({
entityName: action.name,