@terreno/ui 57.19.2 → 57.21.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 (379) hide show
  1. package/.ai/guidelines/core.md +1 -1
  2. package/CHANGELOG.md +443 -0
  3. package/dist/Accordion.d.ts.map +1 -1
  4. package/dist/Accordion.js +3 -3
  5. package/dist/Accordion.js.map +1 -1
  6. package/dist/Avatar.d.ts.map +1 -1
  7. package/dist/Avatar.js +3 -1
  8. package/dist/Avatar.js.map +1 -1
  9. package/dist/Box.d.ts.map +1 -1
  10. package/dist/Box.js +38 -2
  11. package/dist/Box.js.map +1 -1
  12. package/dist/Card.js +2 -2
  13. package/dist/Card.js.map +1 -1
  14. package/dist/Common.d.ts +175 -34
  15. package/dist/Common.d.ts.map +1 -1
  16. package/dist/Common.js.map +1 -1
  17. package/dist/ConsentFormScreen.d.ts +1 -1
  18. package/dist/ConsentFormScreen.d.ts.map +1 -1
  19. package/dist/ConsentFormScreen.js +13 -4
  20. package/dist/ConsentFormScreen.js.map +1 -1
  21. package/dist/DateTimeField.d.ts.map +1 -1
  22. package/dist/DateTimeField.js +11 -9
  23. package/dist/DateTimeField.js.map +1 -1
  24. package/dist/Field.d.ts.map +1 -1
  25. package/dist/Field.js +2 -0
  26. package/dist/Field.js.map +1 -1
  27. package/dist/FormContainer.d.ts +68 -0
  28. package/dist/FormContainer.d.ts.map +1 -0
  29. package/dist/FormContainer.js +79 -0
  30. package/dist/FormContainer.js.map +1 -0
  31. package/dist/GPTChat.d.ts.map +1 -1
  32. package/dist/GPTChat.js +2 -1
  33. package/dist/GPTChat.js.map +1 -1
  34. package/dist/Heading.d.ts +1 -1
  35. package/dist/Heading.d.ts.map +1 -1
  36. package/dist/Heading.js +5 -2
  37. package/dist/Heading.js.map +1 -1
  38. package/dist/HeightField.js +8 -8
  39. package/dist/HeightField.js.map +1 -1
  40. package/dist/Icon.d.ts +4 -0
  41. package/dist/Icon.d.ts.map +1 -1
  42. package/dist/Icon.js +43 -2
  43. package/dist/Icon.js.map +1 -1
  44. package/dist/LabeledCheckBox.d.ts +22 -0
  45. package/dist/LabeledCheckBox.d.ts.map +1 -0
  46. package/dist/LabeledCheckBox.js +30 -0
  47. package/dist/LabeledCheckBox.js.map +1 -0
  48. package/dist/ListDetailLayout.d.ts +36 -0
  49. package/dist/ListDetailLayout.d.ts.map +1 -0
  50. package/dist/ListDetailLayout.js +153 -0
  51. package/dist/ListDetailLayout.js.map +1 -0
  52. package/dist/MarkdownEditor.d.ts.map +1 -1
  53. package/dist/MarkdownEditor.js +2 -1
  54. package/dist/MarkdownEditor.js.map +1 -1
  55. package/dist/MediaQuery.d.ts +1 -1
  56. package/dist/MediaQuery.d.ts.map +1 -1
  57. package/dist/MediaQuery.js +1 -1
  58. package/dist/MediaQuery.js.map +1 -1
  59. package/dist/OtpField.d.ts +60 -0
  60. package/dist/OtpField.d.ts.map +1 -0
  61. package/dist/OtpField.js +154 -0
  62. package/dist/OtpField.js.map +1 -0
  63. package/dist/PickerSelect.js +9 -9
  64. package/dist/PickerSelect.js.map +1 -1
  65. package/dist/ProvisionalConsentSigner.d.ts +21 -0
  66. package/dist/ProvisionalConsentSigner.d.ts.map +1 -0
  67. package/dist/ProvisionalConsentSigner.js +199 -0
  68. package/dist/ProvisionalConsentSigner.js.map +1 -0
  69. package/dist/ResponsiveBreakpoint.d.ts +5 -0
  70. package/dist/ResponsiveBreakpoint.d.ts.map +1 -1
  71. package/dist/ResponsiveBreakpoint.js +7 -0
  72. package/dist/ResponsiveBreakpoint.js.map +1 -1
  73. package/dist/SocialLoginButton.d.ts +10 -0
  74. package/dist/SocialLoginButton.d.ts.map +1 -1
  75. package/dist/SocialLoginButton.js +26 -8
  76. package/dist/SocialLoginButton.js.map +1 -1
  77. package/dist/SplitPage.d.ts +11 -0
  78. package/dist/SplitPage.d.ts.map +1 -1
  79. package/dist/SplitPage.js +11 -5
  80. package/dist/SplitPage.js.map +1 -1
  81. package/dist/SplitPage.native.d.ts.map +1 -1
  82. package/dist/SplitPage.native.js +3 -1
  83. package/dist/SplitPage.native.js.map +1 -1
  84. package/dist/SyncStatusBanner.d.ts +7 -1
  85. package/dist/SyncStatusBanner.d.ts.map +1 -1
  86. package/dist/SyncStatusBanner.js +20 -4
  87. package/dist/SyncStatusBanner.js.map +1 -1
  88. package/dist/TapToEdit.d.ts +1 -1
  89. package/dist/TapToEdit.d.ts.map +1 -1
  90. package/dist/TapToEdit.js.map +1 -1
  91. package/dist/TextField.d.ts.map +1 -1
  92. package/dist/TextField.js +48 -14
  93. package/dist/TextField.js.map +1 -1
  94. package/dist/Theme.d.ts.map +1 -1
  95. package/dist/Theme.js +16 -0
  96. package/dist/Theme.js.map +1 -1
  97. package/dist/fieldElements/FieldError.d.ts.map +1 -1
  98. package/dist/fieldElements/FieldError.js +1 -1
  99. package/dist/fieldElements/FieldError.js.map +1 -1
  100. package/dist/index.d.ts +19 -3
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +14 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +3 -0
  105. package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
  106. package/dist/lazyBoundaries/heavyOptionalExports.js +2 -0
  107. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
  108. package/dist/login/LastUsedBadge.d.ts +14 -0
  109. package/dist/login/LastUsedBadge.d.ts.map +1 -0
  110. package/dist/login/LastUsedBadge.js +23 -0
  111. package/dist/login/LastUsedBadge.js.map +1 -0
  112. package/dist/login/LoginAccountCard.d.ts +38 -0
  113. package/dist/login/LoginAccountCard.d.ts.map +1 -0
  114. package/dist/login/LoginAccountCard.js +72 -0
  115. package/dist/login/LoginAccountCard.js.map +1 -0
  116. package/dist/login/LoginAccountList.d.ts +33 -0
  117. package/dist/login/LoginAccountList.d.ts.map +1 -0
  118. package/dist/login/LoginAccountList.js +30 -0
  119. package/dist/login/LoginAccountList.js.map +1 -0
  120. package/dist/login/LoginScreen.d.ts +4 -4
  121. package/dist/login/LoginScreen.d.ts.map +1 -1
  122. package/dist/login/LoginScreen.js +294 -13
  123. package/dist/login/LoginScreen.js.map +1 -1
  124. package/dist/login/OutlinePill.d.ts +28 -0
  125. package/dist/login/OutlinePill.d.ts.map +1 -0
  126. package/dist/login/OutlinePill.js +48 -0
  127. package/dist/login/OutlinePill.js.map +1 -0
  128. package/dist/login/TwoFactorChallengeScreen.d.ts +26 -0
  129. package/dist/login/TwoFactorChallengeScreen.d.ts.map +1 -0
  130. package/dist/login/TwoFactorChallengeScreen.js +139 -0
  131. package/dist/login/TwoFactorChallengeScreen.js.map +1 -0
  132. package/dist/login/loginMethods.d.ts +27 -0
  133. package/dist/login/loginMethods.d.ts.map +1 -0
  134. package/dist/login/loginMethods.js +37 -0
  135. package/dist/login/loginMethods.js.map +1 -0
  136. package/dist/login/loginTypes.d.ts +202 -5
  137. package/dist/login/loginTypes.d.ts.map +1 -1
  138. package/dist/pdfHtmlTemplate.d.ts +17 -0
  139. package/dist/pdfHtmlTemplate.d.ts.map +1 -1
  140. package/dist/pdfHtmlTemplate.js +78 -0
  141. package/dist/pdfHtmlTemplate.js.map +1 -1
  142. package/dist/security/AccountSecurityScreen.d.ts +10 -0
  143. package/dist/security/AccountSecurityScreen.d.ts.map +1 -0
  144. package/dist/security/AccountSecurityScreen.js +50 -0
  145. package/dist/security/AccountSecurityScreen.js.map +1 -0
  146. package/dist/security/LinkedAccountsCard.d.ts +32 -0
  147. package/dist/security/LinkedAccountsCard.d.ts.map +1 -0
  148. package/dist/security/LinkedAccountsCard.js +145 -0
  149. package/dist/security/LinkedAccountsCard.js.map +1 -0
  150. package/dist/security/PasskeysCard.d.ts +39 -0
  151. package/dist/security/PasskeysCard.d.ts.map +1 -0
  152. package/dist/security/PasskeysCard.js +168 -0
  153. package/dist/security/PasskeysCard.js.map +1 -0
  154. package/dist/security/PasswordCard.d.ts +32 -0
  155. package/dist/security/PasswordCard.d.ts.map +1 -0
  156. package/dist/security/PasswordCard.js +198 -0
  157. package/dist/security/PasswordCard.js.map +1 -0
  158. package/dist/security/SessionsCard.d.ts +39 -0
  159. package/dist/security/SessionsCard.d.ts.map +1 -0
  160. package/dist/security/SessionsCard.js +168 -0
  161. package/dist/security/SessionsCard.js.map +1 -0
  162. package/dist/security/TwoFactorSettingsCard.d.ts +55 -0
  163. package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -0
  164. package/dist/security/TwoFactorSettingsCard.js +458 -0
  165. package/dist/security/TwoFactorSettingsCard.js.map +1 -0
  166. package/dist/security/securityMethods.d.ts +40 -0
  167. package/dist/security/securityMethods.d.ts.map +1 -0
  168. package/dist/security/securityMethods.js +66 -0
  169. package/dist/security/securityMethods.js.map +1 -0
  170. package/dist/security/securityTypes.d.ts +467 -0
  171. package/dist/security/securityTypes.d.ts.map +1 -0
  172. package/dist/security/securityTypes.js +2 -0
  173. package/dist/security/securityTypes.js.map +1 -0
  174. package/dist/security/userAgent.d.ts +26 -0
  175. package/dist/security/userAgent.d.ts.map +1 -0
  176. package/dist/security/userAgent.js +80 -0
  177. package/dist/security/userAgent.js.map +1 -0
  178. package/dist/signUp/OAuthButtons.d.ts +28 -5
  179. package/dist/signUp/OAuthButtons.d.ts.map +1 -1
  180. package/dist/signUp/OAuthButtons.js +44 -5
  181. package/dist/signUp/OAuthButtons.js.map +1 -1
  182. package/dist/signUp/SignUpScreen.d.ts.map +1 -1
  183. package/dist/signUp/SignUpScreen.js +50 -5
  184. package/dist/signUp/SignUpScreen.js.map +1 -1
  185. package/dist/signUp/signUpTypes.d.ts +21 -1
  186. package/dist/signUp/signUpTypes.d.ts.map +1 -1
  187. package/dist/useConsentForms.d.ts +9 -0
  188. package/dist/useConsentForms.d.ts.map +1 -1
  189. package/dist/useConsentForms.js +18 -0
  190. package/dist/useConsentForms.js.map +1 -1
  191. package/dist/useProvisionalConsent.d.ts +124 -0
  192. package/dist/useProvisionalConsent.d.ts.map +1 -0
  193. package/dist/useProvisionalConsent.js +79 -0
  194. package/dist/useProvisionalConsent.js.map +1 -0
  195. package/package.json +5 -2
  196. package/src/Accordion.test.tsx +5 -0
  197. package/src/Accordion.tsx +3 -8
  198. package/src/ActionSheet.test.tsx +13 -13
  199. package/src/AddressField.test.tsx +9 -3
  200. package/src/AnnouncementNavigator.test.tsx +4 -4
  201. package/src/AreaChart.test.tsx +15 -0
  202. package/src/Avatar.test.tsx +8 -0
  203. package/src/Avatar.tsx +2 -0
  204. package/src/Badge.test.tsx +1 -1
  205. package/src/Banner.test.tsx +0 -1
  206. package/src/BarChart.test.tsx +15 -0
  207. package/src/Box.test.tsx +143 -75
  208. package/src/Box.tsx +44 -2
  209. package/src/Button.test.tsx +11 -6
  210. package/src/Card.test.tsx +2 -2
  211. package/src/Card.tsx +2 -2
  212. package/src/Common.ts +194 -36
  213. package/src/ConflictSheet.test.tsx +5 -5
  214. package/src/ConsentFormScreen.test.tsx +87 -1
  215. package/src/ConsentFormScreen.tsx +28 -4
  216. package/src/ConsentNavigator.test.tsx +1 -2
  217. package/src/CustomSelectField.test.tsx +16 -4
  218. package/src/DataTable.test.tsx +4 -4
  219. package/src/DataTableVirtualizationRegression.test.tsx +1 -0
  220. package/src/DateTimeActionSheet.test.tsx +2 -0
  221. package/src/DateTimeField.test.tsx +3 -12
  222. package/src/DateTimeField.tsx +11 -9
  223. package/src/DismissButton.test.tsx +22 -4
  224. package/src/DonutChart.test.tsx +15 -0
  225. package/src/EmailField.test.tsx +13 -22
  226. package/src/EmojiSelector.test.tsx +2 -2
  227. package/src/ErrorBoundary.test.tsx +5 -3
  228. package/src/Field.test.tsx +20 -44
  229. package/src/Field.tsx +2 -0
  230. package/src/FilePickerButton.test.tsx +35 -0
  231. package/src/FormContainer.test.tsx +242 -0
  232. package/src/FormContainer.tsx +177 -0
  233. package/src/GPTChat.test.tsx +40 -16
  234. package/src/GPTChat.tsx +8 -2
  235. package/src/Heading.test.tsx +15 -1
  236. package/src/Heading.tsx +6 -1
  237. package/src/HeightField.tsx +8 -8
  238. package/src/Icon.test.tsx +54 -3
  239. package/src/Icon.tsx +92 -3
  240. package/src/IconButton.test.tsx +85 -0
  241. package/src/Image.test.tsx +1 -1
  242. package/src/LabeledCheckBox.test.tsx +45 -0
  243. package/src/LabeledCheckBox.tsx +89 -0
  244. package/src/Link.test.tsx +11 -4
  245. package/src/ListDetailLayout.tsx +247 -0
  246. package/src/MarkdownEditor.tsx +2 -1
  247. package/src/MarkdownView.test.tsx +1 -1
  248. package/src/MediaQuery.ts +1 -0
  249. package/src/MobileAddressAutoComplete.test.tsx +2 -1
  250. package/src/Modal.test.tsx +7 -2
  251. package/src/ModalSheet.test.tsx +5 -4
  252. package/src/MultiselectField.test.tsx +17 -3
  253. package/src/NumberField.test.tsx +14 -14
  254. package/src/NumberPickerActionSheet.test.tsx +1 -1
  255. package/src/OpenAPIContext.test.tsx +4 -4
  256. package/src/OpenAPIRenderRegression.test.tsx +1 -1
  257. package/src/OtpField.test.tsx +280 -0
  258. package/src/OtpField.tsx +307 -0
  259. package/src/P0RenderRegression.test.tsx +7 -1
  260. package/src/P1RenderRegression.test.tsx +1 -0
  261. package/src/P2ButtonRenderRegression.test.tsx +1 -0
  262. package/src/Page.test.tsx +1 -1
  263. package/src/PhoneNumberField.test.tsx +14 -38
  264. package/src/PickerSelect.tsx +9 -9
  265. package/src/Popover.test.tsx +2 -2
  266. package/src/ProvisionalConsentSigner.test.tsx +625 -0
  267. package/src/ProvisionalConsentSigner.tsx +423 -0
  268. package/src/RadioField.test.tsx +7 -2
  269. package/src/ResponsiveBreakpoint.test.tsx +7 -0
  270. package/src/ResponsiveBreakpoint.tsx +14 -0
  271. package/src/RootImportRegression.test.tsx +3 -0
  272. package/src/SegmentedControl.test.tsx +21 -12
  273. package/src/SidebarNavigation.test.tsx +18 -6
  274. package/src/Signature.test.tsx +20 -23
  275. package/src/Slider.test.tsx +1 -1
  276. package/src/SocialLoginButton.test.tsx +14 -0
  277. package/src/SocialLoginButton.tsx +51 -7
  278. package/src/SplitPage.native.tsx +3 -1
  279. package/src/SplitPage.test.tsx +15 -5
  280. package/src/SplitPage.tsx +11 -5
  281. package/src/SyncStatusBanner.test.tsx +61 -4
  282. package/src/SyncStatusBanner.tsx +29 -3
  283. package/src/TapToEdit.test.tsx +38 -15
  284. package/src/TapToEdit.tsx +1 -1
  285. package/src/TerrenoFontProvider.test.tsx +1 -1
  286. package/src/Text.test.tsx +4 -4
  287. package/src/TextField.test.tsx +232 -9
  288. package/src/TextField.tsx +70 -12
  289. package/src/Theme.test.tsx +49 -0
  290. package/src/Theme.tsx +16 -0
  291. package/src/Toast.test.tsx +5 -5
  292. package/src/ToastNotifications.test.tsx +73 -70
  293. package/src/ToastNotifications.webModal.test.tsx +2 -2
  294. package/src/Tooltip.test.tsx +3 -3
  295. package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
  296. package/src/UserInactivity.test.tsx +4 -2
  297. package/src/WebAddressAutocomplete.test.tsx +12 -12
  298. package/src/WebDropdownMenu.test.tsx +16 -15
  299. package/src/__snapshots__/AddressField.test.tsx.snap +12 -0
  300. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +15 -0
  301. package/src/__snapshots__/Avatar.test.tsx.snap +1 -0
  302. package/src/__snapshots__/Card.test.tsx.snap +1 -1
  303. package/src/__snapshots__/CustomSelectField.test.tsx.snap +3 -0
  304. package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
  305. package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
  306. package/src/__snapshots__/Field.test.tsx.snap +41 -2
  307. package/src/__snapshots__/Heading.test.tsx.snap +1 -1
  308. package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
  309. package/src/__snapshots__/Image.test.tsx.snap +1 -1
  310. package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
  311. package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
  312. package/src/__snapshots__/Page.test.tsx.snap +2 -2
  313. package/src/__snapshots__/PhoneNumberField.test.tsx.snap +12 -0
  314. package/src/__snapshots__/Slider.test.tsx.snap +1 -0
  315. package/src/__snapshots__/SocialLoginButton.test.tsx.snap +43 -22
  316. package/src/__snapshots__/TapToEdit.test.tsx.snap +3 -0
  317. package/src/__snapshots__/Text.test.tsx.snap +1 -1
  318. package/src/__snapshots__/TextArea.test.tsx.snap +17 -1
  319. package/src/__snapshots__/TextField.test.tsx.snap +19 -2
  320. package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -0
  321. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +18 -0
  322. package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +12 -0
  323. package/src/asks/AskCard.test.tsx +16 -13
  324. package/src/asks/AskFiles.test.tsx +5 -1
  325. package/src/asks/askFileRefs.test.ts +1 -1
  326. package/src/asks/askSummary.test.ts +2 -2
  327. package/src/benchmarks/importTiming.ts +1 -1
  328. package/src/blocks/BlocksView.test.tsx +20 -11
  329. package/src/bunSetup.ts +14 -2
  330. package/src/dataTableFilters.test.tsx +1 -1
  331. package/src/fieldElements/FieldError.tsx +1 -0
  332. package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
  333. package/src/index.tsx +42 -1
  334. package/src/isolated/ListDetailLayout.isolated.tsx +632 -0
  335. package/src/lazyBoundaries/heavyOptionalExports.tsx +7 -0
  336. package/src/login/LastUsedBadge.tsx +40 -0
  337. package/src/login/LoginAccountCard.tsx +205 -0
  338. package/src/login/LoginAccountList.tsx +115 -0
  339. package/src/login/LoginScreen.test.tsx +839 -3
  340. package/src/login/LoginScreen.tsx +674 -91
  341. package/src/login/OutlinePill.tsx +110 -0
  342. package/src/login/TwoFactorChallengeScreen.test.tsx +376 -0
  343. package/src/login/TwoFactorChallengeScreen.tsx +307 -0
  344. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +1454 -334
  345. package/src/login/loginMethods.test.ts +53 -0
  346. package/src/login/loginMethods.ts +60 -0
  347. package/src/login/loginTypes.ts +208 -5
  348. package/src/pdfHtmlTemplate.test.ts +243 -4
  349. package/src/pdfHtmlTemplate.ts +93 -0
  350. package/src/security/AccountSecurityScreen.test.tsx +262 -0
  351. package/src/security/AccountSecurityScreen.tsx +156 -0
  352. package/src/security/LinkedAccountsCard.test.tsx +371 -0
  353. package/src/security/LinkedAccountsCard.tsx +297 -0
  354. package/src/security/PasskeysCard.test.tsx +378 -0
  355. package/src/security/PasskeysCard.tsx +371 -0
  356. package/src/security/PasswordCard.test.tsx +445 -0
  357. package/src/security/PasswordCard.tsx +342 -0
  358. package/src/security/SessionsCard.test.tsx +349 -0
  359. package/src/security/SessionsCard.tsx +362 -0
  360. package/src/security/TwoFactorSettingsCard.test.tsx +700 -0
  361. package/src/security/TwoFactorSettingsCard.tsx +872 -0
  362. package/src/security/securityMethods.test.ts +101 -0
  363. package/src/security/securityMethods.ts +104 -0
  364. package/src/security/securityTypes.ts +480 -0
  365. package/src/security/userAgent.test.ts +119 -0
  366. package/src/security/userAgent.ts +102 -0
  367. package/src/signUp/OAuthButtons.test.tsx +27 -0
  368. package/src/signUp/OAuthButtons.tsx +153 -19
  369. package/src/signUp/SignUpScreen.test.tsx +171 -2
  370. package/src/signUp/SignUpScreen.tsx +87 -25
  371. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -11
  372. package/src/signUp/signUpTypes.ts +23 -1
  373. package/src/table/tableContext.test.tsx +5 -5
  374. package/src/test-utils.tsx +56 -1
  375. package/src/testing/reactDomServer.d.ts +7 -0
  376. package/src/useConsentForms.test.ts +38 -2
  377. package/src/useConsentForms.ts +25 -0
  378. package/src/useProvisionalConsent.test.ts +256 -0
  379. package/src/useProvisionalConsent.ts +218 -0
