tests: More updates

- `npm run test:single` runs jest with `-w 1`, makes the output readable
- adds testIds to the radio buttons, I think it's a bit bugged where if
  you click the label it'll automatically switch to the first radio button
  (even if you click the label of the 2nd button)
- moved a misplaced wait
This commit is contained in:
Sanne Raymaekers 2020-11-17 20:35:34 +01:00 committed by Alexander Todorov
parent da5df65394
commit 33e9db6681
3 changed files with 11 additions and 6 deletions

View file

@ -136,16 +136,19 @@ const SubscriptionComponent = (props) => {
<FormGroup isRequired label="Register the system" fieldId="subscribe-radio">
<Radio name="subscribe-radio" isChecked={ props.subscribeNow } id="subscribe-radio"
label="Embed an activation key and register systems on first boot"
onChange={ () => props.setSubscribeNow(true) } />
onChange={ () => props.setSubscribeNow(true) }
data-testid="register-now-radio-button" />
<Radio name="subscribe-radio" isChecked={ !props.subscribeNow }
label="Register the system later" id="subscribe-radio"
onChange={ () => props.setSubscribeNow(false) } />
onChange={ () => props.setSubscribeNow(false) }
data-testid="register-later-radio-button" />
</FormGroup>
{ props.subscribeNow &&
<>
<FormGroup label="Organization ID" fieldId="subscription-organization">
<TextInput isDisabled value={ props.subscription.organization || '' } type="text"
id="subscription-organization" aria-label="Subscription organization ID" />
id="subscription-organization" aria-label="Subscription organization ID"
data-testid="organization-id" />
</FormGroup>
<FormGroup isRequired label="Activation key" fieldId="subscription-activation"
helperTextInvalid={ (props.errors['subscription-activation'] && props.errors['subscription-activation'].value) || '' }

View file

@ -257,13 +257,14 @@ describe('Step Registration', () => {
.getByLabelText('Embed an activation key and register systems on first boot')
.click();
const p1 = waitForElementToBeRemoved(() => screen.queryByLabelText('Organization ID'));
const p1 = waitForElementToBeRemoved(() => screen.queryByTestId('organization-id'));
const p2 = waitForElementToBeRemoved(() => screen.queryByTestId('subscription-activation'));
// then click the first radio button which should remove any input fields
screen
.getByLabelText('Register the system later')
.getByTestId('register-later-radio-button')
.click();
await p1;
await p2;
});
@ -325,10 +326,10 @@ describe('Click through all steps', () => {
next.click();
// registration
await screen.findByTestId('subscription-activation');
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');
next.click();