fix: gsheets import headers fix (#27200)

## Description
For /token call during import process, the env API is not fetched so the
envId passed was wrong. Earlier, we used to fetch from localstorage.
This PR adds the wait call in the saga so that the envs are always
fetched before we can use the token call.

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

#### 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
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
Tested the following on CE DP:

1. Tested import from home page with all Datasources - including OAuth
and GSheets
2. Tested fork of the above app into another workspace
3. Tested import from inside the application with Gsheets DS
4. Tested import from inside the application with OAuth DS
5. Tested fork of a GSheets application into a new workspace
6. Tested import from inside the application with multiple Datasources
including OAuth and Gsheets

#### 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
- [ ] 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:
Ayush Pahwa 2023-09-13 16:09:47 +07:00 committed by GitHub
parent 2cd4555259
commit 2cda8202eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -159,6 +159,7 @@ import {
getCurrentEditingEnvironmentId,
getCurrentEnvironmentDetails,
} from "@appsmith/selectors/environmentSelectors";
import { waitForFetchEnvironments } from "@appsmith/sagas/EnvironmentSagas";
function* fetchDatasourcesSaga(
action: ReduxAction<{ workspaceId?: string } | undefined>,
@ -646,6 +647,8 @@ function* getOAuthAccessTokenSaga(
return;
}
try {
// wait for envs to be fetched
yield call(waitForFetchEnvironments);
// Get access token for datasource
const response: ApiResponse<TokenResponse> = yield OAuthApi.getAccessToken(
datasourceId,

View File

@ -126,7 +126,10 @@ export const saveCurrentEnvironment = async (envId: string, appId: string) => {
};
// Function to fetch the current environment and related appId from indexedDB
export const getSavedCurrentEnvironmentDetails = async () => {
export const getSavedCurrentEnvironmentDetails = async (): Promise<{
envId: string;
appId: string;
}> => {
try {
return (
(await store.getItem(STORAGE_KEYS.CURRENT_ENV)) || {
@ -136,6 +139,10 @@ export const getSavedCurrentEnvironmentDetails = async () => {
);
} catch (error) {
log.error("An error occurred when fetching current env: ", error);
return {
envId: "",
appId: "",
};
}
};