-
Notifications
You must be signed in to change notification settings - Fork 55
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
Adding tests for acceleration components #1495
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Sean Li <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1495 +/- ##
==========================================
- Coverage 56.98% 55.09% -1.90%
==========================================
Files 348 365 +17
Lines 12705 13134 +429
Branches 3214 3303 +89
==========================================
- Hits 7240 7236 -4
- Misses 5412 5843 +431
- Partials 53 55 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
it('Render empty acceleration table', () => { | ||
const wrapper = mount(<AccelerationTable accelerations={[]} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); |
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.
Let's add more interaction tests for flyouts and table once we connect these with the backend. These should be good for now
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.
+1, you can mock like this:
jest.mock('../../../../plugin', () => ({
getRenderAccelerationDetailsFlyout: jest.fn(() =>
jest.fn().mockImplementation(() => console.log('Acceleration Details Flyout Rendered'))
),
getRenderAssociatedObjectsDetailsFlyout: jest.fn(() =>
jest.fn().mockImplementation(() => console.log('Associated Objects Details Flyout Rendered'))
),
}));
so that we can test the render:
it('renders acceleration details correctly and triggers flyout on click', () => {
const wrapper = mount(<AssociatedObjectsDetailsFlyout tableDetail={mockTableDetail} />);
expect(wrapper.find('EuiInMemoryTable').at(0).find('EuiLink').length).toBeGreaterThan(0);
wrapper.find('EuiInMemoryTable').at(0).find('EuiLink').first().simulate('click');
expect(plugin.getRenderAccelerationDetailsFlyout).toHaveBeenCalled();
});
configure({ adapter: new Adapter() }); | ||
|
||
afterEach(() => { | ||
cleanup(); |
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 clean up for?
it('Render empty acceleration table', () => { | ||
const wrapper = mount(<AccelerationTable accelerations={[]} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); |
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.
+1, you can mock like this:
jest.mock('../../../../plugin', () => ({
getRenderAccelerationDetailsFlyout: jest.fn(() =>
jest.fn().mockImplementation(() => console.log('Acceleration Details Flyout Rendered'))
),
getRenderAssociatedObjectsDetailsFlyout: jest.fn(() =>
jest.fn().mockImplementation(() => console.log('Associated Objects Details Flyout Rendered'))
),
}));
so that we can test the render:
it('renders acceleration details correctly and triggers flyout on click', () => {
const wrapper = mount(<AssociatedObjectsDetailsFlyout tableDetail={mockTableDetail} />);
expect(wrapper.find('EuiInMemoryTable').at(0).find('EuiLink').length).toBeGreaterThan(0);
wrapper.find('EuiInMemoryTable').at(0).find('EuiLink').first().simulate('click');
expect(plugin.getRenderAccelerationDetailsFlyout).toHaveBeenCalled();
});
@@ -122,7 +132,12 @@ export const AccelerationDetailsFlyout = (props: AccelerationDetailsFlyoutProps) | |||
</EuiFlexItem> | |||
</EuiFlexGroup> | |||
<EuiSpacer size="m" /> | |||
<EuiTabs style={{ marginBottom: '-25px' }}>{renderTabs()}</EuiTabs> | |||
<EuiTabs | |||
style={{ marginBottom: '-25px' }} |
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 we should avoid this inline style, and we can switch to a SCSS to define this. But yeah, this is not related to this PR, and we can do that as a follow up.
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
…tion menu (opensearch-project#1474) (opensearch-project#1495) * move security management section Signed-off-by: Hailong Cui <[email protected]> * Fix eslint Signed-off-by: Hailong Cui <[email protected]> * Remove plugins pages for management overview registration Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]> Co-authored-by: Darshit Chanpura <[email protected]> Co-authored-by: Craig Perkins <[email protected]> (cherry picked from commit c74973af03efa8b1139864b3779c63450a64e585) Co-authored-by: Hailong Cui <[email protected]>
Description
test
directoryIssues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.