-
Notifications
You must be signed in to change notification settings - Fork 367
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
test: [M3-8565] - Add unit tests for rest of NodeBalancers package #10945
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ca70b3f
quick eslint fixes
coliu-akamai 1b2e61c
unit tests for nb passive check and delete dialog
coliu-akamai ea010ec
starting tests for NodeBalancerConfigNode
coliu-akamai 074cb72
nodebalancerconfignode tests
coliu-akamai c145a69
update tests in config panel to account for active check component
coliu-akamai a17557a
unit test for NodeBalancerCreate to confirm it renders
coliu-akamai 888e46b
Added changeset: Add unit tests for rest of NodeBalancers package
coliu-akamai e6e2833
Update packages/manager/src/features/NodeBalancers/NodeBalancerConfigβ¦
coliu-akamai 0b047fb
Update packages/manager/src/features/NodeBalancers/NodeBalancerCreateβ¦
coliu-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tests | ||
--- | ||
|
||
Add unit tests for rest of NodeBalancers package ([#10945](https://github.com/linode/manager/pull/10945)) |
2 changes: 1 addition & 1 deletion
2
packages/manager/src/features/NodeBalancers/ConfigNodeIPSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/manager/src/features/NodeBalancers/NodeBalancerConfigNode.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { NodeBalancerConfigNode } from './NodeBalancerConfigNode'; | ||
|
||
import type { NodeBalancerConfigNodeProps } from './NodeBalancerConfigNode'; | ||
|
||
const node = { | ||
address: 'some address', | ||
label: 'some label', | ||
}; | ||
|
||
const props: NodeBalancerConfigNodeProps = { | ||
configIdx: 1, | ||
disabled: false, | ||
forEdit: true, | ||
idx: 1, | ||
node, | ||
onNodeAddressChange: vi.fn(), | ||
onNodeLabelChange: vi.fn(), | ||
onNodeModeChange: vi.fn(), | ||
onNodePortChange: vi.fn(), | ||
onNodeWeightChange: vi.fn(), | ||
removeNode: vi.fn(), | ||
}; | ||
|
||
describe('NodeBalancerConfigNode', () => { | ||
it('renders the NodeBalancerConfigNode', () => { | ||
const { getByLabelText, getByText, queryByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} /> | ||
); | ||
|
||
expect(getByLabelText('Label')).toBeVisible(); | ||
expect(getByLabelText('Port')).toBeVisible(); | ||
expect(getByLabelText('Weight')).toBeVisible(); | ||
expect(getByText('Mode')).toBeVisible(); | ||
expect(getByText('Remove')).toBeVisible(); | ||
expect(queryByText('Status')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the node status', () => { | ||
const { getByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} node={{ ...node, status: 'DOWN' }} /> | ||
); | ||
|
||
expect(getByText('Status')).toBeVisible(); | ||
expect(getByText('DOWN')).toBeVisible(); | ||
}); | ||
|
||
it('cannot change the mode if the node is not for edit', () => { | ||
const { queryByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} forEdit={false} /> | ||
); | ||
|
||
expect(queryByText('Mode')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('cannot remove the node if the node is not for edit or is the first node', () => { | ||
const { queryByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} forEdit={false} idx={0} /> | ||
); | ||
|
||
expect(queryByText('Remove')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('removes the node', () => { | ||
const { getByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} /> | ||
); | ||
|
||
fireEvent.click(getByText('Remove')); | ||
expect(props.removeNode).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any reason to not stick with
props
for the variable name?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 exported the props to use in
NodeBalancerPassiveCheck.test.tsx
- thought it might be helpful to mirror how we update the names of interfaces for component props to be more specific when exporting them, and avoid something likeimport { props } from file
.Can definitely change back to props though!
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.
Oh gotcha, in that case I agree with how you handled it originally here ππΎ