@@ -120,11 +120,11 @@ export const Stepper = (stepperProps: StepperProps) => {
|
||||
reviewButtonText = 'Review',
|
||||
} = components;
|
||||
const analytics = useAnalytics();
|
||||
const { presentation, steps } = useTemplateSchema(props.manifest);
|
||||
const apiHolder = useApiHolder();
|
||||
const [activeStep, setActiveStep] = useState(0);
|
||||
const [isValidating, setIsValidating] = useState(false);
|
||||
const [initialState] = useFormDataFromQuery(props.initialState);
|
||||
const { presentation, steps } = useTemplateSchema(props.manifest);
|
||||
const [stepsState, setStepsState] =
|
||||
useState<Record<string, JsonValue>>(initialState);
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ import { analyticsApiRef } from '@backstage/core-plugin-api';
|
||||
import { ScaffolderApi, scaffolderApiRef } from '../../../api';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { catalogApiMock } from '@backstage/plugin-catalog-react/testUtils';
|
||||
import { SecretsContextProvider } from '../../../secrets';
|
||||
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { ScaffolderFormDecoratorsApi } from '../../../../../scaffolder/src/alpha/api/types';
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { formDecoratorsApiRef } from '../../../../../scaffolder/src/alpha/api/ref';
|
||||
|
||||
const scaffolderApiMock: jest.Mocked<ScaffolderApi> = {
|
||||
cancelTask: jest.fn(),
|
||||
@@ -45,19 +39,14 @@ const scaffolderApiMock: jest.Mocked<ScaffolderApi> = {
|
||||
listTasks: jest.fn(),
|
||||
autocomplete: jest.fn(),
|
||||
};
|
||||
const scaffolderDecoratorsMock: jest.Mocked<ScaffolderFormDecoratorsApi> = {
|
||||
getFormDecorators: jest.fn().mockResolvedValue([]),
|
||||
};
|
||||
|
||||
const catalogApi = catalogApiMock.mock();
|
||||
|
||||
const analyticsMock = mockApis.analytics();
|
||||
const apis = TestApiRegistry.from(
|
||||
[scaffolderApiRef, scaffolderApiMock],
|
||||
[formDecoratorsApiRef, scaffolderDecoratorsMock],
|
||||
[catalogApiRef, catalogApi],
|
||||
[analyticsApiRef, analyticsMock],
|
||||
[catalogApiRef, catalogApi],
|
||||
);
|
||||
|
||||
describe('<Workflow />', () => {
|
||||
@@ -93,33 +82,31 @@ describe('<Workflow />', () => {
|
||||
});
|
||||
|
||||
const { getByRole, getAllByRole, getByText } = await renderInTestApp(
|
||||
<SecretsContextProvider initialSecrets={{}}>
|
||||
<ApiProvider apis={apis}>
|
||||
<Workflow
|
||||
title="Different title than template"
|
||||
description={`
|
||||
<ApiProvider apis={apis}>
|
||||
<Workflow
|
||||
title="Different title than template"
|
||||
description={`
|
||||
## This is markdown
|
||||
- overriding the template description
|
||||
`}
|
||||
onCreate={onCreate}
|
||||
onError={onError}
|
||||
namespace="default"
|
||||
templateName="docs-template"
|
||||
initialState={{
|
||||
name: 'prefilled-name',
|
||||
age: '53',
|
||||
}}
|
||||
components={{
|
||||
ReviewStateComponent: () => (
|
||||
<h1>This is a different wrapper for the review page</h1>
|
||||
),
|
||||
reviewButtonText: <i>Onwards</i>,
|
||||
createButtonText: <b>Make</b>,
|
||||
}}
|
||||
extensions={[]}
|
||||
/>
|
||||
</ApiProvider>
|
||||
</SecretsContextProvider>,
|
||||
onCreate={onCreate}
|
||||
onError={onError}
|
||||
namespace="default"
|
||||
templateName="docs-template"
|
||||
initialState={{
|
||||
name: 'prefilled-name',
|
||||
age: '53',
|
||||
}}
|
||||
components={{
|
||||
ReviewStateComponent: () => (
|
||||
<h1>This is a different wrapper for the review page</h1>
|
||||
),
|
||||
reviewButtonText: <i>Onwards</i>,
|
||||
createButtonText: <b>Make</b>,
|
||||
}}
|
||||
extensions={[]}
|
||||
/>
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
// Test template title is overriden
|
||||
|
||||
@@ -72,6 +72,7 @@ export type WorkflowProps = {
|
||||
export const Workflow = (workflowProps: WorkflowProps): JSX.Element | null => {
|
||||
const { title, description, namespace, templateName, onCreate, ...props } =
|
||||
workflowProps;
|
||||
|
||||
const analytics = useAnalytics();
|
||||
const styles = useStyles();
|
||||
const templateRef = stringifyEntityRef({
|
||||
@@ -79,9 +80,13 @@ export const Workflow = (workflowProps: WorkflowProps): JSX.Element | null => {
|
||||
namespace: namespace,
|
||||
name: templateName,
|
||||
});
|
||||
|
||||
const errorApi = useApi(errorApiRef);
|
||||
|
||||
const { loading, manifest, error } = useTemplateParameterSchema(templateRef);
|
||||
|
||||
const sortedManifest = useFilteredSchemaProperties(manifest);
|
||||
|
||||
const minutesSaved = useTemplateTimeSavedMinutes(templateRef);
|
||||
|
||||
const workflowOnCreate = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user