@terreno/ui 0.31.0 → 56.0.0-beta.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.
Files changed (126) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/Avatar.js +1 -4
  3. package/dist/Avatar.js.map +1 -1
  4. package/dist/Box.js +45 -9
  5. package/dist/Box.js.map +1 -1
  6. package/dist/Common.d.ts +21 -0
  7. package/dist/Common.js.map +1 -1
  8. package/dist/ConflictSheet.d.ts +53 -0
  9. package/dist/ConflictSheet.js +132 -0
  10. package/dist/ConflictSheet.js.map +1 -0
  11. package/dist/DateTimeActionSheet.d.ts +2 -1
  12. package/dist/DateTimeField.js +5 -21
  13. package/dist/DateTimeField.js.map +1 -1
  14. package/dist/DecimalRangeActionSheet.d.ts +1 -1
  15. package/dist/EmojiSelector.d.ts +1 -1
  16. package/dist/ErrorPage.d.ts +1 -1
  17. package/dist/HeightActionSheet.d.ts +1 -1
  18. package/dist/Hyperlink.d.ts +2 -1
  19. package/dist/Hyperlink.js +2 -1
  20. package/dist/Hyperlink.js.map +1 -1
  21. package/dist/Image.d.ts +1 -1
  22. package/dist/ImageBackground.d.ts +1 -1
  23. package/dist/MobileAddressAutoComplete.d.ts +1 -1
  24. package/dist/NumberPickerActionSheet.d.ts +1 -1
  25. package/dist/Page.d.ts +5 -4
  26. package/dist/Page.js +0 -2
  27. package/dist/Page.js.map +1 -1
  28. package/dist/PickerSelect.d.ts +1 -1
  29. package/dist/SidebarNavigation.js +1 -1
  30. package/dist/SidebarNavigation.js.map +1 -1
  31. package/dist/SidebarNavigation.native.js +1 -1
  32. package/dist/SidebarNavigation.native.js.map +1 -1
  33. package/dist/SplitPage.d.ts +1 -1
  34. package/dist/SplitPage.js +1 -4
  35. package/dist/SplitPage.js.map +1 -1
  36. package/dist/SplitPage.native.d.ts +1 -1
  37. package/dist/SyncStatusBanner.d.ts +46 -0
  38. package/dist/SyncStatusBanner.js +29 -0
  39. package/dist/SyncStatusBanner.js.map +1 -0
  40. package/dist/Theme.d.ts +1 -1
  41. package/dist/Toast.d.ts +9 -1
  42. package/dist/Toast.js +20 -7
  43. package/dist/Toast.js.map +1 -1
  44. package/dist/ToastNotifications.js +23 -1
  45. package/dist/ToastNotifications.js.map +1 -1
  46. package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
  47. package/dist/Unifier.js +1 -1
  48. package/dist/Unifier.js.map +1 -1
  49. package/dist/conflictFieldDiff.d.ts +14 -0
  50. package/dist/conflictFieldDiff.js +62 -0
  51. package/dist/conflictFieldDiff.js.map +1 -0
  52. package/dist/icons/OfflineIcon.d.ts +1 -1
  53. package/dist/icons/OnlineIcon.d.ts +1 -1
  54. package/dist/icons/OutOfficeIcon.d.ts +1 -1
  55. package/dist/index.d.ts +5 -2
  56. package/dist/index.js +5 -2
  57. package/dist/index.js.map +1 -1
  58. package/dist/pdfHtmlTemplate.d.ts +30 -0
  59. package/dist/pdfHtmlTemplate.js +170 -0
  60. package/dist/pdfHtmlTemplate.js.map +1 -0
  61. package/dist/table/TableTitle.js +1 -3
  62. package/dist/table/TableTitle.js.map +1 -1
  63. package/dist/useAppLaunchOrForeground.d.ts +9 -0
  64. package/dist/useAppLaunchOrForeground.js +27 -0
  65. package/dist/useAppLaunchOrForeground.js.map +1 -0
  66. package/package.json +44 -37
  67. package/src/ActionSheet.test.tsx +123 -136
  68. package/src/Box.test.tsx +68 -30
  69. package/src/Box.tsx +46 -7
  70. package/src/Common.ts +21 -3
  71. package/src/ConflictSheet.test.tsx +461 -0
  72. package/src/ConflictSheet.tsx +399 -0
  73. package/src/ConsentFormScreen.test.tsx +22 -0
  74. package/src/DateTimeField.test.tsx +14 -0
  75. package/src/DateTimeField.tsx +5 -19
  76. package/src/Hyperlink.tsx +1 -1
  77. package/src/Page.tsx +2 -3
  78. package/src/SidebarNavigation.native.tsx +1 -1
  79. package/src/SidebarNavigation.tsx +1 -1
  80. package/src/SyncStatusBanner.test.tsx +204 -0
  81. package/src/SyncStatusBanner.tsx +148 -0
  82. package/src/TerrenoProvider.test.tsx +3 -4
  83. package/src/Toast.test.tsx +60 -0
  84. package/src/Toast.tsx +46 -1
  85. package/src/ToastNotifications.test.tsx +82 -0
  86. package/src/ToastNotifications.tsx +25 -1
  87. package/src/Unifier.ts +1 -1
  88. package/src/WebDropdownMenu.test.tsx +128 -0
  89. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
  90. package/src/__snapshots__/Body.test.tsx.snap +0 -16
  91. package/src/__snapshots__/Box.test.tsx.snap +4 -13
  92. package/src/__snapshots__/Page.test.tsx.snap +0 -84
  93. package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
  94. package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
  95. package/src/__snapshots__/Toast.test.tsx.snap +4 -2
  96. package/src/bunSetup.ts +19 -0
  97. package/src/conflictFieldDiff.test.ts +26 -0
  98. package/src/conflictFieldDiff.ts +78 -0
  99. package/src/index.tsx +5 -2
  100. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
  101. package/src/pdfHtmlTemplate.ts +219 -0
  102. package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
  103. package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
  104. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
  105. package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
  106. package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
  107. package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
  108. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
  109. package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
  110. package/src/useAppLaunchOrForeground.test.tsx +54 -0
  111. package/src/useAppLaunchOrForeground.ts +30 -0
  112. package/dist/ConsentHistory.d.ts +0 -9
  113. package/dist/ConsentHistory.js +0 -70
  114. package/dist/ConsentHistory.js.map +0 -1
  115. package/dist/generateConsentHistoryPdf.d.ts +0 -2
  116. package/dist/generateConsentHistoryPdf.js +0 -185
  117. package/dist/generateConsentHistoryPdf.js.map +0 -1
  118. package/dist/useConsentHistory.d.ts +0 -63
  119. package/dist/useConsentHistory.js +0 -40
  120. package/dist/useConsentHistory.js.map +0 -1
  121. package/src/ConsentHistory.test.tsx +0 -224
  122. package/src/ConsentHistory.tsx +0 -249
  123. package/src/generateConsentHistoryPdf.test.ts +0 -253
  124. package/src/generateConsentHistoryPdf.ts +0 -211
  125. package/src/useConsentHistory.test.ts +0 -106
  126. package/src/useConsentHistory.ts +0 -94
