-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the downloading sub-step (#1221)
* feat: add the downloading substep Signed-off-by: Oleksii Orel <[email protected]>
- Loading branch information
Showing
8 changed files
with
223 additions
and
28 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...d/src/components/WorkspaceProgress/StartingSteps/WorkspaceConditions/PureSubCondition.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { ProgressStepTitle } from '@/components/WorkspaceProgress/StepTitle'; | ||
|
||
export type Props = { | ||
distance: -1 | 0 | 1 | undefined; | ||
title: string | undefined; | ||
}; | ||
|
||
export class PureSubCondition extends React.PureComponent<Props> { | ||
public render(): React.ReactElement { | ||
const { distance, title } = this.props; | ||
|
||
if (!title) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<ol className="pf-c-wizard__nav-list"> | ||
<li className="pf-c-wizard__nav-item"> | ||
<div className="pf-c-wizard__nav-link"> | ||
<ProgressStepTitle distance={distance}>{title}</ProgressStepTitle> | ||
</div> | ||
</li> | ||
</ol> | ||
); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...s/WorkspaceProgress/StartingSteps/WorkspaceConditions/__tests__/PureSubCondition.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { PureSubCondition } from '@/components/WorkspaceProgress/StartingSteps/WorkspaceConditions/PureSubCondition'; | ||
import getComponentRenderer, { screen } from '@/services/__mocks__/getComponentRenderer'; | ||
|
||
const { createSnapshot, renderComponent } = getComponentRenderer(getComponent); | ||
|
||
jest.mock('@/components/WorkspaceProgress/StepTitle'); | ||
|
||
describe('Starting sub-steps, checking rendering', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('snapshot with no title', () => { | ||
expect(createSnapshot(undefined)).toMatchSnapshot(); | ||
}); | ||
|
||
test('snapshot with a title', () => { | ||
expect(createSnapshot('sub-step test', 1)).toMatchSnapshot(); | ||
}); | ||
|
||
it('should show the title and a proper icon(depends on the distance value)', () => { | ||
let distanceElement: HTMLElement | null; | ||
let stepTitle: HTMLElement | null; | ||
|
||
const { reRenderComponent } = renderComponent('sub-step test 1', -1); | ||
|
||
distanceElement = screen.queryByTestId('distance'); | ||
expect(distanceElement).not.toBeNull(); | ||
expect(distanceElement).toHaveTextContent('-1'); | ||
|
||
stepTitle = screen.queryByTestId('step-title'); | ||
expect(stepTitle).not.toBeNull(); | ||
expect(stepTitle).toHaveTextContent('sub-step test 1'); | ||
|
||
reRenderComponent('sub-step test 2', 0); | ||
|
||
distanceElement = screen.queryByTestId('distance'); | ||
expect(distanceElement).not.toBeNull(); | ||
expect(distanceElement).toHaveTextContent('0'); | ||
|
||
stepTitle = screen.queryByTestId('step-title'); | ||
expect(stepTitle).not.toBeNull(); | ||
expect(stepTitle).toHaveTextContent('sub-step test 2'); | ||
|
||
reRenderComponent('sub-step test 3', 1); | ||
|
||
distanceElement = screen.queryByTestId('distance'); | ||
expect(distanceElement).not.toBeNull(); | ||
expect(distanceElement).toHaveTextContent('1'); | ||
|
||
stepTitle = screen.queryByTestId('step-title'); | ||
expect(stepTitle).not.toBeNull(); | ||
expect(stepTitle).toHaveTextContent('sub-step test 3'); | ||
|
||
reRenderComponent(undefined, 1); | ||
|
||
distanceElement = screen.queryByTestId('distance'); | ||
expect(distanceElement).toBeNull(); | ||
|
||
stepTitle = screen.queryByTestId('step-title'); | ||
expect(stepTitle).toBeNull(); | ||
}); | ||
}); | ||
|
||
function getComponent(title: string | undefined, distance?: -1 | 0 | 1): React.ReactElement { | ||
return <PureSubCondition title={title} distance={distance} />; | ||
} |
31 changes: 31 additions & 0 deletions
31
.../StartingSteps/WorkspaceConditions/__tests__/__snapshots__/PureSubCondition.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Starting sub-steps, checking rendering snapshot with a title 1`] = ` | ||
<ol | ||
className="pf-c-wizard__nav-list" | ||
> | ||
<li | ||
className="pf-c-wizard__nav-item" | ||
> | ||
<div | ||
className="pf-c-wizard__nav-link" | ||
> | ||
<div> | ||
<div | ||
data-testid="distance" | ||
> | ||
1 | ||
</div> | ||
<span | ||
className="done" | ||
data-testid="step-title" | ||
> | ||
sub-step test | ||
</span> | ||
</div> | ||
</div> | ||
</li> | ||
</ol> | ||
`; | ||
|
||
exports[`Starting sub-steps, checking rendering snapshot with no title 1`] = `null`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters