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

Ts refs #6

Closed
wants to merge 87 commits into from
Closed

Ts refs #6

wants to merge 87 commits into from

Conversation

mshustov
Copy link
Owner

Summary

  • Moves test_utils coupled with the platform under src/core, with data plugin under src/plugins/data.
  • Creates src/test_utils project

Testing

node ./node_modules/.bin/tsc -p src/core/tsconfig.json --extendedDiagnostics
Without refs:

Files:                        3121
Lines:                      479324
Nodes:                     1625644
Identifiers:                562814

With refs:

Files:                         3121
Lines:                       479118
Nodes:                      1625127
Identifiers:                 562643

Note that the number of processed Lines, Nodes, and Identifiers has decreased.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

rylnd and others added 29 commits August 24, 2020 15:38
* Simplify our kibana mocks

* Simpler mock factory that returns an object instead of a thunk
  * We can use mockReturnValue instead of mockImplementation to
  accomplish the same
  * Allows us to replace createStartServices mock
* Uses unknown instead of any for mocks

* Clean up our manual use of kibana mocks in tests

* Since our useKibana mock returns a consistent mock, we can modify its
return value instead of re-mocking the entire thing
* Removes unnecessary uses of clearing/resetting mocks
  * If your mocks are configured at the beginning of each test this is
  usually unnecessary.
  * I left one case of clearAllMocks in all_cases/index.test since it
  defined several mock functions that were persistent across tests, and
  it was easier than moving their definitions to a beforeEach
* Removes some unnecessary overrides that seemed due to storage
previously not being mocked

* Rename some old occurrences of SIEM

* Cross-reference similar hooks via JSDoc

There's a good chance that the consumer might want the OTHER hook, so
let's make that discoverable.

* Adds jest tests for our useListsConfig hook

* adds mocks for the hooks upon which it depends

* Add a mock for our useListsConfig hook

Leverages this mock factory in our manual mock for this hook.

* Remove unneeded eslint exception

* Move kibana_react mocks into their own .mock file

We're trying to consolidate mocks to this pattern so that they're easier
to find and reuse.

* Remove intermediate mock factory

This was only being consumed by our general createStartServicesMock.

* Replace security_solution's alias for a core mock

This is just noise/tech debt, we should use the core mock directly when
we can.

* Remove unnecessary wrapper around core mocks

Instead let's just reference the core mocks themselves.

* Remove outdated references from upstream

* More accurate mock

