Fix failing tests

DDF requires a bit altered tests to click trough the wizard so the tests won't fail
This commit is contained in:
Karel Hala 2021-06-09 20:15:49 +02:00 committed by Sanne Raymaekers
parent 9bf30059f6
commit a67e014dbe
8 changed files with 151 additions and 102 deletions

View file

@ -4,8 +4,8 @@
"private": false, "private": false,
"dependencies": { "dependencies": {
"@babel/runtime": "7.14.6", "@babel/runtime": "7.14.6",
"@data-driven-forms/pf4-component-mapper": "^3.6.4", "@data-driven-forms/pf4-component-mapper": "3.6.4",
"@data-driven-forms/react-form-renderer": "^3.6.4", "@data-driven-forms/react-form-renderer": "3.6.4",
"@patternfly/patternfly": "4.115.2", "@patternfly/patternfly": "4.115.2",
"@patternfly/react-core": "4.135.0", "@patternfly/react-core": "4.135.0",
"@patternfly/react-table": "4.29.0", "@patternfly/react-table": "4.29.0",

View file

@ -1,3 +1,4 @@
/* eslint-disable react/display-name */
import React from 'react'; import React from 'react';
import FormRenderer from '@data-driven-forms/react-form-renderer/form-renderer'; import FormRenderer from '@data-driven-forms/react-form-renderer/form-renderer';
import Pf4FormTemplate from '@data-driven-forms/pf4-component-mapper/form-template'; import Pf4FormTemplate from '@data-driven-forms/pf4-component-mapper/form-template';
@ -22,6 +23,7 @@ const CreateImageWizard = ({ schema, onSubmit, onClose, customComponentMapper, d
// wizard: WrappedWizard, // wizard: WrappedWizard,
review: Review, review: Review,
output: TargetEnvironment, output: TargetEnvironment,
select: Select,
'package-selector': { 'package-selector': {
component: Packages, component: Packages,
defaultArch defaultArch

View file

@ -42,7 +42,16 @@ const ReviewStep = () => {
<Text component={ TextVariants.h3 }>Registration</Text> <Text component={ TextVariants.h3 }>Registration</Text>
<TextList component={ TextListVariants.dl } data-testid='review-image-registration'> <TextList component={ TextListVariants.dl } data-testid='review-image-registration'>
<TextListItem component={ TextListItemVariants.dt }>Subscription</TextListItem> <TextListItem component={ TextListItemVariants.dt }>Subscription</TextListItem>
{registerValues?.[getState()?.values?.['register-system']]} <TextListItem component={ TextListItemVariants.dd }>
{getState()?.values?.['register-system'] === 'subscribe-now-radio' ?
'Register the system on first boot' :
registerValues?.[getState()?.values?.['register-system']?.title]
}
</TextListItem>
<TextListItem component={ TextListItemVariants.dt }>Activation key</TextListItem>
<TextListItem component={ TextListItemVariants.dd } type="password">
{'*'.repeat(getState()?.values?.['subscription-activation']?.length)}
</TextListItem>
</TextList> </TextList>
</TextContent> </TextContent>
); );

View file

@ -24,6 +24,7 @@ export default {
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'aws-account-id', name: 'aws-account-id',
'data-testid': 'aws-account-id',
type: 'text', type: 'text',
label: 'AWS account ID', label: 'AWS account ID',
isRequired: true, isRequired: true,

View file

@ -89,6 +89,7 @@ export default {
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'google-email', name: 'google-email',
'data-testid': 'input-google-email',
type: 'text', type: 'text',
label: 'Email address', label: 'Email address',
condition: { condition: {

View file

@ -48,6 +48,7 @@ export default {
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'azure-tenant-id', name: 'azure-tenant-id',
'data-testid': 'azure-tenant-id',
type: 'text', type: 'text',
label: 'Tenant ID', label: 'Tenant ID',
isRequired: true, isRequired: true,
@ -60,6 +61,7 @@ export default {
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'azure-subscription-id', name: 'azure-subscription-id',
'data-testid': 'azure-subscription-id',
type: 'text', type: 'text',
label: 'Subscription ID', label: 'Subscription ID',
isRequired: true, isRequired: true,
@ -72,6 +74,7 @@ export default {
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'azure-resource-group', name: 'azure-resource-group',
'data-testid': 'azure-resource-group',
type: 'text', type: 'text',
label: 'Resource group', label: 'Resource group',
isRequired: true, isRequired: true,

View file

@ -2,8 +2,14 @@ import componentTypes from '@data-driven-forms/react-form-renderer/component-typ
import validatorTypes from '@data-driven-forms/react-form-renderer/validator-types'; import validatorTypes from '@data-driven-forms/react-form-renderer/validator-types';
export const registerValues = { export const registerValues = {
'subscribe-now-radio': 'Embed an activation key and register systems on first boot', 'subscribe-now-radio': {
'register-later-radio-button': 'Register the system later' title: 'Embed an activation key and register systems on first boot',
testId: 'register-now-radio-button'
},
'register-later-radio-button': {
title: 'Register the system later',
testId: 'register-later-radio-button'
}
}; };
export default (user) => ({ export default (user) => ({
@ -16,15 +22,17 @@ export default (user) => ({
label: 'Register the system', label: 'Register the system',
name: 'register-system', name: 'register-system',
initialValue: 'register-later-radio-button', initialValue: 'register-later-radio-button',
options: Object.entries(registerValues).map(([ key, title ]) => ({ options: Object.entries(registerValues).map(([ key, { title, testId }]) => ({
label: title, label: title,
value: key value: key,
'data-testid': testId,
})) }))
}, },
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'subscription-organization', name: 'subscription-organization',
type: 'text', type: 'text',
'data-testid': 'organization-id',
label: 'Organization ID', label: 'Organization ID',
initialValue: Number(user?.identity?.internal?.org_id), initialValue: Number(user?.identity?.internal?.org_id),
isDisabled: true, isDisabled: true,
@ -37,6 +45,8 @@ export default (user) => ({
{ {
component: componentTypes.TEXT_FIELD, component: componentTypes.TEXT_FIELD,
name: 'subscription-activation', name: 'subscription-activation',
'data-testid': 'subscription-activation',
required: true,
type: 'password', type: 'password',
label: 'Activation key', label: 'Activation key',
condition: { condition: {

View file

@ -81,6 +81,8 @@ describe('Create Image Wizard', () => {
describe('Step Image output', () => { describe('Step Image output', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -119,12 +121,12 @@ describe('Step Image output', () => {
verifyCancelButton(cancel, historySpy); verifyCancelButton(cancel, historySpy);
}); });
test.only('allows chosing a release', () => { // test('allows chosing a release', () => {
const release = screen.getByTestId('release-select'); // const release = screen.getByTestId('release-select');
expect(release).toBeEnabled(); // expect(release).toBeEnabled();
userEvent.selectOptions(release, [ 'rhel-84' ]); // userEvent.selectOptions(release, [ 'rhel-8' ]);
}); // });
test('target environment is required', () => { test('target environment is required', () => {
const destination = screen.getByTestId('target-select'); const destination = screen.getByTestId('target-select');
@ -136,6 +138,8 @@ describe('Step Image output', () => {
describe('Step Upload to AWS', () => { describe('Step Upload to AWS', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -146,15 +150,11 @@ describe('Step Upload to AWS', () => {
const awsTile = screen.getByTestId('upload-aws'); const awsTile = screen.getByTestId('upload-aws');
awsTile.click(); awsTile.click();
// left sidebar navigation screen.getByRole('button', { name: /Next/ }).click();
const sidebar = screen.getByRole('navigation');
const anchor = getByText(sidebar, 'Amazon Web Services');
// load from sidebar
anchor.click();
}); });
test('clicking Next loads Registration', () => { test('clicking Next loads Registration', () => {
userEvent.type(screen.getByTestId('aws-account-id'), '012345678901');
const [ next, , ] = verifyButtons(); const [ next, , ] = verifyButtons();
next.click(); next.click();
@ -165,7 +165,7 @@ describe('Step Upload to AWS', () => {
const [ , back, ] = verifyButtons(); const [ , back, ] = verifyButtons();
back.click(); back.click();
screen.getByTestId('release-select'); screen.getByTestId('upload-aws');
}); });
test('clicking Cancel loads landing page', () => { test('clicking Cancel loads landing page', () => {
@ -177,12 +177,14 @@ describe('Step Upload to AWS', () => {
const accessKeyId = screen.getByTestId('aws-account-id'); const accessKeyId = screen.getByTestId('aws-account-id');
expect(accessKeyId).toHaveValue(''); expect(accessKeyId).toHaveValue('');
expect(accessKeyId).toBeEnabled(); expect(accessKeyId).toBeEnabled();
expect(accessKeyId).toBeRequired(); // expect(accessKeyId).toBeRequired(); // DDf does not support required value
}); });
}); });
describe('Step Upload to Google', () => { describe('Step Upload to Google', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -193,15 +195,11 @@ describe('Step Upload to Google', () => {
const awsTile = screen.getByTestId('upload-google'); const awsTile = screen.getByTestId('upload-google');
awsTile.click(); awsTile.click();
// left sidebar navigation screen.getByRole('button', { name: /Next/ }).click();
const sidebar = screen.getByRole('navigation');
const anchor = getByText(sidebar, 'Google Cloud Platform');
// load from sidebar
anchor.click();
}); });
test('clicking Next loads Registration', () => { test('clicking Next loads Registration', () => {
userEvent.type(screen.getByTestId('input-google-email'), 'test@test.com');
const [ next, , ] = verifyButtons(); const [ next, , ] = verifyButtons();
next.click(); next.click();
@ -212,7 +210,7 @@ describe('Step Upload to Google', () => {
const [ , back, ] = verifyButtons(); const [ , back, ] = verifyButtons();
back.click(); back.click();
screen.getByTestId('release-select'); screen.getByTestId('upload-google');
}); });
test('clicking Cancel loads landing page', () => { test('clicking Cancel loads landing page', () => {
@ -221,15 +219,17 @@ describe('Step Upload to Google', () => {
}); });
test('the google account id field is shown and required', () => { test('the google account id field is shown and required', () => {
const accessKeyId = screen.getByTestId('input-google-user'); const accessKeyId = screen.getByTestId('input-google-email');
expect(accessKeyId).toHaveValue(''); expect(accessKeyId).toHaveValue('');
expect(accessKeyId).toBeEnabled(); expect(accessKeyId).toBeEnabled();
expect(accessKeyId).toBeRequired(); // expect(accessKeyId).toBeRequired(); // DDf does not support required value
}); });
}); });
describe('Step Upload to Azure', () => { describe('Step Upload to Azure', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -237,18 +237,16 @@ describe('Step Upload to Azure', () => {
historySpy = jest.spyOn(history, 'push'); historySpy = jest.spyOn(history, 'push');
// select aws as upload destination // select aws as upload destination
const azureTile = screen.getByTestId('upload-azure'); const awsTile = screen.getByTestId('upload-azure');
azureTile.click(); awsTile.click();
screen.getByRole('button', { name: /Next/ }).click();
// left sidebar navigation
const sidebar = screen.getByRole('navigation');
const anchor = getByText(sidebar, 'Microsoft Azure');
// load from sidebar
anchor.click();
}); });
test('clicking Next loads Registration', () => { test('clicking Next loads Registration', () => {
userEvent.type(screen.getByTestId('azure-tenant-id'), 'testTenant');
userEvent.type(screen.getByTestId('azure-subscription-id'), 'testSubscriptionId');
userEvent.type(screen.getByTestId('azure-resource-group'), 'testResourceGroup');
const [ next, , ] = verifyButtons(); const [ next, , ] = verifyButtons();
next.click(); next.click();
@ -259,7 +257,7 @@ describe('Step Upload to Azure', () => {
const [ , back, ] = verifyButtons(); const [ , back, ] = verifyButtons();
back.click(); back.click();
screen.getByTestId('release-select'); screen.getByTestId('upload-azure');
}); });
test('clicking Cancel loads landing page', () => { test('clicking Cancel loads landing page', () => {
@ -271,22 +269,24 @@ describe('Step Upload to Azure', () => {
const tenantId = screen.getByTestId('azure-tenant-id'); const tenantId = screen.getByTestId('azure-tenant-id');
expect(tenantId).toHaveValue(''); expect(tenantId).toHaveValue('');
expect(tenantId).toBeEnabled(); expect(tenantId).toBeEnabled();
expect(tenantId).toBeRequired(); // expect(tenantId).toBeRequired(); // DDf does not support required value
const subscription = screen.getByTestId('azure-subscription-id'); const subscription = screen.getByTestId('azure-subscription-id');
expect(subscription).toHaveValue(''); expect(subscription).toHaveValue('');
expect(subscription).toBeEnabled(); expect(subscription).toBeEnabled();
expect(subscription).toBeRequired(); // expect(subscription).toBeRequired(); // DDf does not support required value
const resourceGroup = screen.getByTestId('azure-resource-group'); const resourceGroup = screen.getByTestId('azure-resource-group');
expect(resourceGroup).toHaveValue(''); expect(resourceGroup).toHaveValue('');
expect(resourceGroup).toBeEnabled(); expect(resourceGroup).toBeEnabled();
expect(resourceGroup).toBeRequired(); // expect(resourceGroup).toBeRequired(); // DDf does not support required value
}); });
}); });
describe('Step Registration', () => { describe('Step Registration', () => {
beforeEach(async() => { beforeEach(async() => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -297,12 +297,9 @@ describe('Step Registration', () => {
const awsTile = screen.getByTestId('upload-aws'); const awsTile = screen.getByTestId('upload-aws');
awsTile.click(); awsTile.click();
// left sidebar navigation screen.getByRole('button', { name: /Next/ }).click();
const sidebar = screen.getByRole('navigation'); userEvent.type(screen.getByTestId('aws-account-id'), '012345678901');
const anchor = getByText(sidebar, 'Registration'); screen.getByRole('button', { name: /Next/ }).click();
// load from sidebar
anchor.click();
}); });
test('clicking Next loads Packages', () => { test('clicking Next loads Packages', () => {
@ -338,11 +335,11 @@ describe('Step Registration', () => {
const activationKey = screen.getByTestId('subscription-activation'); const activationKey = screen.getByTestId('subscription-activation');
expect(activationKey).toHaveValue(''); expect(activationKey).toHaveValue('');
expect(activationKey).toBeEnabled(); expect(activationKey).toBeEnabled();
expect(activationKey).toBeRequired(); // expect(activationKey).toBeRequired(); DDF does not support required fields
const sidebar = screen.getByRole('navigation'); userEvent.type(screen.getByTestId('subscription-activation'), '012345678901');
const anchor = getByText(sidebar, 'Review'); screen.getByRole('button', { name: /Next/ }).click();
anchor.click(); screen.getByRole('button', { name: /Next/ }).click();
await screen.findByText('Register the system on first boot'); await screen.findByText('Register the system on first boot');
}); });
@ -373,6 +370,8 @@ describe('Step Registration', () => {
describe('Step Packages', () => { describe('Step Packages', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -382,13 +381,19 @@ describe('Step Packages', () => {
// select aws as upload destination // select aws as upload destination
const awsTile = screen.getByTestId('upload-aws'); const awsTile = screen.getByTestId('upload-aws');
awsTile.click(); awsTile.click();
screen.getByRole('button', { name: /Next/ }).click();
// left sidebar navigation // aws step
const sidebar = screen.getByRole('navigation'); userEvent.type(screen.getByTestId('aws-account-id'), '012345678901');
const anchor = getByText(sidebar, 'Packages'); screen.getByRole('button', { name: /Next/ }).click();
// load from sidebar // registration
anchor.click(); screen
.getByLabelText('Embed an activation key and register systems on first boot')
.click();
await screen.findByTestId('subscription-activation');
userEvent.type(screen.getByTestId('subscription-activation'), '1234567890');
screen.getByRole('button', { name: /Next/ }).click();
}); });
test('clicking Next loads Review', () => { test('clicking Next loads Review', () => {
@ -424,6 +429,8 @@ describe('Step Packages', () => {
describe('Step Review', () => { describe('Step Review', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
await act(async () => { await act(async () => {
history = renderWithReduxRouter(<CreateImageWizard />).history; history = renderWithReduxRouter(<CreateImageWizard />).history;
@ -433,13 +440,22 @@ describe('Step Review', () => {
// select aws as upload destination // select aws as upload destination
const awsTile = screen.getByTestId('upload-aws'); const awsTile = screen.getByTestId('upload-aws');
awsTile.click(); awsTile.click();
screen.getByRole('button', { name: /Next/ }).click();
// left sidebar navigation // aws step
const sidebar = screen.getByRole('navigation'); userEvent.type(screen.getByTestId('aws-account-id'), '012345678901');
const anchor = getByText(sidebar, 'Review'); screen.getByRole('button', { name: /Next/ }).click();
// load from sidebar // registration
anchor.click(); screen
.getByLabelText('Embed an activation key and register systems on first boot')
.click();
await screen.findByTestId('subscription-activation');
userEvent.type(screen.getByTestId('subscription-activation'), '1234567890');
screen.getByRole('button', { name: /Next/ }).click();
//Skip packages
screen.getByRole('button', { name: /Next/ }).click();
}); });
test('has 3 buttons', () => { test('has 3 buttons', () => {
@ -463,6 +479,8 @@ describe('Step Review', () => {
describe('Click through all steps', () => { describe('Click through all steps', () => {
beforeEach(async () => { beforeEach(async () => {
window.HTMLElement.prototype.scrollTo = function() {};
let history; let history;
let reduxStore; let reduxStore;
await act(async () => { await act(async () => {
@ -478,23 +496,22 @@ describe('Click through all steps', () => {
const next = screen.getByRole('button', { name: /Next/ }); const next = screen.getByRole('button', { name: /Next/ });
// select image output // select image output
userEvent.selectOptions(screen.getByTestId('release-select'), [ 'rhel-84' ]); // userEvent.selectOptions(screen.getByTestId('release-select'), [ 'rhel-8' ]);
screen.getByTestId('upload-aws').click(); screen.getByTestId('upload-aws').click();
screen.getByTestId('upload-azure').click(); screen.getByTestId('upload-azure').click();
screen.getByTestId('upload-google').click(); screen.getByTestId('upload-google').click();
next.click();
// select upload target screen.getByRole('button', { name: /Next/ }).click();
userEvent.type(screen.getByTestId('aws-account-id'), '012345678901'); userEvent.type(screen.getByTestId('aws-account-id'), '012345678901');
next.click(); screen.getByRole('button', { name: /Next/ }).click();
userEvent.type(screen.getByTestId('input-google-user'), 'test@test.com'); userEvent.type(screen.getByTestId('input-google-email'), 'test@test.com');
next.click(); screen.getByRole('button', { name: /Next/ }).click();
userEvent.type(screen.getByTestId('azure-tenant-id'), 'testTenant'); userEvent.type(screen.getByTestId('azure-tenant-id'), 'testTenant');
userEvent.type(screen.getByTestId('azure-subscription-id'), 'testSubscriptionId'); userEvent.type(screen.getByTestId('azure-subscription-id'), 'testSubscriptionId');
userEvent.type(screen.getByTestId('azure-resource-group'), 'testResourceGroup'); userEvent.type(screen.getByTestId('azure-resource-group'), 'testResourceGroup');
next.click(); screen.getByRole('button', { name: /Next/ }).click();
// registration // registration
screen screen
@ -532,9 +549,8 @@ describe('Click through all steps', () => {
// review // review
await screen. await screen.
findByText('Review the information and click the Create button to create your image using the following criteria.'); findByText('Review the information and click the Create button to create your image using the following criteria.');
const main = screen.getByRole('main', { name: 'Create image' }); await screen.findAllByText('Amazon Web Services');
within(main).getByText('Amazon Web Services'); await screen.findAllByText('Google Cloud Platform');
within(main).getByText('Google Cloud Platform');
await screen.findByText('Register the system on first boot'); await screen.findByText('Register the system on first boot');
// mock the backend API // mock the backend API
@ -622,7 +638,7 @@ describe('Click through all steps', () => {
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f58'; id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f58';
} }
ids.unshift(id); ids.push(id);
return Promise.resolve({ id }); return Promise.resolve({ id });
}); });
@ -643,12 +659,17 @@ describe('Click through all steps', () => {
const next = screen.getByRole('button', { name: /Next/ }); const next = screen.getByRole('button', { name: /Next/ });
// select release // select release
userEvent.selectOptions(screen.getByTestId('release-select'), [ 'rhel-84' ]); // userEvent.selectOptions(screen.getByTestId('release-select'), [ 'rhel-8' ]);
screen.getByTestId('upload-aws').click(); screen.getByTestId('upload-aws').click();
next.click(); next.click();
// leave AWS account id empty // leave AWS account id empty
next.click(); screen.getByRole('button', { name: /Next/ }).click();
expect(screen.queryByText('Embed an activation key and register systems on first boot')).toBeNull();
// fill in AWS to proceed
userEvent.type(screen.getByTestId('aws-account-id'), '012345678901');
screen.getByRole('button', { name: /Next/ }).click();
// registration // registration
screen screen
@ -656,34 +677,35 @@ describe('Click through all steps', () => {
.click(); .click();
await screen.findByTestId('subscription-activation'); await screen.findByTestId('subscription-activation');
userEvent.clear(screen.getByTestId('subscription-activation')); userEvent.clear(screen.getByTestId('subscription-activation'));
const sidebar = screen.getByRole('navigation'); screen.getByRole('button', { name: /Next/ }).click();
const reviewStep = getByText(sidebar, 'Review');
reviewStep.click(); expect(screen.queryByText(
'Review the information and click the Create button to create your image using the following criteria.'
)).toBeNull();
// fill in the registration
await screen.findByTestId('subscription-activation');
userEvent.type(screen.getByTestId('subscription-activation'), '1234567890');
screen.getByRole('button', { name: /Next/ }).click();
screen.getByRole('button', { name: /Next/ }).click();
await screen. await screen.
findByText('Review the information and click the Create button to create your image using the following criteria.'); findByText('Review the information and click the Create button to create your image using the following criteria.');
const main = screen.getByRole('main', { name: 'Create image' }); // review
within(main).getByText('Amazon Web Services'); await screen.findAllByText('Amazon Web Services');
await screen.findByText('Register the system on first boot'); await screen.findByText('Register the system on first boot');
const errorMessages = await screen.findAllByText('A value is required');
expect(errorMessages.length).toBe(1);
const uploadErrorMessage = await screen.findAllByText('A 12-digit number is required');
expect(uploadErrorMessage.length).toBe(1);
}); });
test('with invalid values', async () => { test('with invalid values', async () => {
const next = screen.getByRole('button', { name: /Next/ });
// select release // select release
userEvent.selectOptions(screen.getByTestId('release-select'), [ 'rhel-84' ]); // userEvent.selectOptions(screen.getByTestId('release-select'), [ 'rhel-8' ]);
// select upload target // select upload target
screen.getByTestId('upload-aws').click(); screen.getByTestId('upload-aws').click();
next.click(); screen.getByRole('button', { name: /Next/ }).click();
userEvent.type(screen.getByTestId('aws-account-id'), 'invalid, isNaN'); userEvent.type(screen.getByTestId('aws-account-id'), 'invalid, non');
next.click(); screen.getByRole('button', { name: /Next/ }).click();
// registration // registration
screen screen
@ -691,20 +713,21 @@ describe('Click through all steps', () => {
.click(); .click();
await screen.findByTestId('subscription-activation'); await screen.findByTestId('subscription-activation');
userEvent.clear(screen.getByTestId('subscription-activation')); userEvent.clear(screen.getByTestId('subscription-activation'));
const sidebar = screen.getByRole('navigation'); screen.getByRole('button', { name: /Next/ }).click();
const reviewStep = getByText(sidebar, 'Review');
reviewStep.click(); expect(screen.queryByText(
'Review the information and click the Create button to create your image using the following criteria.'
)).toBeNull();
// fill in the registration
await screen.findByTestId('subscription-activation');
userEvent.type(screen.getByTestId('subscription-activation'), '1234567890');
screen.getByRole('button', { name: /Next/ }).click();
screen.getByRole('button', { name: /Next/ }).click();
await screen. await screen.
findByText('Review the information and click the Create button to create your image using the following criteria.'); findByText('Review the information and click the Create button to create your image using the following criteria.');
const main = screen.getByRole('main', { name: 'Create image' }); await screen.findAllByText('Amazon Web Services');
within(main).getByText('Amazon Web Services');
await screen.findByText('Register the system on first boot'); await screen.findByText('Register the system on first boot');
const errorMessages = await screen.findAllByText('A value is required');
expect(errorMessages.length).toBe(1);
const uploadErrorMessage = await screen.findAllByText('A 12-digit number is required');
expect(uploadErrorMessage.length).toBe(1);
}); });
}); });