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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jest.mock('@/store/DevWorkspacesCluster', () => {
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const mockNavigate = jest.fn();
Expand Down Expand Up @@ -643,6 +644,7 @@ function getComponent(store: Store, localState?: Partial<State>): React.ReactEle
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ let location: Location;
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const factoryUrl = 'https://factory-url';
Expand Down Expand Up @@ -995,6 +996,7 @@ function getComponent(
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const mockTabManagerRename = jest.fn();
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const resourcesUrl = 'https://resources-url';
Expand Down Expand Up @@ -491,6 +492,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const mockTabManagerReplace = jest.fn();
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const resourcesUrl = 'https://resources-url';
Expand Down Expand Up @@ -774,6 +775,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const { renderComponent } = getComponentRenderer(getComponent);
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const searchParams = new URLSearchParams();
Expand Down Expand Up @@ -68,6 +69,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import { FACTORY_LINK_ATTR } from '@eclipse-che/common';
import { AlertVariant } from '@patternfly/react-core';
import { cleanup, screen, waitFor } from '@testing-library/react';
import userEvent, { UserEvent } from '@testing-library/user-event';
import React from 'react';
Expand Down Expand Up @@ -71,6 +72,7 @@ const { renderComponent } = getComponentRenderer(getComponent);
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const factoryUrl = 'https://factory-url';
Expand Down Expand Up @@ -348,6 +350,11 @@ describe('Creating steps, fetching a devfile', () => {
describe('unsupported git provider', () => {
let emptyStore: Store;
const rejectReason = 'Failed to fetch devfile';
const alertItem = {
key: 'Inspecting repo',
title: 'Failed to fetch devfile. Workspace will start from the default devfile.',
variant: AlertVariant.warning,
};

beforeEach(() => {
emptyStore = new MockStoreBuilder().build();
Expand All @@ -360,6 +367,7 @@ describe('Creating steps, fetching a devfile', () => {
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS);

await waitFor(() => expect(mockOnError).not.toHaveBeenCalled());
expect(mockOnWarning).toHaveBeenCalledWith(alertItem);
expect(mockOnNextStep).toHaveBeenCalled();
});
});
Expand Down Expand Up @@ -710,6 +718,7 @@ function getComponent(
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
errorMessage.startsWith('Could not reach devfile')
) {
this.setState({ useDefaultDevfile: true });
const alertItem = {
key: this.name,
title: 'Failed to fetch devfile. Workspace will start from the default devfile.',
variant: AlertVariant.warning,
};
this.handleWarning(alertItem);
return true;
}
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const { renderComponent } = getComponentRenderer(getComponent);
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const resourcesUrl = 'https://resources-url';
Expand Down Expand Up @@ -262,6 +263,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const { renderComponent } = getComponentRenderer(getComponent);
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

jest.mock('@/services/helpers/location', () => ({
Expand Down Expand Up @@ -464,6 +465,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type ProgressStepProps = {
location: Location;
navigate: NavigateFunction;
onError: (alertItem: AlertItem) => void;
onWarning: (alertItem: AlertItem) => void;
onHideError: (key: string) => void;
onNextStep: () => void;
onRestart: (tabName?: LoaderTab) => void;
Expand Down Expand Up @@ -83,6 +84,10 @@ export abstract class ProgressStep<
this.props.onError(alertItem);
}

protected handleWarning(alertItem: AlertItem) {
this.props.onWarning(alertItem);
}

protected clearStepError() {
this.setState({
lastError: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const { renderComponent } = getComponentRenderer(getComponent);
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const namespace = 'che-user';
Expand Down Expand Up @@ -472,6 +473,7 @@ function getComponent(
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const { renderComponent } = getComponentRenderer(getComponent);
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const namespace = 'che-user';
Expand Down Expand Up @@ -504,6 +505,7 @@ function getComponent(
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jest.mock('@/store/Workspaces', () => {
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const { renderComponent } = getComponentRenderer(getComponent);
Expand Down Expand Up @@ -911,6 +912,7 @@ function getComponent(
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jest.mock('@/components/WorkspaceProgress/StepTitle');
const mockOnNextStep = jest.fn();
const mockOnRestart = jest.fn();
const mockOnError = jest.fn();
const mockOnWarning = jest.fn();
const mockOnHideError = jest.fn();

const { renderComponent, createSnapshot } = getComponentRenderer(getComponent);
Expand Down Expand Up @@ -186,6 +187,7 @@ function getComponent(condition: ConditionType, _matchParams = matchParams): Rea
onNextStep={mockOnNextStep}
onRestart={mockOnRestart}
onError={mockOnError}
onWarning={mockOnWarning}
onHideError={mockOnHideError}
/>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ export class ProgressStep extends React.Component<ProgressStepProps, ProgressSte
protected readonly name: string;

public render() {
const { distance, onError, onNextStep, onRestart } = this.props;
const { distance, onError, onWarning, onNextStep, onRestart } = this.props;
const alertItem: AlertItem = {
title: 'Error',
key: 'error',
variant: AlertVariant.danger,
children: `Error in step ${this.name}`,
};
const warningItem: AlertItem = {
title: 'Warning',
key: 'warning',
variant: AlertVariant.warning,
children: `Warning in step ${this.name}`,
};
return (
<div data-testid="progress-step">
<span data-testid="step-distance">{distance}</span>
Expand All @@ -38,6 +44,13 @@ export class ProgressStep extends React.Component<ProgressStepProps, ProgressSte
type="button"
value="onError"
/>
<input
onClick={() => onWarning(warningItem)}
data-testid="onWarning"
name="onWarning"
type="button"
value="onWarning"
/>
<input
onClick={() => onRestart()}
data-testid="onRestart"
Expand Down
Loading
Loading