@@ -0,0 +1,53 @@
1
+ import {describe, expect, it} from "bun:test";
2
+
3
+ import {getSocialProviderName} from "../SocialLoginButton";
4
+ import {getLoginMethodLabels, maskEmail} from "./loginMethods";
5
+
6
+ describe("getSocialProviderName", () => {
7
+ it("names the branded providers", () => {
8
+ expect(getSocialProviderName("github")).toBe("GitHub");
9
+ });
10
+
11
+ it("returns undefined for other ids, including Object.prototype keys", () => {
12
+ expect(getSocialProviderName("mock-oidc")).toBeUndefined();
13
+ expect(getSocialProviderName("__proto__")).toBeUndefined();
14
+ expect(getSocialProviderName("constructor")).toBeUndefined();
15
+ });
16
+ });
17
+
18
+ describe("getLoginMethodLabels", () => {
19
+ it("names email, passkeys, branded and generic providers", () => {
20
+ expect(getLoginMethodLabels({method: "email"})).toEqual({name: "email", phrase: "email"});
21
+ expect(getLoginMethodLabels({method: "passkey"})).toEqual({
22
+ name: "passkey",
23
+ phrase: "a passkey",
24
+ });
25
+ expect(getLoginMethodLabels({method: "google"})).toEqual({name: "Google", phrase: "Google"});
26
+ expect(
27
+ getLoginMethodLabels({
28
+ genericProviders: [
29
+ {id: "mock-oidc", label: "Mock OIDC", onPress: async (): Promise<void> => {}},
30
+ ],
31
+ method: "mock-oidc",
32
+ })
33
+ ).toEqual({name: "Mock OIDC", phrase: "Mock OIDC"});
34
+ });
35
+
36
+ it("names a method that matches an Object.prototype key by its id", () => {
37
+ expect(getLoginMethodLabels({method: "__proto__"})).toEqual({
38
+ name: "__proto__",
39
+ phrase: "__proto__",
40
+ });
41
+ expect(getLoginMethodLabels({method: "constructor"})).toEqual({
42
+ name: "constructor",
43
+ phrase: "constructor",
44
+ });
45
+ });
46
+ });
47
+
48
+ describe("maskEmail", () => {
49
+ it("keeps the first character of the name and the host", () => {
50
+ expect(maskEmail("josh@nang.io")).toBe("j***@n***.io");
51
+ expect(maskEmail("not-an-email")).toBe("not-an-email");
52
+ });
53
+ });
@@ -0,0 +1,60 @@
1
+ import {getSocialProviderName} from "../SocialLoginButton";
2
+ import type {GenericOAuthProviderConfig} from "../signUp/signUpTypes";
3
+
4
+ /** Ways to name a sign-in method in the login screen's copy. */
5
+ export interface LoginMethodLabels {
6
+ /** Noun form, e.g. "GitHub", "email", "passkey": "Forget this {name} account". */
7
+ name: string;
8
+ /** Form used after "with", e.g. "GitHub", "email", "a passkey": "Continue with {phrase}". */
9
+ phrase: string;
10
+ }
11
+
12
+ /**
13
+ * Names a sign-in method: a branded provider's name, a generic provider's label, "email",
14
+ * "passkey", or the raw id as a last resort.
15
+ */
16
+ export const getLoginMethodLabels = ({
17
+ method,
18
+ genericProviders = [],
19
+ }: {
20
+ method: string;
21
+ genericProviders?: GenericOAuthProviderConfig[];
22
+ }): LoginMethodLabels => {
23
+ if (method === "email") {
24
+ return {name: "email", phrase: "email"};
25
+ }
26
+ if (method === "passkey") {
27
+ return {name: "passkey", phrase: "a passkey"};
28
+ }
29
+ const generic = genericProviders.find((provider) => provider.id === method);
30
+ const name = generic?.label ?? getSocialProviderName(method) ?? method;
31
+ return {name, phrase: name};
32
+ };
33
+
34
+ /**
35
+ * Masks an email for display: `josh@nang.io` becomes `j***@n***.io`. Returns the input when it
36
+ * is not an email.
37
+ */
38
+ export const maskEmail = (email: string): string => {
39
+ const at = email.indexOf("@");
40
+ if (at <= 0 || at === email.length - 1) {
41
+ return email;
42
+ }
43
+ const local = email.slice(0, at);
44
+ const domain = email.slice(at + 1);
45
+ const dot = domain.lastIndexOf(".");
46
+ const host = dot === -1 ? domain : domain.slice(0, dot);
47
+ const tld = dot === -1 ? "" : domain.slice(dot);
48
+ return `${local.charAt(0)}***@${host.charAt(0)}***${tld}`;
49
+ };
50
+
51
+ /** Appends the last-used marker to an accessible name, e.g. "Continue with GitHub, last used". */
52
+ export const withLastUsedLabel = ({
53
+ label,
54
+ lastUsedLabel,
55
+ }: {
56
+ label: string;
57
+ lastUsedLabel: string;
58
+ }): string => {
59
+ return `${label}, ${lastUsedLabel.toLocaleLowerCase()}`;
60
+ };
@@ -1,6 +1,6 @@
1
1
  import type {ReactNode} from "react";
