test: Improve stability of the ImagesTable tests
This should help with tests flaking on the `act()` error.
This commit is contained in:
parent
cbe710e75e
commit
51ad859747
2 changed files with 11 additions and 12 deletions
|
|
@ -129,7 +129,7 @@ describe('On Recreate', () => {
|
||||||
await waitFor(() => expect(createImageButton).toBeEnabled());
|
await waitFor(() => expect(createImageButton).toBeEnabled());
|
||||||
|
|
||||||
// check that the FSC contains a /tmp partition
|
// check that the FSC contains a /tmp partition
|
||||||
const navigation = screen.getByRole('navigation');
|
const navigation = await screen.findByRole('navigation');
|
||||||
await user.click(
|
await user.click(
|
||||||
await within(navigation).findByRole('button', {
|
await within(navigation).findByRole('button', {
|
||||||
name: /file system configuration/i,
|
name: /file system configuration/i,
|
||||||
|
|
|
||||||
|
|
@ -123,18 +123,14 @@ describe('Images Table', () => {
|
||||||
name: 'Actions',
|
name: 'Actions',
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitFor(() => {
|
expect(actionsButton).toBeEnabled();
|
||||||
expect(actionsButton).toBeEnabled();
|
|
||||||
});
|
|
||||||
|
|
||||||
user.click(actionsButton);
|
await user.click(actionsButton);
|
||||||
const recreateButton = await screen.findByRole('menuitem', {
|
const recreateButton = await screen.findByRole('menuitem', {
|
||||||
name: 'Recreate image',
|
name: 'Recreate image',
|
||||||
});
|
});
|
||||||
|
|
||||||
act(() => {
|
await user.click(recreateButton);
|
||||||
user.click(recreateButton);
|
|
||||||
});
|
|
||||||
|
|
||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(router.state.location.pathname).toBe(
|
expect(router.state.location.pathname).toBe(
|
||||||
|
|
@ -157,7 +153,7 @@ describe('Images Table', () => {
|
||||||
const actionsButton = await within(rows[1]).findByRole('button', {
|
const actionsButton = await within(rows[1]).findByRole('button', {
|
||||||
name: 'Actions',
|
name: 'Actions',
|
||||||
});
|
});
|
||||||
user.click(actionsButton);
|
await user.click(actionsButton);
|
||||||
|
|
||||||
const downloadButton = await screen.findByRole('menuitem', {
|
const downloadButton = await screen.findByRole('menuitem', {
|
||||||
name: 'Download compose request (.json)',
|
name: 'Download compose request (.json)',
|
||||||
|
|
@ -165,7 +161,7 @@ describe('Images Table', () => {
|
||||||
|
|
||||||
// No actual clicking because downloading is hard to test.
|
// No actual clicking because downloading is hard to test.
|
||||||
// Instead, we just check href and download properties of the <a> element.
|
// Instead, we just check href and download properties of the <a> element.
|
||||||
const downloadLink = within(downloadButton).getByRole('link');
|
const downloadLink = await within(downloadButton).findByRole('link');
|
||||||
expect(downloadLink.download).toBe(
|
expect(downloadLink.download).toBe(
|
||||||
'request-1579d95b-8f1d-4982-8c53-8c2afa4ab04c.json'
|
'request-1579d95b-8f1d-4982-8c53-8c2afa4ab04c.json'
|
||||||
);
|
);
|
||||||
|
|
@ -174,8 +170,11 @@ describe('Images Table', () => {
|
||||||
expect(hrefParts.length).toBe(2);
|
expect(hrefParts.length).toBe(2);
|
||||||
const [header, encodedRequest] = hrefParts;
|
const [header, encodedRequest] = hrefParts;
|
||||||
expect(header).toBe('data:text/plain;charset=utf-8');
|
expect(header).toBe('data:text/plain;charset=utf-8');
|
||||||
expect(encodedRequest).toBe(
|
|
||||||
encodeURIComponent(JSON.stringify(expectedRequest, null, ' '))
|
await waitFor(() =>
|
||||||
|
expect(encodedRequest).toBe(
|
||||||
|
encodeURIComponent(JSON.stringify(expectedRequest, null, ' '))
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue