Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix 2 issues during recent upgrade (#339)
Browse files Browse the repository at this point in the history
* formik validation too active for CategoryField
* backend failure is propagated as success to frontend
  • Loading branch information
yizheliu-amazon authored Dec 4, 2020
1 parent b551666 commit 341327a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion public/pages/EditFeatures/containers/EditFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export function EditFeatures(props: EditFeaturesProps) {
} else {
setSaveFeatureOption(SAVE_FEATURE_OPTIONS.START_AD_JOB);
}
if (errors.categoryField) {
if (isHCDetector && errors.categoryField) {
focusOnCategoryField();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions public/redux/middleware/__tests__/clientMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ describe('client MiddleWare', () => {
const { next, invoke } = create();
const actionCall = jest
.fn()
.mockReturnValue(fooPromise(true, { ok: false }));
.mockReturnValue(fooPromise(true, { body: { ok: false } }));
const action = { type: 'TEST', request: actionCall };
return invoke(action).then(() => {
expect(next.mock.calls.length).toBe(2);
expect(next.mock.calls[1][0]).toEqual({
result: { ok: false },
result: { body: { ok: false } },
type: 'TEST_SUCCESS',
});
});
Expand Down
4 changes: 2 additions & 2 deletions public/redux/middleware/clientMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default function clientMiddleware<State>(client: HttpSetup) {
next({ ...rest, type: `${type}_REQUEST` });
const result = await request(client);
//@ts-ignore
if (get(result, 'data.ok', true)) {
if (get(result, 'ok', true)) {
next({ ...rest, result, type: `${type}_SUCCESS` });
return result;
} else {
//@ts-ignore
throw get(result, 'data.error', '');
throw get(result, 'error', '');
}
} catch (error) {
next({ ...rest, error, type: `${type}_FAILURE` });
Expand Down

0 comments on commit 341327a

Please sign in to comment.