Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions platform/settings/SubscriptionWizard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('SubscriptionWizard Component', () => {
// Check that all three steps are present in navigation
const navigation = screen.getByRole('navigation', { name: 'Steps' });
expect(navigation).toHaveTextContent('Ansible Automation Platform Subscription');
expect(navigation).toHaveTextContent('Optional: Automation Analytics');
expect(navigation).toHaveTextContent('End User License Agreement');
expect(navigation).toHaveTextContent('Review');

Expand All @@ -45,11 +44,9 @@ describe('SubscriptionWizard Component', () => {
expect(currentStep).toHaveClass('pf-m-current');

// Other steps should be disabled
const analyticsStep = screen.getByRole('button', { name: 'Optional: Automation Analytics' });
const licenseStep = screen.getByRole('button', { name: 'End User License Agreement' });
const reviewStep = screen.getByRole('button', { name: 'Review' });

expect(analyticsStep).toBeDisabled();
expect(licenseStep).toBeDisabled();
expect(reviewStep).toBeDisabled();

Expand Down Expand Up @@ -246,94 +243,4 @@ describe('SubscriptionWizard Component', () => {
});
}, 10000);
});

describe('Automation Analytics Step', () => {
const navigateToAnalyticsStep = async () => {
const user = userEvent.setup();
renderWithRouter();
await user.click(screen.getByRole('button', { name: 'Subscription manifest' }));
const file = new File(['mock manifest content'], 'manifest.zip', {
type: 'application/zip',
});
const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement;
await user.upload(fileInput, file);
const nextButton = screen.getByRole('button', { name: /next/i });
await user.click(nextButton);

return user;
};

it('renders automation analytics step with correct content', async () => {
await navigateToAnalyticsStep();

await waitFor(
() => {
expect(
screen.getByRole('heading', { name: /Optional: Automation Analytics/i })
).toBeInTheDocument();
},
{ timeout: 10000 }
);

expect(
screen.getByText(/Enter client ID and client secret to enable Analytics/i)
).toBeInTheDocument();
expect(screen.getByLabelText(/Client ID/i)).toBeInTheDocument();
expect(screen.getByLabelText(/Client secret/i)).toBeInTheDocument();
expect(screen.getByAltText(/Automation Analytics/i)).toBeInTheDocument();
}, 15000);

it('allows proceeding to next step with filled analytics fields', async () => {
const user = await navigateToAnalyticsStep();

await waitFor(
() => {
expect(screen.getByLabelText(/Client ID/i)).toBeInTheDocument();
},
{ timeout: 10000 }
);

const clientIdField = screen.getByLabelText(/Client ID/i);
const clientSecretField = screen.getByLabelText(/Client secret/i);
await user.type(clientIdField, 'test-client-id');
await user.type(clientSecretField, 'test-client-secret');
// Should be able to proceed to next step
const nextButton = screen.getByRole('button', { name: /next/i });
expect(nextButton).toBeEnabled();
await user.click(nextButton);

await waitFor(
() => {
expect(
screen.getByRole('checkbox', { name: /I agree to the terms of the license agreement/i })
).toBeInTheDocument();
},
{ timeout: 10000 }
);
}, 15000);

it('allows proceeding to next step with empty analytics fields (optional)', async () => {
const user = await navigateToAnalyticsStep();

await waitFor(
() => {
expect(screen.getByRole('button', { name: /next/i })).toBeInTheDocument();
},
{ timeout: 10000 }
);

const nextButton = screen.getByRole('button', { name: /next/i });
expect(nextButton).toBeEnabled();
await user.click(nextButton);

await waitFor(
() => {
expect(
screen.getByRole('checkbox', { name: /I agree to the terms of the license agreement/i })
).toBeInTheDocument();
},
{ timeout: 10000 }
);
}, 15000);
});
});
66 changes: 1 addition & 65 deletions platform/settings/SubscriptionWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import { PageFormHidden } from '@ansible/ansible-ui-framework/PageForm/Utils/Pag
import { awxErrorAdapter } from '@ansible/awx-ui/common/adapters/awxErrorAdapter';
import { awxAPI } from '@ansible/awx-ui/common/api/awx-utils';
import { useAwxConfig, useAwxConfigState } from '@ansible/awx-ui/common/useAwxConfig';
import { postRequest, requestPatch } from '@ansible/common-ui/crud/Data';
import { postRequest } from '@ansible/common-ui/crud/Data';
import { ILicenseInfo } from '@ansible/common-ui/interfaces/Config';
import { useGetDocsUrl } from '@ansible/common-ui/utils/useGetDocsUrl';
import { ExternalLink } from '@ansible/hub-ui//common/ExternalLink';
import {
Content,
Expand All @@ -26,7 +25,6 @@ import {
import { useCallback, useEffect, useMemo } from 'react';
import { useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import AnalyticsGraphic from '../assets/AAGraphic 1.svg?url';

interface SubscriptionWizardData {
subscriptionSelection: 'manifest' | 'service_account' | 'username' | 'satellite';
Expand All @@ -38,8 +36,6 @@ interface SubscriptionWizardData {
satellite_username: string;
satellite_password: string;
subscription_id?: string;
analytics_client_id: string;
analytics_client_secret: string;
agree: boolean;
}

Expand All @@ -54,11 +50,6 @@ export function SubscriptionWizard(props: { onSuccess: () => void }) {
label: t('Ansible Automation Platform Subscription'),
inputs: <SubscriptionStep />,
},
{
id: 'analytics',
label: t('Optional: Automation Analytics'),
inputs: <AutomationAnalyticsStep />,
},
{
id: 'license-agreement',
label: t('End User License Agreement'),
Expand Down Expand Up @@ -98,15 +89,6 @@ export function SubscriptionWizard(props: { onSuccess: () => void }) {
break;
}
refreshAwxConfig?.();

// Set up analytics if client credentials are provided in automation analytics step
if (data.analytics_client_id && data.analytics_client_secret) {
await requestPatch(awxAPI`/settings/all/`, {
REDHAT_USERNAME: data.analytics_client_id,
REDHAT_PASSWORD: data.analytics_client_secret,
INSIGHTS_TRACKING_STATE: true,
});
}
props.onSuccess();
},
[props, refreshAwxConfig]
Expand Down Expand Up @@ -338,52 +320,6 @@ function SubscriptionStep() {
);
}

function AutomationAnalyticsStep() {
const { t } = useTranslation();
const config = useAwxConfig();
const docsUrl = useGetDocsUrl(config, 'configureAnalytics');

return (
<>
<Content>
<Content component="h1">{t('Optional: Automation Analytics')}</Content>
<Content>
{t(
'Enter client ID and client secret to enable Analytics. This collects and transmits analytics on the service usage to Red Hat. For more information, see '
)}
<ExternalLink href={docsUrl}>{t('documentation')}</ExternalLink>
{t('.')}
</Content>
<Content>
<div
style={{
marginTop: 'var(--pf-t--global--spacer--xl)',
marginBottom: 'var(--pf-t--global--spacer--lg)',
}}
>
<img
src={AnalyticsGraphic}
alt={t('Automation Analytics')}
style={{ width: '100%', height: 'auto' }}
/>
</div>
</Content>
</Content>
<PageFormTextInput<SubscriptionWizardData>
name="analytics_client_id"
label={t`Client ID`}
labelHelp={t('Client ID used to send data to Automation Analytics')}
/>
<PageFormTextInput<SubscriptionWizardData>
name="analytics_client_secret"
label={t`Client secret`}
type="password"
labelHelp={t('Client secret used to send data to Automation Analytics')}
/>
</>
);
}

function LicenseAgreementStep() {
const { t } = useTranslation();
const config = useAwxConfig();
Expand Down
Loading