@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
|
@@ -1,103 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Button } from '@patternfly/react-core';
|
|
3
|
-
import { shallow } from 'enzyme';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
2
|
import { QuickStartStatus } from '../../utils/quick-start-types';
|
|
3
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
5
4
|
import QuickStartFooter from '../QuickStartFooter';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
const contextValues = {
|
|
7
|
+
...QuickStartContextDefaults,
|
|
8
|
+
activeQuickStartID: '',
|
|
9
|
+
startQuickStart: jest.fn(),
|
|
10
|
+
restartQuickStart: jest.fn(),
|
|
11
|
+
getResource: (key: string) => key,
|
|
12
|
+
};
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
startQuickStart: () => {},
|
|
22
|
-
restartQuickStart: () => {},
|
|
23
|
-
getResource: (key) => `quickstart~${key}`,
|
|
24
|
-
});
|
|
25
|
-
});
|
|
14
|
+
const renderWithContext = (props: any) =>
|
|
15
|
+
render(
|
|
16
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
17
|
+
<QuickStartFooter {...props} />
|
|
18
|
+
</QuickStartContext.Provider>,
|
|
19
|
+
);
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
describe('QuickStartFooter', () => {
|
|
22
|
+
it('should load Start button for not started tours', async () => {
|
|
23
|
+
renderWithContext({
|
|
29
24
|
status: QuickStartStatus.NOT_STARTED,
|
|
30
25
|
footerClass: 'test',
|
|
31
26
|
quickStartId: 'test-quickstart',
|
|
32
|
-
onNext: ()
|
|
33
|
-
onBack: ()
|
|
27
|
+
onNext: jest.fn(),
|
|
28
|
+
onBack: jest.fn(),
|
|
34
29
|
totalTasks: 4,
|
|
35
30
|
taskNumber: -1,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
expect(
|
|
41
|
-
expect(footerButtons.length).toEqual(1);
|
|
42
|
-
expect(footerButtons.at(0).childAt(0).text()).toBe('quickstart~Start');
|
|
31
|
+
});
|
|
32
|
+
await waitFor(() => {
|
|
33
|
+
expect(screen.getByRole('button', { name: 'Start' })).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
expect(screen.queryByRole('button', { name: 'Back' })).not.toBeInTheDocument();
|
|
43
36
|
});
|
|
44
37
|
|
|
45
|
-
it('should load Continue and Restart buttons for in progress tours at
|
|
46
|
-
|
|
38
|
+
it('should load Continue and Restart buttons for in progress tours at intro page', async () => {
|
|
39
|
+
renderWithContext({
|
|
47
40
|
status: QuickStartStatus.IN_PROGRESS,
|
|
48
41
|
footerClass: 'test',
|
|
49
42
|
quickStartId: 'test-quickstart',
|
|
50
|
-
onNext: ()
|
|
51
|
-
onBack: ()
|
|
43
|
+
onNext: jest.fn(),
|
|
44
|
+
onBack: jest.fn(),
|
|
52
45
|
totalTasks: 4,
|
|
53
46
|
taskNumber: -1,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
expect(
|
|
59
|
-
expect(footerButtons.length).toEqual(2);
|
|
60
|
-
expect(footerButtons.at(0).childAt(0).text()).toBe('quickstart~Continue');
|
|
61
|
-
expect(footerButtons.at(1).childAt(0).text()).toBe('quickstart~Restart');
|
|
47
|
+
});
|
|
48
|
+
await waitFor(() => {
|
|
49
|
+
expect(screen.getByRole('button', { name: 'Continue' })).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
expect(screen.getByRole('button', { name: 'Restart' })).toBeInTheDocument();
|
|
62
52
|
});
|
|
63
53
|
|
|
64
|
-
it('should load Next
|
|
65
|
-
|
|
54
|
+
it('should load Next, Back, and Restart buttons for in progress tours in task page', async () => {
|
|
55
|
+
renderWithContext({
|
|
66
56
|
status: QuickStartStatus.IN_PROGRESS,
|
|
67
57
|
footerClass: 'test',
|
|
68
58
|
quickStartId: 'test-quickstart',
|
|
69
|
-
onNext: ()
|
|
70
|
-
onBack: ()
|
|
59
|
+
onNext: jest.fn(),
|
|
60
|
+
onBack: jest.fn(),
|
|
71
61
|
totalTasks: 4,
|
|
72
62
|
taskNumber: 2,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
expect(
|
|
78
|
-
expect(
|
|
79
|
-
expect(footerButtons.at(0).childAt(0).text()).toBe('quickstart~Next');
|
|
80
|
-
expect(footerButtons.at(1).childAt(0).text()).toBe('quickstart~Back');
|
|
81
|
-
expect(footerButtons.at(2).childAt(0).text()).toBe('quickstart~Restart');
|
|
63
|
+
});
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(screen.getByRole('button', { name: 'Next' })).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
expect(screen.getByRole('button', { name: 'Back' })).toBeInTheDocument();
|
|
68
|
+
expect(screen.getByRole('button', { name: 'Restart' })).toBeInTheDocument();
|
|
82
69
|
});
|
|
83
70
|
|
|
84
|
-
it('should load Close, Back and Restart buttons for completed tours in conclusion page', () => {
|
|
85
|
-
|
|
71
|
+
it('should load Close, Back and Restart buttons for completed tours in conclusion page', async () => {
|
|
72
|
+
renderWithContext({
|
|
86
73
|
status: QuickStartStatus.COMPLETE,
|
|
87
74
|
footerClass: 'test',
|
|
88
75
|
quickStartId: 'test-quickstart',
|
|
89
|
-
onNext: ()
|
|
90
|
-
onBack: ()
|
|
76
|
+
onNext: jest.fn(),
|
|
77
|
+
onBack: jest.fn(),
|
|
91
78
|
totalTasks: 4,
|
|
92
79
|
taskNumber: 4,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
expect(
|
|
98
|
-
expect(
|
|
99
|
-
expect(footerButtons.at(0).childAt(0).text()).toBe('quickstart~Close');
|
|
100
|
-
expect(footerButtons.at(1).childAt(0).text()).toBe('quickstart~Back');
|
|
101
|
-
expect(footerButtons.at(2).childAt(0).text()).toBe('quickstart~Restart');
|
|
80
|
+
});
|
|
81
|
+
await waitFor(() => {
|
|
82
|
+
expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
expect(screen.getByRole('button', { name: 'Back' })).toBeInTheDocument();
|
|
85
|
+
expect(screen.getByRole('button', { name: 'Restart' })).toBeInTheDocument();
|
|
102
86
|
});
|
|
103
87
|
});
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Title, WizardNavItem } from '@patternfly/react-core';
|
|
3
|
-
import { ShallowWrapper, shallow } from 'enzyme';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
2
|
import { QuickStartTaskStatus } from '../../utils/quick-start-types';
|
|
3
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
5
4
|
import QuickStartTaskHeader from '../QuickStartTaskHeader';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const contextValues = {
|
|
7
|
+
...QuickStartContextDefaults,
|
|
8
|
+
getResource: (key: string) => key,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const defaultProps = {
|
|
10
12
|
title: 'title',
|
|
11
13
|
taskIndex: 1,
|
|
12
14
|
subtitle: 'subtitle',
|
|
13
15
|
taskStatus: QuickStartTaskStatus.INIT,
|
|
14
|
-
size: 'lg',
|
|
16
|
+
size: 'lg' as const,
|
|
15
17
|
isActiveTask: true,
|
|
16
18
|
onTaskSelect: jest.fn(),
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
const renderWithContext = (props = {}) =>
|
|
22
|
+
render(
|
|
23
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
24
|
+
<QuickStartTaskHeader {...defaultProps} {...props} />
|
|
25
|
+
</QuickStartContext.Provider>,
|
|
26
|
+
);
|
|
27
|
+
|
|
19
28
|
describe('QuickStartTaskHeader', () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
it('should render subtitle for active task', async () => {
|
|
30
|
+
renderWithContext();
|
|
31
|
+
await waitFor(() => {
|
|
32
|
+
expect(
|
|
33
|
+
screen.getByRole('button', {
|
|
34
|
+
name: new RegExp(`${defaultProps.title}.*${defaultProps.subtitle}`),
|
|
35
|
+
}),
|
|
36
|
+
).toBeInTheDocument();
|
|
37
|
+
});
|
|
23
38
|
});
|
|
24
39
|
|
|
25
|
-
it('should render subtitle
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
it('should not render subtitle if task is not active', () => {
|
|
33
|
-
wrapper = shallow(<QuickStartTaskHeader {...props} isActiveTask={false} />);
|
|
34
|
-
expect(wrapper.find(WizardNavItem).dive().find(Title).length).toBe(1);
|
|
35
|
-
expect(
|
|
36
|
-
wrapper
|
|
37
|
-
.find(WizardNavItem)
|
|
38
|
-
.dive()
|
|
39
|
-
.find('[data-test-id="quick-start-task-subtitle"]')
|
|
40
|
-
.exists(),
|
|
41
|
-
).toBe(false);
|
|
40
|
+
it('should not render subtitle if task is not active', async () => {
|
|
41
|
+
renderWithContext({ isActiveTask: false });
|
|
42
|
+
await waitFor(() => {
|
|
43
|
+
expect(screen.getByRole('button', { name: defaultProps.title })).toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
expect(screen.queryByText(defaultProps.subtitle)).not.toBeInTheDocument();
|
|
42
46
|
});
|
|
43
47
|
});
|
|
@@ -1,42 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ShallowWrapper, shallow } from 'enzyme';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
2
|
import { allQuickStarts } from '../../data/quick-start-test-data';
|
|
4
|
-
import QuickStartMarkdownView from '../../QuickStartMarkdownView';
|
|
5
3
|
import { QuickStartTaskStatus } from '../../utils/quick-start-types';
|
|
4
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
6
5
|
import { getQuickStartByName } from '../../utils/quick-start-utils';
|
|
7
6
|
import QuickStartTaskReview from '../QuickStartTaskReview';
|
|
8
|
-
import { ComponentProps } from 'react';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const contextValues = {
|
|
9
|
+
...QuickStartContextDefaults,
|
|
10
|
+
getResource: (key: string) => key,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const review = getQuickStartByName('explore-serverless', allQuickStarts).spec.tasks[0].review;
|
|
14
|
+
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
review,
|
|
14
17
|
taskStatus: QuickStartTaskStatus.REVIEW,
|
|
15
18
|
onTaskReview: jest.fn(),
|
|
16
19
|
};
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const renderWithContext = (props = {}) =>
|
|
22
|
+
render(
|
|
23
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
24
|
+
<QuickStartTaskReview {...defaultProps} {...props} />
|
|
25
|
+
</QuickStartContext.Provider>,
|
|
26
|
+
);
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
describe('QuickStartTaskReview', () => {
|
|
29
|
+
it('should render review prompt with yes/no while task is in review', async () => {
|
|
30
|
+
renderWithContext();
|
|
31
|
+
await waitFor(() => {
|
|
32
|
+
expect(screen.getByRole('alert')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
expect(screen.getByText('Check your work')).toBeInTheDocument();
|
|
35
|
+
expect(screen.getByRole('radio', { name: 'Yes' })).not.toBeChecked();
|
|
36
|
+
expect(screen.getByRole('radio', { name: 'No' })).not.toBeChecked();
|
|
28
37
|
});
|
|
29
38
|
|
|
30
|
-
it('should
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
it('should mark Yes selected when task status is success', async () => {
|
|
40
|
+
renderWithContext({ taskStatus: QuickStartTaskStatus.SUCCESS });
|
|
41
|
+
await waitFor(() => {
|
|
42
|
+
expect(screen.getByRole('radio', { name: 'Yes' })).toBeChecked();
|
|
43
|
+
});
|
|
44
|
+
expect(screen.getByRole('radio', { name: 'No' })).not.toBeChecked();
|
|
34
45
|
});
|
|
35
46
|
|
|
36
|
-
it('should
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
47
|
+
it('should mark No selected and show failed-task help when task status is failed', async () => {
|
|
48
|
+
renderWithContext({ taskStatus: QuickStartTaskStatus.FAILED });
|
|
49
|
+
await waitFor(() => {
|
|
50
|
+
expect(screen.getByRole('radio', { name: 'No' })).toBeChecked();
|
|
51
|
+
});
|
|
52
|
+
expect(screen.getByRole('radio', { name: 'Yes' })).not.toBeChecked();
|
|
53
|
+
await waitFor(() => {
|
|
54
|
+
expect(document.body.textContent).toMatch(/This task is incomplete/);
|
|
55
|
+
});
|
|
41
56
|
});
|
|
42
57
|
});
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ShallowWrapper, shallow } from 'enzyme';
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
2
|
import { allQuickStarts } from '../../data/quick-start-test-data';
|
|
4
|
-
import QuickStartMarkdownView from '../../QuickStartMarkdownView';
|
|
5
3
|
import { QuickStartTaskStatus } from '../../utils/quick-start-types';
|
|
4
|
+
import { QuickStartContext, QuickStartContextDefaults } from '../../utils/quick-start-context';
|
|
6
5
|
import { getQuickStartByName } from '../../utils/quick-start-utils';
|
|
7
|
-
import
|
|
8
|
-
import QuickStartTaskReview from '../QuickStartTaskReview';
|
|
9
|
-
import QuickStartTask from '../QuickStartTasks';
|
|
6
|
+
import QuickStartTasks from '../QuickStartTasks';
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
8
|
+
const contextValues = {
|
|
9
|
+
...QuickStartContextDefaults,
|
|
10
|
+
activeQuickStartID: '',
|
|
11
|
+
startQuickStart: jest.fn(),
|
|
12
|
+
restartQuickStart: jest.fn(),
|
|
13
|
+
getResource: (key: string) => key,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const tasks = getQuickStartByName('monitor-sampleapp', allQuickStarts).spec.tasks;
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const props: QuickStartTaskProps = {
|
|
22
|
-
tasks: getQuickStartByName('monitor-sampleapp', allQuickStarts).spec.tasks,
|
|
18
|
+
const defaultProps = {
|
|
19
|
+
tasks,
|
|
23
20
|
allTaskStatuses: [
|
|
24
21
|
QuickStartTaskStatus.SUCCESS,
|
|
25
22
|
QuickStartTaskStatus.INIT,
|
|
@@ -30,49 +27,54 @@ const props: QuickStartTaskProps = {
|
|
|
30
27
|
onTaskSelect: jest.fn(),
|
|
31
28
|
};
|
|
32
29
|
|
|
30
|
+
const renderWithContext = (props = {}) =>
|
|
31
|
+
render(
|
|
32
|
+
<QuickStartContext.Provider value={contextValues}>
|
|
33
|
+
<QuickStartTasks {...defaultProps} {...props} />
|
|
34
|
+
</QuickStartContext.Provider>,
|
|
35
|
+
);
|
|
36
|
+
|
|
33
37
|
describe('QuickStartTasks', () => {
|
|
34
38
|
beforeEach(() => {
|
|
35
|
-
|
|
36
|
-
activeQuickStartID: '',
|
|
37
|
-
startQuickStart: () => {},
|
|
38
|
-
restartQuickStart: () => {},
|
|
39
|
-
getResource: (key) => `quickstart~${key}`,
|
|
40
|
-
});
|
|
41
|
-
wrapper = shallow(<QuickStartTask {...props} />);
|
|
39
|
+
jest.clearAllMocks();
|
|
42
40
|
});
|
|
43
41
|
|
|
44
|
-
it('should render correct number of tasks based on currentTaskIndex', () => {
|
|
45
|
-
|
|
42
|
+
it('should render correct number of tasks based on currentTaskIndex', async () => {
|
|
43
|
+
renderWithContext();
|
|
44
|
+
await waitFor(() => {
|
|
45
|
+
// Only non-INIT tasks are rendered; first task is SUCCESS so it shows
|
|
46
|
+
const taskHeaders = screen.getAllByRole('listitem');
|
|
47
|
+
expect(taskHeaders).toHaveLength(1);
|
|
48
|
+
});
|
|
46
49
|
});
|
|
47
50
|
|
|
48
|
-
it('should render
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
51
|
+
it('should render description if a task is active', async () => {
|
|
52
|
+
renderWithContext({
|
|
53
|
+
allTaskStatuses: [
|
|
54
|
+
QuickStartTaskStatus.SUCCESS,
|
|
55
|
+
QuickStartTaskStatus.FAILED,
|
|
56
|
+
QuickStartTaskStatus.VISITED,
|
|
57
|
+
],
|
|
58
|
+
taskNumber: 2,
|
|
59
|
+
});
|
|
60
|
+
await waitFor(() => {
|
|
61
|
+
// All 3 tasks are non-INIT, so all render
|
|
62
|
+
const taskHeaders = screen.getAllByRole('listitem');
|
|
63
|
+
expect(taskHeaders).toHaveLength(3);
|
|
64
|
+
});
|
|
63
65
|
});
|
|
64
66
|
|
|
65
|
-
it('should render review when task is active and in Review state', () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
it('should render review when task is active and in Review state', async () => {
|
|
68
|
+
renderWithContext({
|
|
69
|
+
allTaskStatuses: [
|
|
70
|
+
QuickStartTaskStatus.SUCCESS,
|
|
71
|
+
QuickStartTaskStatus.REVIEW,
|
|
72
|
+
QuickStartTaskStatus.INIT,
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
await waitFor(() => {
|
|
76
|
+
// "Check your work" is the alert title for QuickStartTaskReview
|
|
77
|
+
expect(screen.getByText('Check your work')).toBeInTheDocument();
|
|
78
|
+
});
|
|
77
79
|
});
|
|
78
80
|
});
|