CreateImageWizard: update review step for new subscription strings

The review page and its test now contains the organization id and
additional strings for whether the image is subscribed to insights or
not.
This commit is contained in:
Jacob Kozol 2022-01-19 20:57:44 +01:00 committed by Sanne Raymaekers
parent e48e2ca659
commit f51e9fd9b2
2 changed files with 49 additions and 15 deletions

View file

@ -1,18 +1,30 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import {
DescriptionList, DescriptionListTerm, DescriptionListGroup, DescriptionListDescription,
List, ListItem,
Spinner,
Tabs, Tab, TabTitleText,
Text, TextContent, TextVariants, TextList, TextListVariants, TextListItem, TextListItemVariants
} from '@patternfly/react-core';
import useFormApi from '@data-driven-forms/react-form-renderer/use-form-api';
import { releaseValues } from '../steps/imageOutput';
import { registerValues } from '../steps/registration';
import { googleAccType } from '../steps/googleCloud';
const ReviewStep = () => {
const [ activeTabKey, setActiveTabKey ] = useState(0);
const { getState } = useFormApi();
const [ orgId, setOrgId ] = useState();
const { change, getState } = useFormApi();
useEffect(() => {
if (getState()?.values?.['register-system'] !== 'register-later') {
(async () => {
const userData = await insights?.chrome?.auth?.getUser();
const id = userData?.identity?.internal?.org_id;
setOrgId(id);
change('subscription-organization-id', id);
})();
}
});
const handleTabClick = (event, tabIndex) => {
setActiveTabKey(tabIndex);
@ -127,7 +139,7 @@ const ReviewStep = () => {
</Tab>
{getState()?.values?.release.includes('rhel') &&
<Tab eventKey={ 1 } title={ <TabTitleText>Registration</TabTitleText> } data-testid='tab-registration'>
{getState()?.values?.['register-system'] === 'register-later-radio-button' &&
{getState()?.values?.['register-system'] === 'register-later' &&
<TextContent>
<TextList component={ TextListVariants.dl }>
<TextListItem component={ TextListItemVariants.dt }>
@ -139,24 +151,39 @@ const ReviewStep = () => {
</TextList>
</TextContent>
}
{getState()?.values?.['register-system'] === 'subscribe-now-radio' &&
{(getState()?.values?.['register-system'] === 'register-now' ||
getState()?.values?.['register-system'] === 'register-now-insights') &&
<TextContent>
<TextList component={ TextListVariants.dl }>
<TextListItem component={ TextListItemVariants.dt }>
Subscription
</TextListItem>
<TextListItem component={ TextListItemVariants.dd }>
{getState()?.values?.['register-system'] === 'subscribe-now-radio' ?
'Register the system on first boot' :
registerValues?.[getState()?.values?.['register-system']?.title]
{getState()?.values?.['register-system'] === 'register-now-insights' &&
'Register with Subscriptions and Red Hat Insights'
}
{getState()?.values?.['register-system'] === 'register-now' &&
'Register with Subscriptions'
}
</TextListItem>
<TextListItem component={ TextListItemVariants.dt }>
Activation key
</TextListItem>
<TextListItem component={ TextListItemVariants.dd }>
{getState()?.values?.['subscription-activation']}
{getState()?.values?.['subscription-activation-key']}
</TextListItem>
<TextListItem component={ TextListItemVariants.dt }>
Organization ID
</TextListItem>
{orgId !== undefined ? (
<TextListItem component={ TextListItemVariants.dd } data-testid='organization-id'>
{orgId}
</TextListItem>
) : (
<TextListItem component={ TextListItemVariants.dd }>
<Spinner />
</TextListItem>
)}
</TextList>
</TextContent>
}

View file

@ -392,8 +392,10 @@ describe('Step Registration', () => {
screen.getByRole('button', { name: /Next/ }).click();
screen.getByRole('button', { name: /Next/ }).click();
await screen.findByText('Register with Subscriptions and Red Hat Insights');
await screen.findAllByText('012345678901');
await waitFor(() => {
screen.getByText('Register with Subscriptions and Red Hat Insights');
screen.getAllByText('012345678901');
});
});
test('should allow registering without insights', async () => {
@ -409,8 +411,10 @@ describe('Step Registration', () => {
screen.getByRole('button', { name: /Next/ }).click();
screen.getByRole('button', { name: /Next/ }).click();
await screen.findByText('Register with Subscriptions');
await screen.findAllByText('012345678901');
await waitFor(() => {
screen.getByText('Register with Subscriptions');
screen.getAllByText('012345678901');
});
});
test('should hide input fields when clicking Register the system later', async () => {
@ -432,7 +436,6 @@ describe('Step Registration', () => {
screen.getByRole('button', { name: /Next/ }).click();
screen.getByRole('button', { name: /Next/ }).click();
screen.getByText('Register the system later');
});
});
@ -866,8 +869,12 @@ describe('Click through all steps', () => {
await screen.findByText('VMWare');
await screen.findByText('Virtualization - Guest image');
await screen.findByText('Bare metal - Installer');
await screen.findByText('Register the system on first boot');
await screen.findByText('Register with Subscriptions and Red Hat Insights');
await waitFor(() => {
const id = screen.getByTestId('organization-id');
within(id).getByText(5);
});
// mock the backend API
let ids = [];
const composeImage = jest