Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiProviders] Warn Developer if EuiProvider is missing (#184608)
## Summary Addresses elastic/kibana-team#805 ## Rollout plan These steps will graduate toward a consistency of Dark Mode theming (and I18n, and Analytics for Error Boundaries) by ensuring that EUI components are always rendered with `KibanaRenderContextProvider` wrapping the root of the rendering tree. **The final behavior:** in Dev mode when KibanaRenderContextProvider is missing, developers will see a console.error and a toast Error message. In CI environments, the error scenario will cause the EUI components to fail with an error and developers will have to address the issue with a fix by viewing the test logs. 1. **[Done]** Initial error behavior: throw error if EUI Provider is missing in a Draft PR. In CI of that Draft PR, EUI components will fail to render and show an error. 1. SharedUX team (@tsullivan) implements the fixes using separate PRs 2. **[In this PR]** Soften the error behavior and take effect only in Dev mode 1. Use console.error to give an error message and a stack trace 2. Show an Error toast to convey the error message to Developers 3. **[Not Started]** ~~After running in a mode of step 2 for a length of time, we add restrictions to CI environments with the final error behavior.~~ Update the navigation methods of the common page objects for functional tests, to detect when the toast message appears during functional testing, and throw a helpful error. ## Notification for developers Developers would see this error toast with a message telling them they need to use EuiProvider, plus a link for "more details." They can also check the JS console to see the error details. <img width="1798" alt="image" src="https://github.com/elastic/kibana/assets/908371/061fcec8-4a66-45fd-a77a-c6a2226f7871"> ## How this helps Surfacing these kinds of errors automates the discovery of finding where dark mode issues exist. Here is an example of a hard-to-find dark mode issue that was easily caught by the kinds of testing enabled in this PR: <img width="1436" alt="connection details - before" src="https://github.com/elastic/kibana/assets/908371/ec6c19b0-5697-41bd-a8eb-935e8388983d"> The way to problems in this nature is to wrap the React context in `<KibanaRenderContextProvider>`, and setting the required CoreStart service dependencies of `analytics`, `i18n` and `theme`.
- Loading branch information