-
Notifications
You must be signed in to change notification settings - Fork 472
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
Migrate TraceDiffs/Header from enzyme to RTL #1962
Conversation
@yurishkuro Can you please re-run the testing workflow and review this PR? |
I don't think it's flaky, I am seeing this error:
|
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/TraceHeader.test.js
Outdated
Show resolved
Hide resolved
@yurishkuro But I have only made changes to the tests in |
Codecov ReportAll modified and coverable lines are covered by tests ✅
... and 1 file with indirect coverage changes 📢 Thoughts on this report? Let us know! |
## Which problem is this PR solving? Fixes part of jaegertracing#1668 ## Description of the changes Migrates the test for `ChevronDown.tsx` to RTL ## How was this change tested? Ran the test suite locally ## Checklist - [X] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [X] I have signed all commits - [X] I have added unit tests for the new functionality - [X] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/TraceHeader.test.js
Outdated
Show resolved
Hide resolved
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/TraceHeader.test.js
Show resolved
Hide resolved
expect(shallow(<EmptyAttrs />)).toMatchSnapshot(); | ||
render(<EmptyAttrs />); | ||
expect(screen.getAllByTestId('TraceDiffHeader--traceAttr').length).toBe(1); | ||
expect(screen.getByTestId('TraceDiffHeader--traceAttr').textContent.trim()).toBe(''); |
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.
looking for textContext is a bit weird - what if it is legitimately empty? Could we not assert that getByTestId returns an empty list?
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.
In the current JSX for EmptyAttr
, we return the following:
export function EmptyAttrs() {
return (
<ul className="TraceDiffHeader--traceAttributes">
<li className="TraceDiffHeader--traceAttr" data-testid="TraceDiffHeader--traceAttr">
</li>
</ul>
);
}
which is a list with one item, and blank text content. I feel that the current implementation is the best way to test it. What you're suggesting would be more appropriate if we return just an empty ul
with no li
.
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.
I think I have handled the same in a more graceful manner in the latest changes. Please let me know what you think about it.
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/TraceHeader.test.js
Outdated
Show resolved
Hide resolved
expect(shallow(<Attrs />)).toMatchSnapshot(); | ||
render(<Attrs />); | ||
|
||
// Test that the default values are correctly |
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.
interesting - SHOULD they actually be rendered like this? What is the point of "default values" provided by the UI when it displays externally loaded data?
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 probably shouldn't be. I feel that the same arises from this props definition:
type Props = {
duration: number | TNil;
error?: ApiError;
startTime: number | TNil;
state: FetchedState | TNil;
traceID: string | TNil;
traceName: string | TNil;
totalSpans: number | TNil;
};
type AttrsProps = {
startTime: number | TNil;
duration: number | TNil;
totalSpans: number | TNil;
};
The props should use conditional type which require startTime
, duration
and totalSpans
to be present if the status is DONE
, and otherwise they should be undefined
. And thus the TNil
should be removed from the AttrsProps
IMO. Should I work on applying these fixes?
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.
I agree, the types are unnecessarily lax, it should be either you have an error or pending state, or you have everything else non-optional. But I think fixing this is a lower priority compared to fixing other enzyme tests
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Thanks! |
Which problem is this PR solving?
Fixes part of #1668
Description of the changes
Migrates
TraceHeader.tsx
from enzyme to RTL. Removes the snapshot tests to relevant assertions with the help oftest-ids
.How was this change tested?
Running the test suite locally.
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test