Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard] Fix flaky Dashboard create tests (#156085)
Closes #155777 ## Summary The `"replaces panel with incoming embeddable if id matches existing panel"` test was **not** the flaky one, even though it was the one that showed the failure; it was actually one of the previous `"pulls state <...>"` tests that was failing, which was pretty confusing to catch 🤦 Basically, because we are [running the unsaved changes check on load now](#155648), depending on the timing of the `debounce` on the `checkForUnsavedChangesSubject$` subscription it would sometimes run for the `"pulls state <...>"` tests (but not always) - so whenever it **would** run, because the mocked `loadDashboardStateFromSavedObject` was only returning a partial Dashboard input, this would result in trying to get the property of `undefined` when checking for filter changes, panel changes, etc. This is fixed by ensuring that the `loadDashboardStateFromSavedObject` returns a complete Dashboard input, with all the required keys, for all of the relevant tests. Note that, since you can't test Jest unit tests using the flaky test runner, I was able to run it multiple times by surrounding all the tests with the following in order to ensure that it was no longer flaky: ```typescript for (const i of Array(x) .fill(null) .map((_, i) => i)) { describe(`test run ${i}`, () => { <...> // all the tests go here }); }; ``` I did this with `x = 200`, and the entire test suite passed 200 times in a row 👍 ### 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 ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information