2
2
 
3
- import type {OAuthProviderConfig} from "../signUp/signUpTypes";
3
+ import type {GenericOAuthProviderConfig, OAuthProviderConfig} from "../signUp/signUpTypes";
4
4
 
5
5
  /**
6
6
  * Configuration for a login form field.
@@ -17,7 +17,50 @@ export interface LoginFieldConfig {
17
17
  /** Whether the field is required. */
18
18
  required?: boolean;
19
19
  /** Auto-complete hint for the field. */
20
- autoComplete?: "current-password" | "on" | "off" | "username";
20
+ autoComplete?: "current-password" | "email" | "new-password" | "on" | "off" | "username";
21
+ }
22
+
23
+ /**
24
+ * An account the login screen can offer as a one-tap "Continue" card: a session already signed
25
+ * in on this device, or an account remembered from an earlier sign-in. Identity fields are
26
+ * optional because apps remember only the method by default.
27
+ */
28
+ export interface LoginAccountOption {
29
+ /** Stable id: the session token or user id for a session, the remembered entry id otherwise. */
30
+ id: string;
31
+ /** Display name, when known. */
32
+ name?: string;
33
+ /** Email address, when known. */
34
+ email?: string;
35
+ /** Avatar image URL, when known. */
36
+ image?: string;
37
+ /** How the account signs in: a provider id, `"email"`, or `"passkey"`. */
38
+ method: string;
39
+ }
40
+
41
+ /** Where a "Continue" card came from: a signed-in device session or a remembered account. */
42
+ export type LoginAccountSource = "session" | "remembered";
43
+
44
+ /**
45
+ * A message shown under the heading, such as guidance after an `account_not_linked` error.
46
+ * Info notices can be dismissed. A wrong password is not a notice: it is `passwordError`.
47
+ */
48
+ export interface LoginNotice {
49
+ /** Visual tone of the notice. */
50
+ tone: "info" | "warning" | "error";
51
+ /** Optional bold line above `text`. */
52
+ title?: string;
53
+ /** Message text. */
54
+ text: string;
55
+ /** Label for an optional action button under the text. */
56
+ actionLabel?: string;
57
+ /** Callback for the action button. */
58
+ onAction?: () => void | Promise<void>;
59
+ /**
60
+ * Sign-in method the action should bring forward: `"email"` focuses the email field, any other
61
+ * id expands the method list. The screen does this before calling `onAction`.
62
+ */
63
+ focusMethod?: string;
21
64
  }
