test: Replace .getBy queries by awaited .findBy

Components sometimes render slower than tests run which causes failures when the test suite expects elements that did not finish their rendering yet.

This should help to prevent most of possible problems with the rendering speed.
This commit is contained in:
regexowl 2024-01-16 17:11:24 +01:00 committed by Klara Simickova
parent 7b61700c06
commit f90718815b
10 changed files with 505 additions and 349 deletions

View file

@ -83,7 +83,7 @@ const searchForAvailablePackages = async (searchbox, searchTerm) => {
const switchToAWSManual = async () => {
const user = userEvent.setup();
const manualRadio = screen.getByRole('radio', {
const manualRadio = await screen.findByRole('radio', {
name: /manually enter an account id\./i,
});
await user.click(manualRadio);
@ -91,7 +91,7 @@ const switchToAWSManual = async () => {
};
const getSourceDropdown = async () => {
const sourceDropdown = screen.getByRole('textbox', {
const sourceDropdown = await screen.findByRole('textbox', {
name: /select source/i,
});
await waitFor(() => expect(sourceDropdown).toBeEnabled());
@ -111,19 +111,19 @@ afterEach(() => {
});
describe('Create Image Wizard', () => {
test('renders component', () => {
test('renders component', async () => {
renderCustomRoutesWithReduxRouter('imagewizard', {}, routes);
// check heading
screen.getByRole('heading', { name: /Image Builder/ });
await screen.findByRole('heading', { name: /Image Builder/ });
screen.getByRole('button', { name: 'Image output' });
screen.getByRole('button', { name: 'Register' });
screen.getByRole('button', { name: 'File system configuration' });
screen.getByRole('button', { name: 'Content' });
screen.getByRole('button', { name: 'Additional Red Hat packages' });
screen.getByRole('button', { name: 'Custom repositories' });
screen.getByRole('button', { name: 'Details' });
screen.getByRole('button', { name: 'Review' });
await screen.findByRole('button', { name: 'Image output' });
await screen.findByRole('button', { name: 'Register' });
await screen.findByRole('button', { name: 'File system configuration' });
await screen.findByRole('button', { name: 'Content' });
await screen.findByRole('button', { name: 'Additional Red Hat packages' });
await screen.findByRole('button', { name: 'Custom repositories' });
await screen.findByRole('button', { name: 'Details' });
await screen.findByRole('button', { name: 'Review' });
});
});
@ -161,8 +161,8 @@ describe('Step Image output', () => {
test('target environment is required', async () => {
await setUp();
const destination = screen.getByTestId('target-select');
const required = within(destination).getByText('*');
const destination = await screen.findByTestId('target-select');
const required = await within(destination).findByText('*');
expect(destination).toBeEnabled();
expect(destination).toContainElement(required);
});
@ -171,15 +171,15 @@ describe('Step Image output', () => {
await setUp();
const nextButton = await getNextButton();
const awsTile = screen.getByTestId('upload-aws');
const awsTile = await screen.findByTestId('upload-aws');
// this has already been clicked once in the setup function
await user.click(awsTile); // deselect
const googleTile = screen.getByTestId('upload-google');
const googleTile = await screen.findByTestId('upload-google');
await user.click(googleTile); // select
await user.click(googleTile); // deselect
const azureTile = screen.getByTestId('upload-azure');
const azureTile = await screen.findByTestId('upload-azure');
await user.click(azureTile); // select
await user.click(azureTile); // deselect
@ -215,7 +215,7 @@ describe('Step Image output', () => {
})[0];
await user.click(releaseMenu);
const showOptionsButton = screen.getByRole('button', {
const showOptionsButton = await screen.findByRole('button', {
name: 'Show options for further development of RHEL',
});
await user.click(showOptionsButton);
@ -275,12 +275,12 @@ describe('Step Image output', () => {
})[0];
await user.click(releaseMenu);
const showOptionsButton = screen.getByRole('button', {
const showOptionsButton = await screen.findByRole('button', {
name: 'Show options for further development of RHEL',
});
await user.click(showOptionsButton);
const centOSButton = screen.getByRole('option', {
const centOSButton = await screen.findByRole('option', {
name: 'CentOS Stream 9',
});
await user.click(centOSButton);
@ -326,7 +326,9 @@ describe('Step Upload to AWS', () => {
name: 'Select activation key',
});
screen.getByText('Automatically register and enable advanced capabilities');
await screen.findByText(
'Automatically register and enable advanced capabilities'
);
});
test('clicking Back loads Release', async () => {
@ -334,7 +336,7 @@ describe('Step Upload to AWS', () => {
await clickBack();
screen.getByTestId('upload-aws');
await screen.findByTestId('upload-aws');
});
test('clicking Cancel loads landing page', async () => {
@ -362,12 +364,14 @@ describe('Step Upload to AWS', () => {
expect(nextButton).toHaveClass('pf-m-disabled');
await user.click(
screen.getByRole('radio', { name: /manually enter an account id\./i })
await screen.findByRole('radio', {
name: /manually enter an account id\./i,
})
);
expect(nextButton).toHaveClass('pf-m-disabled');
const awsAccId = screen.getByTestId('aws-account-id');
const awsAccId = await screen.findByTestId('aws-account-id');
expect(awsAccId).toHaveValue('');
expect(awsAccId).toBeEnabled();
await user.type(awsAccId, '012345678901');
@ -375,7 +379,7 @@ describe('Step Upload to AWS', () => {
expect(nextButton).not.toHaveClass('pf-m-disabled');
await user.click(
screen.getByRole('radio', {
await screen.findByRole('radio', {
name: /use an account configured from sources\./i,
})
);
@ -411,7 +415,7 @@ describe('Step Upload to AWS', () => {
name: 'Select activation key',
});
const registerLaterRadio = screen.getByLabelText('Register later');
const registerLaterRadio = await screen.findByLabelText('Register later');
await user.click(registerLaterRadio);
// click through to review step
@ -421,7 +425,7 @@ describe('Step Upload to AWS', () => {
await clickNext();
await clickNext();
await user.click(screen.getByRole('button', { name: /Create/ }));
await user.click(await screen.findByRole('button', { name: /Create/ }));
// returns back to the landing page
await waitFor(() =>
@ -469,7 +473,9 @@ describe('Step Upload to Google', () => {
name: 'Select activation key',
});
screen.getByText('Automatically register and enable advanced capabilities');
await screen.findByText(
'Automatically register and enable advanced capabilities'
);
});
test('clicking Back loads Release', async () => {
@ -477,7 +483,7 @@ describe('Step Upload to Google', () => {
await clickBack();
screen.getByTestId('upload-google');
await screen.findByTestId('upload-google');
});
test('clicking Cancel loads landing page', async () => {
@ -489,11 +495,9 @@ describe('Step Upload to Google', () => {
test('the google account id field is shown and required', async () => {
await setUp();
await waitFor(() => {
screen.getByTestId('account-sharing');
});
await screen.findByTestId('account-sharing');
await user.click(screen.getByTestId('account-sharing'));
await user.click(await screen.findByTestId('account-sharing'));
const accessKeyId = await screen.findByTestId('input-google-email');
expect(accessKeyId).toHaveValue('');
expect(accessKeyId).toBeEnabled();
@ -502,11 +506,14 @@ describe('Step Upload to Google', () => {
test('the google email field must be a valid email', async () => {
await setUp();
await user.click(screen.getByTestId('account-sharing'));
await user.type(screen.getByTestId('input-google-email'), 'a');
await user.click(await screen.findByTestId('account-sharing'));
await user.type(await screen.findByTestId('input-google-email'), 'a');
expect(await getNextButton()).toHaveClass('pf-m-disabled');
expect(await getNextButton()).toBeDisabled();
await user.type(screen.getByTestId('input-google-email'), 'test@test.com');
await user.type(
await screen.findByTestId('input-google-email'),
'test@test.com'
);
expect(await getNextButton()).not.toHaveClass('pf-m-disabled');
expect(await getNextButton()).toBeEnabled();
});
@ -528,9 +535,14 @@ describe('Step Registration', () => {
await clickNext();
await user.click(
screen.getByRole('radio', { name: /manually enter an account id\./i })
await screen.findByRole('radio', {
name: /manually enter an account id\./i,
})
);
await user.type(
await screen.findByTestId('aws-account-id'),
'012345678901'
);
await user.type(screen.getByTestId('aws-account-id'), '012345678901');
await clickNext();
await screen.findByRole('textbox', {
@ -541,7 +553,9 @@ describe('Step Registration', () => {
test('clicking Next loads file system configuration', async () => {
await setUp();
const registerLaterRadio = screen.getByTestId('registration-radio-later');
const registerLaterRadio = await screen.findByTestId(
'registration-radio-later'
);
await user.click(registerLaterRadio);
await clickNext();
@ -557,9 +571,11 @@ describe('Step Registration', () => {
await clickBack();
await user.click(
screen.getByRole('radio', { name: /manually enter an account id\./i })
await screen.findByRole('radio', {
name: /manually enter an account id\./i,
})
);
screen.getByText('AWS account ID');
await screen.findByText('AWS account ID');
});
test('clicking Cancel loads landing page', async () => {
@ -593,14 +609,14 @@ describe('Step Registration', () => {
name: 'name0',
});
await user.click(activationKey);
screen.getByDisplayValue('name0');
await screen.findByDisplayValue('name0');
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await clickNext();
const review = screen.getByTestId('review-registration');
const review = await screen.findByTestId('review-registration');
expect(review).toHaveTextContent(
'Register with Red Hat Subscription Manager (RHSM)'
);
@ -614,15 +630,17 @@ describe('Step Registration', () => {
test('should allow registering without rhc', async () => {
await setUp();
await user.click(screen.getByTestId('registration-additional-options'));
await user.click(screen.getByTestId('registration-checkbox-rhc'));
await user.click(
await screen.findByTestId('registration-additional-options')
);
await user.click(await screen.findByTestId('registration-checkbox-rhc'));
// going back and forward when rhc isn't selected should keep additional options shown
await clickBack();
await screen.findByTestId('aws-account-id');
await clickNext();
screen.getByTestId('registration-checkbox-insights');
screen.getByTestId('registration-checkbox-rhc');
await screen.findByTestId('registration-checkbox-insights');
await screen.findByTestId('registration-checkbox-rhc');
const activationKeyDropdown = await screen.findByRole('textbox', {
name: 'Select activation key',
@ -632,14 +650,14 @@ describe('Step Registration', () => {
name: 'name0',
});
await user.click(activationKey);
screen.getByDisplayValue('name0');
await screen.findByDisplayValue('name0');
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await clickNext();
const review = screen.getByTestId('review-registration');
const review = await screen.findByTestId('review-registration');
expect(review).toHaveTextContent(
'Register with Red Hat Subscription Manager (RHSM)'
);
@ -653,15 +671,19 @@ describe('Step Registration', () => {
test('should allow registering without insights or rhc', async () => {
await setUp();
await user.click(screen.getByTestId('registration-additional-options'));
await user.click(screen.getByTestId('registration-checkbox-insights'));
await user.click(
await screen.findByTestId('registration-additional-options')
);
await user.click(
await screen.findByTestId('registration-checkbox-insights')
);
// going back and forward when neither rhc or insights is selected should keep additional options shown
await clickBack();
await screen.findByTestId('aws-account-id');
await clickNext();
screen.getByTestId('registration-checkbox-insights');
screen.getByTestId('registration-checkbox-rhc');
await screen.findByTestId('registration-checkbox-insights');
await screen.findByTestId('registration-checkbox-rhc');
const activationKeyDropdown = await screen.findByRole('textbox', {
name: 'Select activation key',
@ -671,14 +693,14 @@ describe('Step Registration', () => {
name: 'name0',
});
await user.click(activationKey);
screen.getByDisplayValue('name0');
await screen.findByDisplayValue('name0');
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await clickNext();
const review = screen.getByTestId('review-registration');
const review = await screen.findByTestId('review-registration');
expect(review).toHaveTextContent(
'Register with Red Hat Subscription Manager (RHSM)'
);
@ -696,7 +718,7 @@ describe('Step Registration', () => {
]);
// click the later radio button which should remove any input fields
await user.click(screen.getByTestId('registration-radio-later'));
await user.click(await screen.findByTestId('registration-radio-later'));
await removeKeyInformation;
@ -705,18 +727,26 @@ describe('Step Registration', () => {
await clickNext();
await clickNext();
await clickNext();
screen.getByText('Register the system later');
await screen.findByText('Register the system later');
});
test('registering with rhc implies registering with insights', async () => {
await setUp();
await user.click(screen.getByTestId('registration-additional-options'));
await user.click(
await screen.findByTestId('registration-additional-options')
);
await user.click(screen.getByTestId('registration-checkbox-insights'));
expect(screen.getByTestId('registration-checkbox-rhc')).not.toBeChecked();
await user.click(
await screen.findByTestId('registration-checkbox-insights')
);
expect(
await screen.findByTestId('registration-checkbox-rhc')
).not.toBeChecked();
await user.click(screen.getByTestId('registration-checkbox-rhc'));
expect(screen.getByTestId('registration-checkbox-insights')).toBeChecked();
await user.click(await screen.findByTestId('registration-checkbox-rhc'));
expect(
await screen.findByTestId('registration-checkbox-insights')
).toBeChecked();
});
});
@ -747,7 +777,9 @@ describe('Step File system configuration', () => {
name: 'Select activation key',
});
const registerLaterRadio = screen.getByTestId('registration-radio-later');
const registerLaterRadio = await screen.findByTestId(
'registration-radio-later'
);
await user.click(registerLaterRadio);
await clickNext();
};
@ -755,7 +787,7 @@ describe('Step File system configuration', () => {
test('Error validation occurs upon clicking next button', async () => {
await setUp();
const manuallyConfigurePartitions = screen.getByText(
const manuallyConfigurePartitions = await screen.findByText(
/manually configure partitions/i
);
await user.click(manuallyConfigurePartitions);
@ -771,7 +803,7 @@ describe('Step File system configuration', () => {
// Clicking next causes errors to appear
await clickNext();
const mountPointWarning = screen.getByRole('heading', {
const mountPointWarning = await screen.findByRole('heading', {
name: /danger alert: duplicate mount points: all mount points must be unique\. remove the duplicate or choose a new mount point\./i,
hidden: true,
});
@ -780,7 +812,7 @@ describe('Step File system configuration', () => {
name: /danger alert: duplicate mount point\./i,
});
const tbody = screen.getByTestId('file-system-configuration-tbody');
const tbody = await screen.findByTestId('file-system-configuration-tbody');
const rows = within(tbody).getAllByRole('row');
expect(rows).toHaveLength(3);
@ -828,7 +860,9 @@ describe('Step Details', () => {
name: 'Select activation key',
});
const registerLaterRadio = screen.getByTestId('registration-radio-later');
const registerLaterRadio = await screen.findByTestId(
'registration-radio-later'
);
await user.click(registerLaterRadio);
await clickNext();
@ -844,7 +878,7 @@ describe('Step Details', () => {
await setUp();
// Enter image name
const nameInput = screen.getByRole('textbox', {
const nameInput = await screen.findByRole('textbox', {
name: 'Image Name',
});
// 64 character name
@ -859,7 +893,7 @@ describe('Step Details', () => {
expect(await getNextButton()).toBeEnabled();
// Enter description image
const descriptionInput = screen.getByRole('textbox', {
const descriptionInput = await screen.findByRole('textbox', {
name: /description/i,
});
@ -904,7 +938,9 @@ describe('Step Review', () => {
});
// skip registration
const registerLaterRadio = screen.getByTestId('registration-radio-later');
const registerLaterRadio = await screen.findByTestId(
'registration-radio-later'
);
await user.click(registerLaterRadio);
await clickNext();
@ -926,12 +962,12 @@ describe('Step Review', () => {
})[0];
await user.click(releaseMenu);
const showOptionsButton = screen.getByRole('button', {
const showOptionsButton = await screen.findByRole('button', {
name: 'Show options for further development of RHEL',
});
await user.click(showOptionsButton);
const centos = screen.getByRole('option', {
const centos = await screen.findByRole('option', {
name: 'CentOS Stream 8',
});
await user.click(centos);
@ -962,9 +998,9 @@ describe('Step Review', () => {
test('has 3 buttons', async () => {
await setUp();
screen.getByRole('button', { name: /Create/ });
screen.getByRole('button', { name: /Back/ });
screen.getByRole('button', { name: /Cancel/ });
await screen.findByRole('button', { name: /Create/ });
await screen.findByRole('button', { name: /Back/ });
await screen.findByRole('button', { name: /Cancel/ });
});
test('clicking Back loads Image name', async () => {
@ -972,7 +1008,7 @@ describe('Step Review', () => {
await clickBack();
screen.getByRole('heading', {
await screen.findByRole('heading', {
name: 'Details',
});
});
@ -986,25 +1022,25 @@ describe('Step Review', () => {
test('has Registration expandable section for rhel', async () => {
await setUp();
const targetExpandable = screen.getByTestId(
const targetExpandable = await screen.findByTestId(
'target-environments-expandable'
);
const registrationExpandable = screen.getByTestId(
const registrationExpandable = await screen.findByTestId(
'registration-expandable'
);
const contentExpandable = screen.getByTestId('content-expandable');
const fscExpandable = screen.getByTestId(
const contentExpandable = await screen.findByTestId('content-expandable');
const fscExpandable = await screen.findByTestId(
'file-system-configuration-expandable'
);
await user.click(targetExpandable);
screen.getByText('AWS');
await screen.findByText('AWS');
await user.click(registrationExpandable);
screen.getByText('Register the system later');
await screen.findByText('Register the system later');
await user.click(contentExpandable);
screen.getByText('Additional Red Hatand 3rd party packages');
await screen.findByText('Additional Red Hatand 3rd party packages');
await user.click(fscExpandable);
screen.getByText('Configuration type');
await screen.findByText('Configuration type');
});
test('has no Registration expandable for centos', async () => {
@ -1022,11 +1058,11 @@ describe('Step Review', () => {
).not.toBeInTheDocument();
await user.click(targetExpandable);
screen.getByText('AWS');
await screen.findByText('AWS');
await user.click(contentExpandable);
screen.getByText('Additional Red Hatand 3rd party packages');
await screen.findByText('Additional Red Hatand 3rd party packages');
await user.click(fscExpandable);
screen.getByText('Configuration type');
await screen.findByText('Configuration type');
});
});
@ -1051,44 +1087,52 @@ describe('Click through all steps', () => {
name: /options menu/i,
})[0];
await user.click(releaseMenu);
const releaseOption = screen.getByRole('option', {
const releaseOption = await screen.findByRole('option', {
name: /Red Hat Enterprise Linux \(RHEL\) 8/,
});
await user.click(releaseOption);
await waitFor(() => screen.findByTestId('upload-aws'));
await user.click(screen.getByTestId('upload-azure'));
await user.click(screen.getByTestId('upload-google'));
await user.click(screen.getByTestId('checkbox-vmware'));
await user.click(screen.getByTestId('checkbox-guest-image'));
await user.click(screen.getByTestId('checkbox-image-installer'));
await user.click(await screen.findByTestId('upload-azure'));
await user.click(await screen.findByTestId('upload-google'));
await user.click(await screen.findByTestId('checkbox-vmware'));
await user.click(await screen.findByTestId('checkbox-guest-image'));
await user.click(await screen.findByTestId('checkbox-image-installer'));
await clickNext();
await user.click(
screen.getByRole('radio', { name: /manually enter an account id\./i })
await screen.findByRole('radio', {
name: /manually enter an account id\./i,
})
);
await user.type(
await screen.findByTestId('aws-account-id'),
'012345678901'
);
await user.type(screen.getByTestId('aws-account-id'), '012345678901');
await clickNext();
await user.click(screen.getByTestId('account-sharing'));
await user.click(await screen.findByTestId('account-sharing'));
await user.type(screen.getByTestId('input-google-email'), 'test@test.com');
await user.type(
await screen.findByTestId('input-google-email'),
'test@test.com'
);
await user.click(await screen.findByTestId('account-sharing'));
await clickNext();
await user.click(screen.getByTestId('azure-radio-manual'));
await user.click(await screen.findByTestId('azure-radio-manual'));
// Randomly generated GUID
await user.type(
screen.getByTestId('azure-tenant-id-manual'),
await screen.findByTestId('azure-tenant-id-manual'),
'b8f86d22-4371-46ce-95e7-65c415f3b1e2'
);
await user.type(
screen.getByTestId('azure-subscription-id-manual'),
await screen.findByTestId('azure-subscription-id-manual'),
'60631143-a7dc-4d15-988b-ba83f3c99711'
);
await user.type(
screen.getByTestId('azure-resource-group-manual'),
await screen.findByTestId('azure-resource-group-manual'),
'testResourceGroup'
);
await clickNext();
@ -1102,7 +1146,7 @@ describe('Click through all steps', () => {
name: 'name0',
});
await user.click(activationKey);
screen.getByDisplayValue('name0');
await screen.findByDisplayValue('name0');
await clickNext();
@ -1115,7 +1159,7 @@ describe('Click through all steps', () => {
await user.click(addPartition);
await user.click(addPartition);
const tbody = screen.getByTestId('file-system-configuration-tbody');
const tbody = await screen.findByTestId('file-system-configuration-tbody');
const rows = within(tbody).getAllByRole('row');
await waitFor(() => expect(rows).toHaveLength(3));
await clickNext();
@ -1136,7 +1180,7 @@ describe('Click through all steps', () => {
})
).not.toBeInTheDocument();
await user.type(
within(rows[2]).getByRole('textbox', {
await within(rows[2]).findByRole('textbox', {
name: 'Mount point suffix text input',
}),
'/tmp'
@ -1144,7 +1188,7 @@ describe('Click through all steps', () => {
// set size of the final row to 100 MiB
await user.type(
within(rows[2]).getByRole('textbox', { name: 'Size text input' }),
await within(rows[2]).findByRole('textbox', { name: 'Size text input' }),
'{backspace}100'
);
const unitMenu = within(rows[2]).getAllByRole('button', {
@ -1158,7 +1202,7 @@ describe('Click through all steps', () => {
await user.click(mibButton);
await clickNext();
screen.getByText(
await screen.findByText(
/Images built with Image Builder include all required packages/i
);
@ -1172,7 +1216,9 @@ describe('Click through all steps', () => {
name: /test summary for test package/,
})
);
await user.click(screen.getByRole('button', { name: /Add selected/ }));
await user.click(
await screen.findByRole('button', { name: /Add selected/ })
);
await clickNext();
// Custom repositories
@ -1188,14 +1234,14 @@ describe('Click through all steps', () => {
await clickNext();
// Enter image name
const nameInput = screen.getByRole('textbox', {
const nameInput = await screen.findByRole('textbox', {
name: 'Image Name',
});
await user.type(nameInput, 'my-image-name');
// Enter description for image
const descriptionInput = screen.getByRole('textbox', {
const descriptionInput = await screen.findByRole('textbox', {
name: /Description/,
});
await user.type(
@ -1219,7 +1265,7 @@ describe('Click through all steps', () => {
'registration-expandable'
);
await user.click(registrationExpandable);
const review = screen.getByTestId('review-registration');
const review = await screen.findByTestId('review-registration');
expect(review).toHaveTextContent(
'Use remote host configuration (rhc) utility'
);
@ -1235,13 +1281,15 @@ describe('Click through all steps', () => {
await screen.findByText('Self-Support');
await screen.findByText('Production');
await user.click(screen.getByTestId('repositories-popover-button'));
await user.click(await screen.findByTestId('repositories-popover-button'));
const repotbody = await screen.findByTestId(
'additional-repositories-table'
);
expect(within(repotbody).getAllByRole('row')).toHaveLength(3);
await user.click(screen.getByTestId('file-system-configuration-popover'));
await user.click(
await screen.findByTestId('file-system-configuration-popover')
);
const revtbody = await screen.findByTestId(
'file-system-configuration-tbody-review'
);
@ -1442,7 +1490,7 @@ describe('Click through all steps', () => {
);
})
);
await user.click(screen.getByRole('button', { name: /Create/ }));
await user.click(await screen.findByRole('button', { name: /Create/ }));
expect(receivedComposeReqs).toEqual(expectedComposeReqs);
expect(timesCalled).toEqual(6);
@ -1471,10 +1519,10 @@ describe('Keyboard accessibility', () => {
await waitFor(
async () => await user.click(await screen.findByTestId('upload-aws'))
);
await user.click(screen.getByTestId('upload-google'));
await user.click(screen.getByTestId('upload-azure'));
await user.click(await screen.findByTestId('upload-google'));
await user.click(await screen.findByTestId('upload-azure'));
await user.click(
screen.getByRole('checkbox', {
await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
})
);
@ -1488,7 +1536,7 @@ describe('Keyboard accessibility', () => {
await clickNext();
// Target environment aws
expect(screen.getByTestId('aws-radio-source')).toHaveFocus();
expect(await screen.findByTestId('aws-radio-source')).toHaveFocus();
const awsSourceDropdown = await getSourceDropdown();
await user.click(awsSourceDropdown);
const awsSource = await screen.findByRole('option', {
@ -1508,7 +1556,7 @@ describe('Keyboard accessibility', () => {
await clickNext();
// Target environment azure
expect(screen.getByTestId('azure-radio-source')).toHaveFocus();
expect(await screen.findByTestId('azure-radio-source')).toHaveFocus();
const azureSourceDropdown = await getSourceDropdown();
await user.click(azureSourceDropdown);
const azureSource = await screen.findByRole('option', {
@ -1520,20 +1568,24 @@ describe('Keyboard accessibility', () => {
name: /select resource group/i,
});
await user.click(resourceGroupDropdown);
await user.click(screen.getByLabelText('Resource group myResourceGroup1'));
await user.click(
await screen.findByLabelText('Resource group myResourceGroup1')
);
await clickNext();
// Registration
await screen.findByText(
'Automatically register and enable advanced capabilities'
);
const registerRadio = screen.getByTestId('registration-radio-now');
const registerRadio = await screen.findByTestId('registration-radio-now');
expect(registerRadio).toHaveFocus();
await screen.findByRole('textbox', {
name: 'Select activation key',
});
// skip registration
const registerLaterRadio = screen.getByTestId('registration-radio-later');
const registerLaterRadio = await screen.findByTestId(
'registration-radio-later'
);
await user.click(registerLaterRadio);
await clickNext();
@ -1542,9 +1594,9 @@ describe('Keyboard accessibility', () => {
await clickNext();
// Packages
const view = screen.getByTestId('search-available-pkgs-input');
const view = await screen.findByTestId('search-available-pkgs-input');
const availablePackagesInput = within(view).getByRole('textbox', {
const availablePackagesInput = await within(view).findByRole('textbox', {
name: /search input/i,
});
await waitFor(() => expect(availablePackagesInput).toBeEnabled());
@ -1555,7 +1607,9 @@ describe('Keyboard accessibility', () => {
await clickNext();
// Name
const nameInput = screen.getByRole('textbox', { name: /image name/i });
const nameInput = await screen.findByRole('textbox', {
name: /image name/i,
});
expect(nameInput).toHaveFocus();
await clickNext();
});
@ -1576,7 +1630,7 @@ describe('Keyboard accessibility', () => {
async () => await user.click(await screen.findByTestId('upload-aws'))
);
await user.keyboard('{enter}');
screen.getByRole('heading', {
await screen.findByRole('heading', {
name: /image output/i,
});
});
@ -1594,8 +1648,8 @@ describe('Keyboard accessibility', () => {
await clickNext();
await waitFor(() => screen.findByTestId('upload-aws'));
testTile(screen.getByTestId('upload-aws'));
testTile(screen.getByTestId('upload-google'));
testTile(screen.getByTestId('upload-azure'));
testTile(await screen.findByTestId('upload-aws'));
testTile(await screen.findByTestId('upload-google'));
testTile(await screen.findByTestId('upload-azure'));
});
});