@aleph-alpha/ui-library 5.6.0 → 5.8.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/README.md +4 -0
- package/config.d.ts +5 -1
- package/config.js +23 -1
- package/dist/system/components/UiBreadcrumb/UiBreadcrumb.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbEllipsis.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbItem.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbLink.vue.d.ts +18 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbList.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbPage.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/UiBreadcrumbSeparator.vue.d.ts +17 -0
- package/dist/system/components/UiBreadcrumb/index.d.ts +8 -0
- package/dist/system/components/UiBreadcrumb/types.d.ts +22 -0
- package/dist/system/components/UiField/types.d.ts +2 -1
- package/dist/system/components/UiToggleGroup/types.d.ts +0 -5
- package/dist/system/components/core/breadcrumb/Breadcrumb.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbEllipsis.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbItem.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbLink.vue.d.ts +24 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbList.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbPage.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/BreadcrumbSeparator.vue.d.ts +21 -0
- package/dist/system/components/core/breadcrumb/index.d.ts +7 -0
- package/dist/system/components/core/listbox/Listbox.vue.d.ts +28 -2
- package/dist/system/components/core/listbox/context.d.ts +21 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/lib.js +10062 -9711
- package/dist/system/patterns/UiDatePicker/UiDatePicker.vue.d.ts +1 -1
- package/dist/system/story-sidebar-icons.json +6 -0
- package/package.json +5 -5
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +1 -1
- package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +1419 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbEllipsis.vue +22 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbItem.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbLink.vue +26 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbList.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbPage.vue +19 -0
- package/src/components/UiBreadcrumb/UiBreadcrumbSeparator.vue +22 -0
- package/src/components/UiBreadcrumb/index.ts +8 -0
- package/src/components/UiBreadcrumb/types.ts +28 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +625 -74
- package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +2 -0
- package/src/components/UiField/UiField.stories.ts +1 -1
- package/src/components/UiField/types.ts +2 -1
- package/src/components/UiListbox/UiListbox.stories.ts +1283 -30
- package/src/components/UiListbox/__tests__/UiListbox.test.ts +70 -35
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +995 -0
- package/src/components/UiSelect/UiSelect.stories.ts +1 -1
- package/src/components/UiSwitch/UiSwitch.stories.ts +706 -9
- package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +2 -6
- package/src/components/UiToggle/UiToggle.stories.ts +961 -130
- package/src/components/UiToggle/UiToggle.vue +8 -1
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +55 -65
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +1060 -173
- package/src/components/UiToggleGroup/UiToggleGroup.vue +4 -2
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +117 -325
- package/src/components/UiToggleGroup/types.ts +0 -5
- package/src/components/core/breadcrumb/Breadcrumb.vue +13 -0
- package/src/components/core/breadcrumb/BreadcrumbEllipsis.vue +23 -0
- package/src/components/core/breadcrumb/BreadcrumbItem.vue +17 -0
- package/src/components/core/breadcrumb/BreadcrumbLink.vue +29 -0
- package/src/components/core/breadcrumb/BreadcrumbList.vue +22 -0
- package/src/components/core/breadcrumb/BreadcrumbPage.vue +20 -0
- package/src/components/core/breadcrumb/BreadcrumbSeparator.vue +22 -0
- package/src/components/core/breadcrumb/index.ts +7 -0
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +3 -2
- package/src/components/core/field/FieldTitle.vue +1 -1
- package/src/components/core/listbox/Listbox.vue +14 -2
- package/src/components/core/listbox/ListboxContent.vue +61 -3
- package/src/components/core/listbox/ListboxItem.vue +6 -1
- package/src/components/core/listbox/context.ts +34 -0
- package/src/components/core/toggle/Toggle.vue +15 -1
- package/src/components/core/toggle/index.ts +2 -2
- package/src/components/core/toggle-group/ToggleGroup.vue +1 -1
- package/src/components/core/toggle-group/index.ts +5 -2
- package/src/components/index.ts +1 -0
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +0 -14
- package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +0 -412
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
3
3
|
import UiCheckbox from './UiCheckbox.vue';
|
|
4
|
+
import {
|
|
5
|
+
UiField,
|
|
6
|
+
UiFieldContent,
|
|
7
|
+
UiFieldDescription,
|
|
8
|
+
UiFieldGroup,
|
|
9
|
+
UiFieldLabel,
|
|
10
|
+
UiFieldLegend,
|
|
11
|
+
UiFieldSet,
|
|
12
|
+
UiFieldTitle,
|
|
13
|
+
} from '../UiField';
|
|
4
14
|
import { ref } from 'vue';
|
|
5
15
|
|
|
6
16
|
/**
|
|
@@ -271,12 +281,17 @@ const checked = ref(true)
|
|
|
271
281
|
|
|
272
282
|
<template>
|
|
273
283
|
<div class="flex items-start gap-3">
|
|
274
|
-
<UiCheckbox
|
|
284
|
+
<UiCheckbox
|
|
285
|
+
id="terms-2"
|
|
286
|
+
name="terms-2"
|
|
287
|
+
v-model="checked"
|
|
288
|
+
aria-describedby="terms-2-description"
|
|
289
|
+
/>
|
|
275
290
|
<div class="grid gap-2">
|
|
276
291
|
<label for="terms-2" class="body-14-medium">
|
|
277
292
|
Accept terms and conditions
|
|
278
293
|
</label>
|
|
279
|
-
<p class="body-14-regular text-content-on-surface-muted">
|
|
294
|
+
<p id="terms-2-description" class="body-14-regular text-content-on-surface-muted">
|
|
280
295
|
By clicking this checkbox, you agree to the terms and conditions.
|
|
281
296
|
</p>
|
|
282
297
|
</div>
|
|
@@ -285,6 +300,8 @@ const checked = ref(true)
|
|
|
285
300
|
|
|
286
301
|
/**
|
|
287
302
|
* Checkbox with label and description text.
|
|
303
|
+
* The description is wired with `aria-describedby` so it is announced after the
|
|
304
|
+
* label instead of being visual-only.
|
|
288
305
|
*/
|
|
289
306
|
export const WithDescription: Story = {
|
|
290
307
|
render: (args) => ({
|
|
@@ -294,12 +311,12 @@ export const WithDescription: Story = {
|
|
|
294
311
|
return { args, checked };
|
|
295
312
|
},
|
|
296
313
|
template: `<div class="flex items-start gap-3">
|
|
297
|
-
<UiCheckbox id="terms-2" name="terms-2" v-model="checked" :disabled="args.disabled" :required="args.required" />
|
|
314
|
+
<UiCheckbox id="terms-2" name="terms-2" v-model="checked" :disabled="args.disabled" :required="args.required" aria-describedby="terms-2-description" />
|
|
298
315
|
<div class="grid gap-2">
|
|
299
316
|
<label for="terms-2" class="body-14-medium">
|
|
300
317
|
Accept terms and conditions
|
|
301
318
|
</label>
|
|
302
|
-
<p class="body-14-regular text-content-on-surface-muted">
|
|
319
|
+
<p id="terms-2-description" class="body-14-regular text-content-on-surface-muted">
|
|
303
320
|
By clicking this checkbox, you agree to the terms and conditions.
|
|
304
321
|
</p>
|
|
305
322
|
</div>
|
|
@@ -312,6 +329,30 @@ export const WithDescription: Story = {
|
|
|
312
329
|
},
|
|
313
330
|
},
|
|
314
331
|
},
|
|
332
|
+
play: async ({ canvasElement, step }) => {
|
|
333
|
+
// Scenario (UiCheckbox): the label names the control and the helper text is
|
|
334
|
+
// announced as its description. Non-mutating so the snapshot stays stable.
|
|
335
|
+
const canvas = within(canvasElement);
|
|
336
|
+
const checkbox = canvas.getByRole('checkbox', {
|
|
337
|
+
name: 'Accept terms and conditions',
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
await step(
|
|
341
|
+
'screen-reader: the helper text is announced as the accessible description (WCAG 1.3.1)',
|
|
342
|
+
async () => {
|
|
343
|
+
await expect(checkbox).toHaveAccessibleDescription(
|
|
344
|
+
'By clicking this checkbox, you agree to the terms and conditions.',
|
|
345
|
+
);
|
|
346
|
+
},
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
await step(
|
|
350
|
+
'screen-reader: the checked state is announced (WCAG 4.1.2)',
|
|
351
|
+
async () => {
|
|
352
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'true');
|
|
353
|
+
},
|
|
354
|
+
);
|
|
355
|
+
},
|
|
315
356
|
};
|
|
316
357
|
|
|
317
358
|
const disabledTemplateSource = `<script setup lang="ts">
|
|
@@ -355,7 +396,8 @@ export const Disabled: Story = {
|
|
|
355
396
|
},
|
|
356
397
|
play: async ({ canvasElement, step }) => {
|
|
357
398
|
// Scenario (UiCheckbox): a disabled checkbox reports its disabled state to assistive
|
|
358
|
-
// tech (a disabled control is inherently out of the tab order)
|
|
399
|
+
// tech (a disabled control is inherently out of the tab order) and refuses
|
|
400
|
+
// activation. The forced click is a no-op, so the snapshot stays stable.
|
|
359
401
|
const canvas = within(canvasElement);
|
|
360
402
|
const checkbox = canvas.getByRole('checkbox', {
|
|
361
403
|
name: 'Enable notifications',
|
|
@@ -367,73 +409,300 @@ export const Disabled: Story = {
|
|
|
367
409
|
await expect(checkbox).toBeDisabled();
|
|
368
410
|
},
|
|
369
411
|
);
|
|
412
|
+
|
|
413
|
+
await step(
|
|
414
|
+
'interaction: a disabled checkbox cannot be toggled',
|
|
415
|
+
async () => {
|
|
416
|
+
// Disabled controls render with pointer-events: none, so bypass the
|
|
417
|
+
// check and assert the click is still a no-op.
|
|
418
|
+
await userEvent.click(checkbox, { pointerEventsCheck: 0 });
|
|
419
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'false');
|
|
420
|
+
},
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
await step(
|
|
424
|
+
'keyboard: a disabled checkbox is skipped by Tab (WCAG 2.1.1)',
|
|
425
|
+
async () => {
|
|
426
|
+
await userEvent.tab();
|
|
427
|
+
await expect(checkbox).not.toHaveFocus();
|
|
428
|
+
},
|
|
429
|
+
);
|
|
370
430
|
},
|
|
371
431
|
};
|
|
372
432
|
|
|
373
|
-
const
|
|
433
|
+
const withFieldTemplateSource = `<script setup lang="ts">
|
|
374
434
|
import { ref } from 'vue'
|
|
375
|
-
import {
|
|
435
|
+
import {
|
|
436
|
+
UiCheckbox,
|
|
437
|
+
UiField,
|
|
438
|
+
UiFieldContent,
|
|
439
|
+
UiFieldDescription,
|
|
440
|
+
UiFieldGroup,
|
|
441
|
+
UiFieldLabel,
|
|
442
|
+
UiFieldLegend,
|
|
443
|
+
UiFieldSet,
|
|
444
|
+
UiFieldTitle,
|
|
445
|
+
} from '@aleph-alpha/ui-library'
|
|
376
446
|
|
|
377
|
-
const
|
|
447
|
+
const push = ref(true)
|
|
448
|
+
const email = ref(false)
|
|
378
449
|
</script>
|
|
379
450
|
|
|
380
451
|
<template>
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
452
|
+
<!-- Control at the end: text first, checkbox trailing. -->
|
|
453
|
+
<UiFieldGroup>
|
|
454
|
+
<UiFieldSet>
|
|
455
|
+
<UiFieldLegend variant="label">Notifications</UiFieldLegend>
|
|
456
|
+
<UiFieldDescription>
|
|
457
|
+
Choose how you want to hear about activity.
|
|
458
|
+
</UiFieldDescription>
|
|
459
|
+
|
|
460
|
+
<UiFieldGroup data-slot="checkbox-group">
|
|
461
|
+
<UiFieldLabel for="end-push">
|
|
462
|
+
<UiField orientation="horizontal">
|
|
463
|
+
<UiFieldContent>
|
|
464
|
+
<UiFieldTitle>Push notifications</UiFieldTitle>
|
|
465
|
+
<UiFieldDescription>
|
|
466
|
+
Get alerts on your device as soon as something happens.
|
|
467
|
+
</UiFieldDescription>
|
|
468
|
+
</UiFieldContent>
|
|
469
|
+
<UiCheckbox id="end-push" name="push" v-model="push" />
|
|
470
|
+
</UiField>
|
|
471
|
+
</UiFieldLabel>
|
|
472
|
+
|
|
473
|
+
<UiFieldLabel for="end-email">
|
|
474
|
+
<UiField orientation="horizontal">
|
|
475
|
+
<UiFieldContent>
|
|
476
|
+
<UiFieldTitle>Email digest</UiFieldTitle>
|
|
477
|
+
<UiFieldDescription>
|
|
478
|
+
Receive a single summary of activity every morning.
|
|
479
|
+
</UiFieldDescription>
|
|
480
|
+
</UiFieldContent>
|
|
481
|
+
<UiCheckbox id="end-email" name="email" v-model="email" />
|
|
482
|
+
</UiField>
|
|
483
|
+
</UiFieldLabel>
|
|
484
|
+
</UiFieldGroup>
|
|
485
|
+
</UiFieldSet>
|
|
486
|
+
</UiFieldGroup>
|
|
487
|
+
|
|
488
|
+
<!-- Control at the start: checkbox leading, text after. -->
|
|
489
|
+
<UiFieldGroup>
|
|
490
|
+
<UiFieldSet>
|
|
491
|
+
<UiFieldLegend variant="label">Notifications</UiFieldLegend>
|
|
492
|
+
<UiFieldDescription>
|
|
493
|
+
Choose how you want to hear about activity.
|
|
494
|
+
</UiFieldDescription>
|
|
495
|
+
|
|
496
|
+
<UiFieldGroup data-slot="checkbox-group">
|
|
497
|
+
<UiFieldLabel for="start-push">
|
|
498
|
+
<UiField orientation="horizontal">
|
|
499
|
+
<UiCheckbox id="start-push" name="push" v-model="push" />
|
|
500
|
+
<UiFieldContent>
|
|
501
|
+
<UiFieldTitle>Push notifications</UiFieldTitle>
|
|
502
|
+
<UiFieldDescription>
|
|
503
|
+
Get alerts on your device as soon as something happens.
|
|
504
|
+
</UiFieldDescription>
|
|
505
|
+
</UiFieldContent>
|
|
506
|
+
</UiField>
|
|
507
|
+
</UiFieldLabel>
|
|
508
|
+
|
|
509
|
+
<UiFieldLabel for="start-email">
|
|
510
|
+
<UiField orientation="horizontal">
|
|
511
|
+
<UiCheckbox id="start-email" name="email" v-model="email" />
|
|
512
|
+
<UiFieldContent>
|
|
513
|
+
<UiFieldTitle>Email digest</UiFieldTitle>
|
|
514
|
+
<UiFieldDescription>
|
|
515
|
+
Receive a single summary of activity every morning.
|
|
516
|
+
</UiFieldDescription>
|
|
517
|
+
</UiFieldContent>
|
|
518
|
+
</UiField>
|
|
519
|
+
</UiFieldLabel>
|
|
520
|
+
</UiFieldGroup>
|
|
521
|
+
</UiFieldSet>
|
|
522
|
+
</UiFieldGroup>
|
|
398
523
|
</template>`;
|
|
399
524
|
|
|
400
525
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
526
|
+
* Checkboxes composed with `UiField` as selectable cards, in both control placements.
|
|
527
|
+
* Wrapping a horizontal `UiField` in a `UiFieldLabel` turns the whole row into a
|
|
528
|
+
* bordered, clickable option that highlights while its checkbox is checked. Put the
|
|
529
|
+
* `UiCheckbox` after `UiFieldContent` to trail the text, or before it to lead.
|
|
530
|
+
* Mark the wrapping `UiFieldGroup` with `data-slot="checkbox-group"` so the cards
|
|
531
|
+
* sit at the tighter group spacing. Unlike a radio group, each card toggles
|
|
532
|
+
* independently, so any number of them can be checked at once.
|
|
403
533
|
*/
|
|
404
|
-
export const
|
|
405
|
-
render: (
|
|
406
|
-
components: {
|
|
534
|
+
export const WithField: Story = {
|
|
535
|
+
render: () => ({
|
|
536
|
+
components: {
|
|
537
|
+
UiCheckbox,
|
|
538
|
+
UiField,
|
|
539
|
+
UiFieldContent,
|
|
540
|
+
UiFieldDescription,
|
|
541
|
+
UiFieldGroup,
|
|
542
|
+
UiFieldLabel,
|
|
543
|
+
UiFieldLegend,
|
|
544
|
+
UiFieldSet,
|
|
545
|
+
UiFieldTitle,
|
|
546
|
+
},
|
|
407
547
|
setup() {
|
|
408
|
-
const
|
|
409
|
-
|
|
548
|
+
const pushEnd = ref(true);
|
|
549
|
+
const emailEnd = ref(false);
|
|
550
|
+
const pushStart = ref(true);
|
|
551
|
+
const emailStart = ref(false);
|
|
552
|
+
return { pushEnd, emailEnd, pushStart, emailStart };
|
|
410
553
|
},
|
|
411
|
-
template:
|
|
412
|
-
class="
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
554
|
+
template: `
|
|
555
|
+
<div class="grid w-full max-w-3xl gap-6 md:grid-cols-2">
|
|
556
|
+
<UiFieldGroup>
|
|
557
|
+
<UiFieldSet>
|
|
558
|
+
<UiFieldLegend variant="label">Notifications (control at end)</UiFieldLegend>
|
|
559
|
+
<UiFieldDescription>
|
|
560
|
+
Choose how you want to hear about activity.
|
|
561
|
+
</UiFieldDescription>
|
|
562
|
+
|
|
563
|
+
<UiFieldGroup data-slot="checkbox-group">
|
|
564
|
+
<UiFieldLabel for="end-push">
|
|
565
|
+
<UiField orientation="horizontal">
|
|
566
|
+
<UiFieldContent>
|
|
567
|
+
<UiFieldTitle>Push notifications</UiFieldTitle>
|
|
568
|
+
<UiFieldDescription>
|
|
569
|
+
Get alerts on your device as soon as something happens.
|
|
570
|
+
</UiFieldDescription>
|
|
571
|
+
</UiFieldContent>
|
|
572
|
+
<UiCheckbox id="end-push" name="push-end" v-model="pushEnd" />
|
|
573
|
+
</UiField>
|
|
574
|
+
</UiFieldLabel>
|
|
575
|
+
|
|
576
|
+
<UiFieldLabel for="end-email">
|
|
577
|
+
<UiField orientation="horizontal">
|
|
578
|
+
<UiFieldContent>
|
|
579
|
+
<UiFieldTitle>Email digest</UiFieldTitle>
|
|
580
|
+
<UiFieldDescription>
|
|
581
|
+
Receive a single summary of activity every morning.
|
|
582
|
+
</UiFieldDescription>
|
|
583
|
+
</UiFieldContent>
|
|
584
|
+
<UiCheckbox id="end-email" name="email-end" v-model="emailEnd" />
|
|
585
|
+
</UiField>
|
|
586
|
+
</UiFieldLabel>
|
|
587
|
+
</UiFieldGroup>
|
|
588
|
+
</UiFieldSet>
|
|
589
|
+
</UiFieldGroup>
|
|
590
|
+
|
|
591
|
+
<UiFieldGroup>
|
|
592
|
+
<UiFieldSet>
|
|
593
|
+
<UiFieldLegend variant="label">Notifications (control at start)</UiFieldLegend>
|
|
594
|
+
<UiFieldDescription>
|
|
595
|
+
Choose how you want to hear about activity.
|
|
596
|
+
</UiFieldDescription>
|
|
597
|
+
|
|
598
|
+
<UiFieldGroup data-slot="checkbox-group">
|
|
599
|
+
<UiFieldLabel for="start-push">
|
|
600
|
+
<UiField orientation="horizontal">
|
|
601
|
+
<UiCheckbox id="start-push" name="push-start" v-model="pushStart" />
|
|
602
|
+
<UiFieldContent>
|
|
603
|
+
<UiFieldTitle>Push notifications</UiFieldTitle>
|
|
604
|
+
<UiFieldDescription>
|
|
605
|
+
Get alerts on your device as soon as something happens.
|
|
606
|
+
</UiFieldDescription>
|
|
607
|
+
</UiFieldContent>
|
|
608
|
+
</UiField>
|
|
609
|
+
</UiFieldLabel>
|
|
610
|
+
|
|
611
|
+
<UiFieldLabel for="start-email">
|
|
612
|
+
<UiField orientation="horizontal">
|
|
613
|
+
<UiCheckbox id="start-email" name="email-start" v-model="emailStart" />
|
|
614
|
+
<UiFieldContent>
|
|
615
|
+
<UiFieldTitle>Email digest</UiFieldTitle>
|
|
616
|
+
<UiFieldDescription>
|
|
617
|
+
Receive a single summary of activity every morning.
|
|
618
|
+
</UiFieldDescription>
|
|
619
|
+
</UiFieldContent>
|
|
620
|
+
</UiField>
|
|
621
|
+
</UiFieldLabel>
|
|
622
|
+
</UiFieldGroup>
|
|
623
|
+
</UiFieldSet>
|
|
624
|
+
</UiFieldGroup>
|
|
427
625
|
</div>
|
|
428
|
-
|
|
626
|
+
`,
|
|
429
627
|
}),
|
|
430
628
|
parameters: {
|
|
629
|
+
controls: { disable: true },
|
|
431
630
|
docs: {
|
|
432
631
|
source: {
|
|
433
|
-
code:
|
|
632
|
+
code: withFieldTemplateSource,
|
|
434
633
|
},
|
|
435
634
|
},
|
|
436
635
|
},
|
|
636
|
+
play: async ({ canvasElement, step }) => {
|
|
637
|
+
// Scenario (UiCheckbox): each card is a label wired to its checkbox, so the
|
|
638
|
+
// title and description become the checkbox's accessible name regardless of
|
|
639
|
+
// whether the control leads or trails. The one toggle is undone before the
|
|
640
|
+
// play ends, so the primary snapshot stays stable.
|
|
641
|
+
const canvas = within(canvasElement);
|
|
642
|
+
|
|
643
|
+
await step(
|
|
644
|
+
'screen-reader: each fieldset is a group named by its legend (WCAG 1.3.1)',
|
|
645
|
+
async () => {
|
|
646
|
+
const groups = canvas.getAllByRole('group', { name: /Notifications/ });
|
|
647
|
+
await expect(groups).toHaveLength(2);
|
|
648
|
+
},
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
await step(
|
|
652
|
+
'screen-reader: card labels name their checkboxes in both placements (WCAG 1.3.1 / 4.1.2)',
|
|
653
|
+
async () => {
|
|
654
|
+
const push = canvas.getAllByRole('checkbox', {
|
|
655
|
+
name: /Push notifications/,
|
|
656
|
+
});
|
|
657
|
+
const email = canvas.getAllByRole('checkbox', {
|
|
658
|
+
name: /Email digest/,
|
|
659
|
+
});
|
|
660
|
+
await expect(push).toHaveLength(2);
|
|
661
|
+
await expect(email).toHaveLength(2);
|
|
662
|
+
for (const checkbox of push) await expect(checkbox).toBeChecked();
|
|
663
|
+
for (const checkbox of email) await expect(checkbox).not.toBeChecked();
|
|
664
|
+
},
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
await step(
|
|
668
|
+
'interaction: the selected card is distinguished by more than colour alone (WCAG 1.4.1)',
|
|
669
|
+
async () => {
|
|
670
|
+
// The card highlight is driven by `data-state`, which the label styles
|
|
671
|
+
// key off — so the checked state is exposed in the DOM, not only in the
|
|
672
|
+
// rendered colour.
|
|
673
|
+
for (const checkbox of canvas.getAllByRole('checkbox', {
|
|
674
|
+
name: /Push notifications/,
|
|
675
|
+
})) {
|
|
676
|
+
await expect(checkbox).toHaveAttribute('data-state', 'checked');
|
|
677
|
+
}
|
|
678
|
+
for (const checkbox of canvas.getAllByRole('checkbox', {
|
|
679
|
+
name: /Email digest/,
|
|
680
|
+
})) {
|
|
681
|
+
await expect(checkbox).toHaveAttribute('data-state', 'unchecked');
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
await step(
|
|
687
|
+
'interaction: cards toggle independently, so several can be checked at once',
|
|
688
|
+
async () => {
|
|
689
|
+
const [push] = canvas.getAllByRole('checkbox', {
|
|
690
|
+
name: /Push notifications/,
|
|
691
|
+
});
|
|
692
|
+
const [email] = canvas.getAllByRole('checkbox', {
|
|
693
|
+
name: /Email digest/,
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
await userEvent.click(email);
|
|
697
|
+
await expect(email).toBeChecked();
|
|
698
|
+
await expect(push).toBeChecked();
|
|
699
|
+
|
|
700
|
+
// Restore the initial state so the snapshot is unaffected.
|
|
701
|
+
await userEvent.click(email);
|
|
702
|
+
await expect(email).not.toBeChecked();
|
|
703
|
+
},
|
|
704
|
+
);
|
|
705
|
+
},
|
|
437
706
|
};
|
|
438
707
|
|
|
439
708
|
const indeterminateTemplateSource = `<script setup lang="ts">
|
|
@@ -492,6 +761,137 @@ export const Indeterminate: Story = {
|
|
|
492
761
|
},
|
|
493
762
|
};
|
|
494
763
|
|
|
764
|
+
// Test-only stories drive the test-runner (interactive/a11y checks) but are
|
|
765
|
+
// hidden from the Storybook sidebar and docs via the `!dev` / `!autodocs`
|
|
766
|
+
// tags. They keep the implicit `test` tag, so they still run in CI and appear
|
|
767
|
+
// in the automated report under their `test - …` name. `name`/`tags` must be
|
|
768
|
+
// literal properties so Storybook's static CSF indexer can read them.
|
|
769
|
+
|
|
770
|
+
// Shared render for the test scenarios: a required checkbox with a described
|
|
771
|
+
// label, a disabled one, and one starting in the mixed state — a single fixture
|
|
772
|
+
// covering naming, description, every checked state, and the disabled guard.
|
|
773
|
+
function renderTestCheckboxes() {
|
|
774
|
+
return {
|
|
775
|
+
components: { UiCheckbox },
|
|
776
|
+
setup() {
|
|
777
|
+
const terms = ref(false);
|
|
778
|
+
const newsletter = ref(false);
|
|
779
|
+
const selectAll = ref<'indeterminate' | boolean>('indeterminate');
|
|
780
|
+
return { terms, newsletter, selectAll, onUpdate };
|
|
781
|
+
},
|
|
782
|
+
template: `
|
|
783
|
+
<div class="flex flex-col gap-4">
|
|
784
|
+
<div class="flex items-start gap-3">
|
|
785
|
+
<UiCheckbox
|
|
786
|
+
id="t-terms"
|
|
787
|
+
name="terms"
|
|
788
|
+
v-model="terms"
|
|
789
|
+
required
|
|
790
|
+
aria-describedby="t-terms-description"
|
|
791
|
+
@update:model-value="onUpdate"
|
|
792
|
+
/>
|
|
793
|
+
<div class="grid gap-1">
|
|
794
|
+
<label for="t-terms" class="body-14-medium">Accept terms and conditions</label>
|
|
795
|
+
<p id="t-terms-description" class="body-14-regular text-content-on-surface-muted">
|
|
796
|
+
You can withdraw your consent at any time.
|
|
797
|
+
</p>
|
|
798
|
+
</div>
|
|
799
|
+
</div>
|
|
800
|
+
|
|
801
|
+
<div class="flex items-center gap-3">
|
|
802
|
+
<UiCheckbox id="t-newsletter" name="newsletter" v-model="newsletter" disabled />
|
|
803
|
+
<label for="t-newsletter" class="body-14-medium text-content-on-surface-muted">
|
|
804
|
+
Subscribe to the newsletter
|
|
805
|
+
</label>
|
|
806
|
+
</div>
|
|
807
|
+
|
|
808
|
+
<div class="flex items-center gap-3">
|
|
809
|
+
<UiCheckbox id="t-select-all" name="select-all" v-model="selectAll" />
|
|
810
|
+
<label for="t-select-all" class="body-14-medium">Select all</label>
|
|
811
|
+
</div>
|
|
812
|
+
</div>
|
|
813
|
+
`,
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Toggle behaviour: clicking flips the state and emits, the label is part of the
|
|
819
|
+
* hit area, a mixed checkbox resolves to checked, and a disabled checkbox
|
|
820
|
+
* refuses activation.
|
|
821
|
+
*/
|
|
822
|
+
export const ToggleBehavior: Story = {
|
|
823
|
+
name: 'test - Toggle Behavior',
|
|
824
|
+
tags: ['!dev', '!autodocs'],
|
|
825
|
+
render: renderTestCheckboxes,
|
|
826
|
+
parameters: {
|
|
827
|
+
// The play toggles state; skip the visual snapshot.
|
|
828
|
+
chromatic: { disableSnapshot: true },
|
|
829
|
+
docs: {
|
|
830
|
+
description: {
|
|
831
|
+
story:
|
|
832
|
+
'Toggle the checkbox on and off, activate it through its label, and confirm the disabled guard holds.',
|
|
833
|
+
},
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
play: async ({ canvasElement, step }) => {
|
|
837
|
+
// Scenario (UiCheckbox): a pointer user toggles a checkbox on and off,
|
|
838
|
+
// activates another through its label, advances the mixed checkbox, and
|
|
839
|
+
// finds the disabled one unresponsive.
|
|
840
|
+
onUpdate.mockClear();
|
|
841
|
+
const canvas = within(canvasElement);
|
|
842
|
+
const terms = canvas.getByRole('checkbox', {
|
|
843
|
+
name: 'Accept terms and conditions',
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
await step(
|
|
847
|
+
'interaction: clicking toggles the checked state and emits the new value',
|
|
848
|
+
async () => {
|
|
849
|
+
await userEvent.click(terms);
|
|
850
|
+
await expect(terms).toHaveAttribute('aria-checked', 'true');
|
|
851
|
+
await expect(onUpdate).toHaveBeenCalledWith(true);
|
|
852
|
+
},
|
|
853
|
+
);
|
|
854
|
+
|
|
855
|
+
await step('interaction: clicking again toggles it back off', async () => {
|
|
856
|
+
await userEvent.click(terms);
|
|
857
|
+
await expect(terms).toHaveAttribute('aria-checked', 'false');
|
|
858
|
+
await expect(onUpdate).toHaveBeenLastCalledWith(false);
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
await step(
|
|
862
|
+
'interaction: the associated label is part of the activation target (WCAG 2.5.8)',
|
|
863
|
+
async () => {
|
|
864
|
+
await userEvent.click(canvas.getByText('Accept terms and conditions'));
|
|
865
|
+
await expect(terms).toHaveAttribute('aria-checked', 'true');
|
|
866
|
+
},
|
|
867
|
+
);
|
|
868
|
+
|
|
869
|
+
await step(
|
|
870
|
+
'interaction: a mixed checkbox resolves to checked when activated',
|
|
871
|
+
async () => {
|
|
872
|
+
const selectAll = canvas.getByRole('checkbox', { name: 'Select all' });
|
|
873
|
+
await expect(selectAll).toHaveAttribute('aria-checked', 'mixed');
|
|
874
|
+
await userEvent.click(selectAll);
|
|
875
|
+
await expect(selectAll).toHaveAttribute('aria-checked', 'true');
|
|
876
|
+
},
|
|
877
|
+
);
|
|
878
|
+
|
|
879
|
+
await step(
|
|
880
|
+
'interaction: a disabled checkbox cannot be toggled (WCAG 4.1.2)',
|
|
881
|
+
async () => {
|
|
882
|
+
const newsletter = canvas.getByRole('checkbox', {
|
|
883
|
+
name: 'Subscribe to the newsletter',
|
|
884
|
+
});
|
|
885
|
+
await expect(newsletter).toBeDisabled();
|
|
886
|
+
// Disabled controls render with pointer-events: none, so bypass the
|
|
887
|
+
// check and assert the click is still a no-op.
|
|
888
|
+
await userEvent.click(newsletter, { pointerEventsCheck: 0 });
|
|
889
|
+
await expect(newsletter).toHaveAttribute('aria-checked', 'false');
|
|
890
|
+
},
|
|
891
|
+
);
|
|
892
|
+
},
|
|
893
|
+
};
|
|
894
|
+
|
|
495
895
|
/**
|
|
496
896
|
* `UiCheckbox` is keyboard operable: `Tab` moves focus to it and `Space`
|
|
497
897
|
* toggles the checked state. Hidden test-only story.
|
|
@@ -499,19 +899,7 @@ export const Indeterminate: Story = {
|
|
|
499
899
|
export const KeyboardNavigation: Story = {
|
|
500
900
|
name: 'test - Keyboard Navigation',
|
|
501
901
|
tags: ['!dev', '!autodocs'],
|
|
502
|
-
render:
|
|
503
|
-
components: { UiCheckbox },
|
|
504
|
-
setup() {
|
|
505
|
-
const checked = ref(false);
|
|
506
|
-
return { checked, onUpdate };
|
|
507
|
-
},
|
|
508
|
-
template: `<div class="flex items-center gap-3">
|
|
509
|
-
<UiCheckbox id="subscribe" name="subscribe" v-model="checked" @update:model-value="onUpdate" />
|
|
510
|
-
<label for="subscribe" class="body-14-medium">
|
|
511
|
-
Subscribe to updates
|
|
512
|
-
</label>
|
|
513
|
-
</div>`,
|
|
514
|
-
}),
|
|
902
|
+
render: renderTestCheckboxes,
|
|
515
903
|
parameters: {
|
|
516
904
|
// Focus moves during the play function; skip the visual snapshot so the
|
|
517
905
|
// focus ring doesn't register as a Chromatic diff.
|
|
@@ -524,19 +912,24 @@ export const KeyboardNavigation: Story = {
|
|
|
524
912
|
},
|
|
525
913
|
},
|
|
526
914
|
play: async ({ canvasElement, step }) => {
|
|
527
|
-
// Scenario (UiCheckbox): a keyboard user tabs
|
|
528
|
-
//
|
|
915
|
+
// Scenario (UiCheckbox): a keyboard user tabs through the enabled
|
|
916
|
+
// checkboxes in DOM order, toggles with Space, and never lands on the
|
|
917
|
+
// disabled one.
|
|
529
918
|
onUpdate.mockClear();
|
|
530
919
|
const canvas = within(canvasElement);
|
|
531
|
-
const
|
|
532
|
-
name: '
|
|
920
|
+
const terms = canvas.getByRole('checkbox', {
|
|
921
|
+
name: 'Accept terms and conditions',
|
|
922
|
+
});
|
|
923
|
+
const newsletter = canvas.getByRole('checkbox', {
|
|
924
|
+
name: 'Subscribe to the newsletter',
|
|
533
925
|
});
|
|
926
|
+
const selectAll = canvas.getByRole('checkbox', { name: 'Select all' });
|
|
534
927
|
|
|
535
928
|
await step(
|
|
536
929
|
'keyboard: checkbox is reachable via Tab (WCAG 2.1.1)',
|
|
537
930
|
async () => {
|
|
538
931
|
await userEvent.tab();
|
|
539
|
-
await expect(
|
|
932
|
+
await expect(terms).toHaveFocus();
|
|
540
933
|
},
|
|
541
934
|
);
|
|
542
935
|
|
|
@@ -544,10 +937,163 @@ export const KeyboardNavigation: Story = {
|
|
|
544
937
|
'keyboard: Space toggles the checked state (WCAG 2.1.1)',
|
|
545
938
|
async () => {
|
|
546
939
|
await userEvent.keyboard(' ');
|
|
547
|
-
await expect(
|
|
940
|
+
await expect(terms).toHaveAttribute('aria-checked', 'true');
|
|
548
941
|
await expect(onUpdate).toHaveBeenCalledWith(true);
|
|
549
942
|
},
|
|
550
943
|
);
|
|
944
|
+
|
|
945
|
+
await step('keyboard: Space toggles it back off', async () => {
|
|
946
|
+
await userEvent.keyboard(' ');
|
|
947
|
+
await expect(terms).toHaveAttribute('aria-checked', 'false');
|
|
948
|
+
await expect(onUpdate).toHaveBeenLastCalledWith(false);
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
await step(
|
|
952
|
+
'keyboard: Tab follows DOM order and skips the disabled checkbox (WCAG 2.4.3 Focus Order)',
|
|
953
|
+
async () => {
|
|
954
|
+
await userEvent.tab();
|
|
955
|
+
await expect(newsletter).not.toHaveFocus();
|
|
956
|
+
await expect(selectAll).toHaveFocus();
|
|
957
|
+
},
|
|
958
|
+
);
|
|
959
|
+
|
|
960
|
+
await step(
|
|
961
|
+
'keyboard: Space advances the mixed checkbox to checked (WCAG 2.1.1)',
|
|
962
|
+
async () => {
|
|
963
|
+
await userEvent.keyboard(' ');
|
|
964
|
+
await expect(selectAll).toHaveAttribute('aria-checked', 'true');
|
|
965
|
+
},
|
|
966
|
+
);
|
|
967
|
+
},
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Screen-reader semantics: the checkbox exposes its role, the label as its
|
|
972
|
+
* accessible name, the helper text as its description, and its checked,
|
|
973
|
+
* mixed, required, and disabled states.
|
|
974
|
+
*/
|
|
975
|
+
export const ScreenReader: Story = {
|
|
976
|
+
name: 'test - Screen Reader',
|
|
977
|
+
tags: ['!dev', '!autodocs'],
|
|
978
|
+
render: renderTestCheckboxes,
|
|
979
|
+
parameters: {
|
|
980
|
+
// The play toggles state; skip the visual snapshot.
|
|
981
|
+
chromatic: { disableSnapshot: true },
|
|
982
|
+
docs: {
|
|
983
|
+
description: {
|
|
984
|
+
story:
|
|
985
|
+
'Verifies the roles, names, descriptions, and states that assistive technology announces.',
|
|
986
|
+
},
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
play: async ({ canvasElement, step }) => {
|
|
990
|
+
// Scenario (UiCheckbox): assistive tech reads each control as a checkbox
|
|
991
|
+
// named by its label, hears the helper text as a description, and is told
|
|
992
|
+
// which are checked, mixed, required, or unavailable.
|
|
993
|
+
const canvas = within(canvasElement);
|
|
994
|
+
const terms = canvas.getByRole('checkbox', {
|
|
995
|
+
name: 'Accept terms and conditions',
|
|
996
|
+
});
|
|
997
|
+
const selectAll = canvas.getByRole('checkbox', { name: 'Select all' });
|
|
998
|
+
|
|
999
|
+
await step(
|
|
1000
|
+
'screen-reader: the label supplies the accessible name (WCAG 1.3.1 / 4.1.2)',
|
|
1001
|
+
async () => {
|
|
1002
|
+
await expect(terms).toHaveAccessibleName('Accept terms and conditions');
|
|
1003
|
+
},
|
|
1004
|
+
);
|
|
1005
|
+
|
|
1006
|
+
await step(
|
|
1007
|
+
'screen-reader: the helper text is announced as the description (WCAG 1.3.1)',
|
|
1008
|
+
async () => {
|
|
1009
|
+
await expect(terms).toHaveAccessibleDescription(
|
|
1010
|
+
'You can withdraw your consent at any time.',
|
|
1011
|
+
);
|
|
1012
|
+
},
|
|
1013
|
+
);
|
|
1014
|
+
|
|
1015
|
+
await step(
|
|
1016
|
+
'screen-reader: a required checkbox announces aria-required (WCAG 3.3.2)',
|
|
1017
|
+
async () => {
|
|
1018
|
+
await expect(terms).toHaveAttribute('aria-required', 'true');
|
|
1019
|
+
},
|
|
1020
|
+
);
|
|
1021
|
+
|
|
1022
|
+
await step(
|
|
1023
|
+
'screen-reader: the unchecked, mixed, and disabled states are announced (WCAG 4.1.2)',
|
|
1024
|
+
async () => {
|
|
1025
|
+
await expect(terms).toHaveAttribute('aria-checked', 'false');
|
|
1026
|
+
await expect(selectAll).toHaveAttribute('aria-checked', 'mixed');
|
|
1027
|
+
await expect(
|
|
1028
|
+
canvas.getByRole('checkbox', {
|
|
1029
|
+
name: 'Subscribe to the newsletter',
|
|
1030
|
+
}),
|
|
1031
|
+
).toBeDisabled();
|
|
1032
|
+
},
|
|
1033
|
+
);
|
|
1034
|
+
|
|
1035
|
+
await step(
|
|
1036
|
+
'screen-reader: the announced state follows the selection (WCAG 4.1.2)',
|
|
1037
|
+
async () => {
|
|
1038
|
+
await userEvent.click(terms);
|
|
1039
|
+
await expect(terms).toHaveAttribute('aria-checked', 'true');
|
|
1040
|
+
},
|
|
1041
|
+
);
|
|
1042
|
+
},
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
|
|
1047
|
+
* try 400% reflow (WCAG 1.4.10); every checkbox must stay visible, readable,
|
|
1048
|
+
* and operable. Hidden test-only story.
|
|
1049
|
+
*/
|
|
1050
|
+
export const ZoomMagnification: Story = {
|
|
1051
|
+
name: 'test - Zoom Magnification',
|
|
1052
|
+
tags: ['!dev', '!autodocs'],
|
|
1053
|
+
globals: { zoom: '200' },
|
|
1054
|
+
render: renderTestCheckboxes,
|
|
1055
|
+
parameters: {
|
|
1056
|
+
// The accessible-reflow Chromatic mode already covers magnified snapshots.
|
|
1057
|
+
chromatic: { disableSnapshot: true },
|
|
1058
|
+
docs: {
|
|
1059
|
+
description: {
|
|
1060
|
+
story:
|
|
1061
|
+
'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
|
|
1062
|
+
},
|
|
1063
|
+
},
|
|
1064
|
+
},
|
|
1065
|
+
play: async ({ canvasElement, step }) => {
|
|
1066
|
+
// Scenario (UiCheckbox): at 200% page zoom every checkbox keeps its label
|
|
1067
|
+
// on screen and still toggles.
|
|
1068
|
+
const canvas = within(canvasElement);
|
|
1069
|
+
const terms = canvas.getByRole('checkbox', {
|
|
1070
|
+
name: 'Accept terms and conditions',
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
await step(
|
|
1074
|
+
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
1075
|
+
async () => {
|
|
1076
|
+
await expect(document.documentElement.style.zoom).toBe('200%');
|
|
1077
|
+
},
|
|
1078
|
+
);
|
|
1079
|
+
|
|
1080
|
+
await step(
|
|
1081
|
+
'zoom: every checkbox stays visible with a readable label when magnified',
|
|
1082
|
+
async () => {
|
|
1083
|
+
for (const checkbox of canvas.getAllByRole('checkbox')) {
|
|
1084
|
+
await expect(checkbox).toBeVisible();
|
|
1085
|
+
await expect(checkbox).toHaveAccessibleName();
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
);
|
|
1089
|
+
|
|
1090
|
+
await step(
|
|
1091
|
+
'zoom: the checkbox remains operable when magnified',
|
|
1092
|
+
async () => {
|
|
1093
|
+
await userEvent.click(terms);
|
|
1094
|
+
await expect(terms).toHaveAttribute('aria-checked', 'true');
|
|
1095
|
+
},
|
|
1096
|
+
);
|
|
551
1097
|
},
|
|
552
1098
|
};
|
|
553
1099
|
|
|
@@ -632,12 +1178,17 @@ export const MobileBreakpoint: Story = {
|
|
|
632
1178
|
);
|
|
633
1179
|
|
|
634
1180
|
await step(
|
|
635
|
-
'mobile: the
|
|
1181
|
+
'mobile: the label extends the activation target for touch (WCAG 2.5.8)',
|
|
636
1182
|
async () => {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
await
|
|
640
|
-
await expect(
|
|
1183
|
+
// The control itself is 16px, so it relies on its associated label to
|
|
1184
|
+
// enlarge the tap area — tapping the text must toggle it.
|
|
1185
|
+
await userEvent.click(canvas.getByText('Accept terms and conditions'));
|
|
1186
|
+
await expect(checkbox).toHaveAttribute('aria-checked', 'false');
|
|
1187
|
+
|
|
1188
|
+
const row = checkbox.parentElement as HTMLElement;
|
|
1189
|
+
const { width, height } = row.getBoundingClientRect();
|
|
1190
|
+
await expect(width).toBeGreaterThanOrEqual(24);
|
|
1191
|
+
await expect(height).toBeGreaterThanOrEqual(16);
|
|
641
1192
|
},
|
|
642
1193
|
);
|
|
643
1194
|
},
|