22
65
 
23
66
  /**
@@ -32,13 +75,28 @@ export interface LoginScreenProps {
32
75
  oauthProviders?: OAuthProviderConfig[];
33
76
  /** Custom logo or banner to display above the form. */
34
77
  logo?: ReactNode;
35
- /** Title text for the login form. */
78
+ /**
79
+ * Title text for the login form. Defaults to "Welcome back" when accounts are offered and
80
+ * "Sign in" otherwise.
81
+ */
36
82
  title?: string;
83
+ /**
84
+ * Line under the title. Defaults to "Pick up where you left off." when accounts are offered and
85
+ * "Choose how you want to sign in." otherwise.
86
+ */
87
+ subtitle?: string;
37
88
  /** Whether the form is in a loading state. */
38
89
  loading?: boolean;
39
- /** Error message to display. */
90
+ /** Error message shown in a banner under the heading. A `notice` wins when both are set. */
40
91
  error?: string;
41
- /** Text for the link to navigate to sign up. */
92
+ /**
93
+ * Wrong-password message shown under the password field, not in the banner.
94
+ */
95
+ passwordError?: string;
96
+ /**
97
+ * Text of the "Create an account" link in the footer.
98
+ * @default "Create an account"
99
+ */
42
100
  signUpLinkText?: string;
