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

Add ClusterClient, KibanaRequest, SessionFactory and Lifecycle toolkit mocks #40352

Merged
merged 5 commits into from
Jul 11, 2019

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Jul 4, 2019

Summary

Close #40186

Added mocks for

  • ClusterClient
  • ScopedClusterClient
  • KibanaRequest factory

I noticed 2 problems:

  const dataClient = await setupDeps.elasticsearch.dataClient$.pipe(first()).toPromise();
  const asScoped = (dataClient.asScoped as unknown) as jest.Mock<typeof dataClient.asScoped>
  const scopedClient = asScoped();

The same old problem that we cannot declare mock for a class #33396

@mshustov mshustov requested a review from a team as a code owner July 4, 2019 12:07
@mshustov mshustov changed the title expose Elatissearch mocks, KibanaRequest mock Add ClusterClient mocks & KibanaRequest mock Jul 4, 2019
@mshustov mshustov added chore Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Jul 4, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@mshustov mshustov added v7.4.0 and removed chore labels Jul 4, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov changed the title Add ClusterClient mocks & KibanaRequest mock [WIP] Add ClusterClient mocks & KibanaRequest mock Jul 4, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

- expose Elatissearch mocks, KibanaRequest mock
- Logging service mock should accept LoggerFactory
- Provide mocks for session storage
- add return for registerAuth mock
- add mocks for http lifecycle toolkits
@mshustov mshustov force-pushed the issue-40186-mocks branch from 9b1baf4 to 2eb5d09 Compare July 8, 2019 14:51
headers = { accept: 'something/html' },
params = {},
body = {},
query,
Copy link
Contributor Author

@mshustov mshustov Jul 8, 2019

Choose a reason for hiding this comment

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

query, params and body are passed already parsed in KibanaRequest and not to overcomplicate setup I added them as plain objects

@mshustov mshustov added the review label Jul 8, 2019
@mshustov mshustov changed the title [WIP] Add ClusterClient mocks & KibanaRequest mock Add ClusterClient, KibanaRequest, SessionFactory and Lifecycle toolkit mocks Jul 8, 2019
@mshustov mshustov requested a review from azasypkin July 8, 2019 14:57
@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple minor changes.

src/core/server/http/cookie_session_storage.mocks.ts Outdated Show resolved Hide resolved
src/core/server/http/http_server.mocks.ts Outdated Show resolved Hide resolved
Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

Tested on #39446 and looks good, thanks! Even though we still have issues with mocking of ES6 classes here and there, it's already a huge step forward and simplifies tests a lot.

@mshustov mshustov requested a review from eliperelman July 10, 2019 14:21
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov merged commit 1269ebe into elastic:master Jul 11, 2019
@mshustov mshustov deleted the issue-40186-mocks branch July 11, 2019 14:30
mshustov added a commit to mshustov/kibana that referenced this pull request Jul 11, 2019
…t mocks (elastic#40352)

* add mocks

- expose Elatissearch mocks, KibanaRequest mock
- Logging service mock should accept LoggerFactory
- Provide mocks for session storage
- add return for registerAuth mock
- add mocks for http lifecycle toolkits

* remove leftovers

* address @eli comments
mshustov added a commit that referenced this pull request Jul 15, 2019
…t mocks (#40352) (#40869)

* add mocks

- expose Elatissearch mocks, KibanaRequest mock
- Logging service mock should accept LoggerFactory
- Provide mocks for session storage
- add return for registerAuth mock
- add mocks for http lifecycle toolkits

* remove leftovers

* address @eli comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide Mocks for New Platform concepts
4 participants