@scottish-government/designsystem-react 0.3.0-beta.0 → 0.4.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/common/AbstractNotificationBanner.d.ts +17 -0
- package/@types/components/Table.d.ts +8 -0
- package/@types/components/TaskList.d.ts +1 -1
- package/dist/common/abstract-notification-banner.jsx +63 -0
- package/dist/components/accordion/accordion.jsx +2 -3
- package/dist/components/breadcrumbs/breadcrumbs.jsx +2 -2
- package/dist/components/cookie-banner/cookie-banner.jsx +21 -0
- package/dist/components/notification-banner/notification-banner.jsx +7 -34
- package/dist/components/page-metadata/page-metadata.jsx +2 -3
- package/dist/components/table/table.jsx +24 -0
- package/dist/components/task-list/task-list.jsx +6 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/abstract-notification-banner.test.tsx +126 -0
- package/src/common/abstract-notification-banner.tsx +87 -0
- package/src/common/conditional-wrapper.test.tsx +1 -1
- package/src/common/screen-reader-text.test.tsx +1 -1
- package/src/common/wrapper-tag.test.tsx +3 -3
- package/src/components/accordion/accordion.test.tsx +40 -40
- package/src/components/accordion/accordion.tsx +4 -2
- package/src/components/aspect-box/aspect-box.test.tsx +7 -7
- package/src/components/breadcrumbs/breadcrumbs.tsx +0 -2
- package/src/components/checkbox/checkbox.test.tsx +8 -8
- package/src/components/confirmation-message/confirmation-message.test.tsx +1 -1
- package/src/components/cookie-banner/cookie-banner.test.tsx +25 -0
- package/src/components/cookie-banner/cookie-banner.tsx +36 -0
- package/src/components/details/details.test.tsx +7 -7
- package/src/components/inset-text/inset-text.test.tsx +1 -1
- package/src/components/notification-banner/notification-banner.test.tsx +13 -73
- package/src/components/notification-banner/notification-banner.tsx +13 -41
- package/src/components/notification-panel/notification-panel.test.tsx +6 -6
- package/src/components/page-header/page-header.test.tsx +2 -2
- package/src/components/page-metadata/page-metadata.test.tsx +12 -12
- package/src/components/page-metadata/page-metadata.tsx +4 -2
- package/src/components/pagination/pagination.test.tsx +28 -30
- package/src/components/phase-banner/phase-banner.test.tsx +8 -8
- package/src/components/question/question.test.tsx +3 -3
- package/src/components/radio-button/radio-button.test.tsx +7 -7
- package/src/components/select/select.test.tsx +9 -9
- package/src/components/sequential-navigation/sequential-navigation.test.tsx +4 -4
- package/src/components/side-navigation/side-navigation.test.tsx +1 -1
- package/src/components/site-header/site-header.test.tsx +22 -22
- package/src/components/site-search/site-search.test.tsx +9 -9
- package/src/components/skip-links/skip-links.test.tsx +3 -3
- package/src/components/summary-card/summary-card.test.tsx +2 -2
- package/src/components/summary-list/summary-list.test.tsx +35 -16
- package/src/components/table/table.test.tsx +77 -0
- package/src/components/table/table.tsx +36 -0
- package/src/components/task-list/task-list.test.tsx +81 -83
- package/src/components/task-list/task-list.tsx +9 -5
- package/src/components/text-input/text-input.test.tsx +6 -6
- package/src/components/textarea/textarea.test.tsx +2 -2
- package/src/components/warning-text/warning-text.test.tsx +1 -1
- package/vitest-setup.ts +1 -1
- package/@types/components/NotificationBanner.d.ts +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import TaskList
|
|
3
|
+
import TaskList from './task-list';
|
|
4
4
|
|
|
5
5
|
const taskListHeadingText = 'Application incomplete';
|
|
6
6
|
|
|
@@ -23,27 +23,27 @@ test('task list renders correctly', () => {
|
|
|
23
23
|
<TaskList
|
|
24
24
|
title={taskListHeadingText}
|
|
25
25
|
>
|
|
26
|
-
<
|
|
26
|
+
<TaskList.Item
|
|
27
27
|
id={tasks[0].id}
|
|
28
28
|
statusText={tasks[0].statusText}
|
|
29
29
|
title={tasks[0].title}
|
|
30
30
|
>
|
|
31
31
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
32
|
-
</
|
|
33
|
-
<
|
|
32
|
+
</TaskList.Item>
|
|
33
|
+
<TaskList.Item
|
|
34
34
|
id={tasks[1].id}
|
|
35
35
|
statusText={tasks[1].statusText}
|
|
36
36
|
title={tasks[1].title}
|
|
37
37
|
>
|
|
38
38
|
Tell us about any medication you need.
|
|
39
|
-
</
|
|
40
|
-
<
|
|
39
|
+
</TaskList.Item>
|
|
40
|
+
<TaskList.Item
|
|
41
41
|
id={tasks[2].id}
|
|
42
42
|
statusText={tasks[2].statusText}
|
|
43
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>
|
|
47
47
|
</TaskList>
|
|
48
48
|
);
|
|
49
49
|
|
|
@@ -96,35 +96,34 @@ test('task list with completed tasks', () => {
|
|
|
96
96
|
<TaskList
|
|
97
97
|
title={taskListHeadingText}
|
|
98
98
|
>
|
|
99
|
-
<
|
|
99
|
+
<TaskList.Item
|
|
100
100
|
id={tasks[0].id}
|
|
101
101
|
statusText={tasks[0].statusText}
|
|
102
102
|
title={tasks[0].title}
|
|
103
103
|
isComplete
|
|
104
104
|
>
|
|
105
105
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
106
|
-
</
|
|
107
|
-
<
|
|
106
|
+
</TaskList.Item>
|
|
107
|
+
<TaskList.Item
|
|
108
108
|
id={tasks[1].id}
|
|
109
109
|
statusText={tasks[1].statusText}
|
|
110
110
|
title={tasks[1].title}
|
|
111
111
|
isComplete
|
|
112
112
|
>
|
|
113
113
|
Tell us about any medication you need.
|
|
114
|
-
</
|
|
115
|
-
<
|
|
114
|
+
</TaskList.Item>
|
|
115
|
+
<TaskList.Item
|
|
116
116
|
id={tasks[2].id}
|
|
117
117
|
statusText={tasks[2].statusText}
|
|
118
118
|
title={tasks[2].title}
|
|
119
119
|
>
|
|
120
120
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
121
|
-
</
|
|
121
|
+
</TaskList.Item>
|
|
122
122
|
</TaskList>
|
|
123
123
|
);
|
|
124
124
|
|
|
125
125
|
const taskListStatus = screen.getByRole('navigation');
|
|
126
126
|
const taskListStatus1 = taskListStatus.children[0];
|
|
127
|
-
|
|
128
127
|
const taskListStatusLink = within(taskListStatus).getByRole('link');
|
|
129
128
|
|
|
130
129
|
expect(taskListStatus1.textContent).toEqual('You have completed 2 of 3 sections.');
|
|
@@ -133,52 +132,52 @@ test('task list with completed tasks', () => {
|
|
|
133
132
|
|
|
134
133
|
test('task renders correctly', () => {
|
|
135
134
|
render(
|
|
136
|
-
<
|
|
135
|
+
<TaskList.Item
|
|
137
136
|
id={taskItem.id}
|
|
138
137
|
statusText={taskItem.statusText}
|
|
139
138
|
title={taskItem.title}
|
|
140
139
|
>
|
|
141
140
|
{taskSummaryContent}
|
|
142
|
-
</
|
|
141
|
+
</TaskList.Item>
|
|
143
142
|
);
|
|
144
143
|
|
|
145
144
|
const task = screen.getByRole('listitem');
|
|
146
145
|
const tag = document.querySelector('.ds_tag');
|
|
147
146
|
const taskHeading = within(task).getByRole('heading');
|
|
148
|
-
const taskDetails = taskHeading.
|
|
149
|
-
const taskSummary = taskHeading.
|
|
147
|
+
const taskDetails = taskHeading.parentElement;
|
|
148
|
+
const taskSummary = taskHeading.nextElementSibling;
|
|
150
149
|
|
|
151
150
|
expect(task).toHaveClass('ds_task-list__task');
|
|
152
151
|
expect(task).toHaveAttribute('id', taskItem.id);
|
|
153
152
|
|
|
154
153
|
expect(taskDetails).toHaveClass('ds_task-list__task-details');
|
|
155
|
-
expect(taskDetails
|
|
156
|
-
expect(taskDetails
|
|
154
|
+
expect(taskDetails?.parentElement).toEqual(task);
|
|
155
|
+
expect(taskDetails?.tagName).toEqual('DIV');
|
|
157
156
|
|
|
158
157
|
expect(taskHeading).toHaveClass('ds_task-list__task-heading');
|
|
159
158
|
expect(taskHeading.tagName).toEqual('H3');
|
|
160
159
|
expect(taskHeading.textContent).toEqual(`${taskItem.title}(${taskItem.statusText})`);
|
|
161
160
|
|
|
162
161
|
expect(taskSummary).toHaveClass('ds_task-list__task-summary');
|
|
163
|
-
expect(taskSummary
|
|
164
|
-
expect(taskSummary
|
|
162
|
+
expect(taskSummary?.tagName).toEqual('P');
|
|
163
|
+
expect(taskSummary?.textContent).toEqual(taskSummaryContent);
|
|
165
164
|
|
|
166
165
|
expect(tag).toHaveAttribute('aria-hidden', 'true');
|
|
167
|
-
expect(tag
|
|
166
|
+
expect(tag?.textContent).toEqual(taskItem.statusText);
|
|
168
167
|
});
|
|
169
168
|
|
|
170
169
|
test('task with link', () => {
|
|
171
170
|
const href = '#foo';
|
|
172
171
|
|
|
173
172
|
render(
|
|
174
|
-
<
|
|
173
|
+
<TaskList.Item
|
|
175
174
|
id={taskItem.id}
|
|
176
175
|
statusText={taskItem.statusText}
|
|
177
176
|
title={taskItem.title}
|
|
178
177
|
href={href}
|
|
179
178
|
>
|
|
180
179
|
{taskSummaryContent}
|
|
181
|
-
</
|
|
180
|
+
</TaskList.Item>
|
|
182
181
|
);
|
|
183
182
|
|
|
184
183
|
const task = screen.getByRole('listitem');
|
|
@@ -188,20 +187,20 @@ test('task with link', () => {
|
|
|
188
187
|
expect(link).toHaveClass('ds_task-list__task-link');
|
|
189
188
|
expect(link).toHaveAttribute('href', href);
|
|
190
189
|
expect(link.textContent).toEqual(`${taskItem.title}(${taskItem.statusText})`);
|
|
191
|
-
expect(link.
|
|
190
|
+
expect(link.parentElement).toEqual(taskHeading);
|
|
192
191
|
expect(link.textContent).toEqual(taskHeading.textContent);
|
|
193
192
|
});
|
|
194
193
|
|
|
195
194
|
test('completed task has green tag', () => {
|
|
196
195
|
render(
|
|
197
|
-
<
|
|
196
|
+
<TaskList.Item
|
|
198
197
|
id={taskItem.id}
|
|
199
198
|
statusText={taskItem.statusText}
|
|
200
199
|
title={taskItem.title}
|
|
201
200
|
isComplete
|
|
202
201
|
>
|
|
203
202
|
{taskSummaryContent}
|
|
204
|
-
</
|
|
203
|
+
</TaskList.Item>
|
|
205
204
|
);
|
|
206
205
|
|
|
207
206
|
const tag = document.querySelector('.ds_tag');
|
|
@@ -213,14 +212,14 @@ test('specific tag colour', () => {
|
|
|
213
212
|
const tagColour = 'red';
|
|
214
213
|
|
|
215
214
|
render(
|
|
216
|
-
<
|
|
215
|
+
<TaskList.Item
|
|
217
216
|
id={taskItem.id}
|
|
218
217
|
statusText={taskItem.statusText}
|
|
219
218
|
title={taskItem.title}
|
|
220
219
|
tagColour={tagColour}
|
|
221
220
|
>
|
|
222
221
|
{taskSummaryContent}
|
|
223
|
-
</
|
|
222
|
+
</TaskList.Item>
|
|
224
223
|
);
|
|
225
224
|
|
|
226
225
|
const tag = document.querySelector('.ds_tag');
|
|
@@ -230,12 +229,12 @@ test('specific tag colour', () => {
|
|
|
230
229
|
|
|
231
230
|
test('no status tag when no status text provided', () => {
|
|
232
231
|
render(
|
|
233
|
-
<
|
|
232
|
+
<TaskList.Item
|
|
234
233
|
id={taskItem.id}
|
|
235
234
|
title={taskItem.title}
|
|
236
235
|
>
|
|
237
236
|
{taskSummaryContent}
|
|
238
|
-
</
|
|
237
|
+
</TaskList.Item>
|
|
239
238
|
);
|
|
240
239
|
|
|
241
240
|
const tag = document.querySelector('.ds_tag');
|
|
@@ -247,72 +246,72 @@ test('task group renders correctly', () => {
|
|
|
247
246
|
const taskGroupHeadingText = 'Provide your health details';
|
|
248
247
|
|
|
249
248
|
render(
|
|
250
|
-
<
|
|
251
|
-
<
|
|
249
|
+
<TaskList.Group title={taskGroupHeadingText}>
|
|
250
|
+
<TaskList.Item
|
|
252
251
|
id={tasks[0].id}
|
|
253
252
|
statusText={tasks[0].statusText}
|
|
254
253
|
title={tasks[0].title}
|
|
255
254
|
>
|
|
256
255
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
257
|
-
</
|
|
258
|
-
<
|
|
256
|
+
</TaskList.Item>
|
|
257
|
+
<TaskList.Item
|
|
259
258
|
id={tasks[1].id}
|
|
260
259
|
statusText={tasks[1].statusText}
|
|
261
260
|
title={tasks[1].title}
|
|
262
261
|
>
|
|
263
262
|
Tell us about any medication you need.
|
|
264
|
-
</
|
|
265
|
-
<
|
|
263
|
+
</TaskList.Item>
|
|
264
|
+
<TaskList.Item
|
|
266
265
|
id={tasks[2].id}
|
|
267
266
|
statusText={tasks[2].statusText}
|
|
268
267
|
title={tasks[2].title}
|
|
269
268
|
>
|
|
270
269
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
271
|
-
</
|
|
272
|
-
</
|
|
270
|
+
</TaskList.Item>
|
|
271
|
+
</TaskList.Group>
|
|
273
272
|
);
|
|
274
273
|
|
|
275
274
|
const taskGroup = document.querySelector('.ds_task-list-group__section');
|
|
276
|
-
const taskGroupHeading = taskGroup
|
|
277
|
-
const innerTaskList = taskGroup
|
|
275
|
+
const taskGroupHeading = taskGroup?.querySelector('.ds_task-list-heading');
|
|
276
|
+
const innerTaskList = taskGroup?.querySelector('.ds_task-list');
|
|
278
277
|
|
|
279
278
|
expect(taskGroup).toHaveClass('ds_task-list-group__section');
|
|
280
|
-
expect(taskGroup
|
|
279
|
+
expect(taskGroup?.tagName).toEqual('LI');
|
|
281
280
|
|
|
282
|
-
expect(taskGroupHeading
|
|
283
|
-
expect(taskGroupHeading
|
|
281
|
+
expect(taskGroupHeading?.tagName).toEqual('H2');
|
|
282
|
+
expect(taskGroupHeading?.textContent).toEqual(taskGroupHeadingText);
|
|
284
283
|
|
|
285
284
|
// a bit hacky, but list should be last child
|
|
286
|
-
expect(taskGroup
|
|
285
|
+
expect(taskGroup?.children[taskGroup.children.length - 1]).toEqual(innerTaskList);
|
|
287
286
|
});
|
|
288
287
|
|
|
289
288
|
test('task group with intro text', () => {
|
|
290
289
|
const taskGroupIntroText = 'This information will be used to check what additional benefits you may be able to apply for.';
|
|
291
290
|
|
|
292
291
|
render(
|
|
293
|
-
<
|
|
294
|
-
<
|
|
292
|
+
<TaskList.Group title="Provide your health details" intro={taskGroupIntroText}>
|
|
293
|
+
<TaskList.Item
|
|
295
294
|
id={tasks[0].id}
|
|
296
295
|
statusText={tasks[0].statusText}
|
|
297
296
|
title={tasks[0].title}
|
|
298
297
|
>
|
|
299
298
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
300
|
-
</
|
|
301
|
-
<
|
|
299
|
+
</TaskList.Item>
|
|
300
|
+
<TaskList.Item
|
|
302
301
|
id={tasks[1].id}
|
|
303
302
|
statusText={tasks[1].statusText}
|
|
304
303
|
title={tasks[1].title}
|
|
305
304
|
>
|
|
306
305
|
Tell us about any medication you need.
|
|
307
|
-
</
|
|
308
|
-
<
|
|
306
|
+
</TaskList.Item>
|
|
307
|
+
<TaskList.Item
|
|
309
308
|
id={tasks[2].id}
|
|
310
309
|
statusText={tasks[2].statusText}
|
|
311
310
|
title={tasks[2].title}
|
|
312
311
|
>
|
|
313
312
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
314
|
-
</
|
|
315
|
-
</
|
|
313
|
+
</TaskList.Item>
|
|
314
|
+
</TaskList.Group>
|
|
316
315
|
);
|
|
317
316
|
|
|
318
317
|
const taskGroup = document.querySelector('.ds_task-list-group__section');
|
|
@@ -326,62 +325,61 @@ test('task group with intro text', () => {
|
|
|
326
325
|
test('task list counts completed items from all groups for its status text and the first incomplete section wraps to the next group sensibly', () => {
|
|
327
326
|
render(
|
|
328
327
|
<TaskList>
|
|
329
|
-
<
|
|
330
|
-
<
|
|
328
|
+
<TaskList.Group title="Provide your health details">
|
|
329
|
+
<TaskList.Item
|
|
331
330
|
id={tasks[0].id}
|
|
332
331
|
statusText={tasks[0].statusText}
|
|
333
332
|
title={tasks[0].title}
|
|
334
333
|
isComplete
|
|
335
334
|
>
|
|
336
335
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
337
|
-
</
|
|
338
|
-
<
|
|
336
|
+
</TaskList.Item>
|
|
337
|
+
<TaskList.Item
|
|
339
338
|
id={tasks[1].id}
|
|
340
339
|
statusText={tasks[1].statusText}
|
|
341
340
|
title={tasks[1].title}
|
|
342
341
|
isComplete
|
|
343
342
|
>
|
|
344
343
|
Tell us about any medication you need.
|
|
345
|
-
</
|
|
346
|
-
<
|
|
344
|
+
</TaskList.Item>
|
|
345
|
+
<TaskList.Item
|
|
347
346
|
id={tasks[2].id}
|
|
348
347
|
statusText={tasks[2].statusText}
|
|
349
348
|
title={tasks[2].title}
|
|
350
349
|
isComplete
|
|
351
350
|
>
|
|
352
351
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
353
|
-
</
|
|
354
|
-
</
|
|
355
|
-
<
|
|
356
|
-
<
|
|
352
|
+
</TaskList.Item>
|
|
353
|
+
</TaskList.Group>
|
|
354
|
+
<TaskList.Group title="Provide your health details">
|
|
355
|
+
<TaskList.Item
|
|
357
356
|
id={tasks[0].id + '2'}
|
|
358
357
|
statusText={tasks[0].statusText}
|
|
359
358
|
title={tasks[0].title}
|
|
360
359
|
>
|
|
361
360
|
Tell us about your conditions, symptoms and any sensory issues you have.
|
|
362
|
-
</
|
|
363
|
-
<
|
|
361
|
+
</TaskList.Item>
|
|
362
|
+
<TaskList.Item
|
|
364
363
|
id={tasks[1].id + '2'}
|
|
365
364
|
statusText={tasks[1].statusText}
|
|
366
365
|
title={tasks[1].title}
|
|
367
366
|
>
|
|
368
367
|
Tell us about any medication you need.
|
|
369
|
-
</
|
|
370
|
-
<
|
|
368
|
+
</TaskList.Item>
|
|
369
|
+
<TaskList.Item
|
|
371
370
|
id={tasks[2].id + '2'}
|
|
372
371
|
statusText={tasks[2].statusText}
|
|
373
372
|
title={tasks[2].title}
|
|
374
373
|
isComplete
|
|
375
374
|
>
|
|
376
375
|
Share any supporting documents and provide details of people we can talk to about you.
|
|
377
|
-
</
|
|
378
|
-
</
|
|
376
|
+
</TaskList.Item>
|
|
377
|
+
</TaskList.Group>
|
|
379
378
|
</TaskList>
|
|
380
379
|
);
|
|
381
380
|
|
|
382
381
|
const taskListStatus = screen.getByRole('navigation');
|
|
383
382
|
const taskListStatus1 = taskListStatus.children[0];
|
|
384
|
-
|
|
385
383
|
const taskListStatusLink = within(taskListStatus).getByRole('link');
|
|
386
384
|
|
|
387
385
|
expect(taskListStatus1.textContent).toEqual('You have completed 4 of 6 sections.');
|
|
@@ -397,27 +395,27 @@ test('passing additional props to task list', () => {
|
|
|
397
395
|
);
|
|
398
396
|
|
|
399
397
|
const taskList = screen.getByRole('list');
|
|
400
|
-
const taskListWrapper = taskList.
|
|
398
|
+
const taskListWrapper = taskList.parentElement;
|
|
401
399
|
expect(taskListWrapper?.dataset.test).toEqual('foo');
|
|
402
400
|
});
|
|
403
401
|
|
|
404
402
|
test('passing additional props to task group', () => {
|
|
405
403
|
render(
|
|
406
|
-
<
|
|
407
|
-
</
|
|
404
|
+
<TaskList.Group data-test="foo">
|
|
405
|
+
</TaskList.Group>
|
|
408
406
|
);
|
|
409
407
|
|
|
410
|
-
const taskGroup = document.querySelector('.ds_task-list-group__section');
|
|
408
|
+
const taskGroup = document.querySelector('.ds_task-list-group__section') as HTMLElement;
|
|
411
409
|
expect(taskGroup?.dataset.test).toEqual('foo');
|
|
412
410
|
});
|
|
413
411
|
|
|
414
412
|
test('passing additional props to task', () => {
|
|
415
413
|
render(
|
|
416
|
-
<
|
|
417
|
-
</
|
|
414
|
+
<TaskList.Item data-test="foo">
|
|
415
|
+
</TaskList.Item>
|
|
418
416
|
);
|
|
419
417
|
|
|
420
|
-
const task = document.querySelector('.ds_task-list__task');
|
|
418
|
+
const task = document.querySelector('.ds_task-list__task') as HTMLElement;
|
|
421
419
|
expect(task?.dataset.test).toEqual('foo');
|
|
422
420
|
});
|
|
423
421
|
|
|
@@ -430,14 +428,14 @@ test('passing additional CSS classes to task list', () => {
|
|
|
430
428
|
);
|
|
431
429
|
|
|
432
430
|
const taskList = screen.getByRole('list');
|
|
433
|
-
const taskListWrapper = taskList.
|
|
431
|
+
const taskListWrapper = taskList.parentElement;
|
|
434
432
|
expect(taskListWrapper).toHaveClass('foo');
|
|
435
433
|
});
|
|
436
434
|
|
|
437
435
|
test('passing additional CSS classes to task group', () => {
|
|
438
436
|
render(
|
|
439
|
-
<
|
|
440
|
-
</
|
|
437
|
+
<TaskList.Group className="foo">
|
|
438
|
+
</TaskList.Group>
|
|
441
439
|
);
|
|
442
440
|
|
|
443
441
|
const taskGroup = document.querySelector('.ds_task-list-group__section');
|
|
@@ -446,8 +444,8 @@ test('passing additional CSS classes to task group', () => {
|
|
|
446
444
|
|
|
447
445
|
test('passing additional CSS classes to task', () => {
|
|
448
446
|
render(
|
|
449
|
-
<
|
|
450
|
-
</
|
|
447
|
+
<TaskList.Item className="foo">
|
|
448
|
+
</TaskList.Item>
|
|
451
449
|
);
|
|
452
450
|
|
|
453
451
|
const task = document.querySelector('.ds_task-list__task');
|
|
@@ -4,7 +4,7 @@ import HintText from '../../common/hint-text';
|
|
|
4
4
|
import ScreenReaderText from '../../common/screen-reader-text';
|
|
5
5
|
import Tag from '../tag/tag';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const TaskItem: React.FC<SGDS.Component.TaskList.Item> = ({
|
|
8
8
|
children,
|
|
9
9
|
className,
|
|
10
10
|
href,
|
|
@@ -58,7 +58,7 @@ export const Task: React.FC<SGDS.Component.TaskList.Task> = ({
|
|
|
58
58
|
* @param {string} props.title - The title of the task group
|
|
59
59
|
* @returns {JSX.Element} - The element
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
const TaskGroup: React.FC<SGDS.Component.TaskList.Group> = ({
|
|
62
62
|
children,
|
|
63
63
|
className,
|
|
64
64
|
intro,
|
|
@@ -82,7 +82,9 @@ export const TaskGroup: React.FC<SGDS.Component.TaskList.Group> = ({
|
|
|
82
82
|
);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const TaskList: React.FC<SGDS.Component.TaskList>
|
|
85
|
+
const TaskList: React.FC<SGDS.Component.TaskList>
|
|
86
|
+
& { Group: React.FC<SGDS.Component.TaskList.Group> }
|
|
87
|
+
& { Item: React.FC<SGDS.Component.TaskList.Item> } = ({
|
|
86
88
|
children,
|
|
87
89
|
className,
|
|
88
90
|
headingId = 'task-list',
|
|
@@ -94,7 +96,7 @@ const TaskList: React.FC<SGDS.Component.TaskList> = ({
|
|
|
94
96
|
let completedTasksCount = 0;
|
|
95
97
|
|
|
96
98
|
function processChild(item: any) {
|
|
97
|
-
if (item.type.displayName === '
|
|
99
|
+
if (item.type.displayName === 'TaskItem') {
|
|
98
100
|
taskCount = taskCount + 1;
|
|
99
101
|
|
|
100
102
|
if (item.props.isComplete) {
|
|
@@ -139,7 +141,9 @@ const TaskList: React.FC<SGDS.Component.TaskList> = ({
|
|
|
139
141
|
};
|
|
140
142
|
|
|
141
143
|
TaskList.displayName = 'TaskList';
|
|
142
|
-
|
|
144
|
+
TaskItem.displayName = 'TaskItem';
|
|
143
145
|
TaskGroup.displayName = 'TaskGroup';
|
|
146
|
+
TaskList.Item = TaskItem;
|
|
147
|
+
TaskList.Group = TaskGroup;
|
|
144
148
|
|
|
145
149
|
export default TaskList;
|
|
@@ -56,7 +56,7 @@ test('text input with character count', () => {
|
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
const textInput = screen.getByRole('textbox');
|
|
59
|
-
const textInputWrapper = textInput.
|
|
59
|
+
const textInputWrapper = textInput.parentElement;
|
|
60
60
|
|
|
61
61
|
expect(textInputWrapper).toHaveAttribute('data-maxlength', maxLength.toString());
|
|
62
62
|
expect(textInputWrapper).toHaveAttribute('data-module', 'ds-character-count');
|
|
@@ -76,7 +76,7 @@ test('text input with character count and threshold', () => {
|
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
const textInput = screen.getByRole('textbox');
|
|
79
|
-
const textInputWrapper = textInput.
|
|
79
|
+
const textInputWrapper = textInput.parentElement;
|
|
80
80
|
|
|
81
81
|
expect(textInputWrapper).toHaveAttribute('data-threshold', countThreshold.toString());
|
|
82
82
|
});
|
|
@@ -106,9 +106,9 @@ test('text input with currency', () => {
|
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
const textInput = screen.getByRole('textbox');
|
|
109
|
-
const textInputWrapper = textInput.
|
|
109
|
+
const textInputWrapper = textInput.parentElement;
|
|
110
110
|
|
|
111
|
-
expect(textInputWrapper
|
|
111
|
+
expect(textInputWrapper?.tagName).toEqual('DIV')
|
|
112
112
|
expect(textInputWrapper).toHaveClass('ds_currency-wrapper');
|
|
113
113
|
expect(textInputWrapper).not.toHaveAttribute('data-symbol');
|
|
114
114
|
});
|
|
@@ -126,7 +126,7 @@ test('text input with custom currency symbol', () => {
|
|
|
126
126
|
);
|
|
127
127
|
|
|
128
128
|
const textInput = screen.getByRole('textbox');
|
|
129
|
-
const textInputWrapper = textInput.
|
|
129
|
+
const textInputWrapper = textInput.parentElement;
|
|
130
130
|
|
|
131
131
|
expect(textInputWrapper).toHaveAttribute('data-symbol', symbol);
|
|
132
132
|
});
|
|
@@ -145,7 +145,7 @@ test('text input with button', () => {
|
|
|
145
145
|
);
|
|
146
146
|
|
|
147
147
|
const textInput = screen.getByRole('textbox');
|
|
148
|
-
const textInputWrapper = textInput.
|
|
148
|
+
const textInputWrapper = textInput.parentElement;
|
|
149
149
|
const button = screen.getByRole('button');
|
|
150
150
|
const buttonTextElement = within(button).getByText(buttonText);
|
|
151
151
|
const buttonIconElement = within(button).getByRole('img', { hidden: true });
|
|
@@ -41,7 +41,7 @@ test('textarea with character count', () => {
|
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
const textarea = screen.getByRole('textbox');
|
|
44
|
-
const textareaWrapper = textarea.
|
|
44
|
+
const textareaWrapper = textarea.parentElement;
|
|
45
45
|
|
|
46
46
|
expect(textareaWrapper).toHaveAttribute('data-maxlength', maxLength.toString());
|
|
47
47
|
expect(textareaWrapper).toHaveAttribute('data-module', 'ds-character-count');
|
|
@@ -61,7 +61,7 @@ test('text input with character count and threshold', () => {
|
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
const textarea = screen.getByRole('textbox');
|
|
64
|
-
const textareaWrapper = textarea.
|
|
64
|
+
const textareaWrapper = textarea.parentElement;
|
|
65
65
|
|
|
66
66
|
expect(textareaWrapper).toHaveAttribute('data-threshold', countThreshold.toString());
|
|
67
67
|
});
|
|
@@ -35,7 +35,7 @@ test('passing additional props', () => {
|
|
|
35
35
|
</WarningText>
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
-
const warningTextOuter = document.querySelector('.ds_warning-text');
|
|
38
|
+
const warningTextOuter = document.querySelector('.ds_warning-text') as HTMLElement;
|
|
39
39
|
expect(warningTextOuter?.dataset.test).toEqual('foo');
|
|
40
40
|
});
|
|
41
41
|
|
package/vitest-setup.ts
CHANGED