@terreno/ui 0.23.0 → 0.24.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.
Files changed (43) hide show
  1. package/dist/AiSuggestionBox.d.ts +11 -0
  2. package/dist/AiSuggestionBox.js +50 -23
  3. package/dist/AiSuggestionBox.js.map +1 -1
  4. package/dist/Button.js +4 -3
  5. package/dist/Button.js.map +1 -1
  6. package/dist/Common.d.ts +15 -2
  7. package/dist/Common.js.map +1 -1
  8. package/dist/IconButton.js +8 -4
  9. package/dist/IconButton.js.map +1 -1
  10. package/dist/icons/SparklesIcon.d.ts +7 -0
  11. package/dist/icons/SparklesIcon.js +32 -0
  12. package/dist/icons/SparklesIcon.js.map +1 -0
  13. package/dist/icons/index.d.ts +1 -0
  14. package/dist/icons/index.js +1 -0
  15. package/dist/icons/index.js.map +1 -1
  16. package/package.json +2 -2
  17. package/src/ActionSheet.test.tsx +96 -0
  18. package/src/AiSuggestionBox.test.tsx +184 -15
  19. package/src/AiSuggestionBox.tsx +72 -55
  20. package/src/Button.test.tsx +31 -1
  21. package/src/Button.tsx +5 -4
  22. package/src/Common.ts +16 -2
  23. package/src/ErrorBoundary.test.tsx +3 -4
  24. package/src/IconButton.test.tsx +14 -0
  25. package/src/IconButton.tsx +9 -4
  26. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +489 -102
  27. package/src/__snapshots__/Button.test.tsx.snap +18 -1
  28. package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +2 -0
  29. package/src/__snapshots__/ErrorPage.test.tsx.snap +1 -0
  30. package/src/__snapshots__/HeightActionSheet.test.tsx.snap +2 -0
  31. package/src/__snapshots__/HeightField.test.tsx.snap +5 -0
  32. package/src/__snapshots__/IconButton.test.tsx.snap +4 -0
  33. package/src/__snapshots__/InfoModalIcon.test.tsx.snap +4 -0
  34. package/src/__snapshots__/Modal.test.tsx.snap +3 -0
  35. package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +2 -0
  36. package/src/__snapshots__/Page.test.tsx.snap +1 -0
  37. package/src/icons/SparklesIcon.test.tsx +16 -0
  38. package/src/icons/SparklesIcon.tsx +38 -0
  39. package/src/icons/__snapshots__/SparklesIcon.test.tsx.snap +47 -0
  40. package/src/icons/index.ts +1 -0
  41. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +3 -0
  42. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +2 -0
  43. package/src/testing/resolveTestId.test.ts +101 -0
@@ -60,6 +60,7 @@ exports[`Button renders correctly with default props 1`] = `
60
60
  "borderRadius": 360,
61
61
  "borderWidth": undefined,
62
62
  "flexDirection": "column",
63
+ "height": undefined,
63
64
  "justifyContent": "center",
64
65
  "paddingHorizontal": 20,
65
66
  "paddingVertical": 8,
@@ -131,6 +132,7 @@ exports[`Button renders primary variant 1`] = `
131
132
  "borderRadius": 360,
132
133
  "borderWidth": undefined,
133
134
  "flexDirection": "column",
135
+ "height": undefined,
134
136
  "justifyContent": "center",
135
137
  "paddingHorizontal": 20,
136
138
  "paddingVertical": 8,
@@ -202,6 +204,7 @@ exports[`Button renders secondary variant 1`] = `
202
204
  "borderRadius": 360,
203
205
  "borderWidth": undefined,
204
206
  "flexDirection": "column",
207
+ "height": undefined,
205
208
  "justifyContent": "center",
206
209
  "paddingHorizontal": 20,
207
210
  "paddingVertical": 8,
@@ -273,6 +276,7 @@ exports[`Button renders muted variant 1`] = `
273
276
  "borderRadius": 360,
274
277
  "borderWidth": undefined,
275
278
  "flexDirection": "column",
279
+ "height": undefined,
276
280
  "justifyContent": "center",
277
281
  "paddingHorizontal": 20,
278
282
  "paddingVertical": 8,
@@ -344,6 +348,7 @@ exports[`Button renders outline variant 1`] = `
344
348
  "borderRadius": 360,
345
349
  "borderWidth": 2,
346
350
  "flexDirection": "column",
351
+ "height": undefined,
347
352
  "justifyContent": "center",
348
353
  "paddingHorizontal": 20,
349
354
  "paddingVertical": 6,
@@ -415,6 +420,7 @@ exports[`Button renders destructive variant 1`] = `
415
420
  "borderRadius": 360,
416
421
  "borderWidth": undefined,
417
422
  "flexDirection": "column",
423
+ "height": undefined,
418
424
  "justifyContent": "center",
419
425
  "paddingHorizontal": 20,
420
426
  "paddingVertical": 8,
@@ -486,6 +492,7 @@ exports[`Button renders disabled state 1`] = `
486
492
  "borderRadius": 360,
487
493
  "borderWidth": undefined,
488
494
  "flexDirection": "column",
495
+ "height": undefined,
489
496
  "justifyContent": "center",
490
497
  "paddingHorizontal": 20,
491
498
  "paddingVertical": 8,
@@ -557,6 +564,7 @@ exports[`Button applies disabled styles when disabled 1`] = `
557
564
  "borderRadius": 360,
558
565
  "borderWidth": undefined,
559
566
  "flexDirection": "column",
567
+ "height": undefined,
560
568
  "justifyContent": "center",
561
569
  "paddingHorizontal": 20,
562
570
  "paddingVertical": 8,
@@ -651,6 +659,7 @@ exports[`Button renders loading state 1`] = `
651
659
  "borderRadius": 360,
652
660
  "borderWidth": undefined,
653
661
  "flexDirection": "column",
662
+ "height": undefined,
654
663
  "justifyContent": "center",
655
664
  "paddingHorizontal": 20,
656
665
  "paddingVertical": 8,
@@ -722,6 +731,7 @@ exports[`Button renders fullWidth button 1`] = `
722
731
  "borderRadius": 360,
723
732
  "borderWidth": undefined,
724
733
  "flexDirection": "column",
734
+ "height": undefined,
725
735
  "justifyContent": "center",
726
736
  "paddingHorizontal": 20,
727
737
  "paddingVertical": 8,
@@ -806,6 +816,7 @@ exports[`Button renders with icon on left 1`] = `
806
816
  "borderRadius": 360,
807
817
  "borderWidth": undefined,
808
818
  "flexDirection": "column",
819
+ "height": undefined,
809
820
  "justifyContent": "center",
810
821
  "paddingHorizontal": 20,
811
822
  "paddingVertical": 8,
@@ -890,6 +901,7 @@ exports[`Button renders with icon on right 1`] = `
890
901
  "borderRadius": 360,
891
902
  "borderWidth": undefined,
892
903
  "flexDirection": "column",
904
+ "height": undefined,
893
905
  "justifyContent": "center",
894
906
  "paddingHorizontal": 20,
895
907
  "paddingVertical": 8,
@@ -961,6 +973,7 @@ exports[`Button renders with confirmation modal props 1`] = `
961
973
  "borderRadius": 360,
962
974
  "borderWidth": undefined,
963
975
  "flexDirection": "column",
976
+ "height": undefined,
964
977
  "justifyContent": "center",
965
978
  "paddingHorizontal": 20,
966
979
  "paddingVertical": 8,
@@ -1032,6 +1045,7 @@ exports[`Button renders with tooltip on desktop (wrapped in Tooltip) 1`] = `
1032
1045
  "borderRadius": 360,
1033
1046
  "borderWidth": undefined,
1034
1047
  "flexDirection": "column",
1048
+ "height": undefined,
1035
1049
  "justifyContent": "center",
1036
1050
  "paddingHorizontal": 20,
1037
1051
  "paddingVertical": 8,
@@ -1103,6 +1117,7 @@ exports[`Button renders with custom confirmationText and modalSubTitle 1`] = `
1103
1117
  "borderRadius": 360,
1104
1118
  "borderWidth": undefined,
1105
1119
  "flexDirection": "column",
1120
+ "height": undefined,
1106
1121
  "justifyContent": "center",
1107
1122
  "paddingHorizontal": 20,
1108
1123
  "paddingVertical": 8,
@@ -1197,6 +1212,7 @@ exports[`Button shows loading indicator when loading prop is true 1`] = `
1197
1212
  "borderRadius": 360,
1198
1213
  "borderWidth": undefined,
1199
1214
  "flexDirection": "column",
1215
+ "height": undefined,
1200
1216
  "justifyContent": "center",
1201
1217
  "paddingHorizontal": 20,
1202
1218
  "paddingVertical": 8,
@@ -1263,11 +1279,12 @@ exports[`Button renders ghost variant with correct styles 1`] = `
1263
1279
  "style": {
1264
1280
  "alignItems": "center",
1265
1281
  "alignSelf": "flex-start",
1266
- "backgroundColor": "#FFFFFF",
1282
+ "backgroundColor": "transparent",
1267
1283
  "borderColor": undefined,
1268
1284
  "borderRadius": 360,
1269
1285
  "borderWidth": undefined,
1270
1286
  "flexDirection": "column",
1287
+ "height": undefined,
1271
1288
  "justifyContent": "center",
1272
1289
  "paddingHorizontal": 20,
1273
1290
  "paddingVertical": 8,
@@ -183,6 +183,7 @@ exports[`DecimalRangeActionSheet renders correctly 1`] = `
183
183
  "borderRadius": 360,
184
184
  "borderWidth": undefined,
185
185
  "flexDirection": "column",
186
+ "height": undefined,
186
187
  "justifyContent": "center",
187
188
  "paddingHorizontal": 20,
188
189
  "paddingVertical": 8,
@@ -865,6 +866,7 @@ exports[`DecimalRangeActionSheet renders with different min/max range 1`] = `
865
866
  "borderRadius": 360,
866
867
  "borderWidth": undefined,
867
868
  "flexDirection": "column",
869
+ "height": undefined,
868
870
  "justifyContent": "center",
869
871
  "paddingHorizontal": 20,
870
872
  "paddingVertical": 8,
@@ -168,6 +168,7 @@ exports[`ErrorPage renders correctly 1`] = `
168
168
  "borderRadius": 360,
169
169
  "borderWidth": undefined,
170
170
  "flexDirection": "column",
171
+ "height": undefined,
171
172
  "justifyContent": "center",
172
173
  "paddingHorizontal": 20,
173
174
  "paddingVertical": 8,
@@ -198,6 +198,7 @@ exports[`HeightActionSheet renders correctly 1`] = `
198
198
  "borderRadius": 360,
199
199
  "borderWidth": undefined,
200
200
  "flexDirection": "column",
201
+ "height": undefined,
201
202
  "justifyContent": "center",
202
203
  "paddingHorizontal": 20,
203
204
  "paddingVertical": 8,
@@ -892,6 +893,7 @@ exports[`HeightActionSheet renders with different height value 1`] = `
892
893
  "borderRadius": 360,
893
894
  "borderWidth": undefined,
894
895
  "flexDirection": "column",
896
+ "height": undefined,
895
897
  "justifyContent": "center",
896
898
  "paddingHorizontal": 20,
897
899
  "paddingVertical": 8,
@@ -259,6 +259,7 @@ exports[`HeightField snapshots should match snapshot with default props 1`] = `
259
259
  "borderRadius": 360,
260
260
  "borderWidth": undefined,
261
261
  "flexDirection": "column",
262
+ "height": undefined,
262
263
  "justifyContent": "center",
263
264
  "paddingHorizontal": 20,
264
265
  "paddingVertical": 8,
@@ -1024,6 +1025,7 @@ exports[`HeightField snapshots should match snapshot with value 1`] = `
1024
1025
  "borderRadius": 360,
1025
1026
  "borderWidth": undefined,
1026
1027
  "flexDirection": "column",
1028
+ "height": undefined,
1027
1029
  "justifyContent": "center",
1028
1030
  "paddingHorizontal": 20,
1029
1031
  "paddingVertical": 8,
@@ -1886,6 +1888,7 @@ exports[`HeightField snapshots should match snapshot with all props 1`] = `
1886
1888
  "borderRadius": 360,
1887
1889
  "borderWidth": undefined,
1888
1890
  "flexDirection": "column",
1891
+ "height": undefined,
1889
1892
  "justifyContent": "center",
1890
1893
  "paddingHorizontal": 20,
1891
1894
  "paddingVertical": 8,
@@ -2683,6 +2686,7 @@ exports[`HeightField snapshots should match snapshot when disabled 1`] = `
2683
2686
  "borderRadius": 360,
2684
2687
  "borderWidth": undefined,
2685
2688
  "flexDirection": "column",
2689
+ "height": undefined,
2686
2690
  "justifyContent": "center",
2687
2691
  "paddingHorizontal": 20,
2688
2692
  "paddingVertical": 8,
@@ -3519,6 +3523,7 @@ exports[`HeightField snapshots should match snapshot with error state 1`] = `
3519
3523
  "borderRadius": 360,
3520
3524
  "borderWidth": undefined,
3521
3525
  "flexDirection": "column",
3526
+ "height": undefined,
3522
3527
  "justifyContent": "center",
3523
3528
  "paddingHorizontal": 20,
3524
3529
  "paddingVertical": 8,
@@ -27,3 +27,7 @@ exports[`IconButton calls onClick when pressed 1`] = `null`;
27
27
  exports[`IconButton has correct accessibility props 1`] = `null`;
28
28
 
29
29
  exports[`IconButton renders with confirmation props 1`] = `null`;
30
+
31
+ exports[`IconButton renders ghost variant 1`] = `null`;
32
+
33
+ exports[`IconButton renders sm size 1`] = `null`;
@@ -182,6 +182,7 @@ exports[`InfoModalIcon renders correctly with required props 1`] = `
182
182
  "borderRadius": 360,
183
183
  "borderWidth": undefined,
184
184
  "flexDirection": "column",
185
+ "height": undefined,
185
186
  "justifyContent": "center",
186
187
  "paddingHorizontal": 20,
187
188
  "paddingVertical": 8,
@@ -513,6 +514,7 @@ exports[`InfoModalIcon renders with subtitle 1`] = `
513
514
  "borderRadius": 360,
514
515
  "borderWidth": undefined,
515
516
  "flexDirection": "column",
517
+ "height": undefined,
516
518
  "justifyContent": "center",
517
519
  "paddingHorizontal": 20,
518
520
  "paddingVertical": 8,
@@ -842,6 +844,7 @@ exports[`InfoModalIcon renders with children content 1`] = `
842
844
  "borderRadius": 360,
843
845
  "borderWidth": undefined,
844
846
  "flexDirection": "column",
847
+ "height": undefined,
845
848
  "justifyContent": "center",
846
849
  "paddingHorizontal": 20,
847
850
  "paddingVertical": 8,
@@ -1132,6 +1135,7 @@ exports[`InfoModalIcon opens modal when pressed 1`] = `
1132
1135
  "borderRadius": 360,
1133
1136
  "borderWidth": undefined,
1134
1137
  "flexDirection": "column",
1138
+ "height": undefined,
1135
1139
  "justifyContent": "center",
1136
1140
  "paddingHorizontal": 20,
1137
1141
  "paddingVertical": 8,
@@ -544,6 +544,7 @@ exports[`Modal renders with both buttons 1`] = `
544
544
  "borderRadius": 360,
545
545
  "borderWidth": undefined,
546
546
  "flexDirection": "column",
547
+ "height": undefined,
547
548
  "justifyContent": "center",
548
549
  "paddingHorizontal": 20,
549
550
  "paddingVertical": 8,
@@ -621,6 +622,7 @@ exports[`Modal renders with both buttons 1`] = `
621
622
  "borderRadius": 360,
622
623
  "borderWidth": undefined,
623
624
  "flexDirection": "column",
625
+ "height": undefined,
624
626
  "justifyContent": "center",
625
627
  "paddingHorizontal": 20,
626
628
  "paddingVertical": 8,
@@ -871,6 +873,7 @@ exports[`Modal renders with disabled primary button 1`] = `
871
873
  "borderRadius": 360,
872
874
  "borderWidth": undefined,
873
875
  "flexDirection": "column",
876
+ "height": undefined,
874
877
  "justifyContent": "center",
875
878
  "paddingHorizontal": 20,
876
879
  "paddingVertical": 8,
@@ -183,6 +183,7 @@ exports[`NumberPickerActionSheet renders correctly 1`] = `
183
183
  "borderRadius": 360,
184
184
  "borderWidth": undefined,
185
185
  "flexDirection": "column",
186
+ "height": undefined,
186
187
  "justifyContent": "center",
187
188
  "paddingHorizontal": 20,
188
189
  "paddingVertical": 8,
@@ -1515,6 +1516,7 @@ exports[`NumberPickerActionSheet renders with different range 1`] = `
1515
1516
  "borderRadius": 360,
1516
1517
  "borderWidth": undefined,
1517
1518
  "flexDirection": "column",
1519
+ "height": undefined,
1518
1520
  "justifyContent": "center",
1519
1521
  "paddingHorizontal": 20,
1520
1522
  "paddingVertical": 8,
@@ -835,6 +835,7 @@ exports[`Page renders with right button 1`] = `
835
835
  "borderRadius": 360,
836
836
  "borderWidth": undefined,
837
837
  "flexDirection": "column",
838
+ "height": undefined,
838
839
  "justifyContent": "center",
839
840
  "paddingHorizontal": 20,
840
841
  "paddingVertical": 8,
@@ -0,0 +1,16 @@
1
+ import {describe, expect, it} from "bun:test";
2
+ import {render} from "@testing-library/react-native";
3
+
4
+ import {SparklesIcon} from "./SparklesIcon";
5
+
6
+ describe("SparklesIcon", () => {
7
+ it("renders correctly", () => {
8
+ const {toJSON} = render(<SparklesIcon />);
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
11
+
12
+ it("accepts custom props", () => {
13
+ const {toJSON} = render(<SparklesIcon fill="#0A0A0A" height={24} width={24} />);
14
+ expect(toJSON()).toMatchSnapshot();
15
+ });
16
+ });
@@ -0,0 +1,38 @@
1
+ import type React from "react";
2
+ import Svg, {Path, type SvgProps} from "react-native-svg";
3
+
4
+ /**
5
+ * Builds a four-pointed sparkle path with concave edges, centered at (cx, cy) with
6
+ * outer radius r. FontAwesome 6 free has no standalone `sparkles` glyph (it is a Pro
7
+ * icon), so the glyph is composed locally from three of these sparkle shapes.
8
+ */
9
+ const sparklePath = (cx: number, cy: number, r: number): string => {
10
+ const pinch = r * 0.16;
11
+ return [
12
+ `M ${cx} ${cy - r}`,
13
+ `Q ${cx + pinch} ${cy - pinch} ${cx + r} ${cy}`,
14
+ `Q ${cx + pinch} ${cy + pinch} ${cx} ${cy + r}`,
15
+ `Q ${cx - pinch} ${cy + pinch} ${cx - r} ${cy}`,
16
+ `Q ${cx - pinch} ${cy - pinch} ${cx} ${cy - r}`,
17
+ "Z",
18
+ ].join(" ");
19
+ };
20
+
21
+ /** One large sparkle with two smaller companions, mirroring Font Awesome's sparkles layout. */
22
+ const SPARKLES_PATH = [
23
+ sparklePath(200, 272, 200),
24
+ sparklePath(420, 92, 88),
25
+ sparklePath(420, 428, 80),
26
+ ].join(" ");
27
+
28
+ /**
29
+ * Solid "sparkles" icon (three four-pointed stars). Defaults to 16x16 — pass
30
+ * `height`/`width` to resize and `fill` to recolor.
31
+ */
32
+ export const SparklesIcon = (props: SvgProps): React.ReactElement => {
33
+ return (
34
+ <Svg fill="currentColor" height={16} viewBox="0 0 512 512" width={16} {...props}>
35
+ <Path d={SPARKLES_PATH} />
36
+ </Svg>
37
+ );
38
+ };
@@ -0,0 +1,47 @@
1
+ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2
+
3
+ exports[`SparklesIcon renders correctly 1`] = `
4
+ {
5
+ "$$typeof": Symbol(react.test.json),
6
+ "children": [
7
+ {
8
+ "$$typeof": Symbol(react.test.json),
9
+ "children": null,
10
+ "props": {
11
+ "d": "M 200 72 Q 232 240 400 272 Q 232 304 200 472 Q 168 304 0 272 Q 168 240 200 72 Z M 420 4 Q 434.08 77.92 508 92 Q 434.08 106.08 420 180 Q 405.92 106.08 332 92 Q 405.92 77.92 420 4 Z M 420 348 Q 432.8 415.2 500 428 Q 432.8 440.8 420 508 Q 407.2 440.8 340 428 Q 407.2 415.2 420 348 Z",
12
+ },
13
+ "type": "Path",
14
+ },
15
+ ],
16
+ "props": {
17
+ "fill": "currentColor",
18
+ "height": 16,
19
+ "viewBox": "0 0 512 512",
20
+ "width": 16,
21
+ },
22
+ "type": "Svg",
23
+ }
24
+ `;
25
+
26
+ exports[`SparklesIcon accepts custom props 1`] = `
27
+ {
28
+ "$$typeof": Symbol(react.test.json),
29
+ "children": [
30
+ {
31
+ "$$typeof": Symbol(react.test.json),
32
+ "children": null,
33
+ "props": {
34
+ "d": "M 200 72 Q 232 240 400 272 Q 232 304 200 472 Q 168 304 0 272 Q 168 240 200 72 Z M 420 4 Q 434.08 77.92 508 92 Q 434.08 106.08 420 180 Q 405.92 106.08 332 92 Q 405.92 77.92 420 4 Z M 420 348 Q 432.8 415.2 500 428 Q 432.8 440.8 420 508 Q 407.2 440.8 340 428 Q 407.2 415.2 420 348 Z",
35
+ },
36
+ "type": "Path",
37
+ },
38
+ ],
39
+ "props": {
40
+ "fill": "#0A0A0A",
41
+ "height": 24,
42
+ "viewBox": "0 0 512 512",
43
+ "width": 24,
44
+ },
45
+ "type": "Svg",
46
+ }
47
+ `;
@@ -2,3 +2,4 @@ export * from "./MobileIcon";
2
2
  export * from "./OfflineIcon";
3
3
  export * from "./OnlineIcon";
4
4
  export * from "./OutOfficeIcon";
5
+ export * from "./SparklesIcon";
@@ -371,6 +371,7 @@ exports[`LoginScreen renders correctly with all props 1`] = `
371
371
  "borderRadius": 360,
372
372
  "borderWidth": undefined,
373
373
  "flexDirection": "column",
374
+ "height": undefined,
374
375
  "justifyContent": "center",
375
376
  "paddingHorizontal": 20,
376
377
  "paddingVertical": 8,
@@ -453,6 +454,7 @@ exports[`LoginScreen renders correctly with all props 1`] = `
453
454
  "borderRadius": 360,
454
455
  "borderWidth": undefined,
455
456
  "flexDirection": "column",
457
+ "height": undefined,
456
458
  "justifyContent": "center",
457
459
  "paddingHorizontal": 20,
458
460
  "paddingVertical": 8,
@@ -536,6 +538,7 @@ exports[`LoginScreen renders correctly with all props 1`] = `
536
538
  "borderRadius": 360,
537
539
  "borderWidth": undefined,
538
540
  "flexDirection": "column",
541
+ "height": undefined,
539
542
  "justifyContent": "center",
540
543
  "paddingHorizontal": 20,
541
544
  "paddingVertical": 8,
@@ -711,6 +711,7 @@ exports[`SignUpScreen renders correctly with all props 1`] = `
711
711
  "borderRadius": 360,
712
712
  "borderWidth": undefined,
713
713
  "flexDirection": "column",
714
+ "height": undefined,
714
715
  "justifyContent": "center",
715
716
  "paddingHorizontal": 20,
716
717
  "paddingVertical": 8,
@@ -793,6 +794,7 @@ exports[`SignUpScreen renders correctly with all props 1`] = `
793
794
  "borderRadius": 360,
794
795
  "borderWidth": undefined,
795
796
  "flexDirection": "column",
797
+ "height": undefined,
796
798
  "justifyContent": "center",
797
799
  "paddingHorizontal": 20,
798
800
  "paddingVertical": 8,
@@ -2,12 +2,17 @@ import {describe, expect, it} from "bun:test";
2
2
 
3
3
  import {
4
4
  resolveDataTableRowTestID,
5
+ resolveDataTableTestIDs,
6
+ resolveDataTableTestIDsFromProps,
5
7
  resolveFieldTestIDs,
8
+ resolveFieldTestIDsFromProps,
6
9
  resolveModalTestIDs,
10
+ resolveModalTestIDsFromProps,
7
11
  resolveSegmentedControlTestIDs,
8
12
  resolveSegmentedControlTestIDsFromProps,
9
13
  resolveTestID,
10
14
  toDomTestProps,
15
+ toPlatformTestProps,
11
16
  toTestProps,
12
17
  } from "./resolveTestId";
13
18
 
