-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [M3-9040] - Unit tests to validate aria-labels of Action Menu f…
…or Linode IPs and ranges (#11448) * Add unit tests coverage for ip action menu * Added changeset: Add unit tests to validate aria-labels of Action Menu for Linode IPs & ranges
- Loading branch information
1 parent
ab2943b
commit 8cea97c
Showing
3 changed files
with
73 additions
and
1 deletion.
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 to validate aria-labels of Action Menu for Linode IPs & ranges ([#11448](https://github.com/linode/manager/pull/11448)) |
67 changes: 67 additions & 0 deletions
67
...r/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.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,67 @@ | ||
import * as React from 'react'; | ||
|
||
import { ipAddressFactory } from 'src/factories/networking'; | ||
import { renderWithTheme, resizeScreenSize } from 'src/utilities/testHelpers'; | ||
|
||
import { LinodeNetworkingActionMenu } from './LinodeNetworkingActionMenu'; | ||
|
||
import type { IPRange } from '@linode/api-v4'; | ||
|
||
describe('LinodeNetworkingActionMenu', () => { | ||
beforeAll(() => { | ||
// Set width to 1279px (< 1280px) to ensure the Action menu is visible. | ||
resizeScreenSize(1279); | ||
}); | ||
|
||
const mockLinodeIPv4 = ipAddressFactory.buildList(1, { | ||
public: true, | ||
type: 'ipv4', | ||
})[0]; | ||
|
||
const mockLinodeIPv6Range: IPRange = { | ||
prefix: 64, | ||
range: '2600:3c00:e000:0000::', | ||
region: 'us-west', | ||
route_target: '2a01:7e00::f03c:93ff:fe6e:1233', | ||
}; | ||
|
||
const props = { | ||
isOnlyPublicIP: true, | ||
isVPCOnlyLinode: false, | ||
onEdit: vi.fn(), | ||
onRemove: vi.fn(), | ||
readOnly: false, | ||
}; | ||
|
||
it('should display the correct aria-label for the IP address action menu', () => { | ||
const { getByRole } = renderWithTheme( | ||
<LinodeNetworkingActionMenu | ||
{...props} | ||
ipAddress={mockLinodeIPv4} | ||
ipType="IPv4 – Public" | ||
/> | ||
); | ||
|
||
const actionMenuButton = getByRole('button'); | ||
expect(actionMenuButton).toHaveAttribute( | ||
'aria-label', | ||
`Action menu for IP Address ${mockLinodeIPv4.address}` | ||
); | ||
}); | ||
|
||
it('should display the correct aria-label for the IP range action menu', () => { | ||
const { getByRole } = renderWithTheme( | ||
<LinodeNetworkingActionMenu | ||
{...props} | ||
ipAddress={mockLinodeIPv6Range} | ||
ipType="IPv6 – Range" | ||
/> | ||
); | ||
|
||
const actionMenuButton = getByRole('button'); | ||
expect(actionMenuButton).toHaveAttribute( | ||
'aria-label', | ||
`Action menu for IP Address ${mockLinodeIPv6Range.range}` | ||
); | ||
}); | ||
}); |
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