43
101
  /** Callback triggered when the sign-up link is pressed. */
44
102
  onSignUpPress?: () => void;
@@ -48,6 +106,151 @@ export interface LoginScreenProps {
48
106
  onForgotPasswordPress?: () => void;
49
107
  /** Alias for `onForgotPasswordPress`. */
50
108
  onForgotPassword?: () => void;
109
+ /**
110
+ * Sign-in providers without a branded button (for example a generic OIDC provider). They
111
+ * render after `oauthProviders` with the testID `${testID}-oauth-${id}`.
112
+ */
113
+ genericProviders?: GenericOAuthProviderConfig[];
114
+ /**
115
+ * The method this device signed in with last: a provider id (`"google"`, `"github"`,
116
+ * `"mock-oidc"`, ...), `"email"`, or `"passkey"`. That method gets a "Last used" pill
117
+ * (testID `${testID}-last-used-${method}`). A provider moves to the front of the provider
118
+ * list, and a passkey leads the method stack. Methods stay above the email form. A method the
119
+ * screen does not offer is ignored.
120
+ */
121
+ lastUsedMethod?: string;
122
+ /** Text of the last-used badge. Defaults to "Last used". */
123
+ lastUsedLabel?: string;
124
+ /**
125
+ * Sessions already signed in on this device. Each renders a "Continue" card that switches to
126
+ * it in one tap. Requires `onContinue`.
127
+ */
128
+ currentSessions?: LoginAccountOption[];
129
+ /**
130
+ * Accounts remembered on this device. Each renders a row in the continue-as list that
131
+ * re-authenticates with the remembered method. `onForget` reveals Remove in the list's Edit
132
+ * mode. Requires `onContinue`.
133
+ */
134
+ rememberedAccounts?: LoginAccountOption[];
135
+ /**
136
+ * Called when a "Continue" card is pressed. Cards are numbered sessions first, then remembered
137
+ * accounts (testID `${testID}-continue-${index}`).
138
+ */
139
+ onContinue?: (account: LoginAccountOption, source: LoginAccountSource) => void | Promise<void>;
140
+ /**
141
+ * Called when a remembered account's Remove button is pressed in Edit mode
142
+ * (testID `${testID}-forget-${index}`). Sessions are never forgettable here.
143
+ */
144
+ onForget?: (account: LoginAccountOption) => void | Promise<void>;
145
+ /**
146
+ * Replaces the screen body with the password step for this email account. Set by the controller
147
+ * when a continue-as row has a usable email. Requires `onCancelContinue` to return.
148
+ */
149
+ continuingAccount?: LoginAccountOption;
150
+ /** Leaves the password step and returns to the account list. */
151
+ onCancelContinue?: () => void;
152
+ /**
153
+ * Opens the screen with the other sign-in methods expanded. Returning users start collapsed
154
+ * behind "Sign in another way".
155
+ */
156
+ initialMethodsExpanded?: boolean;
157
+ /** Opens the account list in Edit mode, where remembered accounts can be removed. */
158
+ initialAccountsEditing?: boolean;
159
+ /**
160
+ * Shows a "Sign in with a passkey" button (testID `${testID}-passkey-button`) that calls this.
161
+ */
162
+ onPasskeyPress?: () => void | Promise<void>;
163
+ /** Text of the passkey button. Defaults to "Sign in with a passkey". */
164
+ passkeyButtonText?: string;
165
+ /**
166
+ * On web, sets the email field's `autocomplete` to `"username webauthn"` so the browser offers
167
+ * saved passkeys in the field's autofill (conditional mediation). Ignored on native.
168
+ */
169
+ passkeyAutofill?: boolean;
170
+ /**
171
+ * Values the form starts with, keyed by field name, such as `{email: "jane@example.com"}`.
172
+ * When a new object is passed later, its fields replace what is in the form and the other
173
+ * fields keep what the user typed, so a "Continue" card can prefill the email.
174
+ */
175
+ initialValues?: Record<string, string>;
176
+ /** A message under the heading (testID `${testID}-notice`). */
177
+ notice?: LoginNotice;
51
178
  /** Test ID for the root element. */
52
179
  testID?: string;
53
180
  }
