@happyvertical/smrt-ui 0.53.1 → 0.53.2
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/package.json +3 -3
- package/dist/actions/__tests__/ripple.test.js +0 -82
- package/dist/actions/__tests__/swipe-dismiss.test.js +0 -69
- package/dist/components/calendar/__tests__/CalendarView.test.js +0 -226
- package/dist/components/calendar/__tests__/calendar-model.test.js +0 -138
- package/dist/components/chat/__tests__/chat-primitives.test.js +0 -118
- package/dist/components/data/__tests__/CollectionList.test.js +0 -37
- package/dist/components/data/__tests__/DataTable.test.js +0 -807
- package/dist/components/data/__tests__/DataTableConformance.test.js +0 -212
- package/dist/components/data/__tests__/DataTableController.test.js +0 -371
- package/dist/components/data/__tests__/DataTableIdentity.test.js +0 -29
- package/dist/components/data/__tests__/DataTableLayout.test.js +0 -195
- package/dist/components/data/__tests__/DataTablePerformance.test.js +0 -21
- package/dist/components/data/__tests__/DataTableResponsive.test.js +0 -80
- package/dist/components/data/__tests__/DataTableVirtualization.test.js +0 -80
- package/dist/components/data/__tests__/DataTableVirtualizationComponent.test.js +0 -255
- package/dist/components/data/__tests__/SortableHeader.test.js +0 -101
- package/dist/components/data/__tests__/data-surface.test.js +0 -746
- package/dist/components/data/__tests__/data-table-helpers.test.js +0 -36
- package/dist/components/data/__tests__/data-table-surface.test.js +0 -49
- package/dist/components/data/__tests__/link-step-surface.test.js +0 -172
- package/dist/components/data/__tests__/list-sort-state.svelte.test.js +0 -71
- package/dist/components/data/__tests__/list-sort.test.js +0 -91
- package/dist/components/data/__tests__/mounted-data-surface.test.js +0 -794
- package/dist/components/data/__tests__/responsive-table.fixture.svelte +0 -29
- package/dist/components/data/__tests__/responsive-table.fixture.svelte.d.ts +0 -7
- package/dist/components/data/__tests__/responsive-table.fixture.svelte.d.ts.map +0 -1
- package/dist/components/data/__tests__/surface-navigation.test.js +0 -121
- package/dist/components/display/__tests__/ConfidenceBadge.test.js +0 -109
- package/dist/components/display/__tests__/CurrencyDisplay.test.js +0 -304
- package/dist/components/display/__tests__/CurrencyDisplayI18nHarness.svelte +0 -20
- package/dist/components/display/__tests__/CurrencyDisplayI18nHarness.svelte.d.ts +0 -19
- package/dist/components/display/__tests__/CurrencyDisplayI18nHarness.svelte.d.ts.map +0 -1
- package/dist/components/display/__tests__/CurrencyDisplaySsrHarness.svelte +0 -7
- package/dist/components/display/__tests__/CurrencyDisplaySsrHarness.svelte.d.ts +0 -19
- package/dist/components/display/__tests__/CurrencyDisplaySsrHarness.svelte.d.ts.map +0 -1
- package/dist/components/display/__tests__/DateDisplay.test.js +0 -195
- package/dist/components/display/__tests__/Icon.test.js +0 -223
- package/dist/components/display/__tests__/StatusBadge.test.js +0 -191
- package/dist/components/feedback/__tests__/ConfirmDialog.test.js +0 -181
- package/dist/components/feedback/__tests__/LoadingOverlay.test.js +0 -113
- package/dist/components/feedback/__tests__/Modal.test.js +0 -72
- package/dist/components/feedback/__tests__/PhoneSheet.test.js +0 -101
- package/dist/components/feedback/__tests__/ProgressBar.test.js +0 -89
- package/dist/components/feedback/__tests__/WorkingStrip.test.js +0 -172
- package/dist/components/feedback/__tests__/confirm-message.fixture.svelte +0 -9
- package/dist/components/feedback/__tests__/confirm-message.fixture.svelte.d.ts +0 -19
- package/dist/components/feedback/__tests__/confirm-message.fixture.svelte.d.ts.map +0 -1
- package/dist/components/feedback/__tests__/toast.test.js +0 -190
- package/dist/components/forms/__tests__/CameraCapture.test.js +0 -504
- package/dist/components/forms/__tests__/Combobox.test.js +0 -354
- package/dist/components/forms/__tests__/ControlHitArea.test.js +0 -73
- package/dist/components/forms/__tests__/DictationButton.test.js +0 -176
- package/dist/components/forms/__tests__/Fieldset.test.js +0 -37
- package/dist/components/forms/__tests__/Form.test.js +0 -201
- package/dist/components/forms/__tests__/FormActionBar.test.js +0 -22
- package/dist/components/forms/__tests__/FormGroup.test.js +0 -48
- package/dist/components/forms/__tests__/Input.test.js +0 -49
- package/dist/components/forms/__tests__/Listbox.test.js +0 -303
- package/dist/components/forms/__tests__/MultiSelect.test.js +0 -281
- package/dist/components/forms/__tests__/SearchInput.test.js +0 -92
- package/dist/components/forms/__tests__/Select.test.js +0 -37
- package/dist/components/forms/__tests__/SignaturePad.test.js +0 -338
- package/dist/components/forms/__tests__/StagedControlReview.test.js +0 -702
- package/dist/components/forms/__tests__/Textarea.test.js +0 -39
- package/dist/components/forms/__tests__/Toggle.test.js +0 -87
- package/dist/components/forms/__tests__/camera-capture-session.test.js +0 -207
- package/dist/components/forms/__tests__/capture-form-retry.test.js +0 -166
- package/dist/components/forms/__tests__/capture-form.fixture.svelte +0 -38
- package/dist/components/forms/__tests__/capture-form.fixture.svelte.d.ts +0 -10
- package/dist/components/forms/__tests__/capture-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/capture-test-env.d.ts +0 -70
- package/dist/components/forms/__tests__/capture-test-env.d.ts.map +0 -1
- package/dist/components/forms/__tests__/capture-test-env.js +0 -122
- package/dist/components/forms/__tests__/capture-touch.fixture.svelte +0 -15
- package/dist/components/forms/__tests__/capture-touch.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/capture-touch.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/combobox-form.fixture.svelte +0 -29
- package/dist/components/forms/__tests__/combobox-form.fixture.svelte.d.ts +0 -14
- package/dist/components/forms/__tests__/combobox-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/combobox-labels.fixture.svelte +0 -19
- package/dist/components/forms/__tests__/combobox-labels.fixture.svelte.d.ts +0 -11
- package/dist/components/forms/__tests__/combobox-labels.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/composite-controls.fixture.svelte +0 -47
- package/dist/components/forms/__tests__/composite-controls.fixture.svelte.d.ts +0 -12
- package/dist/components/forms/__tests__/composite-controls.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/composite-controls.test.js +0 -128
- package/dist/components/forms/__tests__/composite-registration.fixture.svelte +0 -29
- package/dist/components/forms/__tests__/composite-registration.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/composite-registration.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/composite-user-edit.fixture.svelte +0 -41
- package/dist/components/forms/__tests__/composite-user-edit.fixture.svelte.d.ts +0 -13
- package/dist/components/forms/__tests__/composite-user-edit.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/control-interaction.test.js +0 -3421
- package/dist/components/forms/__tests__/control-proposals.test.js +0 -63
- package/dist/components/forms/__tests__/core-controls.fixture.svelte +0 -50
- package/dist/components/forms/__tests__/core-controls.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/core-controls.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/core-controls.test.js +0 -311
- package/dist/components/forms/__tests__/decimal-sliders.fixture.svelte +0 -25
- package/dist/components/forms/__tests__/decimal-sliders.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/decimal-sliders.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/dictation-recording.test.js +0 -582
- package/dist/components/forms/__tests__/dictation.test.js +0 -486
- package/dist/components/forms/__tests__/form-attachment.fixture.svelte +0 -28
- package/dist/components/forms/__tests__/form-attachment.fixture.svelte.d.ts +0 -11
- package/dist/components/forms/__tests__/form-attachment.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-group-input.fixture.svelte +0 -16
- package/dist/components/forms/__tests__/form-group-input.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/form-group-input.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-retry-form.fixture.svelte +0 -31
- package/dist/components/forms/__tests__/form-retry-form.fixture.svelte.d.ts +0 -13
- package/dist/components/forms/__tests__/form-retry-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-retry-form.test.js +0 -107
- package/dist/components/forms/__tests__/hidden-controls-form-retry.test.js +0 -69
- package/dist/components/forms/__tests__/hidden-controls-form.fixture.svelte +0 -29
- package/dist/components/forms/__tests__/hidden-controls-form.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/hidden-controls-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/listbox-form.fixture.svelte +0 -27
- package/dist/components/forms/__tests__/listbox-form.fixture.svelte.d.ts +0 -13
- package/dist/components/forms/__tests__/listbox-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/long-press.test.js +0 -175
- package/dist/components/forms/__tests__/multiselect-form.fixture.svelte +0 -27
- package/dist/components/forms/__tests__/multiselect-form.fixture.svelte.d.ts +0 -13
- package/dist/components/forms/__tests__/multiselect-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/native-file-field.test.js +0 -177
- package/dist/components/forms/__tests__/place-picker.fixture.svelte +0 -33
- package/dist/components/forms/__tests__/place-picker.fixture.svelte.d.ts +0 -12
- package/dist/components/forms/__tests__/place-picker.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/segmented-posting.fixture.svelte +0 -28
- package/dist/components/forms/__tests__/segmented-posting.fixture.svelte.d.ts +0 -12
- package/dist/components/forms/__tests__/segmented-posting.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/segmented-posting.test.js +0 -92
- package/dist/components/forms/__tests__/select-interaction.fixture.svelte +0 -25
- package/dist/components/forms/__tests__/select-interaction.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/select-interaction.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/signature-pad-logic.test.js +0 -54
- package/dist/components/forms/__tests__/staged-review-fieldset.fixture.svelte +0 -21
- package/dist/components/forms/__tests__/staged-review-fieldset.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/staged-review-fieldset.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/staged-review-outer-fieldset.fixture.svelte +0 -23
- package/dist/components/forms/__tests__/staged-review-outer-fieldset.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/staged-review-outer-fieldset.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/staged-review.fixture.svelte +0 -56
- package/dist/components/forms/__tests__/staged-review.fixture.svelte.d.ts +0 -12
- package/dist/components/forms/__tests__/staged-review.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/touch-density.fixture.svelte +0 -34
- package/dist/components/forms/__tests__/touch-density.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/touch-density.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/touch-density.test.js +0 -66
- package/dist/components/forms/form-retry/__tests__/boundaries.test.js +0 -23
- package/dist/components/forms/form-retry/__tests__/content-digest.test.js +0 -70
- package/dist/components/forms/form-retry/__tests__/controller.test.js +0 -802
- package/dist/components/forms/form-retry/__tests__/fake-kit.d.ts +0 -82
- package/dist/components/forms/form-retry/__tests__/fake-kit.d.ts.map +0 -1
- package/dist/components/forms/form-retry/__tests__/fake-kit.js +0 -180
- package/dist/components/forms/form-retry/__tests__/form-draft.test.js +0 -169
- package/dist/components/forms/form-retry/__tests__/ssr.test.js +0 -37
- package/dist/components/forms/form-retry/__tests__/storage.d.ts +0 -26
- package/dist/components/forms/form-retry/__tests__/storage.d.ts.map +0 -1
- package/dist/components/forms/form-retry/__tests__/storage.js +0 -63
- package/dist/components/forms/form-retry/__tests__/submission-key.test.js +0 -236
- package/dist/components/forms/form-retry/__tests__/submitted-draft.test.js +0 -334
- package/dist/components/layout/__tests__/Container.test.js +0 -62
- package/dist/components/layout/__tests__/EmptyState.test.js +0 -83
- package/dist/components/layout/__tests__/Footer.test.js +0 -50
- package/dist/components/layout/__tests__/Grid.test.js +0 -121
- package/dist/components/layout/__tests__/Header.test.js +0 -48
- package/dist/components/layout/__tests__/Masthead.test.js +0 -93
- package/dist/components/layout/__tests__/PageHeader.test.js +0 -166
- package/dist/components/layout/__tests__/SummaryCard.test.js +0 -104
- package/dist/components/nav/__tests__/FilterChips.test.js +0 -94
- package/dist/components/nav/__tests__/LinkTabs.test.js +0 -117
- package/dist/components/nav/__tests__/Tabs.test.js +0 -128
- package/dist/components/roles/__tests__/RoleSelector.test.js +0 -134
- package/dist/components/ui/__tests__/Badge.test.js +0 -76
- package/dist/components/ui/__tests__/Button.test.js +0 -166
- package/dist/components/ui/__tests__/Card.test.js +0 -103
- package/dist/components/ui/__tests__/IconToggle.test.js +0 -59
- package/dist/components/ui/__tests__/IconToggleGroup.test.js +0 -30
- package/dist/components/ui/__tests__/Pagination.test.js +0 -113
- package/dist/components/ui/__tests__/Popover.test.js +0 -44
- package/dist/components/ui/__tests__/dropdown-popover-icon.test.js +0 -125
- package/dist/components/ui/__tests__/gap-primitives-interactive.test.js +0 -112
- package/dist/components/ui/__tests__/gap-primitives.test.js +0 -84
- package/dist/components/ui/__tests__/interaction-primitives.fixture.svelte +0 -13
- package/dist/components/ui/__tests__/interaction-primitives.fixture.svelte.d.ts +0 -19
- package/dist/components/ui/__tests__/interaction-primitives.fixture.svelte.d.ts.map +0 -1
- package/dist/components/ui/__tests__/interaction-primitives.test.js +0 -31
- package/dist/components/ui/__tests__/phone-touch-targets.test.js +0 -39
- package/dist/i18n/__tests__/i18n.test.js +0 -74
- package/dist/i18n/__tests__/render-parity.spec.js +0 -37
- package/dist/svelte/__tests__/playground.test.js +0 -20
- package/dist/themes/__tests__/control-boundary-contrast.test.js +0 -112
- package/dist/themes/__tests__/create-theme.test.js +0 -79
- package/dist/themes/__tests__/css-generator.test.js +0 -129
- package/dist/themes/__tests__/happyvertical-theme.test.js +0 -231
- package/dist/themes/__tests__/registry.test.js +0 -43
- package/dist/themes/__tests__/styles-lockstep.test.js +0 -32
- package/dist/themes/__tests__/theme-provider.test.js +0 -147
- package/dist/themes/__tests__/theme-script.test.js +0 -130
- package/dist/themes/__tests__/token-aliases.test.js +0 -178
- package/dist/utils/forms/__tests__/formatters.test.js +0 -27
- package/dist/utils/theme/__tests__/color.test.js +0 -89
- package/dist/utils/theme/__tests__/typography.test.js +0 -11
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Golden test for Textarea (Sweep L1, #1420).
|
|
3
|
-
*
|
|
4
|
-
* Textarea forwards aria attributes and inherits id / describedby / invalid from
|
|
5
|
-
* a wrapping FormGroup via context.
|
|
6
|
-
*/
|
|
7
|
-
import { render, screen } from '@testing-library/svelte';
|
|
8
|
-
import userEvent from '@testing-library/user-event';
|
|
9
|
-
import { describe, expect, it } from 'vitest';
|
|
10
|
-
import { expectNoA11yViolations } from '../../../test-support/a11y';
|
|
11
|
-
import Textarea from '../Textarea.svelte';
|
|
12
|
-
describe('Textarea', () => {
|
|
13
|
-
it('forwards aria-label / aria-describedby / aria-invalid', () => {
|
|
14
|
-
render(Textarea, {
|
|
15
|
-
props: {
|
|
16
|
-
'aria-label': 'Notes',
|
|
17
|
-
'aria-describedby': 'notes-hint',
|
|
18
|
-
'aria-invalid': 'true',
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
const textarea = screen.getByRole('textbox', { name: 'Notes' });
|
|
22
|
-
expect(textarea).toHaveAttribute('aria-describedby', 'notes-hint');
|
|
23
|
-
expect(textarea).toHaveAttribute('aria-invalid', 'true');
|
|
24
|
-
});
|
|
25
|
-
it('accepts typed input', async () => {
|
|
26
|
-
render(Textarea, { props: { 'aria-label': 'Notes' } });
|
|
27
|
-
const textarea = screen.getByRole('textbox', {
|
|
28
|
-
name: 'Notes',
|
|
29
|
-
});
|
|
30
|
-
await userEvent.type(textarea, 'hello');
|
|
31
|
-
expect(textarea).toHaveValue('hello');
|
|
32
|
-
});
|
|
33
|
-
it('is axe-clean when labelled', async () => {
|
|
34
|
-
const { container } = render(Textarea, {
|
|
35
|
-
props: { 'aria-label': 'Notes' },
|
|
36
|
-
});
|
|
37
|
-
await expectNoA11yViolations(container);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component test for Toggle (Sweep S11, #1416).
|
|
3
|
-
*
|
|
4
|
-
* Follows the golden pattern (src/components/ui/__tests__/Button.test.ts):
|
|
5
|
-
* render → assert role/name/state → drive with user-event → prove axe-clean.
|
|
6
|
-
* Toggle renders native checkbox semantics, so it surfaces as a `checkbox` role.
|
|
7
|
-
*/
|
|
8
|
-
import { render, screen } from '@testing-library/svelte';
|
|
9
|
-
import userEvent from '@testing-library/user-event';
|
|
10
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
11
|
-
import { expectNoA11yViolations } from '../../../test-support/a11y';
|
|
12
|
-
import Toggle from '../Toggle.svelte';
|
|
13
|
-
describe('Toggle', () => {
|
|
14
|
-
it('renders a checkbox with its label as the accessible name', () => {
|
|
15
|
-
render(Toggle, { props: { label: 'Email notifications' } });
|
|
16
|
-
const toggle = screen.getByRole('checkbox', {
|
|
17
|
-
name: 'Email notifications',
|
|
18
|
-
});
|
|
19
|
-
expect(toggle).toBeInTheDocument();
|
|
20
|
-
expect(toggle).not.toBeChecked();
|
|
21
|
-
});
|
|
22
|
-
it('prefers ariaLabel over label for the accessible name', () => {
|
|
23
|
-
render(Toggle, { props: { label: 'Visible', ariaLabel: 'Wifi' } });
|
|
24
|
-
expect(screen.getByRole('checkbox', { name: 'Wifi' })).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
it('reflects the checked prop', () => {
|
|
27
|
-
render(Toggle, { props: { ariaLabel: 'Active', checked: true } });
|
|
28
|
-
expect(screen.getByRole('checkbox', { name: 'Active' })).toBeChecked();
|
|
29
|
-
});
|
|
30
|
-
it('reflects the disabled prop', () => {
|
|
31
|
-
render(Toggle, { props: { ariaLabel: 'Active', disabled: true } });
|
|
32
|
-
expect(screen.getByRole('checkbox', { name: 'Active' })).toBeDisabled();
|
|
33
|
-
});
|
|
34
|
-
it('forwards name, value, and id to the input for form submission', () => {
|
|
35
|
-
render(Toggle, {
|
|
36
|
-
props: { ariaLabel: 'Sub', name: 'sub', value: 'on', id: 'sub-toggle' },
|
|
37
|
-
});
|
|
38
|
-
const toggle = screen.getByRole('checkbox', {
|
|
39
|
-
name: 'Sub',
|
|
40
|
-
});
|
|
41
|
-
expect(toggle).toHaveAttribute('name', 'sub');
|
|
42
|
-
expect(toggle).toHaveAttribute('id', 'sub-toggle');
|
|
43
|
-
// Svelte binds `value` as the DOM property on checkboxes (not a reflected attribute).
|
|
44
|
-
expect(toggle.value).toBe('on');
|
|
45
|
-
});
|
|
46
|
-
it('toggles checked and fires onchange when clicked', async () => {
|
|
47
|
-
const onchange = vi.fn();
|
|
48
|
-
render(Toggle, { props: { ariaLabel: 'Active', onchange } });
|
|
49
|
-
const toggle = screen.getByRole('checkbox', { name: 'Active' });
|
|
50
|
-
await userEvent.click(toggle);
|
|
51
|
-
expect(toggle).toBeChecked();
|
|
52
|
-
expect(onchange).toHaveBeenCalledWith(true);
|
|
53
|
-
await userEvent.click(toggle);
|
|
54
|
-
expect(toggle).not.toBeChecked();
|
|
55
|
-
expect(onchange).toHaveBeenLastCalledWith(false);
|
|
56
|
-
});
|
|
57
|
-
it('is keyboard-activatable with Space when focused', async () => {
|
|
58
|
-
const onchange = vi.fn();
|
|
59
|
-
render(Toggle, { props: { ariaLabel: 'Active', onchange } });
|
|
60
|
-
const toggle = screen.getByRole('checkbox', { name: 'Active' });
|
|
61
|
-
toggle.focus();
|
|
62
|
-
expect(toggle).toHaveFocus();
|
|
63
|
-
await userEvent.keyboard(' ');
|
|
64
|
-
expect(toggle).toBeChecked();
|
|
65
|
-
expect(onchange).toHaveBeenCalledWith(true);
|
|
66
|
-
});
|
|
67
|
-
it('does not fire onchange when disabled', async () => {
|
|
68
|
-
const onchange = vi.fn();
|
|
69
|
-
render(Toggle, {
|
|
70
|
-
props: { ariaLabel: 'Active', disabled: true, onchange },
|
|
71
|
-
});
|
|
72
|
-
await userEvent.click(screen.getByRole('checkbox', { name: 'Active' }));
|
|
73
|
-
expect(onchange).not.toHaveBeenCalled();
|
|
74
|
-
});
|
|
75
|
-
it('is axe-clean with a label', async () => {
|
|
76
|
-
const { container } = render(Toggle, {
|
|
77
|
-
props: { label: 'Accessible toggle' },
|
|
78
|
-
});
|
|
79
|
-
await expectNoA11yViolations(container);
|
|
80
|
-
});
|
|
81
|
-
it('is axe-clean in the checked + disabled state', async () => {
|
|
82
|
-
const { container } = render(Toggle, {
|
|
83
|
-
props: { label: 'Locked on', checked: true, disabled: true },
|
|
84
|
-
});
|
|
85
|
-
await expectNoA11yViolations(container);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Camera session lifecycle against a fake `MediaDevices` (smrt#3290).
|
|
3
|
-
* Ported from teamworks-os `camera-capture-session.test.ts` and
|
|
4
|
-
* `camera-capture-logic.test.ts`.
|
|
5
|
-
*/
|
|
6
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
7
|
-
import { classifyGetUserMediaError, createCameraSession, isCameraApiSupported, } from '../camera-capture-session.js';
|
|
8
|
-
function fakeStream(tracks) {
|
|
9
|
-
return { getTracks: () => tracks };
|
|
10
|
-
}
|
|
11
|
-
function deferred() {
|
|
12
|
-
let resolve;
|
|
13
|
-
let reject;
|
|
14
|
-
const promise = new Promise((res, rej) => {
|
|
15
|
-
resolve = res;
|
|
16
|
-
reject = rej;
|
|
17
|
-
});
|
|
18
|
-
return { promise, resolve, reject };
|
|
19
|
-
}
|
|
20
|
-
describe('isCameraApiSupported', () => {
|
|
21
|
-
it('is false without navigator, mediaDevices, or getUserMedia', () => {
|
|
22
|
-
expect(isCameraApiSupported(undefined)).toBe(false);
|
|
23
|
-
expect(isCameraApiSupported({ mediaDevices: undefined })).toBe(false);
|
|
24
|
-
expect(isCameraApiSupported({ mediaDevices: {} })).toBe(false);
|
|
25
|
-
expect(isCameraApiSupported({ mediaDevices: { getUserMedia: 'nope' } })).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
it('is true when getUserMedia is a function', () => {
|
|
28
|
-
expect(isCameraApiSupported({
|
|
29
|
-
mediaDevices: { getUserMedia: async () => ({}) },
|
|
30
|
-
})).toBe(true);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('classifyGetUserMediaError', () => {
|
|
34
|
-
it.each([
|
|
35
|
-
'NotAllowedError',
|
|
36
|
-
'PermissionDeniedError',
|
|
37
|
-
'SecurityError',
|
|
38
|
-
])('maps %s to permission-denied', (name) => {
|
|
39
|
-
expect(classifyGetUserMediaError(new DOMException('x', name))).toBe('permission-denied');
|
|
40
|
-
});
|
|
41
|
-
it.each([
|
|
42
|
-
'NotFoundError',
|
|
43
|
-
'DevicesNotFoundError',
|
|
44
|
-
'OverconstrainedError',
|
|
45
|
-
])('maps %s to no-camera', (name) => {
|
|
46
|
-
expect(classifyGetUserMediaError(new DOMException('x', name))).toBe('no-camera');
|
|
47
|
-
});
|
|
48
|
-
it('maps unknown names and non-errors to error', () => {
|
|
49
|
-
expect(classifyGetUserMediaError(new DOMException('x', 'AbortError'))).toBe('error');
|
|
50
|
-
expect(classifyGetUserMediaError(new Error('boom'))).toBe('error');
|
|
51
|
-
expect(classifyGetUserMediaError('not an error')).toBe('error');
|
|
52
|
-
expect(classifyGetUserMediaError(null)).toBe('error');
|
|
53
|
-
expect(classifyGetUserMediaError({ name: 42 })).toBe('error');
|
|
54
|
-
});
|
|
55
|
-
it('reads name from a plain object, as browser DOMExceptions are not Errors', () => {
|
|
56
|
-
expect(classifyGetUserMediaError({ name: 'NotAllowedError' })).toBe('permission-denied');
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe('createCameraSession', () => {
|
|
60
|
-
it('reports unsupported without touching any API', async () => {
|
|
61
|
-
const session = createCameraSession({ mediaDevices: undefined });
|
|
62
|
-
await expect(session.start('environment')).resolves.toMatchObject({
|
|
63
|
-
ok: false,
|
|
64
|
-
kind: 'unsupported',
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it('classifies rejections and keeps the diagnostic message', async () => {
|
|
68
|
-
const denied = createCameraSession({
|
|
69
|
-
mediaDevices: {
|
|
70
|
-
getUserMedia: vi
|
|
71
|
-
.fn()
|
|
72
|
-
.mockRejectedValue(new DOMException('Permission denied', 'NotAllowedError')),
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
await expect(denied.start('environment')).resolves.toEqual({
|
|
76
|
-
ok: false,
|
|
77
|
-
kind: 'permission-denied',
|
|
78
|
-
message: 'Permission denied',
|
|
79
|
-
});
|
|
80
|
-
const missing = createCameraSession({
|
|
81
|
-
mediaDevices: {
|
|
82
|
-
getUserMedia: vi
|
|
83
|
-
.fn()
|
|
84
|
-
.mockRejectedValue(new DOMException('No device', 'NotFoundError')),
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
await expect(missing.start('environment')).resolves.toEqual({
|
|
88
|
-
ok: false,
|
|
89
|
-
kind: 'no-camera',
|
|
90
|
-
message: 'No device',
|
|
91
|
-
});
|
|
92
|
-
const odd = createCameraSession({
|
|
93
|
-
mediaDevices: { getUserMedia: vi.fn().mockRejectedValue('weird') },
|
|
94
|
-
});
|
|
95
|
-
await expect(odd.start('environment')).resolves.toMatchObject({
|
|
96
|
-
ok: false,
|
|
97
|
-
kind: 'error',
|
|
98
|
-
message: expect.any(String),
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
it('requests video only with the given facing mode and exposes the stream', async () => {
|
|
102
|
-
const stream = fakeStream([{ stop: vi.fn() }]);
|
|
103
|
-
const getUserMedia = vi.fn().mockResolvedValue(stream);
|
|
104
|
-
const session = createCameraSession({ mediaDevices: { getUserMedia } });
|
|
105
|
-
await expect(session.start('user')).resolves.toEqual({ ok: true, stream });
|
|
106
|
-
expect(session.stream).toBe(stream);
|
|
107
|
-
expect(getUserMedia).toHaveBeenCalledWith({
|
|
108
|
-
video: { facingMode: 'user' },
|
|
109
|
-
audio: false,
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
it('stops every track once and forgets the stream; stop is idempotent', async () => {
|
|
113
|
-
const a = { stop: vi.fn() };
|
|
114
|
-
const b = { stop: vi.fn() };
|
|
115
|
-
const session = createCameraSession({
|
|
116
|
-
mediaDevices: {
|
|
117
|
-
getUserMedia: vi.fn().mockResolvedValue(fakeStream([a, b])),
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
await session.start('environment');
|
|
121
|
-
session.stop();
|
|
122
|
-
session.stop();
|
|
123
|
-
expect(a.stop).toHaveBeenCalledTimes(1);
|
|
124
|
-
expect(b.stop).toHaveBeenCalledTimes(1);
|
|
125
|
-
expect(session.stream).toBeNull();
|
|
126
|
-
});
|
|
127
|
-
it('stop before any start is a safe no-op', () => {
|
|
128
|
-
const session = createCameraSession({ mediaDevices: undefined });
|
|
129
|
-
expect(() => session.stop()).not.toThrow();
|
|
130
|
-
expect(session.stream).toBeNull();
|
|
131
|
-
});
|
|
132
|
-
it('discards a stream granted after stop() and releases its tracks', async () => {
|
|
133
|
-
const pending = deferred();
|
|
134
|
-
const track = { stop: vi.fn() };
|
|
135
|
-
const session = createCameraSession({
|
|
136
|
-
mediaDevices: { getUserMedia: vi.fn().mockReturnValue(pending.promise) },
|
|
137
|
-
});
|
|
138
|
-
const result = session.start('environment');
|
|
139
|
-
session.stop();
|
|
140
|
-
pending.resolve(fakeStream([track]));
|
|
141
|
-
await expect(result).resolves.toMatchObject({
|
|
142
|
-
ok: false,
|
|
143
|
-
kind: 'cancelled',
|
|
144
|
-
});
|
|
145
|
-
expect(track.stop).toHaveBeenCalledTimes(1);
|
|
146
|
-
expect(session.stream).toBeNull();
|
|
147
|
-
});
|
|
148
|
-
it('discards a rejection that settles after stop()', async () => {
|
|
149
|
-
const pending = deferred();
|
|
150
|
-
const session = createCameraSession({
|
|
151
|
-
mediaDevices: { getUserMedia: vi.fn().mockReturnValue(pending.promise) },
|
|
152
|
-
});
|
|
153
|
-
const result = session.start('environment');
|
|
154
|
-
session.stop();
|
|
155
|
-
pending.reject(new DOMException('denied', 'NotAllowedError'));
|
|
156
|
-
await expect(result).resolves.toMatchObject({
|
|
157
|
-
ok: false,
|
|
158
|
-
kind: 'cancelled',
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
it('a newer start supersedes a pending one, so overlapping requests never leak', async () => {
|
|
162
|
-
const first = deferred();
|
|
163
|
-
const firstTrack = { stop: vi.fn() };
|
|
164
|
-
const secondStream = fakeStream([{ stop: vi.fn() }]);
|
|
165
|
-
const getUserMedia = vi
|
|
166
|
-
.fn()
|
|
167
|
-
.mockReturnValueOnce(first.promise)
|
|
168
|
-
.mockResolvedValueOnce(secondStream);
|
|
169
|
-
const session = createCameraSession({ mediaDevices: { getUserMedia } });
|
|
170
|
-
const stale = session.start('environment');
|
|
171
|
-
const fresh = session.start('user');
|
|
172
|
-
await expect(fresh).resolves.toEqual({ ok: true, stream: secondStream });
|
|
173
|
-
first.resolve(fakeStream([firstTrack]));
|
|
174
|
-
await expect(stale).resolves.toMatchObject({
|
|
175
|
-
ok: false,
|
|
176
|
-
kind: 'cancelled',
|
|
177
|
-
});
|
|
178
|
-
expect(firstTrack.stop).toHaveBeenCalledTimes(1);
|
|
179
|
-
expect(session.stream).toBe(secondStream);
|
|
180
|
-
});
|
|
181
|
-
it('starting again releases the held stream first', async () => {
|
|
182
|
-
const oldTrack = { stop: vi.fn() };
|
|
183
|
-
const getUserMedia = vi
|
|
184
|
-
.fn()
|
|
185
|
-
.mockResolvedValueOnce(fakeStream([oldTrack]))
|
|
186
|
-
.mockResolvedValueOnce(fakeStream([{ stop: vi.fn() }]));
|
|
187
|
-
const session = createCameraSession({ mediaDevices: { getUserMedia } });
|
|
188
|
-
await session.start('environment');
|
|
189
|
-
await session.start('environment');
|
|
190
|
-
expect(oldTrack.stop).toHaveBeenCalledTimes(1);
|
|
191
|
-
});
|
|
192
|
-
it('a fresh start after stop is not treated as stale', async () => {
|
|
193
|
-
const session = createCameraSession({
|
|
194
|
-
mediaDevices: {
|
|
195
|
-
getUserMedia: vi
|
|
196
|
-
.fn()
|
|
197
|
-
.mockResolvedValue(fakeStream([{ stop: vi.fn() }])),
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
await session.start('environment');
|
|
201
|
-
session.stop();
|
|
202
|
-
await expect(session.start('environment')).resolves.toMatchObject({
|
|
203
|
-
ok: true,
|
|
204
|
-
});
|
|
205
|
-
expect(session.stream).not.toBeNull();
|
|
206
|
-
});
|
|
207
|
-
});
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `createFormRetry()` around a form holding a named `CameraCapture` or
|
|
3
|
-
* `SignaturePad` (#3290, #3291), through the structural fake of SvelteKit's
|
|
4
|
-
* `use:enhance` from the form-retry tests.
|
|
5
|
-
*
|
|
6
|
-
* A successful submit of an unchanged form calls `update({ reset: true })`,
|
|
7
|
-
* which resets the form and so empties every native file input. The capture
|
|
8
|
-
* component must empty with it: otherwise it keeps showing the attachment
|
|
9
|
-
* while the next submit posts an empty file entry, and the person believes a
|
|
10
|
-
* photo or signature went with a record that has none.
|
|
11
|
-
*
|
|
12
|
-
* The reverse matters as much: a capture taken or replaced while the submit is
|
|
13
|
-
* in flight is an edit the server has never seen, so the success must NOT
|
|
14
|
-
* reset it. Under the `formdata`-event strategy the file lives in no element,
|
|
15
|
-
* only in the entry list, so `useBrowserFormData()` makes `new FormData(form)`
|
|
16
|
-
* fire `formdata` as browsers do.
|
|
17
|
-
*/
|
|
18
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/svelte';
|
|
19
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
20
|
-
import { fakeEnhance, fakeRunOnceServer, } from '../form-retry/__tests__/fake-kit.js';
|
|
21
|
-
import { createFormRetry } from '../form-retry/controller.js';
|
|
22
|
-
import { resetFormRetryMemory } from '../form-retry/submission-key.js';
|
|
23
|
-
import CaptureFormFixture from './capture-form.fixture.svelte';
|
|
24
|
-
import { fakeStream, installMediaDevices, removeMediaDevices, stubCanvas, stubMediaPlayback, useBrowserFormData, useFileFieldStrategy, } from './capture-test-env.js';
|
|
25
|
-
const FIELD = { camera: 'photo', signature: 'signature' };
|
|
26
|
-
const FILE = {
|
|
27
|
-
camera: 'file:photo.jpg',
|
|
28
|
-
signature: 'file:signature.png',
|
|
29
|
-
};
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
resetFormRetryMemory();
|
|
32
|
-
sessionStorage.clear();
|
|
33
|
-
stubCanvas();
|
|
34
|
-
stubMediaPlayback();
|
|
35
|
-
useBrowserFormData();
|
|
36
|
-
installMediaDevices({
|
|
37
|
-
getUserMedia: vi.fn().mockResolvedValue(fakeStream()),
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
afterEach(() => {
|
|
41
|
-
removeMediaDevices();
|
|
42
|
-
vi.restoreAllMocks();
|
|
43
|
-
vi.unstubAllGlobals();
|
|
44
|
-
});
|
|
45
|
-
function root(container) {
|
|
46
|
-
return container.querySelector('[data-state]');
|
|
47
|
-
}
|
|
48
|
-
async function expectState(container, state) {
|
|
49
|
-
await waitFor(() => expect(root(container)).toHaveAttribute('data-state', state));
|
|
50
|
-
}
|
|
51
|
-
async function commit(container, kind) {
|
|
52
|
-
if (kind === 'camera') {
|
|
53
|
-
await expectState(container, 'streaming');
|
|
54
|
-
await fireEvent.click(screen.getByRole('button', { name: 'Take photo' }));
|
|
55
|
-
await expectState(container, 'reviewing');
|
|
56
|
-
await fireEvent.click(screen.getByRole('button', { name: 'Use photo' }));
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const canvas = container.querySelector('canvas');
|
|
60
|
-
await fireEvent.pointerDown(canvas, { pointerType: 'mouse', pointerId: 1 });
|
|
61
|
-
await fireEvent.pointerMove(canvas, {
|
|
62
|
-
pointerType: 'mouse',
|
|
63
|
-
pointerId: 1,
|
|
64
|
-
clientX: 40,
|
|
65
|
-
clientY: 20,
|
|
66
|
-
});
|
|
67
|
-
await fireEvent.pointerUp(canvas, { pointerType: 'mouse', pointerId: 1 });
|
|
68
|
-
await fireEvent.click(screen.getByRole('button', { name: 'Use signature' }));
|
|
69
|
-
}
|
|
70
|
-
await expectState(container, 'committed');
|
|
71
|
-
}
|
|
72
|
-
/** Discard the committed capture as the person would, then commit another. */
|
|
73
|
-
async function replace(container, kind) {
|
|
74
|
-
// A different photo or signature: different bytes, so a different file.
|
|
75
|
-
vi.mocked(HTMLCanvasElement.prototype.toBlob).mockImplementation((callback, type) => callback(new Blob(['other pixels'], { type })));
|
|
76
|
-
await fireEvent.click(screen.getByRole('button', {
|
|
77
|
-
name: kind === 'camera' ? 'Retake' : 'Clear',
|
|
78
|
-
}));
|
|
79
|
-
await commit(container, kind);
|
|
80
|
-
}
|
|
81
|
-
function setup(kind, strategy) {
|
|
82
|
-
useFileFieldStrategy(strategy);
|
|
83
|
-
const onClear = vi.fn();
|
|
84
|
-
const view = render(CaptureFormFixture, {
|
|
85
|
-
props: { kind, name: FIELD[kind], onClear },
|
|
86
|
-
});
|
|
87
|
-
const form = view.container.querySelector('form');
|
|
88
|
-
const server = fakeRunOnceServer();
|
|
89
|
-
const retry = createFormRetry({ form: `capture-${kind}`, storage: null });
|
|
90
|
-
retry.attach(form);
|
|
91
|
-
const kit = fakeEnhance(form, retry.enhance(), server);
|
|
92
|
-
return { ...view, form, server, retry, kit, onClear };
|
|
93
|
-
}
|
|
94
|
-
const CASES = [
|
|
95
|
-
['camera', 'data-transfer'],
|
|
96
|
-
['camera', 'formdata-event'],
|
|
97
|
-
['signature', 'data-transfer'],
|
|
98
|
-
['signature', 'formdata-event'],
|
|
99
|
-
];
|
|
100
|
-
describe('createFormRetry with a capture field', () => {
|
|
101
|
-
it.each(CASES)('a successful submit clears the %s (%s), so the next submit cannot post a shown-but-empty attachment', async (kind, strategy) => {
|
|
102
|
-
const name = FIELD[kind];
|
|
103
|
-
const { container, server, retry, kit, onClear } = setup(kind, strategy);
|
|
104
|
-
await waitFor(() => expect(root(container)).toHaveAttribute('data-smrt-file-field', strategy));
|
|
105
|
-
await commit(container, kind);
|
|
106
|
-
await kit.submit();
|
|
107
|
-
expect(retry.state.status).toBe('success');
|
|
108
|
-
expect(kit.updates).toEqual([{ reset: true }]);
|
|
109
|
-
expect(server.rows).toHaveLength(1);
|
|
110
|
-
expect(server.rows[0].fields[name]).toEqual([FILE[kind]]);
|
|
111
|
-
// The reset reached the component: nothing is shown, onClear fired.
|
|
112
|
-
await expectState(container, kind === 'camera' ? 'streaming' : 'empty');
|
|
113
|
-
expect(onClear).toHaveBeenCalledTimes(1);
|
|
114
|
-
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
115
|
-
// The next submit posts what is shown: no file, and not the old one.
|
|
116
|
-
await kit.submit();
|
|
117
|
-
expect(server.rows).toHaveLength(2);
|
|
118
|
-
expect(server.rows[1].fields[name]).toEqual(['file:']);
|
|
119
|
-
// A new capture posts as its own record.
|
|
120
|
-
await commit(container, kind);
|
|
121
|
-
await kit.submit();
|
|
122
|
-
expect(server.rows).toHaveLength(3);
|
|
123
|
-
expect(server.rows[2].fields[name]).toEqual([FILE[kind]]);
|
|
124
|
-
});
|
|
125
|
-
it.each(CASES)('keeps a %s (%s) captured while the submit was in flight', async (kind, strategy) => {
|
|
126
|
-
const name = FIELD[kind];
|
|
127
|
-
const { container, server, retry, kit, onClear } = setup(kind, strategy);
|
|
128
|
-
await waitFor(() => expect(root(container)).toHaveAttribute('data-smrt-file-field', strategy));
|
|
129
|
-
const held = server.hold();
|
|
130
|
-
const first = kit.submit();
|
|
131
|
-
await vi.waitFor(() => expect(retry.state.status).toBe('submitting'));
|
|
132
|
-
// The next entry's capture is taken while the first is unresolved.
|
|
133
|
-
await commit(container, kind);
|
|
134
|
-
held.release();
|
|
135
|
-
await first;
|
|
136
|
-
expect(kit.updates).toEqual([{ reset: false }]);
|
|
137
|
-
expect(root(container)).toHaveAttribute('data-state', 'committed');
|
|
138
|
-
expect(onClear).not.toHaveBeenCalled();
|
|
139
|
-
await kit.submit();
|
|
140
|
-
expect(server.rows.at(-1)?.fields[name]).toEqual([FILE[kind]]);
|
|
141
|
-
});
|
|
142
|
-
it.each(CASES)('keeps a %s (%s) replaced while the submit was in flight', async (kind, strategy) => {
|
|
143
|
-
const name = FIELD[kind];
|
|
144
|
-
const { container, server, retry, kit, onClear } = setup(kind, strategy);
|
|
145
|
-
await waitFor(() => expect(root(container)).toHaveAttribute('data-smrt-file-field', strategy));
|
|
146
|
-
await commit(container, kind);
|
|
147
|
-
const held = server.hold();
|
|
148
|
-
const first = kit.submit();
|
|
149
|
-
await vi.waitFor(() => expect(retry.state.status).toBe('submitting'));
|
|
150
|
-
await replace(container, kind);
|
|
151
|
-
expect(onClear).toHaveBeenCalledTimes(1);
|
|
152
|
-
held.release();
|
|
153
|
-
await first;
|
|
154
|
-
// The first capture was recorded; the newer one is an unsent edit, so the
|
|
155
|
-
// success must leave it on screen and in the field.
|
|
156
|
-
expect(server.rows[0].fields[name]).toEqual([FILE[kind]]);
|
|
157
|
-
expect(kit.updates).toEqual([{ reset: false }]);
|
|
158
|
-
expect(root(container)).toHaveAttribute('data-state', 'committed');
|
|
159
|
-
expect(onClear).toHaveBeenCalledTimes(1);
|
|
160
|
-
await kit.submit();
|
|
161
|
-
const sent = server.requests.at(-1)?.get(name);
|
|
162
|
-
expect(sent.name).toBe(FILE[kind].slice('file:'.length));
|
|
163
|
-
expect(sent.size).toBe('other pixels'.length);
|
|
164
|
-
expect(server.rows).toHaveLength(2);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import CameraCapture from '../CameraCapture.svelte';
|
|
3
|
-
import SignaturePad from '../SignaturePad.svelte';
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
kind,
|
|
7
|
-
inFieldset = false,
|
|
8
|
-
...props
|
|
9
|
-
}: {
|
|
10
|
-
kind: 'camera' | 'signature';
|
|
11
|
-
/** Wrap the component in a `<fieldset>` the test can disable. */
|
|
12
|
-
inFieldset?: boolean;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
} = $props();
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
{#snippet capture()}
|
|
18
|
-
{#if kind === 'camera'}
|
|
19
|
-
<CameraCapture {...props} />
|
|
20
|
-
{:else}
|
|
21
|
-
<SignaturePad {...props} />
|
|
22
|
-
{/if}
|
|
23
|
-
{/snippet}
|
|
24
|
-
|
|
25
|
-
<!-- A plain native form: no submit handler, no hidden inputs wired by the caller. -->
|
|
26
|
-
<form method="POST" enctype="multipart/form-data" action="/submit">
|
|
27
|
-
<input type="hidden" name="note" value="hazard" />
|
|
28
|
-
{#if inFieldset}
|
|
29
|
-
<fieldset>
|
|
30
|
-
<legend>Capture</legend>
|
|
31
|
-
{@render capture()}
|
|
32
|
-
</fieldset>
|
|
33
|
-
{:else}
|
|
34
|
-
{@render capture()}
|
|
35
|
-
{/if}
|
|
36
|
-
<button type="submit">Submit</button>
|
|
37
|
-
<button type="reset">Reset form</button>
|
|
38
|
-
</form>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type $$ComponentProps = {
|
|
2
|
-
kind: 'camera' | 'signature';
|
|
3
|
-
/** Wrap the component in a `<fieldset>` the test can disable. */
|
|
4
|
-
inFieldset?: boolean;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
};
|
|
7
|
-
declare const CaptureForm: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
-
type CaptureForm = ReturnType<typeof CaptureForm>;
|
|
9
|
-
export default CaptureForm;
|
|
10
|
-
//# sourceMappingURL=capture-form.fixture.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capture-form.fixture.svelte.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/__tests__/capture-form.fixture.svelte.ts"],"names":[],"mappings":"AAMC,KAAK,gBAAgB,GAAI;IACxB,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC7B,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAqCF,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* jsdom stand-ins for the browser APIs `CameraCapture` and `SignaturePad` use
|
|
3
|
-
* (smrt#3290). jsdom has no `DataTransfer`, no canvas, no media playback and
|
|
4
|
-
* never fires the `formdata` event, so each is supplied here, as close to the
|
|
5
|
-
* browser contract as the tests need.
|
|
6
|
-
*/
|
|
7
|
-
import { type Mock } from 'vitest';
|
|
8
|
-
/**
|
|
9
|
-
* A real jsdom `FileList` holding `files`. jsdom's `input.files` setter only
|
|
10
|
-
* accepts genuine `FileList` instances and exposes no constructor, so the list
|
|
11
|
-
* is taken from a detached file input and filled through its implementation
|
|
12
|
-
* object. This keeps `new FormData(form)` reading the files exactly as a
|
|
13
|
-
* browser would after `input.files = dataTransfer.files`.
|
|
14
|
-
*/
|
|
15
|
-
export declare function createFileList(files: File[]): FileList;
|
|
16
|
-
/** Browser-shaped `DataTransfer` for jsdom: `items.add()` plus a real `files`. */
|
|
17
|
-
export declare class TestDataTransfer {
|
|
18
|
-
#private;
|
|
19
|
-
readonly items: {
|
|
20
|
-
add: (file: File) => null;
|
|
21
|
-
};
|
|
22
|
-
get files(): FileList;
|
|
23
|
-
}
|
|
24
|
-
/** Marker constructor: its presence is what feature detection reads. */
|
|
25
|
-
export declare class TestFormDataEvent {
|
|
26
|
-
}
|
|
27
|
-
/** Select the posting strategy the component will detect on mount. */
|
|
28
|
-
export declare function useFileFieldStrategy(strategy: 'data-transfer' | 'formdata-event' | 'none'): void;
|
|
29
|
-
/**
|
|
30
|
-
* The entry list a native submit of `form` would send: what `new FormData`
|
|
31
|
-
* builds, plus the browser's `formdata` event (which jsdom never fires) so the
|
|
32
|
-
* fallback strategy's listener can contribute.
|
|
33
|
-
*/
|
|
34
|
-
export declare function submittedEntries(form: HTMLFormElement): FormData;
|
|
35
|
-
/**
|
|
36
|
-
* Make `new FormData(form)` fire `formdata` on the form, as browsers do while
|
|
37
|
-
* constructing the entry list (jsdom does not), so code that snapshots a form
|
|
38
|
-
* — SvelteKit's `enhance`, form-retry's draft comparison — sees files the
|
|
39
|
-
* `formdata`-event strategy appends. Do not combine with
|
|
40
|
-
* {@link submittedEntries}, which dispatches the event itself.
|
|
41
|
-
*/
|
|
42
|
-
export declare function useBrowserFormData(): void;
|
|
43
|
-
/** Canvas 2D, `toBlob` and `toDataURL` stubs. Returns the fake context. */
|
|
44
|
-
/** The canvas 2D surface the capture components touch. */
|
|
45
|
-
export interface FakeCanvasContext {
|
|
46
|
-
drawImage: Mock;
|
|
47
|
-
fillRect: Mock;
|
|
48
|
-
beginPath: Mock;
|
|
49
|
-
moveTo: Mock;
|
|
50
|
-
lineTo: Mock;
|
|
51
|
-
stroke: Mock;
|
|
52
|
-
fillStyle: string;
|
|
53
|
-
strokeStyle: string;
|
|
54
|
-
lineWidth: number;
|
|
55
|
-
lineCap: string;
|
|
56
|
-
lineJoin: string;
|
|
57
|
-
}
|
|
58
|
-
export declare function stubCanvas(): FakeCanvasContext;
|
|
59
|
-
/** `play()` is unimplemented in jsdom; resolve it like an allowed autoplay. */
|
|
60
|
-
export declare function stubMediaPlayback(): void;
|
|
61
|
-
export interface FakeTrack {
|
|
62
|
-
stop: Mock;
|
|
63
|
-
}
|
|
64
|
-
export declare function fakeStream(tracks?: FakeTrack[]): MediaStream;
|
|
65
|
-
/** Install `navigator.mediaDevices` (or remove it with `undefined`). */
|
|
66
|
-
export declare function installMediaDevices(mediaDevices: {
|
|
67
|
-
getUserMedia: (...args: unknown[]) => unknown;
|
|
68
|
-
} | undefined): void;
|
|
69
|
-
export declare function removeMediaDevices(): void;
|
|
70
|
-
//# sourceMappingURL=capture-test-env.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capture-test-env.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/__tests__/capture-test-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,IAAI,EAAM,MAAM,QAAQ,CAAC;AAYvC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,CAWtD;AAED,kFAAkF;AAClF,qBAAa,gBAAgB;;IAE3B,QAAQ,CAAC,KAAK;oBACA,IAAI;MAIhB;IACF,IAAI,KAAK,IAAI,QAAQ,CAEpB;CACF;AAED,wEAAwE;AACxE,qBAAa,iBAAiB;CAAG;AAEjC,sEAAsE;AACtE,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,GAAG,gBAAgB,GAAG,MAAM,GACpD,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,QAAQ,CAMhE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAYzC;AAED,2EAA2E;AAC3E,0DAA0D;AAC1D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,UAAU,IAAI,iBAAiB,CA0B9C;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,UAAU,CAAC,MAAM,GAAE,SAAS,EAAwB,GACjB,WAAW,CAC7D;AAED,wEAAwE;AACxE,wBAAgB,mBAAmB,CACjC,YAAY,EAAE;IAAE,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;CAAE,GAAG,SAAS,GAC1E,IAAI,CAKN;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|