@@ -0,0 +1,461 @@
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {fireEvent, within} from "@testing-library/react-native";
3
+ import {DateTime} from "luxon";
4
+
5
+ import {ConflictSheet, type SyncConflictItem} from "./ConflictSheet";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ /**
9
+ * Timestamps render in the runner's own locale and zone, and the exact
10
+ * separators shift between ICU versions — so derive the expectation the same way
11
+ * the sheet does instead of pinning a literal string.
12
+ */
13
+ const expectedTime = (iso: string): string =>
14
+ DateTime.fromISO(iso).toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS);
15
+
16
+ const buildConflict = (overrides?: Partial<SyncConflictItem>): SyncConflictItem => ({
17
+ collection: "todos",
18
+ entityId: "todo-1",
19
+ localData: JSON.stringify({title: "My local title", updated: "2026-01-02T15:04:00.000Z"}),
20
+ mutationId: "m-1",
21
+ serverData: JSON.stringify({title: "Server title", updated: "2026-01-02T16:05:00.000Z"}),
22
+ ...overrides,
23
+ });
24
+
25
+ const flush = (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0));
26
+ const flushDebounce = (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 550));
27
+
28
+ describe("ConflictSheet", () => {
29
+ it("renders each conflict with local and server summaries", () => {
30
+ const {getByTestId, getByText} = renderWithTheme(
31
+ <ConflictSheet
32
+ conflicts={[buildConflict()]}
33
+ onDismiss={() => {}}
34
+ onResolve={() => {}}
35
+ visible={true}
36
+ />
37
+ );
38
+ expect(getByTestId("conflict-item-todo-1")).toBeTruthy();
39
+ expect(getByText("My local title")).toBeTruthy();
40
+ expect(getByText("Server title")).toBeTruthy();
41
+ // Asserted per row so a swap of the local and server columns fails here.
42
+ expect(getByTestId("conflict-local-time-todo-1").props.children).toBe(
43
+ expectedTime("2026-01-02T15:04:00.000Z")
44
+ );
45
+ expect(getByTestId("conflict-server-time-todo-1").props.children).toBe(
46
+ expectedTime("2026-01-02T16:05:00.000Z")
47
+ );
48
+ });
49
+
50
+ it("always renders a time row when conflict payloads have no usable timestamp", () => {
51
+ const {getAllByText} = renderWithTheme(
52
+ <ConflictSheet
53
+ conflicts={[
54
+ buildConflict({
55
+ localData: JSON.stringify({title: "Local without time"}),
56
+ serverData: JSON.stringify({title: "Server without time"}),
57
+ }),
58
+ ]}
59
+ onDismiss={() => {}}
60
+ onResolve={() => {}}
61
+ visible={true}
62
+ />
63
+ );
64
+ expect(getAllByText("Time unavailable")).toHaveLength(2);
65
+ });
66
+
67
+ it("badges the server side when it has the later timestamp", () => {
68
+ const {getByTestId, queryByTestId} = renderWithTheme(
69
+ <ConflictSheet
70
+ conflicts={[buildConflict()]}
71
+ onDismiss={() => {}}
72
+ onResolve={() => {}}
73
+ visible={true}
74
+ />
75
+ );
76
+ expect(getByTestId("conflict-server-recency-todo-1")).toBeTruthy();
77
+ expect(queryByTestId("conflict-local-recency-todo-1")).toBeNull();
78
+ });
79
+
80
+ it("badges the local side when it has the later timestamp", () => {
81
+ const {getByTestId, queryByTestId} = renderWithTheme(
82
+ <ConflictSheet
83
+ conflicts={[
84
+ buildConflict({
85
+ localData: JSON.stringify({title: "Local", updated: "2026-01-02T18:00:00.000Z"}),
86
+ serverData: JSON.stringify({title: "Server", updated: "2026-01-02T16:05:00.000Z"}),
87
+ }),
88
+ ]}
89
+ onDismiss={() => {}}
90
+ onResolve={() => {}}
91
+ visible={true}
92
+ />
93
+ );
94
+ expect(getByTestId("conflict-local-recency-todo-1")).toBeTruthy();
95
+ expect(queryByTestId("conflict-server-recency-todo-1")).toBeNull();
96
+ });
97
+
98
+ it("badges both sides as the same time when the timestamps match", () => {
99
+ const {getAllByText, getByTestId} = renderWithTheme(
100
+ <ConflictSheet
101
+ conflicts={[
102
+ buildConflict({
103
+ localData: JSON.stringify({title: "Local", updated: "2026-01-02T16:05:00.000Z"}),
104
+ serverData: JSON.stringify({title: "Server", updated: "2026-01-02T16:05:00.000Z"}),
105
+ }),
106
+ ]}
107
+ onDismiss={() => {}}
108
+ onResolve={() => {}}
109
+ visible={true}
110
+ />
111
+ );
112
+ expect(getByTestId("conflict-local-recency-todo-1")).toBeTruthy();
113
+ expect(getByTestId("conflict-server-recency-todo-1")).toBeTruthy();
114
+ expect(getAllByText("Same time")).toHaveLength(2);
115
+ });
116
+
117
+ it("badges neither side when a timestamp is missing or unparseable", () => {
118
+ const {queryByTestId} = renderWithTheme(
119
+ <ConflictSheet
120
+ conflicts={[
121
+ buildConflict({
122
+ localData: JSON.stringify({title: "Local", updated: "not a date"}),
123
+ serverData: JSON.stringify({title: "Server"}),
124
+ }),
125
+ ]}
126
+ onDismiss={() => {}}
127
+ onResolve={() => {}}
128
+ visible={true}
129
+ />
130
+ );
131
+ expect(queryByTestId("conflict-local-recency-todo-1")).toBeNull();
132
+ expect(queryByTestId("conflict-server-recency-todo-1")).toBeNull();
133
+ });
134
+
135
+ it("renders a caller-supplied title and description", () => {
136
+ const {getByText} = renderWithTheme(
137
+ <ConflictSheet
138
+ conflicts={[buildConflict()]}
139
+ description="Pick one for your todos."
140
+ onDismiss={() => {}}
141
+ onResolve={() => {}}
142
+ title="Todos don't match"
143
+ visible={true}
144
+ />
145
+ );
146
+ expect(getByText("Todos don't match")).toBeTruthy();
147
+ expect(getByText("Pick one for your todos.")).toBeTruthy();
148
+ });
149
+
150
+ it("hides the description when an empty string is passed", () => {
151
+ const {queryByTestId} = renderWithTheme(
152
+ <ConflictSheet
153
+ conflicts={[buildConflict()]}
154
+ description=""
155
+ onDismiss={() => {}}
156
+ onResolve={() => {}}
157
+ visible={true}
158
+ />
159
+ );
160
+ expect(queryByTestId("conflict-sheet-description")).toBeNull();
161
+ });
162
+
163
+ it("shows an empty state when there are no conflicts", () => {
164
+ const {getByText} = renderWithTheme(
165
+ <ConflictSheet conflicts={[]} onDismiss={() => {}} onResolve={() => {}} visible={true} />
166
+ );
167
+ expect(getByText("Nothing left to choose — you're all set.")).toBeTruthy();
168
+ });
169
+
170
+ it("keeps overflowing conflict content inside a bounded scroll view", () => {
171
+ const {getByTestId} = renderWithTheme(
172
+ <ConflictSheet
173
+ conflicts={[
174
+ buildConflict(),
175
+ buildConflict({entityId: "todo-2", mutationId: "m-2"}),
176
+ buildConflict({entityId: "todo-3", mutationId: "m-3"}),
177
+ ]}
178
+ onDismiss={() => {}}
179
+ onResolve={() => {}}
180
+ visible={true}
181
+ />
182
+ );
183
+
184
+ const scrollView = getByTestId("conflict-sheet-scroll");
185
+ expect(scrollView.props.style.maxHeight).toBeGreaterThan(0);
186
+ expect(getByTestId("conflict-item-todo-3")).toBeTruthy();
187
+ });
188
+
189
+ it("explains the situation in plain language and labels each side clearly", () => {
190
+ const {getByTestId, getByText, queryByText} = renderWithTheme(
191
+ <ConflictSheet
192
+ conflicts={[buildConflict()]}
193
+ onDismiss={() => {}}
194
+ onResolve={() => {}}
195
+ visible={true}
196
+ />
197
+ );
198
+ expect(getByTestId("conflict-sheet-description")).toBeTruthy();
199
+ expect(getByText("Your change")).toBeTruthy();
200
+ expect(getByText("Other version")).toBeTruthy();
201
+ expect(queryByText("What you edited on this device")).toBeNull();
202
+ expect(
203
+ queryByText("What's saved elsewhere — another device, another person, or an older copy")
204
+ ).toBeNull();
205
+ expect(getByText("Keep my change")).toBeTruthy();
206
+ expect(getByText("Use the other version")).toBeTruthy();
207
+ expect(getByText("Keep all of my changes")).toBeTruthy();
208
+ expect(getByText("Use all other versions")).toBeTruthy();
209
+ });
210
+
211
+ it("renders only changed fields in both version columns", async () => {
212
+ const {getAllByText, getByTestId, getByText, queryByText} = renderWithTheme(
213
+ <ConflictSheet
214
+ conflicts={[
215
+ buildConflict({
216
+ localData: JSON.stringify({
217
+ completed: true,
218
+ title: "My local title",
219
+ unchanged: "same",
220
+ updated: "2026-01-02T15:04:00.000Z",
221
+ }),
222
+ serverData: JSON.stringify({
223
+ completed: false,
224
+ title: "Server title",
225
+ unchanged: "same",
226
+ updated: "2026-01-02T16:05:00.000Z",
227
+ }),
228
+ }),
229
+ ]}
230
+ onDismiss={() => {}}
231
+ onResolve={() => {}}
232
+ visible={true}
233
+ />
234
+ );
235
+
236
+ fireEvent.press(getByTestId("conflict-diff-toggle-todo-1"));
237
+ await flushDebounce();
238
+ expect(getAllByText("Title")).toHaveLength(2);
239
+ expect(getAllByText("Completed")).toHaveLength(2);
240
+ expect(getByText("My local title")).toBeTruthy();
241
+ expect(getByText("Server title")).toBeTruthy();
242
+ expect(getByText("true")).toBeTruthy();
243
+ expect(getByText("false")).toBeTruthy();
244
+ expect(queryByText("Unchanged")).toBeNull();
245
+ expect(queryByText("same")).toBeNull();
246
+ });
247
+
248
+ it("opens field diff rows when Diff is pressed", async () => {
249
+ const {getAllByText, getByTestId, getByText, queryByTestId} = renderWithTheme(
250
+ <ConflictSheet
251
+ conflicts={[
252
+ buildConflict({
253
+ localData: JSON.stringify({completed: true, title: "My local title"}),
254
+ serverData: JSON.stringify({completed: false, title: "Server title"}),
255
+ }),
256
+ ]}
257
+ onDismiss={() => {}}
258
+ onResolve={() => {}}
259
+ visible={true}
260
+ />
261
+ );
262
+
263
+ expect(getByText("Diff")).toBeTruthy();
264
+ expect(queryByTestId("conflict-local-field-completed-todo-1")).toBeNull();
265
+ fireEvent.press(getByTestId("conflict-diff-toggle-todo-1"));
266
+ await flushDebounce();
267
+ expect(getByText("Hide diff")).toBeTruthy();
268
+ expect(getByTestId("conflict-local-field-completed-todo-1")).toBeTruthy();
269
+ expect(getAllByText("Completed")).toHaveLength(2);
270
+ });
271
+
272
+ it("keeps each resolution button inside the version column it applies to", () => {
273
+ const {getByTestId} = renderWithTheme(
274
+ <ConflictSheet
275
+ conflicts={[buildConflict()]}
276
+ onDismiss={() => {}}
277
+ onResolve={() => {}}
278
+ visible={true}
279
+ />
280
+ );
281
+
282
+ const localColumn = getByTestId("conflict-local-column-todo-1");
283
+ const serverColumn = getByTestId("conflict-server-column-todo-1");
284
+ expect(within(localColumn).getByTestId("conflict-keep-mine-button-m-1")).toBeTruthy();
285
+ expect(within(serverColumn).getByTestId("conflict-use-server-button-m-1")).toBeTruthy();
286
+ });
287
+
288
+ it("calls onResolve with keepMine but keeps the sheet open until the conflict clears", async () => {
289
+ const onResolve = mock(() => {});
290
+ const onDismiss = mock(() => {});
291
+ const {getByTestId, rerender} = renderWithTheme(
292
+ <ConflictSheet
293
+ conflicts={[buildConflict()]}
294
+ onDismiss={onDismiss}
295
+ onResolve={onResolve}
296
+ visible={true}
297
+ />
298
+ );
299
+ fireEvent.press(getByTestId("conflict-keep-mine-button-m-1"));
300
+ await flush();
301
+ expect(onResolve).toHaveBeenCalledTimes(1);
302
+ expect(onResolve.mock.calls[0][0]).toEqual({mutationId: "m-1", strategy: "keepMine"});
303
+ // Resolution has not landed yet (async in the data layer) — a failed resolve must
304
+ // leave the conflict on screen rather than closing over it.
305
+ expect(onDismiss).not.toHaveBeenCalled();
306
+
307
+ rerender(
308
+ <ConflictSheet conflicts={[]} onDismiss={onDismiss} onResolve={onResolve} visible={true} />
309
+ );
310
+ await flush();
311
+ expect(onDismiss).toHaveBeenCalledTimes(1);
312
+ });
313
+
314
+ it("keeps the sheet open when a resolution never lands", async () => {
315
+ const onDismiss = mock(() => {});
316
+ const {getByTestId} = renderWithTheme(
317
+ <ConflictSheet
318
+ conflicts={[buildConflict()]}
319
+ onDismiss={onDismiss}
320
+ onResolve={() => {}}
321
+ visible={true}
322
+ />
323
+ );
324
+ fireEvent.press(getByTestId("conflict-use-server-button-m-1"));
325
+ await flush();
326
+ expect(onDismiss).not.toHaveBeenCalled();
327
+ expect(getByTestId("conflict-item-todo-1")).toBeTruthy();
328
+ });
329
+
330
+ it("does not dismiss a sheet opened with no conflicts at all", async () => {
331
+ const onDismiss = mock(() => {});
332
+ renderWithTheme(
333
+ <ConflictSheet conflicts={[]} onDismiss={onDismiss} onResolve={() => {}} visible={true} />
334
+ );
335
+ await flush();
336
+ expect(onDismiss).not.toHaveBeenCalled();
337
+ });
338
+
339
+ it("calls onResolve with useServer without dismissing when other conflicts remain", async () => {
340
+ const onResolve = mock(() => {});
341
+ const onDismiss = mock(() => {});
342
+ const {getByTestId} = renderWithTheme(
343
+ <ConflictSheet
344
+ conflicts={[buildConflict(), buildConflict({entityId: "todo-2", mutationId: "m-2"})]}
345
+ onDismiss={onDismiss}
346
+ onResolve={onResolve}
347
+ visible={true}
348
+ />
349
+ );
350
+ fireEvent.press(getByTestId("conflict-use-server-button-m-1"));
351
+ await flush();
352
+ expect(onResolve).toHaveBeenCalledTimes(1);
353
+ expect(onResolve.mock.calls[0][0]).toEqual({mutationId: "m-1", strategy: "useServer"});
354
+ expect(onDismiss).not.toHaveBeenCalled();
355
+ });
356
+
357
+ it("uses the server version for every conflict after confirmation, dismissing once they clear", async () => {
358
+ const onResolve = mock(() => {});
359
+ const onDismiss = mock(() => {});
360
+ const {findByText, getByTestId, rerender} = renderWithTheme(
361
+ <ConflictSheet
362
+ conflicts={[buildConflict(), buildConflict({entityId: "todo-2", mutationId: "m-2"})]}
363
+ onDismiss={onDismiss}
364
+ onResolve={onResolve}
365
+ visible={true}
366
+ />
367
+ );
368
+
369
+ fireEvent.press(getByTestId("conflict-use-server-all-button"));
370
+ fireEvent.press(await findByText("Confirm"));
371
+ await flush();
372
+
373
+ expect(onResolve).toHaveBeenCalledTimes(2);
374
+ expect(onResolve.mock.calls.map(([args]) => args)).toEqual([
375
+ {mutationId: "m-1", strategy: "useServer"},
376
+ {mutationId: "m-2", strategy: "useServer"},
377
+ ]);
378
+ expect(onDismiss).not.toHaveBeenCalled();
379
+
380
+ rerender(
381
+ <ConflictSheet conflicts={[]} onDismiss={onDismiss} onResolve={onResolve} visible={true} />
382
+ );
383
+ await flush();
384
+ expect(onDismiss).toHaveBeenCalledTimes(1);
385
+ });
386
+
387
+ it("keeps the local version for every conflict after confirmation, dismissing once they clear", async () => {
388
+ const onResolve = mock(() => {});
389
+ const onDismiss = mock(() => {});
390
+ const {findByText, getByTestId, rerender} = renderWithTheme(
391
+ <ConflictSheet
392
+ conflicts={[buildConflict(), buildConflict({entityId: "todo-2", mutationId: "m-2"})]}
393
+ onDismiss={onDismiss}
394
+ onResolve={onResolve}
395
+ visible={true}
396
+ />
397
+ );
398
+
399
+ fireEvent.press(getByTestId("conflict-use-mine-all-button"));
400
+ fireEvent.press(await findByText("Confirm"));
401
+ await flush();
402
+
403
+ expect(onResolve).toHaveBeenCalledTimes(2);
404
+ expect(onResolve.mock.calls.map(([args]) => args)).toEqual([
405
+ {mutationId: "m-1", strategy: "keepMine"},
406
+ {mutationId: "m-2", strategy: "keepMine"},
407
+ ]);
408
+ expect(onDismiss).not.toHaveBeenCalled();
409
+
410
+ rerender(
411
+ <ConflictSheet conflicts={[]} onDismiss={onDismiss} onResolve={onResolve} visible={true} />
412
+ );
413
+ await flush();
414
+ expect(onDismiss).toHaveBeenCalledTimes(1);
415
+ });
416
+
417
+ it("suffixes testIDs with mutationId so multiple conflicts never collide (E6, RN Testing Library strict-mode fix)", () => {
418
+ const {getByTestId} = renderWithTheme(
419
+ <ConflictSheet
420
+ conflicts={[buildConflict(), buildConflict({entityId: "todo-2", mutationId: "m-2"})]}
421
+ onDismiss={() => {}}
422
+ onResolve={() => {}}
423
+ visible={true}
424
+ />
425
+ );
426
+ // getByTestId throws if more than one match is found — this is exactly
427
+ // what would happen with the old shared "conflict-keep-mine-button" /
428
+ // "conflict-use-server-button" testIDs across two rendered conflicts.
429
+ expect(getByTestId("conflict-keep-mine-button-m-1")).toBeTruthy();
430
+ expect(getByTestId("conflict-keep-mine-button-m-2")).toBeTruthy();
431
+ expect(getByTestId("conflict-use-server-button-m-1")).toBeTruthy();
432
+ expect(getByTestId("conflict-use-server-button-m-2")).toBeTruthy();
433
+ });
434
+
435
+ it("renders changed fields when a payload has no title", async () => {
436
+ const {getAllByText, getByTestId, getByText} = renderWithTheme(
437
+ <ConflictSheet
438
+ conflicts={[buildConflict({localData: JSON.stringify({completed: true})})]}
439
+ onDismiss={() => {}}
440
+ onResolve={() => {}}
441
+ visible={true}
442
+ />
443
+ );
444
+ fireEvent.press(getByTestId("conflict-diff-toggle-todo-1"));
445
+ await flushDebounce();
446
+ expect(getAllByText("Completed")).toHaveLength(2);
447
+ expect(getByText("true")).toBeTruthy();
448
+ });
449
+
450
+ it("tolerates invalid JSON payloads", () => {
451
+ const {getByTestId} = renderWithTheme(
452
+ <ConflictSheet
453
+ conflicts={[buildConflict({localData: "not json", serverData: "{bad"})]}
454
+ onDismiss={() => {}}
455
+ onResolve={() => {}}
456
+ visible={true}
457
+ />
458
+ );
459
+ expect(getByTestId("conflict-item-todo-1")).toBeTruthy();
460
+ });
461
+ });