-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Metric] convert mocha tests to jest #54054
[Metric] convert mocha tests to jest #54054
Conversation
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.
LGTM besides some small open questions
}); | ||
|
||
it('should set the metric label and value', function() { | ||
const metrics = metricController._processTableGroups({ | ||
// @ts-ignore | ||
const metrics = metricVis.processTableGroups({ |
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.
It's a bit weird to test react components like this - could we change this to simple enzyme tests with a snapshot assertion instead? Then we don't have to call into the internal method.
@@ -0,0 +1,106 @@ | |||
/* |
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.
Does it make sense to rename this to metric_vis_type.test.ts
? Just to have a mapping to the file its logic it is testing.
@@ -17,11 +17,14 @@ | |||
* under the License. | |||
*/ | |||
|
|||
import expect from '@kbn/expect'; | |||
import { MetricVisComponent } from '../components/metric_vis_controller'; | |||
// @ts-ignore |
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.
leftover from the conversion?
const max = last<{ to: number }>(config.colorsRange).to; | ||
const colors = this.getColors(); | ||
const labels = this.getLabels(); | ||
const metrics: any[] = []; // not yet typed |
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.
It's fine to postpone these types, but could you create a "dummy type" for it? export type MetricVisMetric = any
and then use MetricVisMetric
everywhere. By doing so it will get much easier to propagate the type through your code once it's added.
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.
Great idea!
@@ -12,7 +12,8 @@ | |||
], | |||
"test_utils/*": [ | |||
"src/test_utils/public/*" | |||
] | |||
], | |||
"fixtures/*": ["src/fixtures/*"] |
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.
Do we really need this alias? I don't know how much fixtures
will be used in the future and IMHO it's better to only introduce these if they are really necessary - just using a relative import seems easier to me. But maybe I'm missing an aspect 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.
Yeah, I was questioning whether to add this, but the fixtures files have the fixtures/
aliased paths in them so a relative import still fails. Do you think I should change all the paths in the fixtures files to be relative and get rid of this alias?
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.
Ah good point. @elastic/kibana-operations do you have a suggestion?
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.
IMHO I think we keep this for now until we phase out the fixtures completely. Mainly because I think it's strange to have a path alias in javascript that is not also in typescript.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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 LGTM - visualization still works and tests look good.
@elastic/kibana-operations & @elastic/kibana-app-arch could I get a review whenever you get a chance? Thanks |
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.
Code owner changes LGTM
Hey @spalger are you ok with the operations codeowner changes? |
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.
LGTM - really not sure how I feel about the fixtures but can't come up with a better solution.
@tylersmalley agreed, ideally we phase them out once the mocha tests are gone. Thanks 👍 |
* Add fixtures/* alias to tsconfig and jest config * Convert metric tests to jest * Convert remaining js files to ts
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* upstream/master: (83 commits) [Reporting] Fix map tiles not loading by using Chrome's Remote Protocol (elastic#55137) [Data Plugin] combine autocomplete provider and suggestions provider (elastic#54451) resolves elastic#53038 - remove references to specific license levels (elastic#53858) highlighting rules should still know about url parts when in sql state (elastic#55200) [Metric] convert mocha tests to jest (elastic#54054) [skip-ci] Update vector styling docs for 7.6 UI changes and new features (elastic#55087) Fix enable API to schedule task after alert is updated (elastic#55095) chore(NA): add 7.6 branch to the list of backport branches (elastic#54998) Convert tests to jest in vis_type_timeseries/public & common folders (elastic#55023) [ML] Accessibility fix for structural markup on table rows (elastic#55075) [Mappings editor] include/exclude fields only support custom options (elastic#54949) [Vis] Move Timelion Vis to vis_type_timelion (elastic#52069) Deprecate `chrome.navlinks.update` and add documentation (elastic#54893) [ML] Single Metric Viewer: Fix time bounds with custom strings. (elastic#55045) [Vis: Default editor] EUIficate and Reactify the sidebar (elastic#49864) [Mappings editor] Fix cannot set boolean value for "null_value" param (elastic#55015) [SIEM] Adds support for apm-* to the network map (elastic#54876) [Reporting] Define shims of legacy dependencies (elastic#54082) Resolver is overflow: hidden to prevent obscured elements from showing up (elastic#55076) Upgraded EUI to 18.2.1 (elastic#55090) ...
Summary
fixtures/*
alias to typescriptChecklist
For maintainers