Skip to content

Commit

Permalink
Fix Jest test for ASCS details table (#2134)
Browse files Browse the repository at this point in the history
  • Loading branch information
dottorblaster authored Jan 8, 2024
1 parent c254469 commit 5528efe
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions assets/js/pages/ClusterDetails/AscsErsClusterDetails.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { faker } from '@faker-js/faker';
import { screen, waitFor } from '@testing-library/react';
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom';

Expand Down Expand Up @@ -108,25 +108,29 @@ describe('ClusterDetails AscsErsClusterDetails component', () => {
const table = screen.getByRole('table');

nodes.forEach(
async (
{ id: hostId, name: nodeName, role, virtual_ip: virtualIp, filesysten },
(
{
id: hostId,
name: nodeName,
roles,
virtual_ips: virtualIps,
filesystems,
},
index
) => {
await waitFor(() => {
const row = table.querySelector(`tbody > tr:nth-child(${index}`);
const hostnameCell = row.querySelector('td:nth-child(0)');
expect(hostnameCell).toHaveTextContent(nodeName);
expect(hostnameCell)
.querySelector('a')
.toHaveAttributes('href', hostId);
expect(row.querySelector('td:nth-child(1)')).toHaveTextContent(role);
expect(row.querySelector('td:nth-child(2)')).toHaveTextContent(
virtualIp
);
expect(row.querySelector('td:nth-child(3)')).toHaveTextContent(
filesysten
);
});
const row = table.querySelector(`tbody > tr:nth-child(${index + 1})`);
const hostnameCell = row.querySelector('td:nth-child(1)');
expect(hostnameCell).toHaveTextContent(nodeName);
expect(hostnameCell.querySelector('a')).toHaveAttribute('href', hostId);
expect(row.querySelector('td:nth-child(2)')).toHaveTextContent(
roles[0].toUpperCase()
);
expect(row.querySelector('td:nth-child(3)')).toHaveTextContent(
virtualIps[0]
);
expect(row.querySelector('td:nth-child(4)')).toHaveTextContent(
filesystems[0]
);
}
);
});
Expand Down

0 comments on commit 5528efe

Please sign in to comment.