-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Security Solution] Clearing up all jest errors and warnings #91740
Conversation
...k/plugins/security_solution/public/management/pages/policy/view/policy_forms/locked_card.tsx
Show resolved
Hide resolved
} from '@elastic/eui'; | ||
|
||
import * as timelineMarkdownPlugin from './timeline'; | ||
|
||
export const uiPlugins = [timelineMarkdownPlugin.plugin]; | ||
const uiPlugins: EuiMarkdownEditorUiPlugin[] = getDefaultEuiMarkdownUiPlugins(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clears up 195 instances of the following warning:
Deprecation warning: uiPlugins passed to EuiMarkdownEditor does not include the tooltip plugin, which has been added for you. This automatic inclusion has been deprecated and will be removed in the future, see https://github.com/elastic/eui/pull/4383
Deprecation, no ones fault but @chandlerprall ;)
@@ -34,7 +34,16 @@ describe('QueryBar ', () => { | |||
await waitFor(() => getByTestId('queryInput')); // check for presence of query input | |||
return mount(Component); | |||
}; | |||
let abortSpy: jest.SpyInstance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is in a few spots. Clears up an error thrown by SearchBar
:
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in QueryStringInputUI (created by EnhancedType)
in EnhancedType (created by QueryBarTopRow)
in div (created by EuiFlexItem)
in EuiFlexItem (created by QueryBarTopRow)
in div (created by EuiFlexGroup)
in EuiFlexGroup (created by QueryBarTopRow)
in QueryBarTopRow (created by SearchBarUI)
in div (created by SearchBarUI)
in SearchBarUI (created by EnhancedType)
in EnhancedType (created by InjectIntl(EnhancedType))
in InjectIntl(EnhancedType) (created by WrappedSearchBar)
in Suspense (created by WrappedSearchBar)
in WrappedSearchBar (created by EnhancedType)
in EnhancedType (created by InjectIntl(EnhancedType))
in InjectIntl(EnhancedType)
in Unknown (created by Proxy)
in Provider (created by App)
in App (created by ErrorBoundary)
in ErrorBoundary (created by DragDropContext)
in DragDropContext (created by TestProvidersComponent)
in ThemeProvider (created by TestProvidersComponent)
in Provider (created by TestProvidersComponent)
in ApolloProvider (created by TestProvidersComponent)
in Provider
in Unknown (created by TestProvidersComponent)
in PseudoLocaleWrapper (created by I18nProvider)
in IntlProvider (created by I18nProvider)
in I18nProvider (created by TestProvidersComponent)
in TestProvidersComponent (created by Proxy)
in Proxy
138 |
139 | if (!currentAbortController.signal.aborted) {
> 140 | this.setState({
| ^
141 | indexPatterns: [...objectPatterns, ...objectPatternsFromStrings],
142 | });
143 |
@@ -20,7 +20,15 @@ import { useAllExceptionLists } from './use_all_exception_lists'; | |||
jest.mock('../../../../../../common/lib/kibana'); | |||
jest.mock('./use_all_exception_lists'); | |||
jest.mock('../../../../../../shared_imports'); | |||
jest.mock('@kbn/i18n/react', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also present a few times. Here are the errors we clear up:
console.error
[React Intl] Error formatting relative time.
RangeError: The date value provided to IntlRelativeFormat#format() is not in valid range.
at defaultErrorHandler (node_modules/react-intl/lib/index.js:525:13)
at formatRelative (node_modules/react-intl/lib/index.js:748:5)
at FormattedRelative.render (node_modules/react-intl/lib/index.js:1354:31)
at finishClassComponent (node_modules/react-dom/cjs/react-dom.development.js:18470:31)
at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:18423:24)
at beginWork$1 (node_modules/react-dom/cjs/react-dom.development.js:20186:16)
at beginWork$$1 (node_modules/react-dom/cjs/react-dom.development.js:25756:14)
at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:24698:12)
console.warn
Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.
Please update the following components: FormattedRelative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for doing all of this! Just a quick question so I understand a bit better...isn't FormattedRelative
implemented in the module already? What do we get by mocking it specifically here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean implemented in the module? Just mocking this component since we are not responsible for it, we are not testing anything to do with it, and it is causing errors in jest tests.
@@ -1275,7 +1271,7 @@ describe('helpers', () => { | |||
|
|||
describe('update a timeline', () => { | |||
const updateIsLoading = jest.fn(); | |||
const updateTimeline = jest.fn(); | |||
const updateTimeline = jest.fn().mockImplementation(() => jest.fn()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clears the following type error:
(node:38240) UnhandledPromiseRejectionWarning: TypeError: updateTimeline(...) is not a function
(Use `node --trace-warnings ...` to show where the warning was created)
(node:38240) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:38240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@@ -21,6 +21,14 @@ import { createStore, State } from '../../../common/store'; | |||
import { DetailsPanel } from './index'; | |||
import { TimelineExpandedDetail, TimelineTabs } from '../../../../common/types/timeline'; | |||
import { FlowTarget } from '../../../../common/search_strategy/security_solution/network'; | |||
jest.mock('react-apollo', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clears up the following warning:
console.warn
Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.
Please update the following components: Query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
@elasticmachine merge upstream |
Pinging @elastic/security-solution (Team: SecuritySolution) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks lgtm 👍
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…ndition-for-hiding-recommded-allocation * 'master' of github.com:elastic/kibana: (117 commits) [coverage] ingest data in parallel (elastic#92074) [Lens] Drag and drop performance improvements (elastic#91641) A few more environment uiFilters fixes (elastic#92044) Enabling Uptime and Dashboard a11y test (elastic#91017) [Security Solution][Detections] Adds more granular validation for nested fields (elastic#92041) [Security Solution] [Detections] add overflow-wrap for description (elastic#91945) [Security Solution] [Detections] do not truncate filename in value list table in modal (elastic#91952) Skip flaky apm test elastic#91673 (elastic#92065) [docker] Default server.name to hostname (elastic#90799) Use documentation link service for snapshot restore (elastic#91596) [Security Solution] Clearing up all jest errors and warnings (elastic#91740) Add `@kbn/analytics` to UI Shared Deps (elastic#91810) [7.12][Telemetry] Add missing fields for security telemetry (elastic#91920) [Security Solution] Adds cypress-pipe (elastic#91550) [ML] Fix event rate chart annotation position (elastic#91899) [APM] Break down error table api removing the sparklines (elastic#89138) docs: update dependencies table bug (elastic#91964) [Time to Visualize] Stay in Edit Mode After Dashboard Quicksave (elastic#91729) Unskip Search Sessions Management UI test (elastic#90110) [Fleet] Handle long text in agent details page (elastic#91776) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx # x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx
…bana into task-manager/docs-monitoring * 'task-manager/docs-monitoring' of github.com:gmmorris/kibana: (29 commits) Update docs/developer/plugin-list.asciidoc Update docs/api/task-manager/health.asciidoc Update docs/api/task-manager/health.asciidoc [Lens] Load indexpatterns list from indexPattern Service (elastic#91984) [coverage] ingest data in parallel (elastic#92074) [Lens] Drag and drop performance improvements (elastic#91641) A few more environment uiFilters fixes (elastic#92044) Enabling Uptime and Dashboard a11y test (elastic#91017) [Security Solution][Detections] Adds more granular validation for nested fields (elastic#92041) [Security Solution] [Detections] add overflow-wrap for description (elastic#91945) [Security Solution] [Detections] do not truncate filename in value list table in modal (elastic#91952) Skip flaky apm test elastic#91673 (elastic#92065) [docker] Default server.name to hostname (elastic#90799) Use documentation link service for snapshot restore (elastic#91596) [Security Solution] Clearing up all jest errors and warnings (elastic#91740) Add `@kbn/analytics` to UI Shared Deps (elastic#91810) [7.12][Telemetry] Add missing fields for security telemetry (elastic#91920) [Security Solution] Adds cypress-pipe (elastic#91550) [ML] Fix event rate chart annotation position (elastic#91899) [APM] Break down error table api removing the sparklines (elastic#89138) ...
* master: (36 commits) [Uptime] Thumbnail full screen view steps navigation fix (elastic#91895) Implement ScopedHistory.block (elastic#91099) [Lens] Fix overlowing content on a chart for charts and table (elastic#92006) handle source column differences in embeddable as well (elastic#91987) [Vega] [Map] disable map rotation using right right click / touch rotation gesture (elastic#91996) [Lens] Load indexpatterns list from indexPattern Service (elastic#91984) [coverage] ingest data in parallel (elastic#92074) [Lens] Drag and drop performance improvements (elastic#91641) A few more environment uiFilters fixes (elastic#92044) Enabling Uptime and Dashboard a11y test (elastic#91017) [Security Solution][Detections] Adds more granular validation for nested fields (elastic#92041) [Security Solution] [Detections] add overflow-wrap for description (elastic#91945) [Security Solution] [Detections] do not truncate filename in value list table in modal (elastic#91952) Skip flaky apm test elastic#91673 (elastic#92065) [docker] Default server.name to hostname (elastic#90799) Use documentation link service for snapshot restore (elastic#91596) [Security Solution] Clearing up all jest errors and warnings (elastic#91740) Add `@kbn/analytics` to UI Shared Deps (elastic#91810) [7.12][Telemetry] Add missing fields for security telemetry (elastic#91920) [Security Solution] Adds cypress-pipe (elastic#91550) ...
Summary
Clear various errors and warnings from Security Solution jest suite. If you are tagged on a reviewer in this PR, you introduced one or more of these errors. Don't want to play blame game, but instead to learn from our mistakes. Please review and avoid committing console errors and warnings in jest in the future! Thanks :)
Checklist