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

[Security Solution] Clearing up all jest errors and warnings #91740

Merged
merged 5 commits into from
Feb 19, 2021

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Feb 17, 2021

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

@stephmilovic stephmilovic added the WIP Work in progress label Feb 17, 2021
@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes v7.12.0 v7.13.0 v8.0.0 and removed WIP Work in progress labels Feb 18, 2021
@stephmilovic stephmilovic marked this pull request as ready for review February 18, 2021 17:32
@stephmilovic stephmilovic requested a review from a team as a code owner February 18, 2021 17:32
@stephmilovic stephmilovic changed the title [Security Solution] [skip-ci] Clearing up all jest errors and warnings [Security Solution] Clearing up all jest errors and warnings Feb 18, 2021
} from '@elastic/eui';

import * as timelineMarkdownPlugin from './timeline';

export const uiPlugins = [timelineMarkdownPlugin.plugin];
const uiPlugins: EuiMarkdownEditorUiPlugin[] = getDefaultEuiMarkdownUiPlugins();
Copy link
Contributor Author

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;
Copy link
Contributor Author

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

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

Copy link
Contributor

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?

Copy link
Contributor Author

@stephmilovic stephmilovic Feb 19, 2021

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());
Copy link
Contributor Author

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

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

Copy link
Contributor

@michaelolo24 michaelolo24 left a 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!

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor Author

Screen Shot 2021-02-19 at 8 00 30 AM

Screen Shot 2021-02-19 at 8 00 23 AM

hoping these failures are flakes cuz wtf, locally passes consistantly

@stephmilovic stephmilovic added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Feb 19, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Copy link
Contributor

@kqualters-elastic kqualters-elastic left a comment

Choose a reason for hiding this comment

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

Awesome, thanks lgtm 👍

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 7.7MB 7.7MB +204.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stephmilovic stephmilovic merged commit fc77586 into elastic:master Feb 19, 2021
@stephmilovic stephmilovic deleted the jest-fixing-feb branch February 19, 2021 19:42
stephmilovic added a commit to stephmilovic/kibana that referenced this pull request Feb 19, 2021
jloleysens added a commit to jloleysens/kibana that referenced this pull request Feb 22, 2021
…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
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 22, 2021
…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)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 22, 2021
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v7.12.0 v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants