-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throttle toast storms related to saving/restoring URL state (#154792)
## Summary Resolves #153073. Throttles toast errors related to restoring/saving URL state. Before: <img width="330" alt="image" src="https://user-images.githubusercontent.com/1178348/231315783-98b966a8-b665-4465-91ae-b88933a56c3b.png"> After: <img width="333" alt="image" src="https://user-images.githubusercontent.com/1178348/231315724-7b3109eb-bdc7-405f-865f-36c909b907f4.png"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
61f212f
commit dc1baa9
Showing
5 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/plugins/kibana_utils/public/state_management/url/errors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { withNotifyOnErrors } from './errors'; | ||
import { notificationServiceMock } from '@kbn/core-notifications-browser-mocks'; | ||
|
||
describe('state management URL errors', () => { | ||
const notifications = notificationServiceMock.createStartContract(); | ||
|
||
beforeEach(() => { | ||
notifications.toasts.addError.mockClear(); | ||
}); | ||
|
||
test('notifies on restore error only once', () => { | ||
const { onGetError } = withNotifyOnErrors(notifications.toasts); | ||
const error = new Error(); | ||
onGetError(error); | ||
onGetError(error); | ||
expect(notifications.toasts.addError).toBeCalledTimes(1); | ||
}); | ||
|
||
test('notifies on save error only once', () => { | ||
const { onSetError } = withNotifyOnErrors(notifications.toasts); | ||
const error = new Error(); | ||
onSetError(error); | ||
onSetError(error); | ||
expect(notifications.toasts.addError).toBeCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters