@patternfly/quickstarts 6.5.0-prerelease.3 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +2 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/patternfly-docs/quick-starts/design-guidelines/design-guidelines.md +1 -1
- package/dist/quickstarts-full.es.js +2 -6
- package/dist/quickstarts-full.es.js.map +1 -1
- package/package.json +3 -7
- package/src/ConsoleShared/src/components/markdown-extensions/__tests__/MarkdownCopyClipboard.spec.tsx +25 -11
- package/src/catalog/QuickStartTile.tsx +3 -7
- package/src/catalog/__tests__/QuickStartCatalog.spec.tsx +31 -26
- package/src/catalog/__tests__/QuickStartTile.spec.tsx +47 -27
- package/src/catalog/__tests__/QuickStartTileDescription.spec.tsx +33 -32
- package/src/controller/__tests__/QuickStartConclusion.spec.tsx +52 -54
- package/src/controller/__tests__/QuickStartContent.spec.tsx +48 -29
- package/src/controller/__tests__/QuickStartFooter.spec.tsx +54 -70
- package/src/controller/__tests__/QuickStartTaskHeader.spec.tsx +31 -27
- package/src/controller/__tests__/QuickStartTaskReview.spec.tsx +41 -26
- package/src/controller/__tests__/QuickStartTasks.spec.tsx +55 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/quickstarts",
|
|
3
|
-
"version": "6.5.0
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "PatternFly quick starts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-dom": "^17 || ^18 || ^19"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"dompurify": "^3.2
|
|
54
|
+
"dompurify": "^3.3.2",
|
|
55
55
|
"history": "^5.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
@@ -66,10 +66,9 @@
|
|
|
66
66
|
"@rollup/plugin-commonjs": "^17.0.0",
|
|
67
67
|
"@rollup/plugin-json": "^4.1.0",
|
|
68
68
|
"@rollup/plugin-node-resolve": "^11.1.0",
|
|
69
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
69
70
|
"@testing-library/react": "^13.4.0",
|
|
70
71
|
"@types/dompurify": "^3.0.5",
|
|
71
|
-
"@types/enzyme": "^3.10.7",
|
|
72
|
-
"@types/enzyme-adapter-react-16": "^1.0.6",
|
|
73
72
|
"@types/history": "^4.7.8",
|
|
74
73
|
"@types/node": "^14.14.35",
|
|
75
74
|
"@types/react": "^18.2.79",
|
|
@@ -77,9 +76,6 @@
|
|
|
77
76
|
"clean-css-cli": "^4.3.0",
|
|
78
77
|
"concat-files": "^0.1.1",
|
|
79
78
|
"dart-sass": "^1.25.0",
|
|
80
|
-
"enzyme": "^3.7.0",
|
|
81
|
-
"enzyme-adapter-react-16": "^1.15.5",
|
|
82
|
-
"enzyme-to-json": "^3.6.1",
|
|
83
79
|
"monaco-editor": "0.34.1",
|
|
84
80
|
"node-sass-glob-importer": "^5.3.2",
|
|
85
81
|
"prettier": "^2.8.8",
|
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import {
|
|
3
|
+
QuickStartContext,
|
|
4
|
+
QuickStartContextDefaults,
|
|
5
|
+
} from '@quickstarts/utils/quick-start-context';
|
|
6
|
+
import MarkdownCopyClipboard from '../MarkdownCopyClipboard';
|
|
7
|
+
import { MARKDOWN_COPY_BUTTON_ID } from '../const';
|
|
3
8
|
import { htmlDocumentForCopyClipboard } from './test-data';
|
|
4
9
|
|
|
10
|
+
const contextValues = {
|
|
11
|
+
...QuickStartContextDefaults,
|
|
12
|
+
getResource: (key: string) => key,
|
|
13
|
+
};
|
|
14
|
+
|
|
5
15
|
describe('MarkdownCopyClipboard', () => {
|
|
6
16
|
beforeAll(() => {
|
|
7
17
|
document.body.innerHTML = htmlDocumentForCopyClipboard;
|
|
8
18
|
});
|
|
19
|
+
|
|
9
20
|
it('should render null if no element is found', () => {
|
|
10
|
-
const
|
|
11
|
-
<
|
|
21
|
+
const { container } = render(
|
|
22
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
23
|
+
<MarkdownCopyClipboard docContext={document} rootSelector="#copy-markdown-3" />
|
|
24
|
+
</QuickStartContext.Provider>,
|
|
12
25
|
);
|
|
13
|
-
expect(
|
|
14
|
-
expect(wrapper.find(CopyClipboard).exists()).toBe(false);
|
|
26
|
+
expect(container.firstChild).toBeNull();
|
|
15
27
|
});
|
|
16
28
|
|
|
17
|
-
it('should render
|
|
18
|
-
|
|
19
|
-
<
|
|
29
|
+
it('should render copy targets when rootSelector matches buttons in the document', () => {
|
|
30
|
+
render(
|
|
31
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
32
|
+
<MarkdownCopyClipboard docContext={document} rootSelector="#copy-markdown-1" />
|
|
33
|
+
</QuickStartContext.Provider>,
|
|
20
34
|
);
|
|
21
|
-
|
|
22
|
-
expect(
|
|
35
|
+
const elements = document.querySelectorAll(`#copy-markdown-1 [${MARKDOWN_COPY_BUTTON_ID}]`);
|
|
36
|
+
expect(elements).toHaveLength(2);
|
|
23
37
|
});
|
|
24
38
|
});
|
|
@@ -132,18 +132,14 @@ const QuickStartTile: FC<QuickStartTileProps> = ({
|
|
|
132
132
|
/>
|
|
133
133
|
) : undefined;
|
|
134
134
|
|
|
135
|
+
const cardClasses = `pfext-catalog-item${isActive ? ' pf-m-current' : ''}`;
|
|
136
|
+
|
|
135
137
|
return (
|
|
136
138
|
<Card
|
|
137
139
|
id={`${id}-catalog-tile`}
|
|
138
140
|
style={{ height: '100%' }}
|
|
139
141
|
data-testid={`qs-card-${camelize(displayName)}`}
|
|
140
|
-
className=
|
|
141
|
-
{...(isActive && {
|
|
142
|
-
isClickable: true,
|
|
143
|
-
isSelectable: true,
|
|
144
|
-
isSelected: true,
|
|
145
|
-
isClicked: true,
|
|
146
|
-
})}
|
|
142
|
+
className={cardClasses}
|
|
147
143
|
>
|
|
148
144
|
<CardHeader
|
|
149
145
|
{...(action && {
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { EmptyBox } from '@console/internal/components/utils';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
2
|
import { getQuickStarts } from '../../data/test-utils';
|
|
5
|
-
import {
|
|
3
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
6
4
|
import QuickStartCatalog from '../QuickStartCatalog';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const contextValues = {
|
|
7
|
+
...QuickStartContextDefaults,
|
|
8
|
+
activeQuickStartID: '',
|
|
9
|
+
allQuickStartStates: {},
|
|
10
|
+
getResource: (key: string) => key,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const renderWithContext = (props: any) =>
|
|
14
|
+
render(
|
|
15
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
16
|
+
<QuickStartCatalog {...props} />
|
|
17
|
+
</QuickStartContext.Provider>,
|
|
18
|
+
);
|
|
15
19
|
|
|
16
20
|
describe('QuickStartCatalog', () => {
|
|
17
|
-
it('should
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
expect(
|
|
21
|
+
it('should render an empty state if no QS exist', () => {
|
|
22
|
+
renderWithContext({ quickStarts: [] });
|
|
23
|
+
// When no quickstarts, the catalog renders no cards
|
|
24
|
+
expect(screen.queryByRole('article')).not.toBeInTheDocument();
|
|
21
25
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
|
|
27
|
+
it('should load a gallery if QS exist', async () => {
|
|
28
|
+
const quickStarts = getQuickStarts();
|
|
29
|
+
renderWithContext({ quickStarts });
|
|
30
|
+
// Each tile exposes the quick start display name as the title control (link-styled button)
|
|
31
|
+
await waitFor(() => {
|
|
32
|
+
quickStarts.forEach((qs) => {
|
|
33
|
+
expect(
|
|
34
|
+
screen.getByRole('button', { name: qs.spec.displayName }),
|
|
35
|
+
).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
33
38
|
});
|
|
34
39
|
});
|
|
@@ -1,36 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
2
|
import { getQuickStarts } from '../../data/test-utils';
|
|
4
3
|
import { QuickStartStatus } from '../../utils/quick-start-types';
|
|
4
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
5
5
|
import QuickStartTile from '../QuickStartTile';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const contextValues = {
|
|
8
|
+
...QuickStartContextDefaults,
|
|
9
|
+
activeQuickStartID: '',
|
|
10
|
+
setActiveQuickStart: jest.fn(),
|
|
11
|
+
getResource: (key: string) => key,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const quickstarts = getQuickStarts();
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
16
|
+
const renderWithContext = (props: any) =>
|
|
17
|
+
render(
|
|
18
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
19
|
+
<QuickStartTile {...props} />
|
|
20
|
+
</QuickStartContext.Provider>,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
describe('QuickStartTile', () => {
|
|
24
|
+
it('should load proper catalog tile without featured property', async () => {
|
|
25
|
+
const quickStart = quickstarts[0];
|
|
26
|
+
renderWithContext({
|
|
27
|
+
quickStart,
|
|
28
|
+
status: QuickStartStatus.NOT_STARTED,
|
|
29
|
+
onClick: jest.fn(),
|
|
30
|
+
isActive: false,
|
|
31
|
+
});
|
|
32
|
+
await waitFor(() => {
|
|
33
|
+
expect(
|
|
34
|
+
screen.getByRole('button', { name: quickStart.spec.displayName }),
|
|
35
|
+
).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
// Status label is omitted for not-started tiles
|
|
38
|
+
expect(screen.queryByText('In progress')).not.toBeInTheDocument();
|
|
21
39
|
});
|
|
22
40
|
|
|
23
|
-
it('should load proper catalog tile with featured property', () => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
it('should load proper catalog tile with featured property', async () => {
|
|
42
|
+
const quickStart = quickstarts[1];
|
|
43
|
+
renderWithContext({
|
|
44
|
+
quickStart,
|
|
45
|
+
status: QuickStartStatus.IN_PROGRESS,
|
|
46
|
+
onClick: jest.fn(),
|
|
47
|
+
isActive: true,
|
|
48
|
+
});
|
|
49
|
+
await waitFor(() => {
|
|
50
|
+
expect(
|
|
51
|
+
screen.getByRole('button', { name: quickStart.spec.displayName }),
|
|
52
|
+
).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
expect(screen.getByText('In progress')).toBeInTheDocument();
|
|
35
55
|
});
|
|
36
56
|
});
|
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
2
|
import { getQuickStarts } from '../../data/test-utils';
|
|
3
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
4
4
|
import QuickStartTileDescription from '../QuickStartTileDescription';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
6
|
+
const contextValues = {
|
|
7
|
+
...QuickStartContextDefaults,
|
|
8
|
+
activeQuickStartID: '',
|
|
9
|
+
startQuickStart: jest.fn(),
|
|
10
|
+
restartQuickStart: jest.fn(),
|
|
11
|
+
getResource: (key: string) => key,
|
|
12
|
+
};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
getResource: (key) => `quickstart~${key}`,
|
|
21
|
-
});
|
|
22
|
-
});
|
|
14
|
+
const renderWithContext = (props: any) =>
|
|
15
|
+
render(
|
|
16
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
17
|
+
<QuickStartTileDescription {...props} />
|
|
18
|
+
</QuickStartContext.Provider>,
|
|
19
|
+
);
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
describe('QuickStartTileDescription', () => {
|
|
22
|
+
it('should show prerequisites only if provided', async () => {
|
|
26
23
|
const quickStart = getQuickStarts()[0].spec;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
renderWithContext({ description: quickStart.description });
|
|
25
|
+
await waitFor(() => {
|
|
26
|
+
expect(
|
|
27
|
+
screen.queryByRole('button', { name: 'Show prerequisites' }),
|
|
28
|
+
).not.toBeInTheDocument();
|
|
29
|
+
});
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
it('
|
|
32
|
+
it('should render prerequisites trigger when prerequisite list is non-empty', async () => {
|
|
34
33
|
const quickStart = getQuickStarts()[2].spec;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
renderWithContext({
|
|
35
|
+
description: quickStart.description,
|
|
36
|
+
prerequisites: quickStart.prerequisites,
|
|
37
|
+
});
|
|
38
|
+
await waitFor(() => {
|
|
39
|
+
expect(
|
|
40
|
+
screen.getByRole('button', { name: 'Show prerequisites' }),
|
|
41
|
+
).toBeInTheDocument();
|
|
42
|
+
});
|
|
42
43
|
});
|
|
43
44
|
});
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Button } from '@patternfly/react-core';
|
|
3
|
-
import { ShallowWrapper, shallow } from 'enzyme';
|
|
1
|
+
import { render, waitFor } from '@testing-library/react';
|
|
4
2
|
import { allQuickStarts } from '../../data/quick-start-test-data';
|
|
5
|
-
import QuickStartMarkdownView from '../../QuickStartMarkdownView';
|
|
6
3
|
import { QuickStartTaskStatus } from '../../utils/quick-start-types';
|
|
4
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
7
5
|
import { getQuickStartByName } from '../../utils/quick-start-utils';
|
|
8
6
|
import QuickStartConclusion from '../QuickStartConclusion';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const i18nNS = 'quickstart';
|
|
8
|
+
const contextValues = {
|
|
9
|
+
...QuickStartContextDefaults,
|
|
10
|
+
activeQuickStartID: '',
|
|
11
|
+
startQuickStart: jest.fn(),
|
|
12
|
+
restartQuickStart: jest.fn(),
|
|
13
|
+
getResource: (key: string) => key,
|
|
14
|
+
};
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
let wrapper: ShallowWrapper<QuickStartConclusionProps>;
|
|
22
|
-
const props: QuickStartConclusionProps = {
|
|
16
|
+
const defaultProps = {
|
|
23
17
|
tasks: getQuickStartByName('explore-pipelines', allQuickStarts).spec.tasks,
|
|
24
18
|
allTaskStatuses: [
|
|
25
19
|
QuickStartTaskStatus.SUCCESS,
|
|
@@ -31,52 +25,56 @@ const props: QuickStartConclusionProps = {
|
|
|
31
25
|
onQuickStartChange: jest.fn(),
|
|
32
26
|
};
|
|
33
27
|
|
|
34
|
-
|
|
28
|
+
const renderWithContext = (props = {}) =>
|
|
29
|
+
render(
|
|
30
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
31
|
+
<QuickStartConclusion {...defaultProps} {...props} />
|
|
32
|
+
</QuickStartContext.Provider>,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
describe('QuickStartConclusion', () => {
|
|
35
36
|
beforeEach(() => {
|
|
36
|
-
|
|
37
|
-
activeQuickStartID: '',
|
|
38
|
-
startQuickStart: () => {},
|
|
39
|
-
restartQuickStart: () => {},
|
|
40
|
-
getResource: (key) => `quickstart~${key}`,
|
|
41
|
-
});
|
|
42
|
-
wrapper = shallow(<QuickStartConclusion {...props} />);
|
|
37
|
+
jest.clearAllMocks();
|
|
43
38
|
});
|
|
44
39
|
|
|
45
|
-
it('should render conclusion if there are no failed tasks', () => {
|
|
46
|
-
|
|
40
|
+
it('should render conclusion if there are no failed tasks', async () => {
|
|
41
|
+
renderWithContext();
|
|
42
|
+
await waitFor(() => {
|
|
43
|
+
expect(document.body.textContent).toMatch(/conclusion/);
|
|
44
|
+
});
|
|
47
45
|
});
|
|
48
46
|
|
|
49
|
-
it('should render link for next quick start if nextQuickStart prop is available and there are no failed tasks', () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
);
|
|
47
|
+
it('should render link for next quick start if nextQuickStart prop is available and there are no failed tasks', async () => {
|
|
48
|
+
renderWithContext({
|
|
49
|
+
nextQuickStarts: [getQuickStartByName('explore-pipelines', allQuickStarts)],
|
|
50
|
+
});
|
|
51
|
+
await waitFor(() => {
|
|
52
|
+
expect(document.body.textContent).toMatch(
|
|
53
|
+
/Start Installing the Pipelines Operator quick start/,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
59
56
|
});
|
|
60
57
|
|
|
61
|
-
it('should not render link for next quick start if nextQuickStart props is not available', () => {
|
|
62
|
-
|
|
58
|
+
it('should not render link for next quick start if nextQuickStart props is not available', async () => {
|
|
59
|
+
renderWithContext();
|
|
60
|
+
await waitFor(() => {
|
|
61
|
+
expect(document.body.textContent).toMatch(/conclusion/);
|
|
62
|
+
});
|
|
63
|
+
expect(document.body.textContent).not.toMatch(/Start .* quick start/);
|
|
63
64
|
});
|
|
64
65
|
|
|
65
|
-
it('should not render conclusion
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
expect(
|
|
78
|
-
`${i18nNS}~One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.`,
|
|
79
|
-
);
|
|
80
|
-
expect(wrapper.find(Button).length).toBe(0);
|
|
66
|
+
it('should not render conclusion and should render message for retrying if there are failed tasks', async () => {
|
|
67
|
+
renderWithContext({
|
|
68
|
+
nextQuickStarts: [getQuickStartByName('explore-pipelines', allQuickStarts)],
|
|
69
|
+
allTaskStatuses: [
|
|
70
|
+
QuickStartTaskStatus.FAILED,
|
|
71
|
+
QuickStartTaskStatus.SUCCESS,
|
|
72
|
+
QuickStartTaskStatus.SUCCESS,
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
await waitFor(() => {
|
|
76
|
+
expect(document.body.textContent).toMatch(/One or more verifications did not pass/);
|
|
77
|
+
});
|
|
78
|
+
expect(document.body.textContent).not.toMatch(/Start .* quick start/);
|
|
81
79
|
});
|
|
82
80
|
});
|
|
@@ -1,52 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ShallowWrapper, shallow } from 'enzyme';
|
|
1
|
+
import { render, waitFor } from '@testing-library/react';
|
|
3
2
|
import { allQuickStarts } from '../../data/quick-start-test-data';
|
|
4
3
|
import { QuickStartTaskStatus } from '../../utils/quick-start-types';
|
|
4
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
5
5
|
import { getQuickStartByName } from '../../utils/quick-start-utils';
|
|
6
|
-
import QuickStartConclusion from '../QuickStartConclusion';
|
|
7
6
|
import QuickStartContent from '../QuickStartContent';
|
|
8
|
-
import QuickStartIntroduction from '../QuickStartIntroduction';
|
|
9
|
-
import QuickStartTasks from '../QuickStartTasks';
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
const contextValues = {
|
|
9
|
+
...QuickStartContextDefaults,
|
|
10
|
+
getResource: (key: string) => key,
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const quickStart = getQuickStartByName('explore-serverless', allQuickStarts);
|
|
14
|
+
const totalTasks = quickStart.spec.tasks.length;
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
quickStart
|
|
17
|
-
allTaskStatuses: [
|
|
18
|
-
QuickStartTaskStatus.INIT,
|
|
19
|
-
QuickStartTaskStatus.INIT,
|
|
20
|
-
QuickStartTaskStatus.INIT,
|
|
21
|
-
],
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
quickStart,
|
|
18
|
+
allTaskStatuses: [QuickStartTaskStatus.INIT, QuickStartTaskStatus.INIT],
|
|
22
19
|
taskNumber: -1,
|
|
23
20
|
onTaskReview: jest.fn(),
|
|
24
21
|
onTaskSelect: jest.fn(),
|
|
25
22
|
onQuickStartChange: jest.fn(),
|
|
26
23
|
};
|
|
27
24
|
|
|
25
|
+
const renderWithContext = (props = {}) =>
|
|
26
|
+
render(
|
|
27
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
28
|
+
<QuickStartContent {...defaultProps} {...props} />
|
|
29
|
+
</QuickStartContext.Provider>,
|
|
30
|
+
);
|
|
31
|
+
|
|
28
32
|
describe('QuickStartContent', () => {
|
|
29
33
|
beforeEach(() => {
|
|
30
|
-
|
|
34
|
+
jest.clearAllMocks();
|
|
31
35
|
});
|
|
32
36
|
|
|
33
|
-
it('should render QuickStartIntroduction when the tour status is Not Started', () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
it('should render QuickStartIntroduction when the tour status is Not Started', async () => {
|
|
38
|
+
renderWithContext();
|
|
39
|
+
await waitFor(() => {
|
|
40
|
+
expect(document.body.textContent).toMatch(
|
|
41
|
+
new RegExp(`In this quick start, you will complete ${totalTasks} task`),
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
expect(document.body.textContent).not.toMatch(/Your Serverless Operator is ready/);
|
|
37
45
|
});
|
|
38
46
|
|
|
39
|
-
it('should render QuickStartTasks when the tour is In Progress', () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
it('should render QuickStartTasks when the tour is In Progress', async () => {
|
|
48
|
+
// taskNumber is 0-based index into spec.tasks; first task visible and active when non-INIT
|
|
49
|
+
renderWithContext({
|
|
50
|
+
taskNumber: 0,
|
|
51
|
+
allTaskStatuses: [QuickStartTaskStatus.VISITED, QuickStartTaskStatus.INIT],
|
|
52
|
+
});
|
|
53
|
+
await waitFor(() => {
|
|
54
|
+
expect(document.body.textContent).toMatch(/Install the OpenShift Serverless Operator/);
|
|
55
|
+
});
|
|
56
|
+
expect(document.body.textContent).not.toMatch(
|
|
57
|
+
new RegExp(`In this quick start, you will complete ${totalTasks} task`),
|
|
58
|
+
);
|
|
44
59
|
});
|
|
45
60
|
|
|
46
|
-
it('should render QuickStartConclusion when the tour is Complete', () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
it('should render QuickStartConclusion when the tour is Complete', async () => {
|
|
62
|
+
renderWithContext({ taskNumber: totalTasks });
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
expect(document.body.textContent).toMatch(/Your Serverless Operator is ready/);
|
|
65
|
+
});
|
|
66
|
+
// Conclusion still lists task headers; intro copy is not shown
|
|
67
|
+
expect(document.body.textContent).not.toMatch(
|
|
68
|
+
/In this quick start, you will complete \d+ task/,
|
|
69
|
+
);
|
|
51
70
|
});
|
|
52
71
|
});
|