Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIQM-740 Don't show warn/fail error toasts when there are no warns/fails. #766

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('when saving form without validation warnings or errors', () => {
describe('when saving form without validation warnings and errors', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In English you can say "without X or Y" meaning "without X and without Y". A little weird, but that's how it is.
Interestingly, it works the same way as De Morgan's law in boolean logic, where "not (A or B) = (not A) and (not B)"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I haven't thought about De Morgan since grad school!

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 () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should show a toast notification about validation warning and error', async () => {
it('should not 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