@delacour/react-native-ui 0.6.0-alpha.20261103164139 → 0.6.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/package.json +13 -7
- package/src/components/accordion/AGENTS.md +1 -0
- package/src/components/accordion/accordion.render.test.tsx +330 -0
- package/src/components/alert/AGENTS.md +1 -0
- package/src/components/alert/alert.render.test.tsx +162 -0
- package/src/components/animated-badge/AGENTS.md +1 -0
- package/src/components/animated-badge/animated-badge.render.test.tsx +136 -0
- package/src/components/attachment/AGENTS.md +1 -0
- package/src/components/attachment/attachment.render.test.tsx +422 -0
- package/src/components/avatar/AGENTS.md +1 -0
- package/src/components/avatar/avatar.render.test.tsx +353 -0
- package/src/components/badge/AGENTS.md +1 -0
- package/src/components/badge/badge.render.test.tsx +216 -0
- package/src/components/bottom-sheet/AGENTS.md +1 -0
- package/src/components/bottom-sheet/bottom-sheet.render.test.tsx +190 -0
- package/src/components/breadcrumb/AGENTS.md +1 -0
- package/src/components/breadcrumb/breadcrumb.render.test.tsx +324 -0
- package/src/components/button/AGENTS.md +1 -0
- package/src/components/button/button.render.test.tsx +67 -0
- package/src/components/calendar/AGENTS.md +1 -0
- package/src/components/calendar/calendar.render.test.tsx +388 -0
- package/src/components/card/AGENTS.md +1 -0
- package/src/components/card/card.render.test.tsx +287 -0
- package/src/components/carousel/AGENTS.md +3 -0
- package/src/components/carousel/carousel-content.tsx +3 -1
- package/src/components/carousel/carousel.render.test.tsx +356 -0
- package/src/components/chart/AGENTS.md +1 -0
- package/src/components/chart/chart.render.test.tsx +443 -0
- package/src/components/checkbox/AGENTS.md +2 -0
- package/src/components/checkbox/checkbox.render.test.tsx +250 -0
- package/src/components/checkbox/checkbox.tsx +2 -1
- package/src/components/chip/chip.render.test.tsx +277 -0
- package/src/components/circular-text/AGENTS.md +1 -0
- package/src/components/circular-text/circular-text.render.test.tsx +154 -0
- package/src/components/collapsible/AGENTS.md +1 -0
- package/src/components/collapsible/collapsible.render.test.tsx +243 -0
- package/src/components/color-picker/AGENTS.md +1 -0
- package/src/components/color-picker/color-picker.render.test.tsx +347 -0
- package/src/components/combobox/AGENTS.md +1 -0
- package/src/components/combobox/combobox.render.test.tsx +464 -0
- package/src/components/compare/AGENTS.md +1 -0
- package/src/components/compare/compare.render.test.tsx +265 -0
- package/src/components/context-menu/AGENTS.md +1 -0
- package/src/components/context-menu/context-menu.render.test.tsx +183 -0
- package/src/components/countdown/AGENTS.md +1 -0
- package/src/components/countdown/countdown.render.test.tsx +194 -0
- package/src/components/date-picker/AGENTS.md +1 -0
- package/src/components/date-picker/date-picker.render.test.tsx +378 -0
- package/src/components/date-time-picker/AGENTS.md +1 -0
- package/src/components/date-time-picker/date-time-picker.render.test.tsx +356 -0
- package/src/components/dialog/AGENTS.md +1 -0
- package/src/components/dialog/dialog.render.test.tsx +67 -0
- package/src/components/direction/AGENTS.md +1 -0
- package/src/components/direction/direction.render.test.tsx +150 -0
- package/src/components/drawer/AGENTS.md +1 -0
- package/src/components/drawer/drawer.render.test.tsx +340 -0
- package/src/components/empty-state/AGENTS.md +1 -0
- package/src/components/empty-state/empty-state.render.test.tsx +134 -0
- package/src/components/fab/AGENTS.md +1 -0
- package/src/components/fab/fab.render.test.tsx +278 -0
- package/src/components/feedback/AGENTS.md +1 -0
- package/src/components/feedback/feedback.render.test.tsx +257 -0
- package/src/components/field/AGENTS.md +1 -0
- package/src/components/field/field.render.test.tsx +361 -0
- package/src/components/flip-card/AGENTS.md +1 -0
- package/src/components/flip-card/flip-card.render.test.tsx +259 -0
- package/src/components/flow/AGENTS.md +1 -0
- package/src/components/flow/flow.render.test.tsx +354 -0
- package/src/components/frame/AGENTS.md +1 -0
- package/src/components/frame/frame.render.test.tsx +273 -0
- package/src/components/grid-item/AGENTS.md +1 -0
- package/src/components/grid-item/grid-item.render.test.tsx +326 -0
- package/src/components/icon/AGENTS.md +1 -0
- package/src/components/icon/icon.render.test.tsx +110 -0
- package/src/components/image-viewer/AGENTS.md +5 -0
- package/src/components/image-viewer/image-viewer.render.test.tsx +244 -0
- package/src/components/image-viewer/image-viewer.tsx +6 -3
- package/src/components/input/AGENTS.md +1 -0
- package/src/components/input/input.render.test.tsx +246 -0
- package/src/components/item/AGENTS.md +1 -0
- package/src/components/item/item.render.test.tsx +276 -0
- package/src/components/kpi/AGENTS.md +1 -0
- package/src/components/kpi/kpi.render.test.tsx +232 -0
- package/src/components/label/AGENTS.md +1 -0
- package/src/components/label/label.render.test.tsx +81 -0
- package/src/components/leaderboard/AGENTS.md +1 -0
- package/src/components/leaderboard/leaderboard.render.test.tsx +198 -0
- package/src/components/list-group/AGENTS.md +1 -0
- package/src/components/list-group/list-group.render.test.tsx +279 -0
- package/src/components/map/AGENTS.md +1 -0
- package/src/components/map/map.render.test.tsx +460 -0
- package/src/components/markdown-editor/AGENTS.md +1 -0
- package/src/components/markdown-editor/markdown-editor.render.test.tsx +461 -0
- package/src/components/marker/AGENTS.md +1 -0
- package/src/components/marker/marker.render.test.tsx +232 -0
- package/src/components/marquee/AGENTS.md +1 -0
- package/src/components/marquee/marquee.render.test.tsx +145 -0
- package/src/components/menu/AGENTS.md +2 -0
- package/src/components/menu/menu-item.tsx +40 -1
- package/src/components/menu/menu.render.test.tsx +449 -0
- package/src/components/message/AGENTS.md +1 -0
- package/src/components/message/message.render.test.tsx +401 -0
- package/src/components/message-scroller/AGENTS.md +1 -0
- package/src/components/message-scroller/message-scroller.render.test.tsx +295 -0
- package/src/components/meter/AGENTS.md +1 -0
- package/src/components/meter/meter.render.test.tsx +249 -0
- package/src/components/number-input/AGENTS.md +2 -0
- package/src/components/number-input/number-input-field.tsx +3 -2
- package/src/components/number-input/number-input.render.test.tsx +426 -0
- package/src/components/otp-input/AGENTS.md +3 -0
- package/src/components/otp-input/otp-input.render.test.tsx +405 -0
- package/src/components/otp-input/otp-input.tsx +9 -2
- package/src/components/overlay/AGENTS.md +7 -1
- package/src/components/overlay/overlay-teleport.ts +21 -0
- package/src/components/overlay/overlay.render.test.tsx +367 -0
- package/src/components/overlay/overlay.tsx +5 -2
- package/src/components/page-header/AGENTS.md +1 -0
- package/src/components/page-header/page-header.render.test.tsx +217 -0
- package/src/components/pagination/AGENTS.md +1 -0
- package/src/components/pagination/pagination.render.test.tsx +293 -0
- package/src/components/planner/AGENTS.md +1 -0
- package/src/components/planner/planner.render.test.tsx +429 -0
- package/src/components/popover/AGENTS.md +1 -0
- package/src/components/popover/popover.render.test.tsx +206 -0
- package/src/components/post/AGENTS.md +4 -0
- package/src/components/post/post-author.tsx +8 -1
- package/src/components/post/post-community.tsx +7 -1
- package/src/components/post/post.render.test.tsx +456 -0
- package/src/components/pressable/AGENTS.md +7 -0
- package/src/components/pressable/pressable.render.test.tsx +183 -0
- package/src/components/pressable/pressable.tsx +1 -1
- package/src/components/progress/AGENTS.md +1 -0
- package/src/components/progress/progress.render.test.tsx +192 -0
- package/src/components/progress-button/AGENTS.md +1 -0
- package/src/components/progress-button/progress-button.render.test.tsx +251 -0
- package/src/components/provider/AGENTS.md +1 -0
- package/src/components/provider/provider.render.test.tsx +101 -0
- package/src/components/qr-code/AGENTS.md +1 -0
- package/src/components/qr-code/qr-code.render.test.tsx +117 -0
- package/src/components/questionnaire/AGENTS.md +1 -0
- package/src/components/questionnaire/questionnaire.render.test.tsx +549 -0
- package/src/components/radio/AGENTS.md +1 -0
- package/src/components/radio/radio.render.test.tsx +334 -0
- package/src/components/rating/AGENTS.md +5 -0
- package/src/components/rating/rating-stars.tsx +4 -0
- package/src/components/rating/rating.render.test.tsx +402 -0
- package/src/components/screen/AGENTS.md +9 -0
- package/src/components/screen/screen-error.tsx +3 -1
- package/src/components/screen/screen-navbar-title.tsx +6 -1
- package/src/components/screen/screen.render.test.tsx +309 -0
- package/src/components/scroll-blur/AGENTS.md +1 -0
- package/src/components/scroll-blur/scroll-blur.render.test.tsx +197 -0
- package/src/components/scroll-canvas/AGENTS.md +1 -0
- package/src/components/scroll-canvas/scroll-canvas.render.test.tsx +184 -0
- package/src/components/scroll-fade/AGENTS.md +1 -0
- package/src/components/scroll-fade/scroll-fade-edge.tsx +1 -0
- package/src/components/scroll-fade/scroll-fade.render.test.tsx +122 -0
- package/src/components/scroll-header/AGENTS.md +1 -0
- package/src/components/scroll-header/scroll-header.render.test.tsx +168 -0
- package/src/components/scroll-text/AGENTS.md +1 -0
- package/src/components/scroll-text/scroll-text.render.test.tsx +191 -0
- package/src/components/search-bar/AGENTS.md +1 -0
- package/src/components/search-bar/search-bar.render.test.tsx +377 -0
- package/src/components/section-progress/AGENTS.md +1 -0
- package/src/components/section-progress/section-progress.render.test.tsx +186 -0
- package/src/components/section-rail/AGENTS.md +1 -0
- package/src/components/section-rail/section-rail.render.test.tsx +341 -0
- package/src/components/select/AGENTS.md +1 -0
- package/src/components/select/select.render.test.tsx +466 -0
- package/src/components/selection-mode/AGENTS.md +1 -0
- package/src/components/selection-mode/selection-mode.render.test.tsx +487 -0
- package/src/components/separator/AGENTS.md +1 -0
- package/src/components/separator/separator.render.test.tsx +43 -0
- package/src/components/signature/AGENTS.md +4 -0
- package/src/components/signature/signature-pad.tsx +4 -0
- package/src/components/signature/signature.render.test.tsx +257 -0
- package/src/components/skeleton/AGENTS.md +2 -1
- package/src/components/skeleton/skeleton.render.test.tsx +222 -0
- package/src/components/sketch/AGENTS.md +2 -0
- package/src/components/sketch/sketch-canvas.tsx +4 -0
- package/src/components/sketch/sketch.render.test.tsx +527 -0
- package/src/components/slide-button/AGENTS.md +2 -0
- package/src/components/slide-button/slide-button.render.test.tsx +354 -0
- package/src/components/slide-button/slide-button.tsx +4 -0
- package/src/components/slider/AGENTS.md +12 -0
- package/src/components/slider/slider-thumb.tsx +2 -1
- package/src/components/slider/slider-track.tsx +4 -1
- package/src/components/slider/slider.render.test.tsx +254 -0
- package/src/components/slider/slider.tsx +11 -0
- package/src/components/sortable/AGENTS.md +2 -0
- package/src/components/sortable/sortable-item.tsx +2 -1
- package/src/components/sortable/sortable.render.test.tsx +204 -0
- package/src/components/spinner/AGENTS.md +3 -0
- package/src/components/spinner/spinner.render.test.tsx +88 -0
- package/src/components/spinner/spinner.tsx +1 -0
- package/src/components/split-view/AGENTS.md +1 -0
- package/src/components/split-view/split-view-drag-area.tsx +2 -0
- package/src/components/split-view/split-view.render.test.tsx +423 -0
- package/src/components/splitter/AGENTS.md +7 -0
- package/src/components/splitter/splitter-handle.tsx +2 -0
- package/src/components/splitter/splitter.render.test.tsx +307 -0
- package/src/components/stack-card/AGENTS.md +3 -0
- package/src/components/stack-card/stack-card.render.test.tsx +309 -0
- package/src/components/stack-card/stack-card.tsx +1 -1
- package/src/components/steps/AGENTS.md +1 -0
- package/src/components/steps/steps.render.test.tsx +318 -0
- package/src/components/support/AGENTS.md +1 -0
- package/src/components/support/support.render.test.tsx +331 -0
- package/src/components/surface/AGENTS.md +1 -0
- package/src/components/surface/surface.render.test.tsx +129 -0
- package/src/components/swipe/AGENTS.md +3 -0
- package/src/components/swipe/swipe.render.test.tsx +280 -0
- package/src/components/swipe/swipe.tsx +7 -4
- package/src/components/switch/AGENTS.md +5 -0
- package/src/components/switch/switch.render.test.tsx +46 -0
- package/src/components/switch/switch.tsx +5 -1
- package/src/components/table/AGENTS.md +1 -0
- package/src/components/table/table.render.test.tsx +294 -0
- package/src/components/tabs/AGENTS.md +6 -0
- package/src/components/tabs/tabs.render.test.tsx +325 -0
- package/src/components/tabs/tabs.tsx +12 -1
- package/src/components/tag-input/AGENTS.md +1 -0
- package/src/components/tag-input/tag-input.render.test.tsx +655 -0
- package/src/components/text/AGENTS.md +1 -0
- package/src/components/text/text.render.test.tsx +197 -0
- package/src/components/text-animation/AGENTS.md +1 -0
- package/src/components/text-animation/text-animation.render.test.tsx +283 -0
- package/src/components/textarea/AGENTS.md +1 -0
- package/src/components/textarea/textarea.render.test.tsx +192 -0
- package/src/components/theme-selector/AGENTS.md +1 -0
- package/src/components/theme-selector/theme-selector.render.test.tsx +196 -0
- package/src/components/time-picker/AGENTS.md +1 -0
- package/src/components/time-picker/time-picker.render.test.tsx +466 -0
- package/src/components/timeline/AGENTS.md +1 -0
- package/src/components/timeline/timeline.render.test.tsx +316 -0
- package/src/components/toast/AGENTS.md +1 -0
- package/src/components/toast/toast.render.test.tsx +245 -0
- package/src/components/toggle-button/AGENTS.md +1 -0
- package/src/components/toggle-button/toggle-button.render.test.tsx +392 -0
- package/src/components/tooltip/AGENTS.md +1 -0
- package/src/components/tooltip/tooltip.render.test.tsx +231 -0
- package/src/components/tour/AGENTS.md +1 -0
- package/src/components/tour/tour.render.test.tsx +217 -0
- package/src/components/tree/AGENTS.md +1 -0
- package/src/components/tree/tree.render.test.tsx +395 -0
- package/src/display-name.test.ts +9 -3
- package/src/render-tests.test.ts +27 -0
- package/src/test/AGENTS.md +121 -0
- package/src/test/render.tsx +22 -0
- package/src/test/setup.ts +142 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import { createRef } from "react";
|
|
3
|
+
import { AccessibilityInfo } from "react-native";
|
|
4
|
+
import { fireGestureHandler, getByGestureTestId } from "react-native-gesture-handler/jest-utils";
|
|
5
|
+
import { act, fireEvent, renderWithProviders, screen } from "../../test/render";
|
|
6
|
+
import { Field } from "../field";
|
|
7
|
+
import { Signature } from "./signature";
|
|
8
|
+
import type { SignatureHandle, SignatureValue } from "./signature.types";
|
|
9
|
+
import { SIGNATURE_PAD_GESTURE_ID } from "./signature-pad";
|
|
10
|
+
|
|
11
|
+
const TWO_STROKES: SignatureValue = {
|
|
12
|
+
width: 200,
|
|
13
|
+
height: 100,
|
|
14
|
+
strokes: [
|
|
15
|
+
[
|
|
16
|
+
{ x: 10, y: 10 },
|
|
17
|
+
{ x: 50, y: 40 },
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
{ x: 60, y: 20 },
|
|
21
|
+
{ x: 90, y: 60 },
|
|
22
|
+
],
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const ONE_STROKE: SignatureValue = { width: 200, height: 100, strokes: [TWO_STROKES.strokes[0] ?? []] };
|
|
27
|
+
|
|
28
|
+
/** Draws one stroke by driving the pad's pan the way Gesture Handler would. */
|
|
29
|
+
async function drawStroke(): Promise<void> {
|
|
30
|
+
await fireGestureHandler(getByGestureTestId(SIGNATURE_PAD_GESTURE_ID), [
|
|
31
|
+
{ x: 10, y: 10 },
|
|
32
|
+
{ x: 40, y: 30 },
|
|
33
|
+
{ x: 80, y: 50 },
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function activate(name: string): Promise<void> {
|
|
38
|
+
await fireEvent(screen.getByRole("button", { name }), "accessibilityTap");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe("Signature", () => {
|
|
42
|
+
test("an empty pad describes itself and offers no actions", async () => {
|
|
43
|
+
await renderWithProviders(<Signature />);
|
|
44
|
+
const pad = screen.getByLabelText("Signature pad, empty");
|
|
45
|
+
expect(pad).toBeOnTheScreen();
|
|
46
|
+
expect(pad.props.accessibilityActions ?? []).toHaveLength(0);
|
|
47
|
+
expect(screen.getByText("Sign here")).toBeOnTheScreen();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("a drawn pad counts its strokes and offers undo and clear", async () => {
|
|
51
|
+
await renderWithProviders(<Signature defaultValue={TWO_STROKES} />);
|
|
52
|
+
const pad = screen.getByLabelText("Signature, drawn, 2 strokes");
|
|
53
|
+
expect(pad).toBeOnTheScreen();
|
|
54
|
+
expect(pad.props.accessibilityRole).toBe("image");
|
|
55
|
+
const names = (pad.props.accessibilityActions as { name: string }[]).map((action) => action.name);
|
|
56
|
+
expect(names).toEqual(["undo", "clear"]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("one stroke is announced in the singular", async () => {
|
|
60
|
+
await renderWithProviders(<Signature defaultValue={ONE_STROKE} />);
|
|
61
|
+
expect(screen.getByLabelText("Signature, drawn, 1 stroke")).toBeOnTheScreen();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("an enclosing Field's label names the pad", async () => {
|
|
65
|
+
await renderWithProviders(
|
|
66
|
+
<Field>
|
|
67
|
+
<Field.Label>Witness</Field.Label>
|
|
68
|
+
<Signature defaultValue={ONE_STROKE} />
|
|
69
|
+
</Field>
|
|
70
|
+
);
|
|
71
|
+
expect(screen.getByLabelText("Witness, drawn, 1 stroke")).toBeOnTheScreen();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("the toolbar disables what would do nothing", async () => {
|
|
75
|
+
await renderWithProviders(
|
|
76
|
+
<Signature>
|
|
77
|
+
<Signature.Pad />
|
|
78
|
+
<Signature.Toolbar>
|
|
79
|
+
<Signature.Undo />
|
|
80
|
+
<Signature.Redo />
|
|
81
|
+
<Signature.Clear />
|
|
82
|
+
</Signature.Toolbar>
|
|
83
|
+
</Signature>
|
|
84
|
+
);
|
|
85
|
+
expect(screen.getByRole("button", { name: "Undo" })).toBeDisabled();
|
|
86
|
+
expect(screen.getByRole("button", { name: "Redo" })).toBeDisabled();
|
|
87
|
+
expect(screen.getByRole("button", { name: "Clear signature" })).toBeDisabled();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("a drawn stroke fires onBegin, onEnd and onValueChange once", async () => {
|
|
91
|
+
const onBegin = jest.fn();
|
|
92
|
+
const onEnd = jest.fn();
|
|
93
|
+
const onValueChange = jest.fn();
|
|
94
|
+
const announce = jest.spyOn(AccessibilityInfo, "announceForAccessibility").mockImplementation(() => undefined);
|
|
95
|
+
await renderWithProviders(<Signature onBegin={onBegin} onEnd={onEnd} onValueChange={onValueChange} />);
|
|
96
|
+
|
|
97
|
+
await drawStroke();
|
|
98
|
+
|
|
99
|
+
expect(onBegin).toHaveBeenCalledTimes(1);
|
|
100
|
+
expect(onEnd).toHaveBeenCalledTimes(1);
|
|
101
|
+
expect(onValueChange).toHaveBeenCalledTimes(1);
|
|
102
|
+
const reported = onValueChange.mock.calls[0]?.[0] as SignatureValue;
|
|
103
|
+
expect(reported.strokes).toHaveLength(1);
|
|
104
|
+
expect(onEnd).toHaveBeenCalledWith(reported);
|
|
105
|
+
expect(announce).toHaveBeenCalledWith("Signature captured");
|
|
106
|
+
expect(await screen.findByLabelText("Signature, drawn, 1 stroke")).toBeOnTheScreen();
|
|
107
|
+
announce.mockRestore();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("a disabled pad takes no stroke", async () => {
|
|
111
|
+
const onEnd = jest.fn();
|
|
112
|
+
await renderWithProviders(<Signature isDisabled onEnd={onEnd} />);
|
|
113
|
+
expect(screen.getByLabelText("Signature pad, empty")).toBeDisabled();
|
|
114
|
+
await drawStroke();
|
|
115
|
+
expect(onEnd).not.toHaveBeenCalled();
|
|
116
|
+
expect(screen.getByLabelText("Signature pad, empty")).toBeOnTheScreen();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("undo, redo and clear through the toolbar report and update the pad", async () => {
|
|
120
|
+
const onValueChange = jest.fn();
|
|
121
|
+
await renderWithProviders(
|
|
122
|
+
<Signature defaultValue={TWO_STROKES} onValueChange={onValueChange}>
|
|
123
|
+
<Signature.Pad />
|
|
124
|
+
<Signature.Toolbar>
|
|
125
|
+
<Signature.Undo />
|
|
126
|
+
<Signature.Redo />
|
|
127
|
+
<Signature.Clear />
|
|
128
|
+
</Signature.Toolbar>
|
|
129
|
+
</Signature>
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
await activate("Undo");
|
|
133
|
+
expect(screen.getByLabelText("Signature, drawn, 1 stroke")).toBeOnTheScreen();
|
|
134
|
+
const last = onValueChange.mock.lastCall?.[0] as SignatureValue | null;
|
|
135
|
+
expect(last?.strokes).toHaveLength(1);
|
|
136
|
+
expect(screen.getByRole("button", { name: "Redo" })).toBeEnabled();
|
|
137
|
+
|
|
138
|
+
await activate("Redo");
|
|
139
|
+
expect(screen.getByLabelText("Signature, drawn, 2 strokes")).toBeOnTheScreen();
|
|
140
|
+
|
|
141
|
+
const announce = jest.spyOn(AccessibilityInfo, "announceForAccessibility").mockImplementation(() => undefined);
|
|
142
|
+
await activate("Clear signature");
|
|
143
|
+
expect(screen.getByLabelText("Signature pad, empty")).toBeOnTheScreen();
|
|
144
|
+
expect(onValueChange).toHaveBeenLastCalledWith(null);
|
|
145
|
+
expect(announce).toHaveBeenCalledWith("Signature cleared");
|
|
146
|
+
expect(screen.getByRole("button", { name: "Clear signature" })).toBeDisabled();
|
|
147
|
+
expect(screen.getByRole("button", { name: "Redo" })).toBeDisabled();
|
|
148
|
+
announce.mockRestore();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("the pad's custom accessibility actions run undo and clear", async () => {
|
|
152
|
+
const onValueChange = jest.fn();
|
|
153
|
+
await renderWithProviders(<Signature defaultValue={TWO_STROKES} onValueChange={onValueChange} />);
|
|
154
|
+
|
|
155
|
+
await fireEvent(screen.getByLabelText("Signature, drawn, 2 strokes"), "accessibilityAction", {
|
|
156
|
+
nativeEvent: { actionName: "undo" },
|
|
157
|
+
});
|
|
158
|
+
expect(screen.getByLabelText("Signature, drawn, 1 stroke")).toBeOnTheScreen();
|
|
159
|
+
|
|
160
|
+
await fireEvent(screen.getByLabelText("Signature, drawn, 1 stroke"), "accessibilityAction", {
|
|
161
|
+
nativeEvent: { actionName: "clear" },
|
|
162
|
+
});
|
|
163
|
+
expect(screen.getByLabelText("Signature pad, empty")).toBeOnTheScreen();
|
|
164
|
+
expect(onValueChange).toHaveBeenLastCalledWith(null);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("a disabled pad ignores accessibility actions and toolbar presses", async () => {
|
|
168
|
+
const onValueChange = jest.fn();
|
|
169
|
+
await renderWithProviders(<Signature defaultValue={TWO_STROKES} isDisabled onValueChange={onValueChange} />);
|
|
170
|
+
const pad = screen.getByLabelText("Signature, drawn, 2 strokes");
|
|
171
|
+
expect(pad.props.accessibilityActions ?? []).toHaveLength(0);
|
|
172
|
+
await fireEvent(pad, "accessibilityAction", { nativeEvent: { actionName: "clear" } });
|
|
173
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
174
|
+
expect(screen.getByRole("button", { name: "Undo" })).toBeDisabled();
|
|
175
|
+
expect(screen.getByRole("button", { name: "Clear signature" })).toBeDisabled();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("read-only shows the drawing with no toolbar, hint or actions", async () => {
|
|
179
|
+
await renderWithProviders(
|
|
180
|
+
<Signature defaultValue={TWO_STROKES} isReadOnly onRequestAlternative={() => undefined} />
|
|
181
|
+
);
|
|
182
|
+
const pad = screen.getByLabelText("Signature, drawn, 2 strokes");
|
|
183
|
+
expect(pad.props.accessibilityHint).toBeUndefined();
|
|
184
|
+
expect(pad.props.accessibilityActions ?? []).toHaveLength(0);
|
|
185
|
+
expect(screen.queryByRole("button", { name: "Undo" })).not.toBeOnTheScreen();
|
|
186
|
+
expect(screen.queryByText("Can't sign? Type your name")).not.toBeOnTheScreen();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("an interactive pad carries the drawing hint", async () => {
|
|
190
|
+
await renderWithProviders(<Signature />);
|
|
191
|
+
expect(screen.getByLabelText("Signature pad, empty").props.accessibilityHint).toBe(
|
|
192
|
+
"Double tap and hold, then drag to draw."
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("uncontrolled: defaultValue seeds it and the ref reads it back", async () => {
|
|
197
|
+
const ref = createRef<SignatureHandle>();
|
|
198
|
+
await renderWithProviders(<Signature defaultValue={TWO_STROKES} ref={ref} />);
|
|
199
|
+
expect(ref.current?.isEmpty).toBe(false);
|
|
200
|
+
expect(ref.current?.strokeCount).toBe(2);
|
|
201
|
+
expect(ref.current?.value?.strokes).toHaveLength(2);
|
|
202
|
+
expect(ref.current?.toPaths()).toHaveLength(2);
|
|
203
|
+
expect(ref.current?.toSVG()).toContain("<svg");
|
|
204
|
+
|
|
205
|
+
await act(async () => ref.current?.clear());
|
|
206
|
+
expect(ref.current?.isEmpty).toBe(true);
|
|
207
|
+
expect(ref.current?.value).toBeNull();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("controlled: a new value re-seeds the drawing and does not echo onValueChange", async () => {
|
|
211
|
+
const onValueChange = jest.fn();
|
|
212
|
+
const view = await renderWithProviders(<Signature onValueChange={onValueChange} value={ONE_STROKE} />);
|
|
213
|
+
expect(screen.getByLabelText("Signature, drawn, 1 stroke")).toBeOnTheScreen();
|
|
214
|
+
|
|
215
|
+
await view.rerender(<Signature onValueChange={onValueChange} value={TWO_STROKES} />);
|
|
216
|
+
expect(screen.getByLabelText("Signature, drawn, 2 strokes")).toBeOnTheScreen();
|
|
217
|
+
|
|
218
|
+
await view.rerender(<Signature onValueChange={onValueChange} value={null} />);
|
|
219
|
+
expect(screen.getByLabelText("Signature pad, empty")).toBeOnTheScreen();
|
|
220
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("Signature.Alternative renders only with onRequestAlternative and calls it, even disabled", async () => {
|
|
224
|
+
const onRequestAlternative = jest.fn();
|
|
225
|
+
const view = await renderWithProviders(<Signature />);
|
|
226
|
+
expect(screen.queryByText("Can't sign? Type your name")).not.toBeOnTheScreen();
|
|
227
|
+
|
|
228
|
+
await view.rerender(<Signature isDisabled onRequestAlternative={onRequestAlternative} />);
|
|
229
|
+
const link = screen.getByRole("button", { name: "Can't sign? Type your name" });
|
|
230
|
+
expect(link).toBeEnabled();
|
|
231
|
+
await fireEvent(link, "accessibilityTap");
|
|
232
|
+
expect(onRequestAlternative).toHaveBeenCalledTimes(1);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("placeholder and guideline label are configurable", async () => {
|
|
236
|
+
await renderWithProviders(<Signature guidelineLabel="Sign above the line" placeholder="Sign in the box" />);
|
|
237
|
+
expect(screen.getByText("Sign in the box")).toBeOnTheScreen();
|
|
238
|
+
expect(screen.getByText("Sign above the line")).toBeOnTheScreen();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test.each([
|
|
242
|
+
["Signature.Pad", <Signature.Pad key="pad" />],
|
|
243
|
+
["Signature.Toolbar", <Signature.Toolbar key="toolbar" />],
|
|
244
|
+
["Signature.Undo", <Signature.Undo key="undo" />],
|
|
245
|
+
["Signature.Redo", <Signature.Redo key="redo" />],
|
|
246
|
+
["Signature.Clear", <Signature.Clear key="clear" />],
|
|
247
|
+
["Signature.Alternative", <Signature.Alternative key="alt" />],
|
|
248
|
+
])("%s outside a Signature throws its documented error", async (name, part) => {
|
|
249
|
+
const original = console.error;
|
|
250
|
+
console.error = () => undefined;
|
|
251
|
+
try {
|
|
252
|
+
await expect(renderWithProviders(part)).rejects.toThrow(`${name} must be rendered inside a <Signature>.`);
|
|
253
|
+
} finally {
|
|
254
|
+
console.error = original;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
@@ -18,7 +18,8 @@ with a glint sweeping across it, or a pulse, on the UI thread. Compound root plu
|
|
|
18
18
|
| `skeleton-clock.ts` | `useSkeletonClock`, the 0 → 1 UI-thread loop both animations read |
|
|
19
19
|
| `skeleton.context.tsx` | `SkeletonGroupProvider`, `useSkeletonGroup()` |
|
|
20
20
|
| `skeleton.variants.ts` | Pure `tv()` slots + resolvers + worklets, no RN imports |
|
|
21
|
-
| `skeleton.variants.test.ts` | |
|
|
21
|
+
| `skeleton.variants.test.ts` | Pure suite for the variants, resolvers and worklets |
|
|
22
|
+
| `skeleton.render.test.tsx` | Mounted under Jest — accessibility (hidden / busy progressbar / content), group and per-skeleton `isLoading`, children kept mounted and inert while loading, `Skeleton.Lines` labelling |
|
|
22
23
|
|
|
23
24
|
## Design
|
|
24
25
|
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import { Pressable, Text } from "react-native";
|
|
3
|
+
import { renderWithProviders, screen } from "../../test/render";
|
|
4
|
+
import { Skeleton } from "./skeleton";
|
|
5
|
+
|
|
6
|
+
const HIDDEN = { includeHiddenElements: true } as const;
|
|
7
|
+
|
|
8
|
+
// Reanimated's `measure()` warns under Jest every time the shimmer's style runs; that is not what these tests are about.
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.spyOn(console, "warn").mockImplementation(() => undefined);
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
jest.restoreAllMocks();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("Skeleton", () => {
|
|
17
|
+
test("an unlabelled skeleton is hidden from assistive technology", async () => {
|
|
18
|
+
await renderWithProviders(<Skeleton animation="none" testID="sk" />);
|
|
19
|
+
const root = screen.getByTestId("sk", HIDDEN);
|
|
20
|
+
expect(root).toHaveProp("accessibilityElementsHidden", true);
|
|
21
|
+
expect(root).toHaveProp("importantForAccessibility", "no-hide-descendants");
|
|
22
|
+
expect(screen.queryByTestId("sk")).not.toBeOnTheScreen();
|
|
23
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("a label makes it one busy progressbar with that name", async () => {
|
|
27
|
+
await renderWithProviders(<Skeleton animation="none" label="Loading profile" />);
|
|
28
|
+
const bar = screen.getByRole("progressbar", { name: "Loading profile" });
|
|
29
|
+
expect(bar).toBeOnTheScreen();
|
|
30
|
+
expect(bar).toBeBusy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("once loaded it adds no accessibility props and the content speaks", async () => {
|
|
34
|
+
await renderWithProviders(
|
|
35
|
+
<Skeleton animation="none" isLoading={false} label="Loading profile" testID="sk">
|
|
36
|
+
<Text>Ada Lovelace</Text>
|
|
37
|
+
</Skeleton>
|
|
38
|
+
);
|
|
39
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
40
|
+
const root = screen.getByTestId("sk");
|
|
41
|
+
expect(root).not.toHaveProp("accessibilityElementsHidden");
|
|
42
|
+
expect(root).not.toHaveProp("accessibilityLabel");
|
|
43
|
+
expect(screen.getByText("Ada Lovelace")).toBeOnTheScreen();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("children stay mounted while loading but are hidden from a screen reader", async () => {
|
|
47
|
+
await renderWithProviders(
|
|
48
|
+
<Skeleton animation="none">
|
|
49
|
+
<Text>Ada Lovelace</Text>
|
|
50
|
+
</Skeleton>
|
|
51
|
+
);
|
|
52
|
+
expect(screen.getByText("Ada Lovelace", HIDDEN)).toBeOnTheScreen();
|
|
53
|
+
expect(screen.queryByText("Ada Lovelace")).not.toBeOnTheScreen();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("children are not unmounted when loading flips, and become visible", async () => {
|
|
57
|
+
const { rerender } = await renderWithProviders(
|
|
58
|
+
<Skeleton animation="none">
|
|
59
|
+
<Text>Ada Lovelace</Text>
|
|
60
|
+
</Skeleton>
|
|
61
|
+
);
|
|
62
|
+
expect(screen.queryByText("Ada Lovelace")).not.toBeOnTheScreen();
|
|
63
|
+
await rerender(
|
|
64
|
+
<Skeleton animation="none" isLoading={false}>
|
|
65
|
+
<Text>Ada Lovelace</Text>
|
|
66
|
+
</Skeleton>
|
|
67
|
+
);
|
|
68
|
+
expect(screen.getByText("Ada Lovelace")).toBeOnTheScreen();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("children take no touches while loading and do once loaded", async () => {
|
|
72
|
+
const { rerender } = await renderWithProviders(
|
|
73
|
+
<Skeleton animation="none">
|
|
74
|
+
<Pressable testID="inner">
|
|
75
|
+
<Text>Open</Text>
|
|
76
|
+
</Pressable>
|
|
77
|
+
</Skeleton>
|
|
78
|
+
);
|
|
79
|
+
const wrapper = () => screen.getByTestId("inner", HIDDEN).parent;
|
|
80
|
+
expect(wrapper()).toHaveProp("pointerEvents", "none");
|
|
81
|
+
await rerender(
|
|
82
|
+
<Skeleton animation="none" isLoading={false}>
|
|
83
|
+
<Pressable testID="inner">
|
|
84
|
+
<Text>Open</Text>
|
|
85
|
+
</Pressable>
|
|
86
|
+
</Skeleton>
|
|
87
|
+
);
|
|
88
|
+
expect(wrapper()).toHaveProp("pointerEvents", "auto");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("forwards testID and other View props", async () => {
|
|
92
|
+
await renderWithProviders(<Skeleton animation="none" nativeID="sk-id" testID="sk" />);
|
|
93
|
+
expect(screen.getByTestId("sk", HIDDEN)).toHaveProp("nativeID", "sk-id");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test.each(["shimmer", "pulse", "none"] as const)(
|
|
97
|
+
"animation=%s mounts without changing what is announced",
|
|
98
|
+
async (animation) => {
|
|
99
|
+
await renderWithProviders(<Skeleton animation={animation} label="Loading" />);
|
|
100
|
+
expect(screen.getByRole("progressbar", { name: "Loading" })).toBeBusy();
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("Skeleton.Group", () => {
|
|
106
|
+
test("a labelled group is one busy progressbar", async () => {
|
|
107
|
+
await renderWithProviders(
|
|
108
|
+
<Skeleton.Group animation="none" label="Loading inbox">
|
|
109
|
+
<Skeleton animation="none" testID="a" />
|
|
110
|
+
<Skeleton animation="none" testID="b" />
|
|
111
|
+
</Skeleton.Group>
|
|
112
|
+
);
|
|
113
|
+
const bar = screen.getByRole("progressbar", { name: "Loading inbox" });
|
|
114
|
+
expect(bar).toBeBusy();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("an unlabelled group takes no role and does not hide real content beside the placeholders", async () => {
|
|
118
|
+
await renderWithProviders(
|
|
119
|
+
<Skeleton.Group animation="none" testID="group">
|
|
120
|
+
<Text>Inbox</Text>
|
|
121
|
+
<Skeleton animation="none" testID="a" />
|
|
122
|
+
</Skeleton.Group>
|
|
123
|
+
);
|
|
124
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
125
|
+
expect(screen.getByTestId("group")).not.toHaveProp("accessibilityElementsHidden");
|
|
126
|
+
expect(screen.getByText("Inbox")).toBeOnTheScreen();
|
|
127
|
+
expect(screen.queryByTestId("a")).not.toBeOnTheScreen();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("isLoading on the group reveals every skeleton inside", async () => {
|
|
131
|
+
const tree = (isLoading: boolean) => (
|
|
132
|
+
<Skeleton.Group animation="none" isLoading={isLoading} label="Loading inbox">
|
|
133
|
+
<Skeleton testID="a">
|
|
134
|
+
<Text>First</Text>
|
|
135
|
+
</Skeleton>
|
|
136
|
+
<Skeleton testID="b">
|
|
137
|
+
<Text>Second</Text>
|
|
138
|
+
</Skeleton>
|
|
139
|
+
</Skeleton.Group>
|
|
140
|
+
);
|
|
141
|
+
const { rerender } = await renderWithProviders(tree(true));
|
|
142
|
+
expect(screen.queryByText("First")).not.toBeOnTheScreen();
|
|
143
|
+
expect(screen.queryByText("Second")).not.toBeOnTheScreen();
|
|
144
|
+
await rerender(tree(false));
|
|
145
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
146
|
+
expect(screen.getByText("First")).toBeOnTheScreen();
|
|
147
|
+
expect(screen.getByText("Second")).toBeOnTheScreen();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("a skeleton's own isLoading wins over the group's", async () => {
|
|
151
|
+
await renderWithProviders(
|
|
152
|
+
<Skeleton.Group animation="none" isLoading>
|
|
153
|
+
<Skeleton isLoading={false} label="Own" testID="own">
|
|
154
|
+
<Text>Done</Text>
|
|
155
|
+
</Skeleton>
|
|
156
|
+
<Skeleton testID="inherited">
|
|
157
|
+
<Text>Pending</Text>
|
|
158
|
+
</Skeleton>
|
|
159
|
+
</Skeleton.Group>
|
|
160
|
+
);
|
|
161
|
+
expect(screen.getByText("Done")).toBeOnTheScreen();
|
|
162
|
+
expect(screen.queryByText("Pending")).not.toBeOnTheScreen();
|
|
163
|
+
expect(screen.queryByRole("progressbar", { name: "Own" })).not.toBeOnTheScreen();
|
|
164
|
+
expect(screen.getByText("Pending", HIDDEN)).toBeOnTheScreen();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("a group with a running animation mounts its skeletons", async () => {
|
|
168
|
+
await renderWithProviders(
|
|
169
|
+
<Skeleton.Group animation="pulse">
|
|
170
|
+
<Skeleton label="One" />
|
|
171
|
+
</Skeleton.Group>
|
|
172
|
+
);
|
|
173
|
+
expect(screen.getByRole("progressbar", { name: "One" })).toBeBusy();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe("Skeleton.Lines", () => {
|
|
178
|
+
test("renders `lines` placeholder lines, hidden when unlabelled", async () => {
|
|
179
|
+
await renderWithProviders(<Skeleton.Lines animation="none" lines={4} testID="lines" />);
|
|
180
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
181
|
+
expect(screen.getByTestId("lines", { includeHiddenElements: true }).children).toHaveLength(4);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("the label goes on the paragraph once, as one busy progressbar", async () => {
|
|
185
|
+
await renderWithProviders(<Skeleton.Lines animation="none" label="Loading bio" lines={3} />);
|
|
186
|
+
expect(screen.getAllByRole("progressbar")).toHaveLength(1);
|
|
187
|
+
expect(screen.getByRole("progressbar", { name: "Loading bio" })).toBeBusy();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test("inside a group the paragraph still announces its own label once", async () => {
|
|
191
|
+
await renderWithProviders(
|
|
192
|
+
<Skeleton.Group animation="none">
|
|
193
|
+
<Skeleton.Lines animation="none" label="Loading bio" lines={2} />
|
|
194
|
+
</Skeleton.Group>
|
|
195
|
+
);
|
|
196
|
+
expect(screen.getAllByRole("progressbar")).toHaveLength(1);
|
|
197
|
+
expect(screen.getByRole("progressbar", { name: "Loading bio" })).toBeBusy();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("once loaded it shows its children and no placeholder", async () => {
|
|
201
|
+
await renderWithProviders(
|
|
202
|
+
<Skeleton.Lines animation="none" isLoading={false} label="Loading bio" testID="lines">
|
|
203
|
+
<Text>Real paragraph</Text>
|
|
204
|
+
</Skeleton.Lines>
|
|
205
|
+
);
|
|
206
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
207
|
+
expect(screen.getByText("Real paragraph")).toBeOnTheScreen();
|
|
208
|
+
expect(screen.getByTestId("lines")).toBeOnTheScreen();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test("follows an enclosing group's isLoading", async () => {
|
|
212
|
+
await renderWithProviders(
|
|
213
|
+
<Skeleton.Group animation="none" isLoading={false}>
|
|
214
|
+
<Skeleton.Lines label="Loading bio">
|
|
215
|
+
<Text>Real paragraph</Text>
|
|
216
|
+
</Skeleton.Lines>
|
|
217
|
+
</Skeleton.Group>
|
|
218
|
+
);
|
|
219
|
+
expect(screen.queryByRole("progressbar")).not.toBeOnTheScreen();
|
|
220
|
+
expect(screen.getByText("Real paragraph")).toBeOnTheScreen();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
@@ -33,6 +33,7 @@ full-screen or in a sheet is the caller's composition).
|
|
|
33
33
|
| `sketch.paths.test.ts` | Including text-level assertions that the leaf has no `import` and the canvas is Skia, not SVG |
|
|
34
34
|
| `sketch.variants.ts` | The slotted `tv()`, the label record, colour/size/label/export resolvers |
|
|
35
35
|
| `sketch.variants.test.ts` | |
|
|
36
|
+
| `sketch.render.test.tsx` | Mounted under Jest — tools, shapes, swatches, size, undo and the handle, disabled, strokes driven through the pan's `sketch-pan` test id, the part-outside-root errors. Skia is stubbed, so it asserts the React side, not pixels |
|
|
36
37
|
|
|
37
38
|
DisplayNames: `DelacourUI.Sketch`, `.Sketch.Canvas`, `.Toolbar`, `.Tool`,
|
|
38
39
|
`.Swatches`, `.Size`, `.Undo`, and the internal `.Sketch.Provider` and
|
|
@@ -89,6 +90,7 @@ DisplayNames: `DelacourUI.Sketch`, `.Sketch.Canvas`, `.Toolbar`, `.Tool`,
|
|
|
89
90
|
outside it.** So the eraser cuts committed ink as it moves, and the stroke
|
|
90
91
|
being drawn is never erased by itself. Both paths are always mounted, empty
|
|
91
92
|
between strokes.
|
|
93
|
+
- **The pan carries `.withTestId(SKETCH_PAN_TEST_ID)` (`"sketch-pan"`)**, exported from `sketch-canvas.tsx`, so a render test can drive a stroke with Gesture Handler's `fireGestureHandler`. No behaviour change.
|
|
92
94
|
- **A shape drag under 4pt on both axes commits nothing**; a tap with a shape tool
|
|
93
95
|
is not a shape. Line and arrow follow the drag; the rest use its normalised
|
|
94
96
|
bounds, so dragging up-left draws the same rectangle as down-right.
|
|
@@ -28,6 +28,9 @@ const LIVE_NONE = 0;
|
|
|
28
28
|
const LIVE_INK = 1;
|
|
29
29
|
const LIVE_ERASE = 2;
|
|
30
30
|
|
|
31
|
+
/** The pan's Gesture Handler test id, which `fireGestureHandler` drives in render tests. */
|
|
32
|
+
export const SKETCH_PAN_TEST_ID = "sketch-pan";
|
|
33
|
+
|
|
31
34
|
const ACCESSIBILITY_ACTIONS = [
|
|
32
35
|
{ label: "Undo", name: "undo" },
|
|
33
36
|
{ label: "Clear", name: "clear" },
|
|
@@ -110,6 +113,7 @@ export function SketchCanvas({ children, className, onLayout, ...props }: Sketch
|
|
|
110
113
|
const gesture = useMemo(
|
|
111
114
|
() =>
|
|
112
115
|
Gesture.Pan()
|
|
116
|
+
.withTestId(SKETCH_PAN_TEST_ID)
|
|
113
117
|
.enabled(!isDisabled && isMeasured)
|
|
114
118
|
.minDistance(0)
|
|
115
119
|
.maxPointers(1)
|