181
+
182
+ /** Which kind of second factor a two-factor challenge submits. */
183
+ export type TwoFactorCodeKind = "totp" | "backup";
184
+
185
+ /** What {@link TwoFactorChallengeScreenProps.onSubmit} receives. */
186
+ export interface TwoFactorChallengeSubmission {
187
+ /** The code as entered: six digits for `totp`, a trimmed backup code for `backup`. */
188
+ code: string;
189
+ /** `totp` for an authenticator app code, `backup` for a one-time backup code. */
190
+ kind: TwoFactorCodeKind;
191
+ /** True when the user checked "Don't ask again on this device". Always false without `trustDeviceDays`. */
192
+ trustDevice: boolean;
193
+ }
194
+
195
+ /**
196
+ * Props for the TwoFactorChallengeScreen component.
197
+ */
198
+ export interface TwoFactorChallengeScreenProps {
199
+ /** Called with the code, its kind, and the trust-device choice. A TOTP code submits itself once complete. */
200
+ onSubmit: (values: TwoFactorChallengeSubmission) => void | Promise<void>;
201
+ /** Disables the form and shows a spinner on the submit button. */
202
+ loading?: boolean;
203
+ /** Error text, such as an invalid code, shown with `role="alert"`. A new error clears the entered code. */
204
+ error?: string;
205
+ /**
206
+ * Shows a "Don't ask again on this device for N days" checkbox. Leave unset to hide it. Better
207
+ * Auth trusts a device for 30 days by default.
208
+ */
209
+ trustDeviceDays?: number;
210
+ /** Shows a back link and a footer link (text via `cancelText`), for example back to sign-in. */
211
+ onCancel?: () => void;
212
+ /**
213
+ * Text for the footer link.
214
+ * @default "Sign in a different way"
215
+ */
216
+ cancelText?: string;
217
+ /**
218
+ * Heading text. Defaults to "Enter your code" for an authenticator code and "Use a backup code"
219
+ * for a backup code.
220
+ */
221
+ title?: string;
222
+ /**
223
+ * Account the code is for, usually an email. The authenticator subtitle names it. The screen
224
+ * masks an email address.
225
+ */
226
+ accountLabel?: string;
227
+ /** Optional logo above the heading. */
228
+ logo?: ReactNode;
229
+ /**
230
+ * Digits in an authenticator code.
231
+ * @default 6
232
+ */
233
+ codeLength?: number;
234
+ /**
235
+ * The mode the screen opens in.
236
+ * @default "totp"
237
+ */
238
+ initialKind?: TwoFactorCodeKind;
239
+ /**
240
+ * Whether "Trust this device" starts checked. Defaults to checked for an authenticator code
241
+ * and unchecked for a backup code. Set `false` to start unchecked.
242
+ */
243
+ initialTrustDevice?: boolean;
244
+ /**
245
+ * Focuses the first code cell when the screen mounts. Turn it off when the screen is not the
246
+ * page's main task (a preview or gallery), since focusing scrolls the page to the cells. A
247
+ * rejected code still returns focus to the first cell.
248
+ * @default true
249
+ */
250
+ autoFocus?: boolean;
251
+ /**
252
+ * Root testID; child testIDs are derived from it.
253
+ * @default "two-factor-challenge"
254
+ */
255
+ testID?: string;
256
+ }
@@ -1,14 +1,27 @@
1
- import {describe, expect, it, mock} from "bun:test";
1
+ import {beforeEach, describe, expect, it, type Mock, mock} from "bun:test";
2
+ import * as Print from "expo-print";
3
+ import {DateTime} from "luxon";
2
4
  import {Platform} from "react-native";