Throw an error of the same type if an unexpected key is used.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Corey Robertson <corey.robertson@elastic.co>
…, and manage error connecting at top app-level (elastic#75790)

* [Setup] Change error connecting status code to 502

- For clearer error handling

* Set up new HttpProvider/Logic Kea store & listeners

- This allows us to:
  - connect() directly to HttpLogic in other Kea logic files that need to make http calls, instead of passing in http manually via args
  - Set http interceptors & remove them interceptors on unmount within Kea
  - Share state derived from http (e.g. errorConnecting, readOnlyMode) between both AS & WS (but allow each app to handle that state differently if needed)

+ Refactors necessary for these changes:
  - Kea types - add events key, clarify that mount returns an unmount function, fix reducer state type
  - ReactDOM unmount - remove resetContext({}), was preventing logic from unmounting properly

* Update AS & WS to show error connecting component at app level

* [WS] Remove errorConnecting logic & http arg from Overview

- Since main app is now handling errorConnecting
- http can now be connected directly from HttpLogic Kea store, so no need to pass it
+ minor cleanup in logic_overview.test.ts - remove unneeded unmount(), act(), switch to HttpLogic mock

* [AS] Add top-level ErrorConnecting component & remove error logic from EngineOverview

* [AS] Clean up/move EngineOverview child components into subfolder

- delete old ErrorState component
- move LoadingState, EmptyState, and EngineOverviewHeader into subfolders in engine_overview

* PR feedback: Update test assertions 404 copy
The release manager is currently expecting a Docker asset image with
the format of `kibana-8.0.0-SNAPSHOT-docker-image.tar.gz`. If this
target is not found, it will re-export the image. Making this change to
produce the expected filename will remove that duplicated effort.
Additionally, the release manager plans to remove this fallback in the
future anyways.

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* Rename Whitelist to AllowList in Actions and Alerting

* revert not related change

* Fixed due to comments and tests failing

* Fixed failing tests

* Fixed due to comments
…ctions proxy set on for parallel process running using commands 'scripts/functional_tests_server' and 'scripts/functional_test_runner' (elastic#75232)

* Fixed alerting_api_integration/security_and_spaces tests failing if actions proxy set on for parallel process running using commands 'scripts/functional_tests_server' and 'scripts/functional_test_runner'

* -

* Fixed get port from range for Slack and webhook simulators, removed some test warnings

* Added check for listening proxy server

* changed logger to debug removed not useful error

* -

* changed proxy to dynamic target in a single place

* test retry

* -

* -

* -

* -

* test with no cleanup

* -

* -

* -

* -

* Added environment variable ALERTING_PROXY_PORT

* fixed type checks

* fixed clean up proxy server port
…ink (elastic#75755)

* replaces the route when parmeter is missing

* fixing unit test
* Don't override sync strategy in XPACK

* search name

* docs

* mock

* Use enhancement pattern

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* Add chart previews for log threshold alerts
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* craete new path for client side monitoring

* update

* update app

* fix i18n

* remove space

* added feature on server

* use lazy load

* update test

* update

* remove csm serve file

* update test

* added design improvements

* imrpove design

* fix types

* rervet conflict screw up

* revert

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…lastic#75717)

* remove getConfig and uiSettingsValues from IndexPattern class
@@ -351,7 +351,7 @@ module.exports = {
from: [
'(src|x-pack)/plugins/**/(public|server)/**/*',
'!(src|x-pack)/plugins/**/(public|server)/mocks/index.{js,mjs,ts}',
'!(src|x-pack)/plugins/**/(public|server)/(index|mocks).{js,mjs,ts,tsx}',
'!(src|x-pack)/plugins/**/(public|server)/(index|mocks|test_utils).{js,mjs,ts,tsx}',
Copy link
Owner Author

Choose a reason for hiding this comment

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

we can make it a part of mock, but it's not entirely the same. open to suggestions.

bhavyarm and others added 29 commits August 26, 2020 10:02
…st associated with rule (elastic#75898)

## Summary

**Current behavior:**
  - **Scenario 1:** User is in the exceptions viewer flow, they select to edit an exception item, but the list the item is associated with has since been deleted (let's say by another user) - a user is able to open modal to edit exception item and on save, an error toaster shows but no information is given to the user to indicate the issue.
  - **Scenario 2:** User exports rules from space 'X' and imports into space 'Y'. The exception lists associated with their newly imported rules do not exist in space 'Y' - a user goes to add an exception item and gets a modal with an error, unable to add any exceptions. 
  - **Workaround:** current workaround exists only via API - user would need to remove the exception list from their rule via API

**New behavior:**
  - **Scenario 1:** User is still able to oped edit modal, but on save they see an error explaining that the associated exception list does not exist and prompts them to remove the exception list --> now they're able to add exceptions to their rule
  - **Scenario 2:** User navigates to exceptions after importing their rule, tries to add  exception, modal pops up with error informing them that they need to remove association to missing exception list, button prompts them to do so --> now can continue adding exceptions to rule
## Summary

Found in 7.9.0, if you post a rule with an action that has a missing "meta" then you are going to get errors in your UI that look something like:

```ts
An error occurred during rule execution: message: "Cannot read property 'kibana_siem_app_url' of null"
name: "Unusual Windows Remote User" id: "1cc27e7e-d7c7-4f6a-b918-8c272fc6b1a3"
rule id: "1781d055-5c66-4adf-9e93-fc0fa69550c9" signals index: ".siem-signals-default"
```

This fixes the accidental referencing of the null/undefined property and adds both integration and unit tests in that area of code.

If you have an action id handy you can manually test this by editing the json file of:

```ts
test_cases/queries/action_without_meta.json
```

to have your action id and then posting it like so:

```ts
./post_rule.sh ./rules/test_cases/queries/action_without_meta.json
```

### Checklist

Delete any items that are not applicable to this PR.

- [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
…ption list associated with rule (elastic#75898)"

This reverts commit b9c8201.
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
* Return ID when default output is found

* Fix typing
* rename uuid service to environment service

* adapt resolve_uuid to directly use the configurations

* move data folder creation to core

* update generated doc

* fix types

* fix monitoring tests

* move instanceUuid to plugin initializer context

* update generated doc
…erts' action (elastic#75945)

## Summary

Resolves elastic#75194

Fixes issue where the `Select all [x] alerts` feature would not select the checkboxes within the Alerts Table. Also resolves issue where bulk actions wouldn't work with Building Block Alerts.


##### Select All Before
<p align="center">
  <img width="700" src="https://user-images.githubusercontent.com/2946766/91266588-d2d66800-e72e-11ea-8c57-c91bd80a8f0e.gif" />
</p>




##### Select All After
<p align="center">
  <img width="700" src="https://user-images.githubusercontent.com/2946766/91266573-cc47f080-e72e-11ea-9812-67e7182f90f3.gif" />
</p>



##### Building Block Query Before
<p align="center">
  <img width="700" src="https://user-images.githubusercontent.com/2946766/91266516-af132200-e72e-11ea-9088-63de64d2774e.gif" />
</p>

##### Building Block Query After
<p align="center">
  <img width="700" src="https://user-images.githubusercontent.com/2946766/91266531-bb977a80-e72e-11ea-8071-904b355856f7.gif" />
</p>
Co-authored-by: Catherine Liu <catherine.liu@elastic.co>
Co-authored-by: Ryan Keairns <contactryank@gmail.com>
Co-authored-by: Catherine Liu <catherineqliu@outlook.com>
Co-authored-by: Michael Marcialis <michael.marcialis@elastic.co>
* Trusted Apps initial setup for route registration

* Added types for TrustedApp entries

* trusted apps list API returns results

* use methods and const from latest PR merge to lists

* a quick generator for trusted apps entries

* support cli options for trusted app data loader

* Add mocked `createTrustedAppsList()` method to `ExceptionListClientMock`

* tests fro trusted apps route handlers

* tests for trusted apps schema

* Correct name of mock method

* Fix service to ensure return value of `getExceptionList` service throws if service not available

* Fix types

* Refactor TrustedApp type + code review feedback
Added UI for sharing saved objects, and updated UI for importing and copying too
Changed wording on duplicate title warning.
…76009)

* Add new Workplace Search initial data properties

* Add app logic

* Refactor index to match App Search

Adds the easier-to-read ComponentConfigured and ComponentUnconfigured FCs with a ternary in the root compoenent

* Remove ‘Logic’ from interface names

* Extract initial data from WS into interface

This allows for breaking apart the app-specific data and also having an interface to extend in the app_logic file

* Destructuring FTW
* delete integration tests

* remove legacy version healthcheck / waitUntilReady

* remove handleESError

* remove createCluster

* no longer depends on kibana plugin

* fix kbn_server

* remove deprecated comment and dead code

* revert code removal, apparently was used (?)

* Revert "revert code removal, apparently was used (?)"

This reverts commit 6948185
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
…om" param on rules (elastic#76000)

* updates validation on 'from' param to prevent malformed datemath strings from being accepted

* fix imports

* copy paste is not my friend

* missed type check somehow

* forgot to mock common utils

* updates bodies for request validation tests
* [Lens] Decouple visualizations from specific operations

* Remove unused mock
…st associated with rule (elastic#76012)

## Summary

**Current behavior:**
  - **Scenario 1:** User is in the exceptions viewer flow, they select to edit an exception item, but the list the item is associated with has since been deleted (let's say by another user) - a user is able to open modal to edit exception item and on save, an error toaster shows but no information is given to the user to indicate the issue.
  - **Scenario 2:** User exports rules from space 'X' and imports into space 'Y'. The exception lists associated with their newly imported rules do not exist in space 'Y' - a user goes to add an exception item and gets a modal with an error, unable to add any exceptions. 
  - **Workaround:** current workaround exists only via API - user would need to remove the exception list from their rule via API

**New behavior:**
  - **Scenario 1:** User is still able to oped edit modal, but on save they see an error explaining that the associated exception list does not exist and prompts them to remove the exception list --> now they're able to add exceptions to their rule
  - **Scenario 2:** User navigates to exceptions after importing their rule, tries to add  exception, modal pops up with error informing them that they need to remove association to missing exception list, button prompts them to do so --> now can continue adding exceptions to rule
elastic#75917)

* incorporating test_user wth specific roles for the canvas functional ui tests

* additional checks - removed comments

* changes to incorporate code comments

* lint check

* incorporate code reviews

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
elastic#75926)

* [Security Solution][Resolver] Word-break long titles in related event description lists

* word-break long titles at non-word boundaries

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* WIP

* added anomaly alert

* update types

* update types

* update

* types

* types

* update ML part

* update ML part

* update ML part

* unnecessary change

* icon for disable

* update test

* update api

* update labels

* resolve conflicts

* fix types

* fix editing alert

* fix types

* added actions column

* added code to add alert

* update anomaly message

* added anomaly alert test

* update

* update type

* fix ml legacy scoped client

* update

* WIP

* fix conflict

* added aria label

* Added deleteion loading

* fix type

* update

* update tests

* update

* update type

* fix types

* WIP

* added enabled alerts section

* add data

* update

* update tests

* fix test

* update i18n

* update i18n

* update i18n

* fix

* update message

* update

* update

* update

* revert

* update types

* added component

* update test

* incorporate PR feedback

* fix focus

* update drawer

* handle edge case

* improve btn text

* improve btn text

* use switch instead of icons

* update snapshot

* use compressed form

* fix type

* update snapshot

* update snapshot

* update test

* update test

* PR feedback

* fix test and type

* remove delete action

* remove unnecessary function

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* bump ts to v4

* MOAR RAM

* fix type errors for OSS

* first pass on x-pack errors

* second pass on x-pack type errors

* 3rd pass on x-pack type-errors

* mute errors if complex cases

* don't delete if spread suffices

* mute other complex cases

* make User fields optional

* fix optional types

* fix tests

* fix typings for time_range

* fix type errors in x-pack/tests

* rebuild kbn-pm

* remove leftovers from master update

* fix alert tests

* [Telemetry Checker] TS4 Fixes

* bump to 4.0.1-rc

* fix new errors in master

* bump typescript-eslint to version supporting TS v4 syntax

* fix merge commit errors

* update to the stable TS version 4.0.2

* bump ts-eslint to version supporting ts v4

* fix typo

* fix type errors after merge

* update ts in another new package.json

* TEMP: remove me

* Revert "TEMP: remove me"

This reverts commit dc0fc3b.

* [Telemetry] Update snapshot for new TS4 SyntaxKind

* bump prettier to support TS v4 syntax

* fix prettier rules

* last style change

* fix new type errors

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
@mshustov mshustov closed this Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.