Skip to content

Commit

Permalink
test: [M3-8863, M3-9040] - Cypress test to validate aria label of Lin…
Browse files Browse the repository at this point in the history
…ode IP Addresses/Ranges action menu (linode#11435)

* Add cypress test to validate ip address table row action menu label

* Few updates

* Added changeset: Cypress test to validate aria label of Linode IP Addresses action menu

* Add test coverage for ip range
  • Loading branch information
pmakode-akamai authored Dec 20, 2024
1 parent 9c2d7b8 commit 0b0fa66
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 12 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11435-tests-1734516339389.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Cypress test to validate aria label of Linode IP Addresses action menu ([#11435](https://github.com/linode/manager/pull/11435))
75 changes: 63 additions & 12 deletions packages/manager/cypress/e2e/core/linodes/linode-network.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { linodeFactory, ipAddressFactory } from '@src/factories';

import type { IPRange } from '@linode/api-v4';

import {
mockGetLinodeDetails,
mockGetLinodeIPAddresses,
Expand All @@ -9,19 +11,31 @@ import { mockUpdateIPAddress } from 'support/intercepts/networking';
import { ui } from 'support/ui';

describe('linode networking', () => {
/**
* - Confirms the success toast message after editing RDNS
*/
it('checks for the toast message upon editing an RDNS', () => {
const mockLinode = linodeFactory.build();
const linodeIPv4 = mockLinode.ipv4[0];
const mockRDNS = `${linodeIPv4}.ip.linodeusercontent.com`;
const ipAddress = ipAddressFactory.build({
address: linodeIPv4,
linode_id: mockLinode.id,
rdns: mockRDNS,
});
const mockLinode = linodeFactory.build();
const linodeIPv4 = mockLinode.ipv4[0];
const mockRDNS = `${linodeIPv4}.ip.linodeusercontent.com`;
const ipAddress = ipAddressFactory.build({
address: linodeIPv4,
linode_id: mockLinode.id,
rdns: mockRDNS,
});
const _ipv6Range: IPRange = {
prefix: 64,
range: '2fff:db08:e003:1::',
region: 'us-east',
route_target: '2600:3c02::f03c:92ff:fe9d:0f25',
};
const ipv6Range = `${_ipv6Range.range}/${_ipv6Range.prefix}`;
const ipv6Address = ipAddressFactory.build({
address: mockLinode.ipv6 ?? '2600:3c00::f03c:92ff:fee2:6c40/64',
gateway: 'fe80::1',
linode_id: mockLinode.id,
prefix: 64,
subnet_mask: 'ffff:ffff:ffff:ffff::',
type: 'ipv6',
});

beforeEach(() => {
mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode');
mockGetLinodeFirewalls(mockLinode.id, []).as('getLinodeFirewalls');
mockGetLinodeIPAddresses(mockLinode.id, {
Expand All @@ -31,12 +45,22 @@ describe('linode networking', () => {
shared: [],
reserved: [],
},
ipv6: {
global: [_ipv6Range],
link_local: ipv6Address,
slaac: ipv6Address,
},
}).as('getLinodeIPAddresses');
mockUpdateIPAddress(linodeIPv4, mockRDNS).as('updateIPAddress');

cy.visitWithLogin(`linodes/${mockLinode.id}/networking`);
cy.wait(['@getLinode', '@getLinodeFirewalls', '@getLinodeIPAddresses']);
});

/**
* - Confirms the success toast message after editing RDNS
*/
it('checks for the toast message upon editing an RDNS', () => {
cy.findByLabelText('IPv4 Addresses')
.should('be.visible')
.within(() => {
Expand Down Expand Up @@ -80,4 +104,31 @@ describe('linode networking', () => {
// confirm RDNS toast message
ui.toast.assertMessage(`Successfully updated RDNS for ${linodeIPv4}`);
});

it('validates the action menu title (aria-label) for the IP address in the table row', () => {
// Set the viewport to 1279px x 800px (width < 1280px) to ensure the Action menu is visible.
cy.viewport(1279, 800);

// Ensure the action menu has the correct aria-label for the IP address.
cy.get(`[data-qa-ip="${linodeIPv4}"]`)
.should('be.visible')
.closest('tr')
.within(() => {
cy.findByText('IPv4 – Public').should('be.visible');
ui.actionMenu
.findByTitle(`Action menu for IP Address ${linodeIPv4}`)
.should('be.visible');
});

// Ensure the action menu has the correct aria-label for the IP Range.
cy.get(`[data-qa-ip="${ipv6Range}"]`)
.should('be.visible')
.closest('tr')
.within(() => {
cy.findByText('IPv6 – Range').should('be.visible');
ui.actionMenu
.findByTitle(`Action menu for IP Address ${_ipv6Range.range}`)
.should('be.visible');
});
});
});

0 comments on commit 0b0fa66

Please sign in to comment.