ImagesTable: Adapt to new compose status response

This commit is contained in:
Sanne Raymaekers 2021-02-17 18:29:45 +01:00 committed by Tom Gundersen
parent 17ff7d1c6d
commit 9a590a946e
2 changed files with 28 additions and 8 deletions

View file

@ -53,11 +53,13 @@ class ImagesTable extends Component {
let { updateCompose, composes } = this.props;
Object.entries(composes).map(([ id, compose ]) => {
/* Skip composes that have been complete */
if (compose.status === 'success' || compose.status === 'failure')
return
if (compose.image_status.status === 'success' || compose.image_status.status === 'failure') {
return;
}
api.getComposeStatus(id).then(response => {
let newCompose = {};
newCompose[id] = Object.assign({}, compose, { status: response.status });
newCompose[id] = Object.assign({}, compose, { image_status: response.image_status });
updateCompose(newCompose);
});
});
@ -74,7 +76,7 @@ class ImagesTable extends Component {
id,
uploadOptions[compose.image_type] ? uploadOptions[compose.image_type] : compose.image_type,
{ title: <Release release={ compose.distribution } /> },
{ title: <ImageBuildStatus status={ compose.status } /> },
{ title: <ImageBuildStatus status={ compose.image_status.status } /> },
''
]
};

View file

@ -8,19 +8,37 @@ import '@testing-library/jest-dom';
const store = {
composes: {
'c1cfa347-4c37-49b5-8e73-6aa1d1746cfa': {
status: 'building',
image_status: {
status: 'running',
upload_status: {
type: 'aws',
status: 'success'
}
},
distribution: 'fedora-31',
architecture: 'x86_64',
image_type: 'qcow2'
},
'61b0effa-c901-4ee5-86b9-2010b47f1b22': {
status: 'uploading',
image_status: {
status: 'failure',
upload_status: {
type: 'aws',
status: 'failure'
}
},
distribution: 'fedora-31',
architecture: 'x86_64',
image_type: 'qcow2'
},
'551de6f6-1533-4b46-a69f-7924051f9bc6': {
status: 'success',
image_status: {
status: 'running',
upload_status: {
type: 'aws',
status: ''
}
},
distribution: 'fedora-31',
architecture: 'x86_64',
image_type: 'qcow2'
@ -54,7 +72,7 @@ describe('Images Table', () => {
// render the expected <ImageBuildStatus /> and compare the text content
let testElement = document.createElement('testElement');
render(<ImageBuildStatus status={ compose.status } />, { container: testElement });
render(<ImageBuildStatus status={ compose.image_status.status } />, { container: testElement });
expect(row.cells[3]).toHaveTextContent(testElement.textContent);
}
});