diff --git a/packages/manager/.changeset/pr-11448-tests-1734703218321.md b/packages/manager/.changeset/pr-11448-tests-1734703218321.md new file mode 100644 index 00000000000..c07cf0e9b8b --- /dev/null +++ b/packages/manager/.changeset/pr-11448-tests-1734703218321.md @@ -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)) diff --git a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.test.tsx b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.test.tsx new file mode 100644 index 00000000000..bcb1d6373dc --- /dev/null +++ b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.test.tsx @@ -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( + + ); + + 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( + + ); + + const actionMenuButton = getByRole('button'); + expect(actionMenuButton).toHaveAttribute( + 'aria-label', + `Action menu for IP Address ${mockLinodeIPv6Range.range}` + ); + }); +}); diff --git a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.tsx b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.tsx index d5afac3024a..9f9871b4b24 100644 --- a/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.tsx +++ b/packages/manager/src/features/Linodes/LinodesDetail/LinodeNetworking/LinodeNetworkingActionMenu.tsx @@ -122,6 +122,6 @@ export const LinodeNetworkingActionMenu = (props: Props) => { )} ) : ( - + ); };