3
5
 
4
- import {buildConsentPdfHtml, type PdfTemplateData, sharePdfFromHtml} from "./pdfHtmlTemplate";
6
+ import {
7
+ buildConsentPdfHtml,
8
+ type PdfTemplateData,
9
+ printConsentHtml,
10
+ sharePdfFromHtml,
11
+ } from "./pdfHtmlTemplate";
5
12
 
6
- const printToFileAsync = mock(() => Promise.resolve({uri: "file:///tmp/consent.pdf"}));
13
+ // expo-print is mocked once in the bun preload (src/bunSetup.ts).
14
+ const printAsync = Print.printAsync as unknown as Mock<typeof Print.printAsync>;
15
+ const printToFileAsync = Print.printToFileAsync as unknown as Mock<typeof Print.printToFileAsync>;
7
16
  const shareAsync = mock(() => Promise.resolve());
8
17
 
9
- mock.module("expo-print", () => ({printToFileAsync}));
10
18
  mock.module("expo-sharing", () => ({shareAsync}));
11
19
 
20
+ beforeEach(() => {
21
+ printAsync.mockClear();
22
+ printToFileAsync.mockClear();
23
+ });
24
+
12
25
  const baseData: PdfTemplateData = {
13
26
  fields: [
14
27
  {label: "Full Name", value: "Jane <Doe>"},
@@ -92,6 +105,232 @@ describe("buildConsentPdfHtml", () => {
92
105
  });
93
106
  });
94
107
 
