Revert "ImagesTable: Update ClonesTable"

This reverts commit 2f55648310.
This commit is contained in:
Klara Simickova 2023-06-01 17:38:57 +02:00
parent 2f55648310
commit 6af015f0e0
2 changed files with 65 additions and 49 deletions

View file

@ -198,11 +198,17 @@ describe('Images Table', () => {
name: /details/i,
});
expect(screen.getByText(/ami-0e778053cd490ad21/i)).not.toBeVisible();
expect(
screen.getAllByText(/1579d95b-8f1d-4982-8c53-8c2afa4ab04c/i)[1]
).not.toBeVisible();
await user.click(toggleButton);
expect(screen.getByText(/ami-0e778053cd490ad21/i)).toBeVisible();
expect(
screen.getAllByText(/1579d95b-8f1d-4982-8c53-8c2afa4ab04c/i)[1]
).toBeVisible();
await user.click(toggleButton);
expect(screen.getByText(/ami-0e778053cd490ad21/i)).not.toBeVisible();
expect(
screen.getAllByText(/1579d95b-8f1d-4982-8c53-8c2afa4ab04c/i)[1]
).not.toBeVisible();
});
test('check error details', async () => {
@ -239,7 +245,7 @@ describe('Images Table Toolbar', () => {
describe('Clones table', () => {
test('renders clones table', async () => {
renderWithReduxRouter('', {});
const view = renderWithReduxRouter('', {});
const table = await screen.findByTestId('images-table');
@ -247,6 +253,8 @@ describe('Clones table', () => {
const emptyState = screen.queryByTestId('empty-state');
expect(emptyState).not.toBeInTheDocument();
const state = view.store.getState();
// get rows
const { getAllByRole } = within(table);
const rows = getAllByRole('row');
@ -264,24 +272,29 @@ describe('Clones table', () => {
// remove first row from list since it is just header labels
const header = cloneRows.shift();
// test the header has correct labels
expect(header.cells[0]).toHaveTextContent('AMI');
expect(header.cells[1]).toHaveTextContent('Region');
expect(header.cells[2]).toHaveTextContent('Status');
expect(header.cells[0]).toHaveTextContent('UUID');
expect(header.cells[1]).toHaveTextContent('Account');
expect(header.cells[2]).toHaveTextContent('Region');
expect(header.cells[3]).toHaveTextContent('Status');
// shift by a parent compose as the row has a different format
cloneRows.shift();
expect(cloneRows).toHaveLength(4);
expect(cloneRows).toHaveLength(5);
// prepend parent data
const clonesTableData = {
ami: [
...mockClones.data.map(
(clone) => mockCloneStatus[clone.id].options.ami
),
uuid: [
'1579d95b-8f1d-4982-8c53-8c2afa4ab04c',
...mockClones.data.map((clone) => clone.id),
],
created: [
'2021-04-27 12:31:12.794809 +0000 UTC',
...mockClones.data.map((clone) => clone.created_at),
],
account: [
'123123123123',
...mockClones.data.map((clone) => clone.request.share_with_accounts[0]),
],
created: [...mockClones.data.map((clone) => clone.created_at)],
region: [
'us-east-1',
...mockClones.data.map(
(clone) => mockCloneStatus[clone.id].options.region
),
@ -289,28 +302,25 @@ describe('Clones table', () => {
};
for (const [index, row] of cloneRows.entries()) {
// render AMIs in correct order
switch (index) {
case (0, 1, 3):
expect(row.cells[0]).toHaveTextContent(clonesTableData.ami[index]);
break;
case 2:
expect(row.cells[0]).toHaveTextContent('');
break;
}
// render UUIDs in correct order
expect(row.cells[0]).toHaveTextContent(clonesTableData.uuid[index]);
// account cell
expect(row.cells[1]).toHaveTextContent(clonesTableData.account[index]);
// region cell
expect(row.cells[1]).toHaveTextContent(clonesTableData.region[index]);
expect(row.cells[2]).toHaveTextContent(clonesTableData.region[index]);
const testElement = document.createElement('testElement');
const imageId = clonesTableData.uuid[index];
// status cell
switch (index) {
case (0, 1, 3):
expect(row.cells[2]).toHaveTextContent('Ready');
break;
case 2:
expect(row.cells[2]).toHaveTextContent('Image build failed');
break;
}
renderWithProvider(
<ImageBuildStatus imageId={imageId} />,
testElement,
state
);
expect(row.cells[3]).toHaveTextContent(testElement.textContent);
}
});
});