-
Notifications
You must be signed in to change notification settings - Fork 667
CONSOLE-4598: Migrate enzyme __tests__/components/utils unit tests to React Testing… #15442
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
CONSOLE-4598: Migrate enzyme __tests__/components/utils unit tests to React Testing… #15442
Conversation
|
@cajieh: This pull request references CONSOLE-4598 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
57ff13e to
09aed35
Compare
|
/retest |
09aed35 to
d5ae638
Compare
|
@cajieh: This pull request references CONSOLE-4598 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/test frontend |
c397474 to
bc783fe
Compare
|
/test frontend |
fd20554 to
4b0f530
Compare
logonoff
left a comment
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.
/label px-approved
/label docs-approved
| jest.mock('../../../components/utils/status-box', () => ({ | ||
| LoadingBox: () => | ||
| require('react').createElement('div', { 'data-test': 'loading-box' }, 'Loading...'), | ||
| })); |
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 it would be a bit cleaner to just return a string and detect for this text instead of checking a testid
| jest.mock('../../../components/utils/status-box', () => ({ | |
| LoadingBox: () => | |
| require('react').createElement('div', { 'data-test': 'loading-box' }, 'Loading...'), | |
| })); | |
| jest.mock('../../../components/utils/status-box', () => ({ | |
| LoadingBox: () => "Loading..." | |
| })); |
| jest.mock('react-i18next', () => ({ | ||
| withTranslation: () => (Component) => { | ||
| const WrappedComponent = (props) => { | ||
| const t = (key) => key.split('~')[1] || key; | ||
| return require('react').createElement(Component, { ...props, t }); | ||
| }; | ||
| WrappedComponent.displayName = `withTranslation(${Component.displayName || Component.name})`; | ||
| return WrappedComponent; | ||
| }, | ||
| useTranslation: () => ({ | ||
| t: (key) => key.split('~')[1] || key, | ||
| }), | ||
| })); |
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'd recommend we use the same mocks as we usually do without needing to require react
| jest.mock('react-i18next', () => ({ | |
| withTranslation: () => (Component) => { | |
| const WrappedComponent = (props) => { | |
| const t = (key) => key.split('~')[1] || key; | |
| return require('react').createElement(Component, { ...props, t }); | |
| }; | |
| WrappedComponent.displayName = `withTranslation(${Component.displayName || Component.name})`; | |
| return WrappedComponent; | |
| }, | |
| useTranslation: () => ({ | |
| t: (key) => key.split('~')[1] || key, | |
| }), | |
| })); | |
| jest.mock('react-i18next', () => ({ | |
| useTranslation: () => ({ | |
| t: (key: string) => key, | |
| }), | |
| withTranslation: () => (Component: any) => Component, | |
| })); |
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.
Did you try this change? It appears not to work because withTranslation HOC is designed to inject the t function as a prop into the wrapped component.
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 did not try this change with this test suite specifically; however, this mock is already used by several other unit tests
4b0f530 to
9905587
Compare
logonoff
left a comment
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
|
QE Approver: |
|
/retest-required |
|
/test frontend |
|
|
|
/test frontend |
| import { Map as ImmutableMap } from 'immutable'; | ||
|
|
||
| export { PodModel } from '../../../models'; | ||
| export { PodModel, ServiceModel } from '../../../models'; |
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.
what is this changed targeted for?
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.
what is this changed targeted for?
Oh, that wasn't needed. Removed it. Thanks for the catch!
|
/retest-required |
1 similar comment
|
/retest-required |
|
|
|
@yapei: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/label qe-approved |
|
@cajieh: This pull request references CONSOLE-4598 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cajieh, logonoff The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@cajieh: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
No description provided.