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

Fix unit test waring in dr brownfield #1112

Conversation

TimothyAsirJeyasing
Copy link
Contributor

No description provided.

Copy link
Contributor

openshift-ci bot commented Nov 30, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: TimothyAsirJeyasing
Once this PR has been reviewed and has the lgtm label, please assign gowthamshanmugam for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@TimothyAsirJeyasing
Copy link
Contributor Author

@SanjalKatiyar, @GowthamShanmugam Please review

@TimothyAsirJeyasing
Copy link
Contributor Author

image

HealthItem: ({ title }: { title: string }) => <div>{title}</div>,
ViewDocumentation: ({ text, doclink }: { text: string; doclink: string }) => (
<a href={doclink}>{text}</a>
),
HealthState: {
NOT_AVAILABLE: 'NOT_AVAILABLE',
OK: 'OK',
},
}));

jest.mock('../../../../utils/osd-migration');
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, Why the util function is mocked? if ceph status has all data, utils function will be executed without any issue.

Copy link
Contributor Author

@TimothyAsirJeyasing TimothyAsirJeyasing Nov 30, 2023

Choose a reason for hiding this comment

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

I have mocked the internal components HealthItem, HealthBody to isolate the unit test and focus on testing the specific behavior of the OSDMigrationProgress component as i received lot of issues without mocking them mainly with HealthItem and HealthBody.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, HealthItem and HealthBody should not give any error, In case you are seeing many error, Then we need to check the severity of the error and it needs to be investigated.

Comment on lines 8 to 13
jest.mock('@odf/shared/dashboards/status-card/states', () => ({
...jest.requireActual('@odf/shared/dashboards/status-card/states'),
GrayUnknownIcon: ({ title }: { title: string }) => (
<div title={title}>MockGrayUnknownIcon</div>
),
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to mock all of this?

Comment on lines 18 to 21
HealthItem: ({ title }: { title: string }) => <div>{title}</div>,
ViewDocumentation: ({ text, doclink }: { text: string; doclink: string }) => (
<a href={doclink}>{text}</a>
),
Copy link
Contributor

Choose a reason for hiding this comment

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

same here why HealthItem and viewDcoumentation has to be mocked ?

Copy link
Contributor Author

@TimothyAsirJeyasing TimothyAsirJeyasing Nov 30, 2023

Choose a reason for hiding this comment

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

I was facing issues with only HealthItem and HealthBody. when i debug this, i notice that it adds a nested <default> tag while rendering which causes an issue. So i have mocked them to isolate this issue..

Copy link
Contributor

Choose a reason for hiding this comment

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

oh!, ok also face this issue sometime, ok then lets mock HealthItem

Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
@@ -39,11 +31,7 @@ describe('OSDMigrationStatus', () => {

getOSDMigrationStatus.mockReturnValue('Completed');
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not mock getOSDMigrationStatus... pass a dummy Ceph CR to it with all the required statuses and use except to check if function is returning correct value...

@@ -68,11 +56,7 @@ describe('OSDMigrationStatus', () => {

getOSDMigrationStatus.mockReturnValue('In Progress');
Copy link
Collaborator

Choose a reason for hiding this comment

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

u have mentioned here In Progress, but test title it is saying PENDING...


describe('OSDMigrationStatus', () => {
describe('OSDMigrationProgress', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add more cases, for each status that CR reports, not just "In progress" and "Completed"...


describe('OSDMigrationStatus', () => {
describe('OSDMigrationProgress', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add case for calculateOSDMigration function as well, by passing dummy Ceph CR to it.. it should return expected result...


describe('OSDMigrationStatus', () => {
describe('OSDMigrationProgress', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add checks for doc links in ur test cases...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants