Skip to content

Commit

Permalink
UIQM-740 Don't show warn/fail error toasts when there are no warns/fa…
Browse files Browse the repository at this point in the history
…ils.
  • Loading branch information
BogdanDenis committed Dec 2, 2024
1 parent 6fab277 commit 9d545a2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* [UIQM-716](https://issues.folio.org/browse/UIQM-716) *BREAKING* Consolidate routes based on MARC type for bib and authority records to avoid page refresh after redirecting from the create page to the edit one.
* [UIQM-730](https://issues.folio.org/browse/UIQM-730) Create/Edit/Derive MARC record - Retain focus when MARC record validation rules error display. Show validation issues toasts.
* [UIQM-740](https://issues.folio.org/browse/UIQM-740) Don't show warn/fail error toasts when there are no warns/fails.

## [9.0.1](https://github.com/folio-org/ui-quick-marc/tree/v9.0.1) (2024-11-22)

Expand Down
5 changes: 5 additions & 0 deletions src/QuickMarcEditor/QuickMarcEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,16 @@ const QuickMarcEditor = ({
const failCount = allIssuesArray.filter(issue => issue.severity === SEVERITY.ERROR).length;
const warnCount = allIssuesArray.length - failCount;

if (!failCount && !warnCount) {
return;
}

const values = {
warnCount,
failCount,
breakingLine: <br />,
};

let messageId = null;

if (failCount && warnCount) {
Expand Down
24 changes: 24 additions & 0 deletions src/QuickMarcEditor/QuickMarcEditor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,30 @@ describe('Given QuickMarcEditor', () => {
});
});

describe('when saving form without validation warnings or errors', () => {
beforeEach(async () => {
mockValidate.mockClear().mockResolvedValue({});

const {
getByText,
getByTestId,
} = renderQuickMarcEditor();

const contentField = getByTestId('content-field-3');

fireEvent.change(contentField, { target: { value: '' } });
await fireEvent.click(getByText('stripes-acq-components.FormFooter.save'));
});

it('should show a toast notification about validation warning and error', async () => {
await waitFor(() => {
expect(mockShowCallout).not.toHaveBeenCalledWith(expect.objectContaining({
messageId: expect.stringContaining('ui-quick-marc.record.save.error'),
}));
});
});
});

describe('when marc record is of type HOLDINGS', () => {
describe('when action is create', () => {
it('should not show "Save & keep editing" button', () => {
Expand Down

0 comments on commit 9d545a2

Please sign in to comment.