Skip to content

Commit

Permalink
[Workplace Search] Fix error message in Schema (#90869) (#90959)
Browse files Browse the repository at this point in the history
In SchemaErrors, we have an edge case where a user navigates to a non-existent error message state. When migrating I took a stab at passing the custom message to the `flashAPIErrors` helper. It turns out that since we don’t have to parse an error object, we can just set the error message directly
  • Loading branch information
scottybollinger authored Feb 10, 2021
1 parent 64f1a46 commit 747a5fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ import { SchemaLogic, dataTypeOptions } from './schema_logic';

describe('SchemaLogic', () => {
const { http } = mockHttpValues;
const { clearFlashMessages, flashAPIErrors, setSuccessMessage } = mockFlashMessageHelpers;
const {
clearFlashMessages,
flashAPIErrors,
setSuccessMessage,
setErrorMessage,
} = mockFlashMessageHelpers;
const { mount } = new LogicMounter(SchemaLogic);

const defaultValues = {
Expand Down Expand Up @@ -298,10 +303,7 @@ describe('SchemaLogic', () => {
);
await nextTick();

expect(flashAPIErrors).toHaveBeenCalledWith({
error: 'this is an error',
message: SCHEMA_FIELD_ERRORS_ERROR_MESSAGE,
});
expect(setErrorMessage).toHaveBeenCalledWith(SCHEMA_FIELD_ERRORS_ERROR_MESSAGE);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ADD, UPDATE } from '../../../../../shared/constants/operations';
import {
flashAPIErrors,
setSuccessMessage,
setErrorMessage,
clearFlashMessages,
} from '../../../../../shared/flash_messages';
import { HttpLogic } from '../../../../../shared/http';
Expand Down Expand Up @@ -295,7 +296,7 @@ export const SchemaLogic = kea<MakeLogicType<SchemaValues, SchemaActions>>({
fieldCoercionErrors: response.fieldCoercionErrors,
});
} catch (e) {
flashAPIErrors({ ...e, message: SCHEMA_FIELD_ERRORS_ERROR_MESSAGE });
setErrorMessage(SCHEMA_FIELD_ERRORS_ERROR_MESSAGE);
}
},
addNewField: ({ fieldName, newFieldType }) => {
Expand Down

0 comments on commit 747a5fd

Please sign in to comment.