Skip to content

Commit

Permalink
show message for retrying in conclusion if there are failed tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesis09 committed Sep 3, 2020
1 parent a889aa9 commit 4eb1d14
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const QuickStartConclusion: React.FC<QuickStartConclusionProps> = ({
onQuickStartChange,
onTaskSelect,
}) => {
const hasFailedTask = allTaskStatuses.includes(QuickStartTaskStatus.FAILED);
return (
<>
{tasks.map((task, index) => (
Expand All @@ -34,8 +35,14 @@ const QuickStartConclusion: React.FC<QuickStartConclusionProps> = ({
onTaskSelect={onTaskSelect}
/>
))}
<SyncMarkdownView content={conclusion} />
{nextQuickStart && (
<SyncMarkdownView
content={
hasFailedTask
? 'One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.'
: conclusion
}
/>
{nextQuickStart && !hasFailedTask && (
<Button variant="link" onClick={() => onQuickStartChange(nextQuickStart)} isInline>
{`Start ${nextQuickStart} quick start`}{' '}
<ArrowRightIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { Button } from '@patternfly/react-core';
import { getQuickStartByName } from '../../utils/quick-start-utils';
import { QuickStartTaskStatus } from '../../utils/quick-start-types';
import QuickStartConclusion from '../QuickStartConclusion';
import { SyncMarkdownView } from '@console/internal/components/markdown-view';

type QuickStartConclusionProps = React.ComponentProps<typeof QuickStartConclusion>;
let wrapper: ShallowWrapper<QuickStartConclusionProps>;
const props: QuickStartConclusionProps = {
tasks: getQuickStartByName('explore-serverless').spec.tasks,
allTaskStatuses: [
QuickStartTaskStatus.INIT,
QuickStartTaskStatus.INIT,
QuickStartTaskStatus.INIT,
QuickStartTaskStatus.SUCCESS,
QuickStartTaskStatus.SUCCESS,
QuickStartTaskStatus.SUCCESS,
],
conclusion: 'conclusion',
onTaskSelect: jest.fn(),
Expand All @@ -24,11 +25,16 @@ describe('QuickStartConclusion', () => {
wrapper = shallow(<QuickStartConclusion {...props} />);
});

it('should not render link for next quick start if nextQuickStart props is available', () => {
expect(wrapper.find(Button).length).toBe(0);
it('should render conclusion if there are no failed tasks', () => {
expect(
wrapper
.find(SyncMarkdownView)
.first()
.props().content,
).toEqual('conclusion');
});

it('should render link for next quick start if nextQuickStart props is available', () => {
it('should render link for next quick start if nextQuickStart prop is available and there are no failed tasks', () => {
wrapper = shallow(<QuickStartConclusion {...props} nextQuickStart="Serverless Application" />);
expect(
wrapper
Expand All @@ -37,4 +43,31 @@ describe('QuickStartConclusion', () => {
.props().children[0],
).toEqual('Start Serverless Application quick start');
});

it('should not render link for next quick start if nextQuickStart props is not available', () => {
expect(wrapper.find(Button).length).toBe(0);
});

it('should not render conclusion, link for next quick start and should render message for retrying if there are failed tasks', () => {
wrapper = shallow(
<QuickStartConclusion
{...props}
nextQuickStart="Serverless Application"
allTaskStatuses={[
QuickStartTaskStatus.FAILED,
QuickStartTaskStatus.SUCCESS,
QuickStartTaskStatus.SUCCESS,
]}
/>,
);
expect(
wrapper
.find(SyncMarkdownView)
.first()
.props().content,
).toEqual(
'One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.',
);
expect(wrapper.find(Button).length).toBe(0);
});
});

0 comments on commit 4eb1d14

Please sign in to comment.