@@ -40,6 +45,21 @@ describe("toDomTestProps", () => {
40
45
  it("returns data-testid for DOM elements", () => {
41
46
  expect(toDomTestProps("submit")).toEqual({"data-testid": "submit"});
42
47
  });
48
+
49
+ it("returns empty object when id is absent", () => {
50
+ expect(toDomTestProps(undefined)).toEqual({});
51
+ });
52
+ });
53
+
54
+ describe("toPlatformTestProps", () => {
55
+ it("returns empty object when id is absent", () => {
56
+ expect(toPlatformTestProps(undefined)).toEqual({});
57
+ });
58
+
59
+ it("returns testID on non-web platforms", () => {
60
+ const result = toPlatformTestProps("my-button");
61
+ expect(result.testID ?? result["data-testid"]).toBeDefined();
62
+ });
43
63
  });
44
64
 
45
65
  describe("resolveFieldTestIDs", () => {
@@ -79,11 +99,92 @@ describe("resolveModalTestIDs", () => {
79
99
  });
80
100
  });
81
101
 
102
+ describe("resolveFieldTestIDsFromProps", () => {
103
+ it("resolves from props with testID", () => {
104
+ const result = resolveFieldTestIDsFromProps({testID: "email"});
105
+ expect(result.input).toBe("email");
106
+ expect(result.label).toBe("email.label");
107
+ expect(result.error).toBe("email.error");
108
+ expect(result.helper).toBe("email.helper");
109
+ });
110
+
111
+ it("uses testIDs overrides from props", () => {
112
+ const result = resolveFieldTestIDsFromProps({
113
+ testID: "email",
114
+ testIDs: {input: "custom-input"},
115
+ });
116
+ expect(result.input).toBe("custom-input");
117
+ expect(result.label).toBe("email.label");
118
+ });
119
+ });
120
+
121
+ describe("resolveModalTestIDsFromProps", () => {
122
+ it("resolves from props with testID", () => {
123
+ const result = resolveModalTestIDsFromProps({testID: "dialog"});
124
+ expect(result.root).toBe("dialog");
125
+ expect(result.dismiss).toBe("dialog.dismiss");
126
+ expect(result.primaryButton).toBe("dialog.primary");
127
+ expect(result.secondaryButton).toBe("dialog.secondary");
128
+ expect(result.title).toBe("dialog.title");
129
+ });
130
+
131
+ it("uses testIDs overrides from props", () => {
132
+ const result = resolveModalTestIDsFromProps({
133
+ testID: "dialog",
134
+ testIDs: {dismiss: "close-btn"},
135
+ });
136
+ expect(result.dismiss).toBe("close-btn");
137
+ });
138
+ });
139
+
140
+ describe("resolveDataTableTestIDs", () => {
141
+ it("applies dot-suffix defaults", () => {
142
+ expect(resolveDataTableTestIDs("users-table")).toEqual({
143
+ body: "users-table.body",
144
+ header: "users-table.header",
145
+ pagination: "users-table.pagination",
146
+ root: "users-table",
147
+ row: "users-table.row",
148
+ });
149
+ });
150
+
151
+ it("allows testIDs overrides", () => {
152
+ expect(
153
+ resolveDataTableTestIDs("users-table", {header: "custom-header", root: "custom-root"})
154
+ ).toEqual({
155
+ body: "users-table.body",
156
+ header: "custom-header",
157
+ pagination: "users-table.pagination",
158
+ root: "custom-root",
159
+ row: "users-table.row",
160
+ });
161
+ });
162
+
163
+ it("returns undefined-based results when base is absent", () => {
164
+ const result = resolveDataTableTestIDs(undefined);
165
+ expect(result.root).toBeUndefined();
166
+ expect(result.header).toBeUndefined();
167
+ });
168
+ });
169
+
170
+ describe("resolveDataTableTestIDsFromProps", () => {
171
+ it("resolves from props with testID", () => {
172
+ const result = resolveDataTableTestIDsFromProps({testID: "table"});
173
+ expect(result.root).toBe("table");
174
+ expect(result.body).toBe("table.body");
175
+ expect(result.row).toBe("table.row");
176
+ });
177
+ });
178
+
82
179
  describe("resolveDataTableRowTestID", () => {
83
180
  it("appends row key to row test id base", () => {
84
181
  expect(resolveDataTableRowTestID("users-table.row", "abc123")).toBe("users-table.row-abc123");
85
182
  });
86
183
 
184
+ it("handles numeric row keys", () => {
185
+ expect(resolveDataTableRowTestID("table.row", 42)).toBe("table.row-42");
186
+ });
187
+
87
188
  it("returns undefined when base is absent", () => {
88
189
  expect(resolveDataTableRowTestID(undefined, "abc123")).toBeUndefined();
89
190
  });