108
+ describe("buildConsentPdfHtml provisional signature", () => {
109
+ const signedAt = "2026-10-20T15:30:00.000Z";
110
+ const voidedAt = "2026-10-21T09:00:00.000Z";
111
+ const full = (iso: string): string =>
112
+ DateTime.fromISO(iso).toLocaleString(DateTime.DATETIME_FULL);
113
+
114
+ it("renders the signer and date", () => {
115
+ const html = buildConsentPdfHtml({
116
+ ...baseData,
117
+ provisionalSignature: {signedAt, signedByName: "Dana <Rivera>"},
118
+ });
119
+
120
+ expect(html).toContain("<h2>Provisional signature</h2>");
121
+ expect(html).toContain('<td class="field-value">Dana &lt;Rivera&gt;</td>');
122
+ expect(html).toContain(`<td class="field-value">${full(signedAt)}</td>`);
123
+ expect(html).not.toContain("Note:");
124
+ expect(html).not.toContain("Signer IP:");
125
+ expect(html).not.toContain("Voided");
126
+ });
127
+
128
+ it("renders the escaped note, signer IP, and void date when given", () => {
129
+ const html = buildConsentPdfHtml({
130
+ ...baseData,
131
+ provisionalSignature: {
132
+ note: 'Guardian said "yes" <by phone>',
133
+ signedAt,
134
+ signedByName: "Dana Rivera",
135
+ signerIp: "10.0.0.7",
136
+ voidedAt,
137
+ },
138
+ });
139
+
140
+ expect(html).toContain('<td class="field-label">Note:</td>');
141
+ expect(html).toContain(
142
+ '<td class="field-value">Guardian said &quot;yes&quot; &lt;by phone&gt;</td>'
143
+ );
144
+ expect(html).toContain('<td class="field-value">10.0.0.7</td>');
145
+ expect(html).toContain(`<div class="voided">Voided ${full(voidedAt)}</div>`);
146
+ });
147
+
148
+ it("prints a date that is not ISO as written", () => {
149
+ const html = buildConsentPdfHtml({
150
+ ...baseData,
151
+ provisionalSignature: {signedAt: "Oct 20, 2026", signedByName: "Dana Rivera"},
152
+ });
153
+ expect(html).toContain('<td class="field-value">Oct 20, 2026</td>');
154
+ });
155
+
156
+ it("omits the date row when the signing date is unknown", () => {
157
+ const html = buildConsentPdfHtml({
158
+ ...baseData,
159
+ provisionalSignature: {signedAt: "", signedByName: "Dana Rivera"},
160
+ });
161
+ expect(html).toContain("<h2>Provisional signature</h2>");
162
+ expect(html).not.toContain("Signed at:");
163
+ });
164
+
165
+ it("renders nothing extra without a provisional signature", () => {
166
+ expect(buildConsentPdfHtml(baseData)).not.toContain("Provisional signature");
167
+ });
168
+ });
169
+
170
+ interface FakeIframe {
171
+ attributes: Record<string, string>;
172
+ contentWindow: {
173
+ addEventListener: (event: string, listener: () => void) => void;
174
+ focus: ReturnType<typeof mock>;
175
+ print: ReturnType<typeof mock>;
176
+ };
177
+ onload: (() => void) | null;
178
+ removed: boolean;
179
+ remove: () => void;
180
+ setAttribute: (name: string, value: string) => void;
181
+ srcdoc: string;
182
+ style: Record<string, string>;
183
+ }
184
+
185
+ /** A minimal DOM: appending the iframe loads it, like a browser does with `srcdoc`. */
186
+ const installFakeDocument = (): {iframes: FakeIframe[]; restore: () => void} => {
187
+ const iframes: FakeIframe[] = [];
188
+ const g = globalThis as unknown as {document?: unknown};
189
+ const originalDocument = g.document;
190
+ g.document = {
191
+ body: {
192
+ appendChild: (iframe: FakeIframe) => {
193
+ iframe.onload?.();
194
+ },
195
+ },
196
+ createElement: (tag: string) => {
197
+ expect(tag).toBe("iframe");
198
+ const listeners: Record<string, () => void> = {};
199
+ const iframe: FakeIframe = {
200
+ attributes: {},
201
+ contentWindow: {
202
+ addEventListener: (event, listener) => {
203
+ listeners[event] = listener;
204
+ },
205
+ focus: mock(() => {}),
206
+ print: mock(() => {
207
+ listeners.afterprint?.();
208
+ }),
209
+ },
210
+ onload: null,
211
+ remove: () => {
212
+ iframe.removed = true;
213
+ },
214
+ removed: false,
215
+ setAttribute: (name, value) => {
216
+ iframe.attributes[name] = value;
217
+ },
218
+ srcdoc: "",
219
+ style: {},
220
+ };
221
+ iframes.push(iframe);
222
+ return iframe;
223
+ },
224
+ };
225
+ return {
226
+ iframes,
227
+ restore: () => {
228
+ g.document = originalDocument;
229
+ },
230
+ };
231
+ };
232
+
233
+ describe("printConsentHtml", () => {
234
+ it("opens the native print dialog with the HTML on native", async () => {
235
+ printAsync.mockClear();
236
+ await printConsentHtml({html: "<p>consent</p>"});
237
+ expect(printAsync).toHaveBeenCalledWith({html: "<p>consent</p>"});
238
+ });
239
+
240
+ it("prints from a hidden iframe on web and removes it afterwards", async () => {
241
+ const originalOS = Platform.OS;
242
+ Platform.OS = "web";
243
+ const {iframes, restore} = installFakeDocument();
244
+ printAsync.mockClear();
245
+ try {
246
+ await printConsentHtml({html: "<p>consent</p>"});
247
+ } finally {
248
+ Platform.OS = originalOS;
249
+ restore();
250
+ }
251
+
252
+ expect(iframes).toHaveLength(1);
253
+ expect(iframes[0].srcdoc).toBe("<p>consent</p>");
254
+ expect(iframes[0].attributes["aria-hidden"]).toBe("true");
255
+ expect(iframes[0].style.visibility).toBe("hidden");
256
+ expect(iframes[0].contentWindow.print).toHaveBeenCalledTimes(1);
257
+ expect(iframes[0].removed).toBe(true);
258
+ expect(printAsync).not.toHaveBeenCalled();
259
+ });
260
+
261
+ it("removes the iframe and rejects when printing throws on web", async () => {
262
+ const originalOS = Platform.OS;
263
+ Platform.OS = "web";
264
+ const {iframes, restore} = installFakeDocument();
265
+ const failure = new Error("print blocked");
266
+ const g = globalThis as unknown as {document: {createElement: (tag: string) => FakeIframe}};
267
+ const createElement = g.document.createElement;
268
+ g.document.createElement = (tag: string): FakeIframe => {
269
+ const iframe = createElement(tag);
270
+ iframe.contentWindow.print = mock(() => {
271
+ throw failure;
272
+ });
273
+ return iframe;
274
+ };
275
+ try {
276
+ await expect(printConsentHtml({html: "<p>consent</p>"})).rejects.toBe(failure);
277
+ } finally {
278
+ Platform.OS = originalOS;
279
+ restore();
280
+ }
281
+ expect(iframes[0].removed).toBe(true);
282
+ });
283
+ });
284
+
285
+ describe("printConsentHtml when afterprint never fires", () => {
286
+ it("removes the previous print frame before printing again", async () => {
287
+ const originalOS = Platform.OS;
288
+ Platform.OS = "web";
289
+ const {iframes, restore} = installFakeDocument();
290
+ const g = globalThis as unknown as {document: {createElement: (tag: string) => FakeIframe}};
291
+ const createElement = g.document.createElement;
292
+ g.document.createElement = (tag: string): FakeIframe => {
293
+ const iframe = createElement(tag);
294
+ iframe.contentWindow.print = mock(() => {});
295
+ return iframe;
296
+ };
297
+ try {
298
+ await printConsentHtml({html: "<p>first</p>"});
299
+ expect(iframes[0].removed).toBe(false);
300
+ await printConsentHtml({html: "<p>second</p>"});
301
+ } finally {
302
+ Platform.OS = originalOS;
303
+ restore();
304
+ }
305
+ expect(iframes[0].removed).toBe(true);
306
+ expect(iframes[1].srcdoc).toBe("<p>second</p>");
307
+ });
308
+ });
309
+
310
+ describe("printConsentHtml without a frame window", () => {
311
+ it("removes the iframe and rejects", async () => {
312
+ const originalOS = Platform.OS;
313
+ Platform.OS = "web";
314
+ const {iframes, restore} = installFakeDocument();
315
+ const g = globalThis as unknown as {document: {createElement: (tag: string) => FakeIframe}};
316
+ const createElement = g.document.createElement;
317
+ g.document.createElement = (tag: string): FakeIframe => {
318
+ const iframe = createElement(tag);
319
+ (iframe as unknown as {contentWindow: null}).contentWindow = null;
320
+ return iframe;
321
+ };
322
+ try {
323
+ await expect(printConsentHtml({html: "<p>consent</p>"})).rejects.toThrow(
324
+ "Print frame did not load"
325
+ );
326
+ } finally {
327
+ Platform.OS = originalOS;
328
+ restore();
329
+ }
330
+ expect(iframes[0].removed).toBe(true);
331
+ });
332
+ });
333
+
95
334
  describe("sharePdfFromHtml", () => {
96
335
  it("throws on web", async () => {
97
336
  const originalOS = Platform.OS;