@scottish-government/designsystem-react 0.6.0 → 0.7.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/@types/components/Accordion.d.ts +2 -2
- package/@types/components/ConfirmationMessage.d.ts +1 -1
- package/@types/components/NotificationPanel.d.ts +1 -1
- package/@types/components/SummaryCard.d.ts +1 -1
- package/@types/components/Tabs.d.ts +1 -1
- package/@types/sgds.d.ts +1 -1
- package/CHANGELOG.md +81 -0
- package/README.md +4 -0
- package/dist/common/AbstractNotificationBanner.jsx +63 -0
- package/dist/common/ConditionalWrapper.jsx +8 -0
- package/dist/common/FileIcon.jsx +51 -0
- package/dist/common/HintText.jsx +9 -0
- package/dist/common/Icon.jsx +57 -0
- package/dist/common/ScreenReaderText.jsx +9 -0
- package/dist/common/WrapperTag.jsx +11 -0
- package/dist/components/Accordion/Accordion.jsx +102 -0
- package/dist/components/AspectBox/AspectBox.jsx +79 -0
- package/dist/components/BackToTop/BackToTop.jsx +27 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +28 -0
- package/dist/components/Button/Button.jsx +30 -0
- package/dist/components/Checkbox/Checkbox.jsx +62 -0
- package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +24 -0
- package/dist/components/ContentsNav/ContentsNav.jsx +33 -0
- package/dist/components/CookieBanner/CookieBanner.jsx +21 -0
- package/dist/components/DatePicker/DatePicker.jsx +54 -0
- package/dist/components/Details/Details.jsx +17 -0
- package/dist/components/ErrorMessage/ErrorMessage.jsx +12 -0
- package/dist/components/ErrorSummary/ErrorSummary.jsx +27 -0
- package/dist/components/FileDownload/FileDownload.jsx +50 -0
- package/dist/components/HideThisPage/HideThisPage.jsx +71 -0
- package/dist/components/InsetText/InsetText.jsx +14 -0
- package/dist/components/NotificationBanner/NotificationBanner.jsx +26 -0
- package/dist/components/NotificationPanel/NotificationPanel.jsx +21 -0
- package/dist/components/PageHeader/PageHeader.jsx +15 -0
- package/dist/components/PageMetadata/PageMetadata.jsx +26 -0
- package/dist/components/Pagination/Pagination.jsx +97 -0
- package/dist/components/PhaseBanner/PhaseBanner.jsx +23 -0
- package/dist/components/Question/Question.jsx +22 -0
- package/dist/components/RadioButton/RadioButton.jsx +43 -0
- package/dist/components/Select/Select.jsx +52 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +31 -0
- package/dist/components/SideNavigation/SideNavigation.jsx +52 -0
- package/dist/components/SiteHeader/SiteHeader.jsx +68 -0
- package/dist/components/SiteNavigation/SiteNavigation.jsx +22 -0
- package/dist/components/SiteSearch/SiteSearch.jsx +55 -0
- package/dist/components/SkipLinks/SkipLinks.jsx +21 -0
- package/dist/components/SummaryCard/SummaryCard.jsx +67 -0
- package/dist/components/SummaryList/SummaryList.jsx +75 -0
- package/dist/components/Table/Table.jsx +24 -0
- package/dist/components/Tabs/Tabs.jsx +99 -0
- package/dist/components/Tag/Tag.jsx +13 -0
- package/dist/components/TaskList/TaskList.jsx +95 -0
- package/dist/components/TextInput/TextInput.jsx +58 -0
- package/dist/components/Textarea/Textarea.jsx +54 -0
- package/dist/components/WarningText/WarningText.jsx +16 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
- package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
- package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
- package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
- package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
- package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
- package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
- package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
- package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
- package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
- package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
- package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
- package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
- package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
- package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
- package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
- package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
- package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
- package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
- package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
- package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
- package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
- package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
- package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
- package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
- package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
- package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
- package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
- package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
- package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
- package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
- package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
- package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
- package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
- package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
- package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
- package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
- package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
- package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
- package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
- package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
- package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
- package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
- package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
- package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
- package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
- package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
- package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
- package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
- package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
- package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
- package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
- package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
- package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
- package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
- package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
- package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
- package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
- package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
- package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
- package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
- package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
- package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
- package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
- package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
- package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
- package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
- package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
- package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
- package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
- package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
- package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
- package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
- package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
- /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
- /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
- /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
- /package/src/common/{icon.tsx → Icon.tsx} +0 -0
- /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
- /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
- /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
- /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
- /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
- /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
- /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
- /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
- /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
- /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
- /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
- /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
- /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
- /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
- /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
- /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import TaskList from './
|
|
3
|
+
import TaskList from './TaskList';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const TASK_LIST_HEADING_TEXT = 'Application incomplete';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const TASKS = [
|
|
8
8
|
{ id: 'task-conditions', statusText: 'Cannot start yet', title: 'Conditions' },
|
|
9
9
|
{ id: 'task-medications', statusText: 'Cannot start yet', title: 'Medications' },
|
|
10
10
|
{ id: 'task-contacts', statusText: 'Cannot start yet', title: 'Contacts and supporting information' },
|
|
11
11
|
];
|
|
12
|
-
const
|
|
12
|
+
const TASK_ITEM = {
|
|
13
13
|
id: 'task-conditions',
|
|
14
14
|
statusText: 'Cannot start yet',
|
|
15
15
|
title: 'Conditions',
|
|
16
16
|
href: '#foo'
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
const TASK_SUMMARY_CONTENT = 'Tell us about your conditions, symptoms and any sensory issues you have.';
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
test('task list renders correctly', () => {
|
|
22
22
|
render(
|
|
23
23
|
<TaskList
|
|
24
|
-
title={
|
|
24
|
+
title={TASK_LIST_HEADING_TEXT}
|
|
25
25
|
>
|
|
26
26
|
<TaskList.Item
|
|
27
|
-
id={
|
|
28
|
-
statusText={
|
|
29
|
-
title={
|
|
27
|
+
id={TASKS[0].id}
|
|
28
|
+
statusText={TASKS[0].statusText}
|
|
29
|
+
title={TASKS[0].title}
|
|
30
30
|
>
|
|
31
31
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
32
32
|
</TaskList.Item>
|
|
33
33
|
<TaskList.Item
|
|
34
|
-
id={
|
|
35
|
-
statusText={
|
|
36
|
-
title={
|
|
34
|
+
id={TASKS[1].id}
|
|
35
|
+
statusText={TASKS[1].statusText}
|
|
36
|
+
title={TASKS[1].title}
|
|
37
37
|
>
|
|
38
38
|
Tell us about any medication you need.
|
|
39
39
|
</TaskList.Item>
|
|
40
40
|
<TaskList.Item
|
|
41
|
-
id={
|
|
42
|
-
statusText={
|
|
43
|
-
title={
|
|
41
|
+
id={TASKS[2].id}
|
|
42
|
+
statusText={TASKS[2].statusText}
|
|
43
|
+
title={TASKS[2].title}
|
|
44
44
|
>
|
|
45
45
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
46
46
|
</TaskList.Item>
|
|
@@ -57,7 +57,7 @@ test('task list renders correctly', () => {
|
|
|
57
57
|
|
|
58
58
|
expect(taskListHeading).toHaveClass('ds_task-list-status-heading');
|
|
59
59
|
expect(taskListHeading).toHaveAttribute('id', 'task-list-status');
|
|
60
|
-
expect(taskListHeading.textContent).toEqual(
|
|
60
|
+
expect(taskListHeading.textContent).toEqual(TASK_LIST_HEADING_TEXT);
|
|
61
61
|
|
|
62
62
|
expect(taskListStatus).toHaveClass('ds_task-list-status');
|
|
63
63
|
expect(taskListStatus).toHaveAttribute('aria-labelledby', taskListHeading.id);
|
|
@@ -67,19 +67,20 @@ test('task list renders correctly', () => {
|
|
|
67
67
|
expect(taskListStatus2.tagName).toEqual('P');
|
|
68
68
|
expect(taskListStatusLink.tagName).toEqual('A');
|
|
69
69
|
expect(taskListStatusLink.textContent).toEqual('Skip to first incomplete section');
|
|
70
|
-
expect(taskListStatusLink).toHaveAttribute('href', `#${
|
|
70
|
+
expect(taskListStatusLink).toHaveAttribute('href', `#${TASKS[0].id}`);
|
|
71
71
|
|
|
72
72
|
expect(taskList).toHaveClass('ds_task-list');
|
|
73
73
|
expect(taskList.tagName).toEqual('UL');
|
|
74
|
-
expect(taskList.children.length).toEqual(
|
|
74
|
+
expect(taskList.children.length).toEqual(TASKS.length);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
test('task list with custom ID', () => {
|
|
78
|
-
const
|
|
78
|
+
const TASKLIST_HEADING_ID = 'my-id';
|
|
79
|
+
|
|
79
80
|
render(
|
|
80
81
|
<TaskList
|
|
81
|
-
title={
|
|
82
|
-
headingId={
|
|
82
|
+
title={TASK_LIST_HEADING_TEXT}
|
|
83
|
+
headingId={TASKLIST_HEADING_ID}
|
|
83
84
|
>
|
|
84
85
|
</TaskList>
|
|
85
86
|
);
|
|
@@ -87,35 +88,35 @@ test('task list with custom ID', () => {
|
|
|
87
88
|
const taskListStatus = screen.getByRole('navigation');
|
|
88
89
|
const taskListHeading = screen.getAllByRole('heading')[0];
|
|
89
90
|
|
|
90
|
-
expect(taskListHeading).toHaveAttribute('id', `${
|
|
91
|
+
expect(taskListHeading).toHaveAttribute('id', `${TASKLIST_HEADING_ID}-status`);
|
|
91
92
|
expect(taskListStatus).toHaveAttribute('aria-labelledby', taskListHeading.id);
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
test('task list with completed tasks', () => {
|
|
95
96
|
render(
|
|
96
97
|
<TaskList
|
|
97
|
-
title={
|
|
98
|
+
title={TASK_LIST_HEADING_TEXT}
|
|
98
99
|
>
|
|
99
100
|
<TaskList.Item
|
|
100
|
-
id={
|
|
101
|
-
statusText={
|
|
102
|
-
title={
|
|
101
|
+
id={TASKS[0].id}
|
|
102
|
+
statusText={TASKS[0].statusText}
|
|
103
|
+
title={TASKS[0].title}
|
|
103
104
|
isComplete
|
|
104
105
|
>
|
|
105
106
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
106
107
|
</TaskList.Item>
|
|
107
108
|
<TaskList.Item
|
|
108
|
-
id={
|
|
109
|
-
statusText={
|
|
110
|
-
title={
|
|
109
|
+
id={TASKS[1].id}
|
|
110
|
+
statusText={TASKS[1].statusText}
|
|
111
|
+
title={TASKS[1].title}
|
|
111
112
|
isComplete
|
|
112
113
|
>
|
|
113
114
|
Tell us about any medication you need.
|
|
114
115
|
</TaskList.Item>
|
|
115
116
|
<TaskList.Item
|
|
116
|
-
id={
|
|
117
|
-
statusText={
|
|
118
|
-
title={
|
|
117
|
+
id={TASKS[2].id}
|
|
118
|
+
statusText={TASKS[2].statusText}
|
|
119
|
+
title={TASKS[2].title}
|
|
119
120
|
>
|
|
120
121
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
121
122
|
</TaskList.Item>
|
|
@@ -127,17 +128,17 @@ test('task list with completed tasks', () => {
|
|
|
127
128
|
const taskListStatusLink = within(taskListStatus).getByRole('link');
|
|
128
129
|
|
|
129
130
|
expect(taskListStatus1.textContent).toEqual('You have completed 2 of 3 sections.');
|
|
130
|
-
expect(taskListStatusLink).toHaveAttribute('href', `#${
|
|
131
|
+
expect(taskListStatusLink).toHaveAttribute('href', `#${TASKS[2].id}`);
|
|
131
132
|
});
|
|
132
133
|
|
|
133
134
|
test('task renders correctly', () => {
|
|
134
135
|
render(
|
|
135
136
|
<TaskList.Item
|
|
136
|
-
id={
|
|
137
|
-
statusText={
|
|
138
|
-
title={
|
|
137
|
+
id={TASK_ITEM.id}
|
|
138
|
+
statusText={TASK_ITEM.statusText}
|
|
139
|
+
title={TASK_ITEM.title}
|
|
139
140
|
>
|
|
140
|
-
{
|
|
141
|
+
{TASK_SUMMARY_CONTENT}
|
|
141
142
|
</TaskList.Item>
|
|
142
143
|
);
|
|
143
144
|
|
|
@@ -148,7 +149,7 @@ test('task renders correctly', () => {
|
|
|
148
149
|
const taskSummary = taskHeading.nextElementSibling;
|
|
149
150
|
|
|
150
151
|
expect(task).toHaveClass('ds_task-list__task');
|
|
151
|
-
expect(task).toHaveAttribute('id',
|
|
152
|
+
expect(task).toHaveAttribute('id', TASK_ITEM.id);
|
|
152
153
|
|
|
153
154
|
expect(taskDetails).toHaveClass('ds_task-list__task-details');
|
|
154
155
|
expect(taskDetails?.parentElement).toEqual(task);
|
|
@@ -156,27 +157,27 @@ test('task renders correctly', () => {
|
|
|
156
157
|
|
|
157
158
|
expect(taskHeading).toHaveClass('ds_task-list__task-heading');
|
|
158
159
|
expect(taskHeading.tagName).toEqual('H3');
|
|
159
|
-
expect(taskHeading.textContent).toEqual(`${
|
|
160
|
+
expect(taskHeading.textContent).toEqual(`${TASK_ITEM.title}(${TASK_ITEM.statusText})`);
|
|
160
161
|
|
|
161
162
|
expect(taskSummary).toHaveClass('ds_task-list__task-summary');
|
|
162
163
|
expect(taskSummary?.tagName).toEqual('P');
|
|
163
|
-
expect(taskSummary?.textContent).toEqual(
|
|
164
|
+
expect(taskSummary?.textContent).toEqual(TASK_SUMMARY_CONTENT);
|
|
164
165
|
|
|
165
166
|
expect(tag).toHaveAttribute('aria-hidden', 'true');
|
|
166
|
-
expect(tag?.textContent).toEqual(
|
|
167
|
+
expect(tag?.textContent).toEqual(TASK_ITEM.statusText);
|
|
167
168
|
});
|
|
168
169
|
|
|
169
170
|
test('task with link', () => {
|
|
170
|
-
const
|
|
171
|
+
const TASK_HREF = '#foo';
|
|
171
172
|
|
|
172
173
|
render(
|
|
173
174
|
<TaskList.Item
|
|
174
|
-
id={
|
|
175
|
-
statusText={
|
|
176
|
-
title={
|
|
177
|
-
href={
|
|
175
|
+
id={TASK_ITEM.id}
|
|
176
|
+
statusText={TASK_ITEM.statusText}
|
|
177
|
+
title={TASK_ITEM.title}
|
|
178
|
+
href={TASK_HREF}
|
|
178
179
|
>
|
|
179
|
-
{
|
|
180
|
+
{TASK_SUMMARY_CONTENT}
|
|
180
181
|
</TaskList.Item>
|
|
181
182
|
);
|
|
182
183
|
|
|
@@ -185,8 +186,8 @@ test('task with link', () => {
|
|
|
185
186
|
const link = within(task).getByRole('link');
|
|
186
187
|
|
|
187
188
|
expect(link).toHaveClass('ds_task-list__task-link');
|
|
188
|
-
expect(link).toHaveAttribute('href',
|
|
189
|
-
expect(link.textContent).toEqual(`${
|
|
189
|
+
expect(link).toHaveAttribute('href', TASK_HREF);
|
|
190
|
+
expect(link.textContent).toEqual(`${TASK_ITEM.title}(${TASK_ITEM.statusText})`);
|
|
190
191
|
expect(link.parentElement).toEqual(taskHeading);
|
|
191
192
|
expect(link.textContent).toEqual(taskHeading.textContent);
|
|
192
193
|
});
|
|
@@ -194,12 +195,12 @@ test('task with link', () => {
|
|
|
194
195
|
test('completed task has green tag', () => {
|
|
195
196
|
render(
|
|
196
197
|
<TaskList.Item
|
|
197
|
-
id={
|
|
198
|
-
statusText={
|
|
199
|
-
title={
|
|
198
|
+
id={TASK_ITEM.id}
|
|
199
|
+
statusText={TASK_ITEM.statusText}
|
|
200
|
+
title={TASK_ITEM.title}
|
|
200
201
|
isComplete
|
|
201
202
|
>
|
|
202
|
-
{
|
|
203
|
+
{TASK_SUMMARY_CONTENT}
|
|
203
204
|
</TaskList.Item>
|
|
204
205
|
);
|
|
205
206
|
|
|
@@ -209,31 +210,31 @@ test('completed task has green tag', () => {
|
|
|
209
210
|
});
|
|
210
211
|
|
|
211
212
|
test('specific tag colour', () => {
|
|
212
|
-
const
|
|
213
|
+
const TAG_COLOUR = 'red';
|
|
213
214
|
|
|
214
215
|
render(
|
|
215
216
|
<TaskList.Item
|
|
216
|
-
id={
|
|
217
|
-
statusText={
|
|
218
|
-
title={
|
|
219
|
-
tagColour={
|
|
217
|
+
id={TASK_ITEM.id}
|
|
218
|
+
statusText={TASK_ITEM.statusText}
|
|
219
|
+
title={TASK_ITEM.title}
|
|
220
|
+
tagColour={TAG_COLOUR}
|
|
220
221
|
>
|
|
221
|
-
{
|
|
222
|
+
{TASK_SUMMARY_CONTENT}
|
|
222
223
|
</TaskList.Item>
|
|
223
224
|
);
|
|
224
225
|
|
|
225
226
|
const tag = document.querySelector('.ds_tag');
|
|
226
227
|
|
|
227
|
-
expect(tag).toHaveClass(`ds_tag--${
|
|
228
|
+
expect(tag).toHaveClass(`ds_tag--${TAG_COLOUR}`);
|
|
228
229
|
});
|
|
229
230
|
|
|
230
231
|
test('no status tag when no status text provided', () => {
|
|
231
232
|
render(
|
|
232
233
|
<TaskList.Item
|
|
233
|
-
id={
|
|
234
|
-
title={
|
|
234
|
+
id={TASK_ITEM.id}
|
|
235
|
+
title={TASK_ITEM.title}
|
|
235
236
|
>
|
|
236
|
-
{
|
|
237
|
+
{TASK_SUMMARY_CONTENT}
|
|
237
238
|
</TaskList.Item>
|
|
238
239
|
);
|
|
239
240
|
|
|
@@ -243,28 +244,28 @@ test('no status tag when no status text provided', () => {
|
|
|
243
244
|
});
|
|
244
245
|
|
|
245
246
|
test('task group renders correctly', () => {
|
|
246
|
-
const
|
|
247
|
+
const TASK_GROUP_HEADING_TEXT = 'Provide your health details';
|
|
247
248
|
|
|
248
249
|
render(
|
|
249
|
-
<TaskList.Group title={
|
|
250
|
+
<TaskList.Group title={TASK_GROUP_HEADING_TEXT}>
|
|
250
251
|
<TaskList.Item
|
|
251
|
-
id={
|
|
252
|
-
statusText={
|
|
253
|
-
title={
|
|
252
|
+
id={TASKS[0].id}
|
|
253
|
+
statusText={TASKS[0].statusText}
|
|
254
|
+
title={TASKS[0].title}
|
|
254
255
|
>
|
|
255
256
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
256
257
|
</TaskList.Item>
|
|
257
258
|
<TaskList.Item
|
|
258
|
-
id={
|
|
259
|
-
statusText={
|
|
260
|
-
title={
|
|
259
|
+
id={TASKS[1].id}
|
|
260
|
+
statusText={TASKS[1].statusText}
|
|
261
|
+
title={TASKS[1].title}
|
|
261
262
|
>
|
|
262
263
|
Tell us about any medication you need.
|
|
263
264
|
</TaskList.Item>
|
|
264
265
|
<TaskList.Item
|
|
265
|
-
id={
|
|
266
|
-
statusText={
|
|
267
|
-
title={
|
|
266
|
+
id={TASKS[2].id}
|
|
267
|
+
statusText={TASKS[2].statusText}
|
|
268
|
+
title={TASKS[2].title}
|
|
268
269
|
>
|
|
269
270
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
270
271
|
</TaskList.Item>
|
|
@@ -279,35 +280,35 @@ test('task group renders correctly', () => {
|
|
|
279
280
|
expect(taskGroup?.tagName).toEqual('LI');
|
|
280
281
|
|
|
281
282
|
expect(taskGroupHeading?.tagName).toEqual('H2');
|
|
282
|
-
expect(taskGroupHeading?.textContent).toEqual(
|
|
283
|
+
expect(taskGroupHeading?.textContent).toEqual(TASK_GROUP_HEADING_TEXT);
|
|
283
284
|
|
|
284
285
|
// a bit hacky, but list should be last child
|
|
285
286
|
expect(taskGroup?.children[taskGroup.children.length - 1]).toEqual(innerTaskList);
|
|
286
287
|
});
|
|
287
288
|
|
|
288
289
|
test('task group with intro text', () => {
|
|
289
|
-
const
|
|
290
|
+
const TASK_GROUP_INTRO_TEXT = 'This information will be used to check what additional benefits you may be able to apply for.';
|
|
290
291
|
|
|
291
292
|
render(
|
|
292
|
-
<TaskList.Group title="Provide your health details" intro={
|
|
293
|
+
<TaskList.Group title="Provide your health details" intro={TASK_GROUP_INTRO_TEXT}>
|
|
293
294
|
<TaskList.Item
|
|
294
|
-
id={
|
|
295
|
-
statusText={
|
|
296
|
-
title={
|
|
295
|
+
id={TASKS[0].id}
|
|
296
|
+
statusText={TASKS[0].statusText}
|
|
297
|
+
title={TASKS[0].title}
|
|
297
298
|
>
|
|
298
299
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
299
300
|
</TaskList.Item>
|
|
300
301
|
<TaskList.Item
|
|
301
|
-
id={
|
|
302
|
-
statusText={
|
|
303
|
-
title={
|
|
302
|
+
id={TASKS[1].id}
|
|
303
|
+
statusText={TASKS[1].statusText}
|
|
304
|
+
title={TASKS[1].title}
|
|
304
305
|
>
|
|
305
306
|
Tell us about any medication you need.
|
|
306
307
|
</TaskList.Item>
|
|
307
308
|
<TaskList.Item
|
|
308
|
-
id={
|
|
309
|
-
statusText={
|
|
310
|
-
title={
|
|
309
|
+
id={TASKS[2].id}
|
|
310
|
+
statusText={TASKS[2].statusText}
|
|
311
|
+
title={TASKS[2].title}
|
|
311
312
|
>
|
|
312
313
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
313
314
|
</TaskList.Item>
|
|
@@ -318,7 +319,7 @@ test('task group with intro text', () => {
|
|
|
318
319
|
const taskGroupHeading = taskGroup?.querySelector('.ds_task-list-heading');
|
|
319
320
|
const taskGroupIntro = taskGroup?.querySelector('.ds_task-list-intro');
|
|
320
321
|
|
|
321
|
-
expect(taskGroupIntro?.textContent).toEqual(
|
|
322
|
+
expect(taskGroupIntro?.textContent).toEqual(TASK_GROUP_INTRO_TEXT);
|
|
322
323
|
expect(taskGroupIntro?.previousSibling).toEqual(taskGroupHeading);
|
|
323
324
|
});
|
|
324
325
|
|
|
@@ -327,25 +328,25 @@ test('task list counts completed items from all groups for its status text and t
|
|
|
327
328
|
<TaskList>
|
|
328
329
|
<TaskList.Group title="Provide your health details">
|
|
329
330
|
<TaskList.Item
|
|
330
|
-
id={
|
|
331
|
-
statusText={
|
|
332
|
-
title={
|
|
331
|
+
id={TASKS[0].id}
|
|
332
|
+
statusText={TASKS[0].statusText}
|
|
333
|
+
title={TASKS[0].title}
|
|
333
334
|
isComplete
|
|
334
335
|
>
|
|
335
336
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
336
337
|
</TaskList.Item>
|
|
337
338
|
<TaskList.Item
|
|
338
|
-
id={
|
|
339
|
-
statusText={
|
|
340
|
-
title={
|
|
339
|
+
id={TASKS[1].id}
|
|
340
|
+
statusText={TASKS[1].statusText}
|
|
341
|
+
title={TASKS[1].title}
|
|
341
342
|
isComplete
|
|
342
343
|
>
|
|
343
344
|
Tell us about any medication you need.
|
|
344
345
|
</TaskList.Item>
|
|
345
346
|
<TaskList.Item
|
|
346
|
-
id={
|
|
347
|
-
statusText={
|
|
348
|
-
title={
|
|
347
|
+
id={TASKS[2].id}
|
|
348
|
+
statusText={TASKS[2].statusText}
|
|
349
|
+
title={TASKS[2].title}
|
|
349
350
|
isComplete
|
|
350
351
|
>
|
|
351
352
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
@@ -353,23 +354,23 @@ test('task list counts completed items from all groups for its status text and t
|
|
|
353
354
|
</TaskList.Group>
|
|
354
355
|
<TaskList.Group title="Provide your health details">
|
|
355
356
|
<TaskList.Item
|
|
356
|
-
id={
|
|
357
|
-
statusText={
|
|
358
|
-
title={
|
|
357
|
+
id={TASKS[0].id + '2'}
|
|
358
|
+
statusText={TASKS[0].statusText}
|
|
359
|
+
title={TASKS[0].title}
|
|
359
360
|
>
|
|
360
361
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
361
362
|
</TaskList.Item>
|
|
362
363
|
<TaskList.Item
|
|
363
|
-
id={
|
|
364
|
-
statusText={
|
|
365
|
-
title={
|
|
364
|
+
id={TASKS[1].id + '2'}
|
|
365
|
+
statusText={TASKS[1].statusText}
|
|
366
|
+
title={TASKS[1].title}
|
|
366
367
|
>
|
|
367
368
|
Tell us about any medication you need.
|
|
368
369
|
</TaskList.Item>
|
|
369
370
|
<TaskList.Item
|
|
370
|
-
id={
|
|
371
|
-
statusText={
|
|
372
|
-
title={
|
|
371
|
+
id={TASKS[2].id + '2'}
|
|
372
|
+
statusText={TASKS[2].statusText}
|
|
373
|
+
title={TASKS[2].title}
|
|
373
374
|
isComplete
|
|
374
375
|
>
|
|
375
376
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
@@ -383,13 +384,13 @@ test('task list counts completed items from all groups for its status text and t
|
|
|
383
384
|
const taskListStatusLink = within(taskListStatus).getByRole('link');
|
|
384
385
|
|
|
385
386
|
expect(taskListStatus1.textContent).toEqual('You have completed 4 of 6 sections.');
|
|
386
|
-
expect(taskListStatusLink).toHaveAttribute('href', `#${
|
|
387
|
+
expect(taskListStatusLink).toHaveAttribute('href', `#${TASKS[0].id + '2'}`);
|
|
387
388
|
});
|
|
388
389
|
|
|
389
390
|
test('passing additional props to task list', () => {
|
|
390
391
|
render(
|
|
391
392
|
<TaskList
|
|
392
|
-
title={
|
|
393
|
+
title={TASK_LIST_HEADING_TEXT}
|
|
393
394
|
data-test="foo"
|
|
394
395
|
/>
|
|
395
396
|
);
|
|
@@ -422,7 +423,7 @@ test('passing additional props to task', () => {
|
|
|
422
423
|
test('passing additional CSS classes to task list', () => {
|
|
423
424
|
render(
|
|
424
425
|
<TaskList
|
|
425
|
-
title={
|
|
426
|
+
title={TASK_LIST_HEADING_TEXT}
|
|
426
427
|
className="foo"
|
|
427
428
|
/>
|
|
428
429
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Children } from 'react';
|
|
2
|
-
import ConditionalWrapper from '../../common/
|
|
3
|
-
import HintText from '../../common/
|
|
4
|
-
import ScreenReaderText from '../../common/
|
|
5
|
-
import Tag from '../
|
|
2
|
+
import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
3
|
+
import HintText from '../../common/HintText';
|
|
4
|
+
import ScreenReaderText from '../../common/ScreenReaderText';
|
|
5
|
+
import Tag from '../Tag/Tag';
|
|
6
6
|
|
|
7
7
|
const TaskItem: React.FC<SGDS.Component.TaskList.Item> = ({
|
|
8
8
|
children,
|