Fixed the extraction of ServerApiError. (#86732)

This commit is contained in:
Bohdan Tsymbala 2020-12-22 15:43:01 +01:00 committed by GitHub
parent 8527b6cbe3
commit 128a772ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 12 deletions

View file

@ -179,7 +179,9 @@ describe('middleware', () => {
const service = createTrustedAppsServiceMock();
const { store, spyMiddleware } = createStoreSetup(service);
service.getTrustedAppsList.mockRejectedValue(createServerApiError('Internal Server Error'));
service.getTrustedAppsList.mockRejectedValue({
body: createServerApiError('Internal Server Error'),
});
store.dispatch(createUserChangedUrlAction('/trusted_apps', '?page_index=2&page_size=50'));
@ -315,7 +317,7 @@ describe('middleware', () => {
const { store, spyMiddleware } = createStoreSetup(service);
service.getTrustedAppsList.mockResolvedValue(getTrustedAppsListResponse);
service.deleteTrustedApp.mockRejectedValue(notFoundError);
service.deleteTrustedApp.mockRejectedValue({ body: notFoundError });
store.dispatch(createUserChangedUrlAction('/trusted_apps'));

View file

@ -95,7 +95,7 @@ const refreshListIfNeeded = async (
store.dispatch(
createTrustedAppsListResourceStateChangedAction({
type: 'FailedResourceState',
error,
error: error.body,
lastLoadedState: getLastLoadedListResourceState(store.getState()),
})
);
@ -103,13 +103,6 @@ const refreshListIfNeeded = async (
}
};
const createTrustedAppDeletionSubmissionResourceStateChanged = (
newState: Immutable<AsyncResourceState>
): Immutable<TrustedAppDeletionSubmissionResourceStateChanged> => ({
type: 'trustedAppDeletionSubmissionResourceStateChanged',
payload: { newState },
});
const updateCreationDialogIfNeeded = (
store: ImmutableMiddlewareAPI<TrustedAppsListPageState, AppAction>
) => {
@ -167,7 +160,7 @@ const submitCreationIfNeeded = async (
store.dispatch(
createTrustedAppCreationSubmissionResourceStateChanged({
type: 'FailedResourceState',
error,
error: error.body,
lastLoadedState: getLastLoadedResourceState(submissionResourceState),
})
);
@ -175,6 +168,13 @@ const submitCreationIfNeeded = async (
}
};
const createTrustedAppDeletionSubmissionResourceStateChanged = (
newState: Immutable<AsyncResourceState>
): Immutable<TrustedAppDeletionSubmissionResourceStateChanged> => ({
type: 'trustedAppDeletionSubmissionResourceStateChanged',
payload: { newState },
});
const submitDeletionIfNeeded = async (
store: ImmutableMiddlewareAPI<TrustedAppsListPageState, AppAction>,
trustedAppsService: TrustedAppsService
@ -209,7 +209,7 @@ const submitDeletionIfNeeded = async (
store.dispatch(
createTrustedAppDeletionSubmissionResourceStateChanged({
type: 'FailedResourceState',
error,
error: error.body,
lastLoadedState: getLastLoadedResourceState(submissionResourceState),
})
);