@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-alpha.1

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 (378) hide show
  1. package/.claude-flow/data/pending-insights.jsonl +43 -0
  2. package/.claude-flow/sessions/session-1794323376548.json +14 -0
  3. package/CHANGELOG.md +41 -0
  4. package/jest.config.cjs +22 -0
  5. package/lib/assets/home/loop-day.jpg +0 -0
  6. package/lib/assets/home/loop-day.mp4 +0 -0
  7. package/lib/assets/home/loop-time-back.jpg +0 -0
  8. package/lib/assets/home/loop-time-back.mp4 +0 -0
  9. package/lib/assets/home/loop-where.jpg +0 -0
  10. package/lib/assets/home/loop-where.mp4 +0 -0
  11. package/lib/assets/home/reel-gym.jpg +0 -0
  12. package/lib/assets/home/reel-gym.mp4 +0 -0
  13. package/lib/assets/home/reel-internet.jpg +0 -0
  14. package/lib/assets/home/reel-internet.mp4 +0 -0
  15. package/lib/assets/icon.png +0 -0
  16. package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  17. package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
  18. package/lib/assets/lottie/lucy-mark-call.json +1470 -0
  19. package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
  20. package/lib/assets/lottie/lucy-mark-details.json +1735 -0
  21. package/lib/assets/lottie/lucy-mark-email.json +1363 -0
  22. package/lib/assets/lottie/lucy-mark-message.json +1154 -0
  23. package/lib/assets/lottie/lucy-mark-search.json +1067 -0
  24. package/lib/assets/lottie/lucy-mark-think.json +1253 -0
  25. package/lib/assets/lottie/lucy-mark-write.json +1532 -0
  26. package/lib/assets/lottie/time-back.json +16458 -0
  27. package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
  28. package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
  29. package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  30. package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  31. package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  32. package/lib/assets/sounds/hours-back.m4a +0 -0
  33. package/lib/assets/sounds/meet-lucy.m4a +0 -0
  34. package/lib/assets/sounds/power-on.m4a +0 -0
  35. package/lib/assets/sounds/wind-back.m4a +0 -0
  36. package/lib/assets/sounds/youre-in.m4a +0 -0
  37. package/lib/chat/agent.js +358 -0
  38. package/lib/chat/agent.js.map +1 -0
  39. package/lib/chat/appFront.js +32 -0
  40. package/lib/chat/appFront.js.map +1 -0
  41. package/lib/chat/auth.js +370 -0
  42. package/lib/chat/auth.js.map +1 -0
  43. package/lib/chat/chores.js +360 -0
  44. package/lib/chat/chores.js.map +1 -0
  45. package/lib/chat/connectors.js +45 -0
  46. package/lib/chat/connectors.js.map +1 -0
  47. package/lib/chat/jobs.js +223 -0
  48. package/lib/chat/jobs.js.map +1 -0
  49. package/lib/chat/lucyMotion.js +6 -0
  50. package/lib/chat/lucyMotion.js.map +1 -0
  51. package/lib/chat/protocol.js +111 -0
  52. package/lib/chat/protocol.js.map +1 -0
  53. package/lib/chat/results.js +133 -0
  54. package/lib/chat/results.js.map +1 -0
  55. package/lib/chat/store.js +81 -0
  56. package/lib/chat/store.js.map +1 -0
  57. package/lib/chat/useDictation.js +168 -0
  58. package/lib/chat/useDictation.js.map +1 -0
  59. package/lib/chat/useLucyChat.js +451 -0
  60. package/lib/chat/useLucyChat.js.map +1 -0
  61. package/lib/chat/useMyComputer.js +32 -0
  62. package/lib/chat/useMyComputer.js.map +1 -0
  63. package/lib/chat/whereLucyWorks.js +52 -0
  64. package/lib/chat/whereLucyWorks.js.map +1 -0
  65. package/lib/chat/workspace.js +124 -0
  66. package/lib/chat/workspace.js.map +1 -0
  67. package/lib/components/AreaShot.js +289 -0
  68. package/lib/components/AreaShot.js.map +1 -0
  69. package/lib/components/Backdrops.js +262 -0
  70. package/lib/components/Backdrops.js.map +1 -0
  71. package/lib/components/BottomSheet.js +61 -0
  72. package/lib/components/BottomSheet.js.map +1 -0
  73. package/lib/components/ChatSheets.js +429 -0
  74. package/lib/components/ChatSheets.js.map +1 -0
  75. package/lib/components/ConnectorLogo.js +91 -0
  76. package/lib/components/ConnectorLogo.js.map +1 -0
  77. package/lib/components/CustomDrawer.js +534 -0
  78. package/lib/components/CustomDrawer.js.map +1 -0
  79. package/lib/components/IdeasPane.js +394 -0
  80. package/lib/components/IdeasPane.js.map +1 -0
  81. package/lib/components/ImessageSheet.js +261 -0
  82. package/lib/components/ImessageSheet.js.map +1 -0
  83. package/lib/components/KeyboardAvoider.js +29 -0
  84. package/lib/components/KeyboardAvoider.js.map +1 -0
  85. package/lib/components/Logo.js +81 -0
  86. package/lib/components/Logo.js.map +1 -0
  87. package/lib/components/LucyWorking.js +67 -0
  88. package/lib/components/LucyWorking.js.map +1 -0
  89. package/lib/components/Markdown.js +260 -0
  90. package/lib/components/Markdown.js.map +1 -0
  91. package/lib/components/Media.js +93 -0
  92. package/lib/components/Media.js.map +1 -0
  93. package/lib/components/MessagesAppIcon.js +23 -0
  94. package/lib/components/MessagesAppIcon.js.map +1 -0
  95. package/lib/components/MicButton.js +71 -0
  96. package/lib/components/MicButton.js.map +1 -0
  97. package/lib/components/ResultCards.js +974 -0
  98. package/lib/components/ResultCards.js.map +1 -0
  99. package/lib/components/SignInPrompt.js +148 -0
  100. package/lib/components/SignInPrompt.js.map +1 -0
  101. package/lib/components/SignedOut.js +38 -0
  102. package/lib/components/SignedOut.js.map +1 -0
  103. package/lib/components/TalkToLucyHero.js +487 -0
  104. package/lib/components/TalkToLucyHero.js.map +1 -0
  105. package/lib/components/TalkToLucySheet.js +182 -0
  106. package/lib/components/TalkToLucySheet.js.map +1 -0
  107. package/lib/components/WhereLucyWorks.js +277 -0
  108. package/lib/components/WhereLucyWorks.js.map +1 -0
  109. package/lib/components/WorkspaceSection.js +271 -0
  110. package/lib/components/WorkspaceSection.js.map +1 -0
  111. package/lib/components/YantraMark.js +13 -0
  112. package/lib/components/YantraMark.js.map +1 -0
  113. package/lib/components/drawerHeader.js +38 -0
  114. package/lib/components/drawerHeader.js.map +1 -0
  115. package/lib/components/lottieInstalled.js +6 -0
  116. package/lib/components/lottieInstalled.js.map +1 -0
  117. package/lib/components/ui.js +550 -0
  118. package/lib/components/ui.js.map +1 -0
  119. package/lib/components/useSignOut.js +7 -0
  120. package/lib/components/useSignOut.js.map +1 -0
  121. package/lib/components/viewport.js +121 -0
  122. package/lib/components/viewport.js.map +1 -0
  123. package/lib/components/voiceDial.js +10 -0
  124. package/lib/components/voiceDial.js.map +1 -0
  125. package/lib/compute.js +157 -0
  126. package/lib/compute.js.map +1 -0
  127. package/lib/config/env-config.js +27 -0
  128. package/lib/config/env-config.js.map +1 -0
  129. package/lib/config/routes.js +15 -0
  130. package/lib/config/routes.js.map +1 -0
  131. package/lib/content.js +25 -0
  132. package/lib/content.js.map +1 -0
  133. package/lib/hooks/keyboardCover.js +39 -0
  134. package/lib/hooks/keyboardCover.js.map +1 -0
  135. package/lib/hooks/useKeyboard.js +121 -0
  136. package/lib/hooks/useKeyboard.js.map +1 -0
  137. package/lib/hooks/useReducedMotion.js +13 -0
  138. package/lib/hooks/useReducedMotion.js.map +1 -0
  139. package/lib/imessage/openMessages.js +25 -0
  140. package/lib/imessage/openMessages.js.map +1 -0
  141. package/lib/imessage/platform.js +12 -0
  142. package/lib/imessage/platform.js.map +1 -0
  143. package/lib/imessage/textLink.js +262 -0
  144. package/lib/imessage/textLink.js.map +1 -0
  145. package/lib/index.js +1 -0
  146. package/lib/index.js.map +1 -0
  147. package/lib/live/card.js +28 -0
  148. package/lib/live/card.js.map +1 -0
  149. package/lib/live/liveActivity.js +144 -0
  150. package/lib/live/liveActivity.js.map +1 -0
  151. package/lib/module.js +3 -0
  152. package/lib/module.js.map +1 -0
  153. package/lib/offer/BlackFridayOffer.js +378 -0
  154. package/lib/offer/BlackFridayOffer.js.map +1 -0
  155. package/lib/offer/blackFriday.js +78 -0
  156. package/lib/offer/blackFriday.js.map +1 -0
  157. package/lib/offer/parts.js +624 -0
  158. package/lib/offer/parts.js.map +1 -0
  159. package/lib/offer/state.js +63 -0
  160. package/lib/offer/state.js.map +1 -0
  161. package/lib/push/push.js +142 -0
  162. package/lib/push/push.js.map +1 -0
  163. package/lib/push/usePushNotifications.js +39 -0
  164. package/lib/push/usePushNotifications.js.map +1 -0
  165. package/lib/routes.json +175 -0
  166. package/lib/screens/Account/index.js +209 -0
  167. package/lib/screens/Account/index.js.map +1 -0
  168. package/lib/screens/Chat/index.js +710 -0
  169. package/lib/screens/Chat/index.js.map +1 -0
  170. package/lib/screens/Chores/index.js +18 -0
  171. package/lib/screens/Chores/index.js.map +1 -0
  172. package/lib/screens/Connectors/index.js +17 -0
  173. package/lib/screens/Connectors/index.js.map +1 -0
  174. package/lib/screens/History/index.js +380 -0
  175. package/lib/screens/History/index.js.map +1 -0
  176. package/lib/screens/Home/index.js +2715 -0
  177. package/lib/screens/Home/index.js.map +1 -0
  178. package/lib/screens/Home/media.js +25 -0
  179. package/lib/screens/Home/media.js.map +1 -0
  180. package/lib/screens/Welcome/index.js +1066 -0
  181. package/lib/screens/Welcome/index.js.map +1 -0
  182. package/lib/talk/talkToLucy.js +139 -0
  183. package/lib/talk/talkToLucy.js.map +1 -0
  184. package/lib/theme/colors.js +29 -0
  185. package/lib/theme/colors.js.map +1 -0
  186. package/lib/theme/fonts.js +17 -0
  187. package/lib/theme/fonts.js.map +1 -0
  188. package/lib/theme/muse.js +134 -0
  189. package/lib/theme/muse.js.map +1 -0
  190. package/lib/utils/links.js +54 -0
  191. package/lib/utils/links.js.map +1 -0
  192. package/lib/utils/yantraLinks.js +68 -0
  193. package/lib/utils/yantraLinks.js.map +1 -0
  194. package/lib/welcome/flow.js +375 -0
  195. package/lib/welcome/flow.js.map +1 -0
  196. package/lib/welcome/haptics.js +125 -0
  197. package/lib/welcome/haptics.js.map +1 -0
  198. package/lib/welcome/parts.js +1996 -0
  199. package/lib/welcome/parts.js.map +1 -0
  200. package/lib/welcome/powerOn.js +29 -0
  201. package/lib/welcome/powerOn.js.map +1 -0
  202. package/lib/welcome/seen.js +41 -0
  203. package/lib/welcome/seen.js.map +1 -0
  204. package/lib/welcome/sound.js +110 -0
  205. package/lib/welcome/sound.js.map +1 -0
  206. package/package.json +66 -5
  207. package/rollup.config.mjs +42 -0
  208. package/src/.claude-flow/data/pending-insights.jsonl +19 -0
  209. package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
  210. package/src/__tests__/auth.test.ts +94 -0
  211. package/src/__tests__/blackFriday.test.ts +75 -0
  212. package/src/__tests__/cardTokens.test.ts +77 -0
  213. package/src/__tests__/chores.test.ts +188 -0
  214. package/src/__tests__/choresList.test.ts +100 -0
  215. package/src/__tests__/connectLink.test.ts +21 -0
  216. package/src/__tests__/content.test.ts +54 -0
  217. package/src/__tests__/dictation.test.ts +186 -0
  218. package/src/__tests__/envConfig.test.ts +14 -0
  219. package/src/__tests__/haptics.test.ts +202 -0
  220. package/src/__tests__/jobs.test.ts +130 -0
  221. package/src/__tests__/keyboardCover.test.ts +84 -0
  222. package/src/__tests__/liveCard.test.ts +39 -0
  223. package/src/__tests__/lockedPhone.test.ts +355 -0
  224. package/src/__tests__/lucyMotion.test.ts +34 -0
  225. package/src/__tests__/platform.test.ts +32 -0
  226. package/src/__tests__/powerOn.test.ts +62 -0
  227. package/src/__tests__/protocol.test.ts +125 -0
  228. package/src/__tests__/push.test.ts +111 -0
  229. package/src/__tests__/results.test.ts +256 -0
  230. package/src/__tests__/sound.test.ts +248 -0
  231. package/src/__tests__/talkToLucy.test.ts +205 -0
  232. package/src/__tests__/textLink.test.ts +91 -0
  233. package/src/__tests__/voiceDial.test.ts +53 -0
  234. package/src/__tests__/welcomeFlow.test.ts +157 -0
  235. package/src/__tests__/whereLucyWorks.test.ts +81 -0
  236. package/src/__tests__/yantraLinks.test.ts +96 -0
  237. package/src/assets/home/loop-day.jpg +0 -0
  238. package/src/assets/home/loop-day.mp4 +0 -0
  239. package/src/assets/home/loop-time-back.jpg +0 -0
  240. package/src/assets/home/loop-time-back.mp4 +0 -0
  241. package/src/assets/home/loop-where.jpg +0 -0
  242. package/src/assets/home/loop-where.mp4 +0 -0
  243. package/src/assets/home/reel-gym.jpg +0 -0
  244. package/src/assets/home/reel-gym.mp4 +0 -0
  245. package/src/assets/home/reel-internet.jpg +0 -0
  246. package/src/assets/home/reel-internet.mp4 +0 -0
  247. package/src/assets/icon.png +0 -0
  248. package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  249. package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
  250. package/src/assets/lottie/lucy-mark-call.json +1470 -0
  251. package/src/assets/lottie/lucy-mark-connect.json +2552 -0
  252. package/src/assets/lottie/lucy-mark-details.json +1735 -0
  253. package/src/assets/lottie/lucy-mark-email.json +1363 -0
  254. package/src/assets/lottie/lucy-mark-message.json +1154 -0
  255. package/src/assets/lottie/lucy-mark-search.json +1067 -0
  256. package/src/assets/lottie/lucy-mark-think.json +1253 -0
  257. package/src/assets/lottie/lucy-mark-write.json +1532 -0
  258. package/src/assets/lottie/time-back.json +16458 -0
  259. package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
  260. package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
  261. package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  262. package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  263. package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  264. package/src/assets/sounds/hours-back.m4a +0 -0
  265. package/src/assets/sounds/meet-lucy.m4a +0 -0
  266. package/src/assets/sounds/power-on.m4a +0 -0
  267. package/src/assets/sounds/wind-back.m4a +0 -0
  268. package/src/assets/sounds/youre-in.m4a +0 -0
  269. package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
  270. package/src/chat/agent.ts +376 -0
  271. package/src/chat/appFront.ts +39 -0
  272. package/src/chat/auth.ts +433 -0
  273. package/src/chat/chores.ts +394 -0
  274. package/src/chat/connectors.ts +75 -0
  275. package/src/chat/jobs.ts +228 -0
  276. package/src/chat/lucyMotion.ts +33 -0
  277. package/src/chat/protocol.ts +192 -0
  278. package/src/chat/results.ts +224 -0
  279. package/src/chat/store.ts +87 -0
  280. package/src/chat/useDictation.ts +201 -0
  281. package/src/chat/useLucyChat.ts +458 -0
  282. package/src/chat/useMyComputer.ts +41 -0
  283. package/src/chat/whereLucyWorks.ts +97 -0
  284. package/src/chat/workspace.ts +127 -0
  285. package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
  286. package/src/components/AreaShot.tsx +239 -0
  287. package/src/components/Backdrops.tsx +323 -0
  288. package/src/components/BottomSheet.tsx +96 -0
  289. package/src/components/ChatSheets.tsx +565 -0
  290. package/src/components/ConnectorLogo.tsx +116 -0
  291. package/src/components/CustomDrawer.tsx +526 -0
  292. package/src/components/IdeasPane.tsx +318 -0
  293. package/src/components/ImessageSheet.tsx +280 -0
  294. package/src/components/KeyboardAvoider.tsx +45 -0
  295. package/src/components/Logo.tsx +97 -0
  296. package/src/components/LucyWorking.tsx +122 -0
  297. package/src/components/Markdown.tsx +219 -0
  298. package/src/components/Media.tsx +173 -0
  299. package/src/components/MessagesAppIcon.tsx +51 -0
  300. package/src/components/MicButton.tsx +92 -0
  301. package/src/components/ResultCards.tsx +1067 -0
  302. package/src/components/SignInPrompt.tsx +182 -0
  303. package/src/components/SignedOut.tsx +47 -0
  304. package/src/components/TalkToLucyHero.tsx +540 -0
  305. package/src/components/TalkToLucySheet.tsx +208 -0
  306. package/src/components/VoiceOrb.tsx +364 -0
  307. package/src/components/WhereLucyWorks.tsx +261 -0
  308. package/src/components/WorkspaceSection.tsx +307 -0
  309. package/src/components/YantraMark.tsx +30 -0
  310. package/src/components/drawerHeader.tsx +46 -0
  311. package/src/components/kit.tsx +309 -0
  312. package/src/components/lottieInstalled.ts +7 -0
  313. package/src/components/ui.tsx +700 -0
  314. package/src/components/useSignOut.ts +21 -0
  315. package/src/components/viewport.tsx +166 -0
  316. package/src/components/voiceDial.ts +45 -0
  317. package/src/compute.ts +168 -0
  318. package/src/config/env-config.ts +50 -0
  319. package/src/config/routes.ts +28 -0
  320. package/src/content.ts +217 -0
  321. package/src/hooks/keyboardCover.ts +70 -0
  322. package/src/hooks/useKeyboard.ts +135 -0
  323. package/src/hooks/useReducedMotion.ts +19 -0
  324. package/src/imessage/openMessages.ts +53 -0
  325. package/src/imessage/platform.ts +32 -0
  326. package/src/imessage/textLink.ts +307 -0
  327. package/src/index.ts +24 -0
  328. package/src/live/card.ts +62 -0
  329. package/src/live/liveActivity.ts +192 -0
  330. package/src/module.ts +8 -0
  331. package/src/offer/BlackFridayOffer.tsx +394 -0
  332. package/src/offer/blackFriday.ts +109 -0
  333. package/src/offer/parts.tsx +650 -0
  334. package/src/offer/state.ts +78 -0
  335. package/src/push/push.ts +171 -0
  336. package/src/push/usePushNotifications.ts +47 -0
  337. package/src/screens/Account/index.tsx +310 -0
  338. package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
  339. package/src/screens/Chat/index.tsx +891 -0
  340. package/src/screens/Chores/index.tsx +35 -0
  341. package/src/screens/Connectors/index.tsx +35 -0
  342. package/src/screens/History/index.tsx +346 -0
  343. package/src/screens/Home/index.tsx +2776 -0
  344. package/src/screens/Home/media.ts +31 -0
  345. package/src/screens/Welcome/index.tsx +1182 -0
  346. package/src/talk/talkToLucy.ts +187 -0
  347. package/src/theme/colors.ts +38 -0
  348. package/src/theme/fonts.ts +30 -0
  349. package/src/theme/muse.ts +86 -0
  350. package/src/utils/links.ts +84 -0
  351. package/src/utils/yantraLinks.ts +94 -0
  352. package/src/welcome/flow.ts +418 -0
  353. package/src/welcome/haptics.ts +179 -0
  354. package/src/welcome/parts.tsx +2160 -0
  355. package/src/welcome/powerOn.ts +84 -0
  356. package/src/welcome/seen.ts +68 -0
  357. package/src/welcome/sound.ts +173 -0
  358. package/tools/lottie/chat.motion +0 -0
  359. package/tools/lottie/cloud.motion +0 -0
  360. package/tools/lottie/generate.mjs +1209 -0
  361. package/tools/lottie/inter-glyphs.json +4416 -0
  362. package/tools/lottie/lucy-mark-calendar.motion +0 -0
  363. package/tools/lottie/lucy-mark-call.motion +0 -0
  364. package/tools/lottie/lucy-mark-connect.motion +0 -0
  365. package/tools/lottie/lucy-mark-details.motion +0 -0
  366. package/tools/lottie/lucy-mark-email.motion +0 -0
  367. package/tools/lottie/lucy-mark-message.motion +0 -0
  368. package/tools/lottie/lucy-mark-search.motion +0 -0
  369. package/tools/lottie/lucy-mark-think.motion +0 -0
  370. package/tools/lottie/lucy-mark-write.motion +0 -0
  371. package/tools/lottie/mark.json +1 -0
  372. package/tools/lottie/mine-none.motion +0 -0
  373. package/tools/lottie/mine-offline.motion +0 -0
  374. package/tools/lottie/mine-online.motion +0 -0
  375. package/tools/lottie/time-back.mjs +604 -0
  376. package/tools/sounds/render.mjs +730 -0
  377. package/tsconfig.json +17 -0
  378. package/README.md +0 -3
@@ -0,0 +1,62 @@
1
+ // The power-on's timeline (welcome/powerOn.ts): the ring speeds up as it fills, and the vibration lands on its beats.
2
+ import { describe, expect, it } from '@jest/globals';
3
+ import {
4
+ POWER_ON,
5
+ POWER_ON_ANDROID,
6
+ POWER_ON_TRACK,
7
+ THOOM_EVERY,
8
+ THOOM_HITS,
9
+ tickLitAt,
10
+ vibrationPattern,
11
+ } from '../welcome/powerOn';
12
+
13
+ describe('the power-on', () => {
14
+ it('lights the ring from twelve, all sixty ticks before the hand clicks', () => {
15
+ expect(tickLitAt(0)).toBe(0);
16
+ expect(tickLitAt(59)).toBe(POWER_ON.ring);
17
+ expect(POWER_ON.ring).toBeLessThan(POWER_ON.click);
18
+ });
19
+
20
+ it('speeds up as the ring fills: each gap between ticks no longer than the one before', () => {
21
+ const gaps = Array.from({ length: 59 }, (_, i) => tickLitAt(i + 1) - tickLitAt(i));
22
+ // Rounded to whole ms, so allow a ms either way.
23
+ gaps.slice(1).forEach((gap, i) => expect(gap).toBeLessThanOrEqual(gaps[i] + 1));
24
+ expect(gaps[0]).toBeGreaterThan(gaps[58] * 5);
25
+ });
26
+
27
+ it('vibrates in time: taps closing in, then the click, the thoom and the heartbeat on their beats', () => {
28
+ const times = POWER_ON_TRACK.map(([ms]) => ms);
29
+ expect(times).toEqual([...times].sort((a, b) => a - b));
30
+ const revving = POWER_ON_TRACK.filter(([ms]) => ms < POWER_ON.click).map(([ms]) => ms);
31
+ const gaps = revving.slice(1).map((ms, i) => ms - revving[i]);
32
+ gaps.slice(1).forEach((gap, i) => expect(gap).toBeLessThan(gaps[i]));
33
+ expect(POWER_ON_TRACK).toContainEqual([POWER_ON.click, 'rigid']);
34
+ expect(POWER_ON_TRACK).toContainEqual([POWER_ON.ignite, 'heavy']);
35
+ expect(times.filter((ms) => (POWER_ON.beats as readonly number[]).includes(ms))).toHaveLength(2);
36
+ expect(Math.max(...times)).toBeLessThan(POWER_ON.done);
37
+ });
38
+
39
+ it('hands over only once Lucy has sunk into the pin and the hands have settled', () => {
40
+ expect(POWER_ON.done).toBeGreaterThanOrEqual(POWER_ON.sink + 380);
41
+ expect(POWER_ON.done).toBeGreaterThanOrEqual(POWER_ON.settle + 620);
42
+ });
43
+
44
+ it('builds as it revs: each tap at least as hard as the one before, ending heavy', () => {
45
+ const order = ['soft', 'light', 'medium', 'heavy'];
46
+ const revving = POWER_ON_TRACK.filter(([ms]) => ms < POWER_ON.click).map(([, kind]) => order.indexOf(kind));
47
+ revving.slice(1).forEach((k, i) => expect(k).toBeGreaterThanOrEqual(revving[i]));
48
+ expect(revving[revving.length - 1]).toBe(order.indexOf('heavy'));
49
+ });
50
+
51
+ it('hits hardest on the thoom: a burst of heavy hits, felt as one rumble', () => {
52
+ const burst = POWER_ON_TRACK.filter(([ms]) => ms >= POWER_ON.ignite && ms < POWER_ON.beats[0]);
53
+ expect(burst).toHaveLength(THOOM_HITS);
54
+ burst.forEach(([, kind]) => expect(kind).toBe('heavy'));
55
+ expect(burst[burst.length - 1][0] - burst[0][0]).toBe((THOOM_HITS - 1) * THOOM_EVERY);
56
+ });
57
+
58
+ it("puts Android's buzzes on the click, the thoom and the heartbeat, as one Vibration pattern", () => {
59
+ expect(POWER_ON_ANDROID.map(([ms]) => ms)).toEqual([POWER_ON.click, POWER_ON.ignite, ...POWER_ON.beats]);
60
+ expect(vibrationPattern(POWER_ON_ANDROID)).toEqual([900, 40, 60, 140, 110, 60, 140, 45]);
61
+ });
62
+ });
@@ -0,0 +1,125 @@
1
+ import {
2
+ agentTurn,
3
+ chatTitle,
4
+ displayText,
5
+ formatAskAnswers,
6
+ joinOutput,
7
+ parseAskUser,
8
+ statusLine,
9
+ toolLine,
10
+ visibleOutput,
11
+ SYSTEM_PROMPT,
12
+ } from '../chat/protocol';
13
+
14
+ describe('visibleOutput', () => {
15
+ it('drops terminal furniture and keeps the words', () => {
16
+ const raw =
17
+ '\n \u001b[1mDone.\u001b[0m\n🧠 thinking about it\n⚡ Tokens: 1200 in / 300 out\n│ 1. Option │\nYour gym is cancelled.';
18
+ expect(visibleOutput(raw)).toBe('Done.\nYour gym is cancelled.');
19
+ });
20
+
21
+ it('drops the terminal copy of a question', () => {
22
+ expect(visibleOutput('Hi[CDECLI_ASK_USER_QUESTION]{"x":1}[/CDECLI_ASK_USER_QUESTION]')).toBe('Hi');
23
+ });
24
+ });
25
+
26
+ describe('joinOutput', () => {
27
+ it('starts an output on its own paragraph', () => {
28
+ expect(joinOutput('Calling now.', 'Done.')).toBe('Calling now.\n\nDone.');
29
+ expect(joinOutput('Calling now.\n', 'Done.')).toBe('Calling now.\n\nDone.');
30
+ expect(joinOutput('', 'Done.')).toBe('Done.');
31
+ });
32
+ });
33
+
34
+ describe('question cards', () => {
35
+ const reply =
36
+ 'Sure.\n[ASK_USER]{"requestId":"r1","questions":[{"id":"q1","header":"Gym","title":"Which gym?","options":["Planet Fitness",{"id":"b","label":"Equinox","description":"Downtown"}]},{"id":"q2","question":"Any account number:","allowText":true}]}[/ASK_USER]';
37
+
38
+ it('parses the block, accepting the shorthand fields', () => {
39
+ const ask = parseAskUser(reply);
40
+ expect(ask?.requestId).toBe('r1');
41
+ expect(ask?.questions).toHaveLength(2);
42
+ expect(ask?.questions[0].options).toEqual([
43
+ { id: 'o0', label: 'Planet Fitness' },
44
+ { id: 'b', label: 'Equinox', detail: 'Downtown' },
45
+ ]);
46
+ expect(ask?.questions[1].title).toBe('Any account number:');
47
+ });
48
+
49
+ it('ignores a block still streaming in', () => {
50
+ expect(parseAskUser('[ASK_USER]{"requestId":"r1","questions":[')).toBeNull();
51
+ });
52
+
53
+ it('answers as the web does: bold titles, typed text wins, skipped questions left out', () => {
54
+ const ask = parseAskUser(reply)!;
55
+ expect(
56
+ formatAskAnswers(ask, {
57
+ q1: { picked: ['Equinox'], text: '' },
58
+ q2: { picked: [], text: '' },
59
+ }),
60
+ ).toBe('**Which gym?:** Equinox');
61
+ expect(
62
+ formatAskAnswers(ask, { q1: { picked: ['Equinox'], text: 'Crunch' }, q2: { picked: [], text: '1234' } }),
63
+ ).toBe('**Which gym?:** Crunch\n\n**Any account number:** 1234');
64
+ });
65
+
66
+ it('keeps the block out of the bubble', () => {
67
+ expect(displayText(reply)).toBe('Sure.');
68
+ });
69
+ });
70
+
71
+ describe('displayText', () => {
72
+ it('drops web-only cards and keeps surface labels', () => {
73
+ const t =
74
+ 'On it. [[surface:phone-calls|Phone Calls]]\n\n```yantra:widget {"propsComponent":"travel"}```\n[CONNECTOR_CONNECT]{"id":"gmail"}[/CONNECTOR_CONNECT]';
75
+ expect(displayText(t)).toBe('On it. Phone Calls');
76
+ });
77
+
78
+ const envelope = JSON.stringify({
79
+ propsComponent: 'shopping',
80
+ propsConfiguration: { contents: { attachment: { properties: [{ title: 'Jockey tee', price: 579 }] } } },
81
+ });
82
+
83
+ it('keeps a result block out of the bubble in every form a model writes it', () => {
84
+ expect(displayText(`Here you go.\n\n\`\`\`json\n${envelope}\n\`\`\``)).toBe('Here you go.');
85
+ expect(displayText(`Here you go.\n\nyantra:widget\n${envelope}`)).toBe('Here you go.');
86
+ expect(displayText(`Here you go.\n\n${envelope}\n\nWant a size up?`)).toBe('Here you go.\n\nWant a size up?');
87
+ });
88
+
89
+ it('never shows a block still streaming in', () => {
90
+ expect(displayText('Here you go.\n\n```yantra:widget\n{"propsComponent":"shop')).toBe('Here you go.');
91
+ expect(displayText('Here you go.\n\n```json\n{"propsCompo')).toBe('Here you go.');
92
+ });
93
+ });
94
+
95
+ describe('agentTurn', () => {
96
+ it('carries the note on result cards after the words, for the agent alone', () => {
97
+ const turn = agentTurn('Find me a flight to Mumbai');
98
+ expect(turn.startsWith('Find me a flight to Mumbai\n\n<agent-context>Result cards:')).toBe(true);
99
+ expect(turn.endsWith('</agent-context>')).toBe(true);
100
+ expect(turn).toContain('"propsComponent":"travel"');
101
+ expect(turn).toContain('"propsComponent":"shopping"');
102
+ });
103
+ });
104
+
105
+ describe('small lines', () => {
106
+ it('words tool activity for a person', () => {
107
+ expect(toolLine('yantra-phone-calls')).toBe('Making a call');
108
+ expect(toolLine('Bash', 'curl https://example.com')).toBe('Looking it up');
109
+ expect(toolLine('mystery')).toBe('Working on it');
110
+ });
111
+
112
+ it('strips a status line of its glyphs', () => {
113
+ expect(statusLine('⏳ Queued behind another turn')).toBe('Queued behind another turn');
114
+ });
115
+
116
+ it('titles a chat from its first message', () => {
117
+ expect(chatTitle('**Cancel** my gym')).toBe('Cancel my gym');
118
+ expect(chatTitle('')).toBe('New chat');
119
+ });
120
+
121
+ it('opens sessions as Lucy, taught to ask with cards', () => {
122
+ expect(SYSTEM_PROMPT).toContain('You are Lucy');
123
+ expect(SYSTEM_PROMPT).toContain('[ASK_USER]');
124
+ });
125
+ });
@@ -0,0 +1,111 @@
1
+ // push.ts talks to expo-notifications and to Yantra's backend through chat/auth: stub both for node.
2
+ const n = {
3
+ getPermissionsAsync: jest.fn(async () => ({ granted: true, status: 'granted' })),
4
+ requestPermissionsAsync: jest.fn(async () => ({})),
5
+ getExpoPushTokenAsync: jest.fn(async () => ({ data: 'ExponentPushToken[abc]' })),
6
+ setNotificationChannelAsync: jest.fn(async () => undefined),
7
+ setNotificationHandler: jest.fn(),
8
+ AndroidImportance: { HIGH: 4 },
9
+ AndroidNotificationVisibility: { PRIVATE: 0 },
10
+ IosAuthorizationStatus: { PROVISIONAL: 3 },
11
+ };
12
+ let linked = true;
13
+ jest.mock('expo-modules-core', () => ({ requireOptionalNativeModule: () => (linked ? {} : null) }), { virtual: true });
14
+ jest.mock('expo-notifications', () => n, { virtual: true });
15
+ jest.mock('expo-device', () => ({ isDevice: true }), { virtual: true });
16
+ jest.mock(
17
+ 'expo-constants',
18
+ () => ({ __esModule: true, default: { expoConfig: { extra: { eas: { projectId: 'p1' } } } } }),
19
+ {
20
+ virtual: true,
21
+ },
22
+ );
23
+ jest.mock('react-native', () => ({ Platform: { OS: 'ios' } }), { virtual: true });
24
+ const gql = jest.fn(async () => ({ setDeviceToken: { id: 'u1' } }));
25
+ jest.mock('../chat/auth', () => ({
26
+ agentBackendUrl: async () => 'https://backend/graphql',
27
+ auth0Token: async () => 'token',
28
+ gql: (...args: unknown[]) => gql(...(args as [])),
29
+ }));
30
+
31
+ describe('registerForPush', () => {
32
+ beforeEach(() => {
33
+ jest.resetModules();
34
+ jest.clearAllMocks();
35
+ linked = true;
36
+ });
37
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
38
+ const load = () => require('../push/push') as typeof import('../push/push');
39
+
40
+ it('saves the Expo push token to the account with setDeviceToken, once', async () => {
41
+ const { registerForPush } = load();
42
+ await expect(registerForPush()).resolves.toBe('granted');
43
+ expect(n.getExpoPushTokenAsync).toHaveBeenCalledWith({ projectId: 'p1' });
44
+ expect(gql).toHaveBeenCalledWith(
45
+ 'https://backend/graphql',
46
+ 'token',
47
+ expect.stringContaining('setDeviceToken'),
48
+ { deviceToken: 'ExponentPushToken[abc]' },
49
+ );
50
+ await registerForPush();
51
+ expect(gql).toHaveBeenCalledTimes(1);
52
+ });
53
+
54
+ it('does not prompt unless asked', async () => {
55
+ n.getPermissionsAsync.mockResolvedValue({ granted: false, status: 'undetermined' });
56
+ const { registerForPush } = load();
57
+ await expect(registerForPush()).resolves.toBe('undetermined');
58
+ expect(n.requestPermissionsAsync).not.toHaveBeenCalled();
59
+ expect(gql).not.toHaveBeenCalled();
60
+ n.getPermissionsAsync.mockResolvedValue({ granted: true, status: 'granted' });
61
+ });
62
+
63
+ it('is unsupported, not a crash, on a build without expo-notifications', async () => {
64
+ linked = false;
65
+ const { registerForPush } = load();
66
+ await expect(registerForPush({ ask: true })).resolves.toBe('unsupported');
67
+ expect(gql).not.toHaveBeenCalled();
68
+ });
69
+ });
70
+
71
+ describe('Lucy’s chore notifications', () => {
72
+ beforeEach(() => {
73
+ jest.resetModules();
74
+ jest.clearAllMocks();
75
+ linked = true;
76
+ n.getPermissionsAsync.mockResolvedValue({ granted: true, status: 'granted' });
77
+ });
78
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
79
+ const load = () => require('../push/push') as typeof import('../push/push');
80
+ const done = { kind: 'lucy-chore', taskId: 't1', choreId: 'board-1' };
81
+
82
+ it('names this phone on a chore only once its token is registered to the account', async () => {
83
+ const push = load();
84
+ expect(push.registeredPushToken()).toBeNull();
85
+ await push.registerForPush();
86
+ expect(push.registeredPushToken()).toBe('ExponentPushToken[abc]');
87
+ push.forgetPushToken();
88
+ expect(push.registeredPushToken()).toBeNull();
89
+ });
90
+
91
+ it('a chore’s end stays quiet while her chat is on screen, and shows anywhere else', () => {
92
+ const push = load();
93
+ expect(push.presentWhileOpen(done)).toMatchObject({ shouldShowBanner: true, shouldPlaySound: true });
94
+ push.setChatOnScreen(true);
95
+ expect(push.presentWhileOpen(done)).toMatchObject({ shouldShowBanner: false, shouldPlaySound: false });
96
+ // Anything else still shows in her chat.
97
+ expect(push.presentWhileOpen({ kind: 'reminder' })).toMatchObject({ shouldShowBanner: true });
98
+ push.setChatOnScreen(false);
99
+ expect(push.presentWhileOpen(done)).toMatchObject({ shouldShowBanner: true });
100
+ });
101
+
102
+ it('the installed handler decides from the notification’s data', async () => {
103
+ const push = load();
104
+ push.installNotificationHandler();
105
+ const { handleNotification } = n.setNotificationHandler.mock.calls[0][0];
106
+ push.setChatOnScreen(true);
107
+ await expect(handleNotification({ request: { content: { data: done } } })).resolves.toMatchObject({
108
+ shouldShowBanner: false,
109
+ });
110
+ });
111
+ });
@@ -0,0 +1,256 @@
1
+ import {
2
+ beyondLabel,
3
+ cardPicks,
4
+ conditionOf,
5
+ describeFlight,
6
+ describeItem,
7
+ laterWords,
8
+ legWhen,
9
+ moreSurface,
10
+ noteFor,
11
+ platformBase,
12
+ shownRows,
13
+ splitClock,
14
+ surfaceUrl,
15
+ takeResults,
16
+ type FlightsCard,
17
+ type ListCard,
18
+ } from '../chat/results';
19
+
20
+ /** A flight offer as Lucy is asked to write one (RESULT_CARDS_PROMPT): airport-local times, a slice per direction. */
21
+ function offer(
22
+ id: string,
23
+ airline: string,
24
+ price: number,
25
+ departAt: string,
26
+ arriveAt: string,
27
+ minutes: number,
28
+ extra: { number?: string; stops?: number; via?: { airport: string; layoverDuration: string } } = {},
29
+ ) {
30
+ return {
31
+ id,
32
+ title: airline,
33
+ price,
34
+ flight: {
35
+ airline,
36
+ ...(extra.number ? { flightNumbers: [extra.number] } : {}),
37
+ cabinClass: 'economy',
38
+ slices: [
39
+ {
40
+ origin: 'BLR',
41
+ destination: 'BOM',
42
+ departAt,
43
+ arriveAt,
44
+ stops: extra.stops ?? 0,
45
+ durationMinutes: minutes,
46
+ ...(extra.via ? { connections: [extra.via] } : {}),
47
+ },
48
+ ],
49
+ },
50
+ };
51
+ }
52
+
53
+ function widget(component: 'travel' | 'shopping', attachment: object): string {
54
+ return [
55
+ '```yantra:widget',
56
+ JSON.stringify({ propsComponent: component, propsConfiguration: { contents: { attachment } } }),
57
+ '```',
58
+ ].join('\n');
59
+ }
60
+
61
+ const FLIGHTS_REPLY = [
62
+ 'IndiGo is cheapest at $70, but it stops in Chennai for 5h 45m.',
63
+ '',
64
+ widget('travel', {
65
+ currency: 'USD',
66
+ properties: [
67
+ offer('qp', 'Akasa Air', 95, '2026-11-22T22:10', '2026-11-23T00:10', 120, { number: 'QP 1134' }),
68
+ offer('ai', 'Air India', 101, '2026-11-22T21:45', '2026-11-22T23:45', 120, { number: 'AI 2642' }),
69
+ offer('6e', 'IndiGo', 70, '2026-11-22T22:40', '2026-11-23T07:35', 535, {
70
+ stops: 1,
71
+ via: { airport: 'MAA', layoverDuration: '5h 45m' },
72
+ }),
73
+ offer('6e977', 'IndiGo', 72, '2026-11-22T21:00', '2026-11-23T02:40', 340, {
74
+ number: '6E 977',
75
+ stops: 1,
76
+ via: { airport: 'GOI', layoverDuration: '2h 55m' },
77
+ }),
78
+ offer('sg', 'SpiceJet', 88, '2026-11-22T19:20', '2026-11-22T21:15', 115),
79
+ ],
80
+ }),
81
+ ].join('\n');
82
+
83
+ const PRODUCTS_REPLY = [
84
+ 'Every M4 I could confirm is open-box, pre-owned or restored.',
85
+ widget('shopping', {
86
+ title: 'MacBook Pro M4, cheapest',
87
+ currency: 'USD',
88
+ properties: [
89
+ {
90
+ title: 'Apple MacBook Pro 14-inch M4 16GB 512GB Silver, Open Box, 1-Year Warranty',
91
+ price: 1399,
92
+ source: 'Google',
93
+ },
94
+ { title: 'Pre-Owned Apple MacBook Pro 14" M4 16GB RAM 512GB SSD', price: 1549, source: 'Walmart' },
95
+ ],
96
+ }),
97
+ ].join('\n');
98
+
99
+ const flightsOf = (reply: string) => takeResults(reply, 'm1').cards[0] as FlightsCard;
100
+
101
+ describe('a reply with results', () => {
102
+ it('becomes its words and a card, read the way the web chat reads it', () => {
103
+ const { content, cards } = takeResults(FLIGHTS_REPLY, 'm1');
104
+ expect(content).toBe('IndiGo is cheapest at $70, but it stops in Chennai for 5h 45m.');
105
+ expect(cards).toHaveLength(1);
106
+ const card = cards[0] as FlightsCard;
107
+ expect(card.kind).toBe('flights');
108
+ expect(card.rows.map((row) => row.airline)).toEqual(['Akasa Air', 'Air India', 'IndiGo', 'IndiGo', 'SpiceJet']);
109
+ expect(card.rows[0].badges).toContain('pick');
110
+ expect(card.rows[2].badges).toContain('cheapest');
111
+ expect(card.rows[4].badges).toContain('fastest');
112
+ });
113
+
114
+ it('draws products as a list card', () => {
115
+ const card = takeResults(PRODUCTS_REPLY, 'm2').cards[0] as ListCard;
116
+ expect(card.kind).toBe('products');
117
+ expect(card.title).toBe('MacBook Pro M4, cheapest');
118
+ expect(card.rows[0].seller).toBe('Google');
119
+ });
120
+
121
+ it('reads the pick from what was sent after the reply', () => {
122
+ const { cards } = takeResults(FLIGHTS_REPLY, 'm1');
123
+ const card = cards[0] as FlightsCard;
124
+ const thread = [
125
+ { role: 'user', content: 'Find me a flight' },
126
+ { role: 'assistant', content: FLIGHTS_REPLY },
127
+ { role: 'user', content: 'Thanks' },
128
+ { role: 'user', content: card.rows[1].reply },
129
+ ];
130
+ expect(laterWords(thread, 1)).toEqual(['Thanks', card.rows[1].reply]);
131
+ expect(cardPicks(cards, laterWords(thread, 1))).toEqual({ [card.key]: card.rows[1].reply });
132
+ expect(cardPicks(cards, laterWords(thread, 3))).toEqual({});
133
+ });
134
+ });
135
+
136
+ describe('shownRows', () => {
137
+ const rows = flightsOf(FLIGHTS_REPLY).rows;
138
+
139
+ it('shows the first three, the rest behind Show more', () => {
140
+ const shown = shownRows(rows, false);
141
+ expect(shown.rows).toHaveLength(3);
142
+ expect(shown.toggle).toBe('Show 2 more');
143
+ expect(shownRows(rows, true)).toEqual({ rows, toggle: 'Show fewer' });
144
+ });
145
+
146
+ it('shows one row past the cut rather than folding it', () => {
147
+ expect(shownRows(rows.slice(0, 4), false)).toEqual({ rows: rows.slice(0, 4), toggle: '' });
148
+ });
149
+
150
+ it('folds to the pick, and opens again to the others', () => {
151
+ const pick = rows[3].reply;
152
+ expect(shownRows(rows, false, pick)).toEqual({ rows: [rows[3]], toggle: 'Show the other 4' });
153
+ expect(shownRows(rows, true, pick)).toEqual({ rows, toggle: 'Show fewer' });
154
+ expect(shownRows(rows.slice(0, 2), false, rows[0].reply).toggle).toBe('Show the other one');
155
+ expect(shownRows(rows.slice(0, 1), false, rows[0].reply)).toEqual({ rows: rows.slice(0, 1), toggle: '' });
156
+ });
157
+
158
+ it('ignores a pick that is none of its rows', () => {
159
+ expect(shownRows(rows, false, 'Book something else.').rows).toHaveLength(3);
160
+ });
161
+ });
162
+
163
+ describe('the line under a card', () => {
164
+ it('says how a tap works, then waits on Lucy, then has the pick', () => {
165
+ expect(noteFor('flights', false, false)).toBe(
166
+ 'Tap Book and Lucy takes it from there, asking before she pays. Fares change until booked.',
167
+ );
168
+ expect(noteFor('products', false, false)).toBe(
169
+ 'Tap Choose and Lucy takes it from there. Prices can change until it is bought.',
170
+ );
171
+ expect(noteFor('stays', false, false)).toBe('Tap Book and Lucy takes it from there, asking before she pays.');
172
+ expect(noteFor('products', false, true)).toBe('You can choose one when Lucy is done.');
173
+ expect(noteFor('flights', true, true)).toBe('Lucy has your pick.');
174
+ });
175
+ });
176
+
177
+ describe('more than Lucy found', () => {
178
+ it('goes to Travel, or to Shopping for products', () => {
179
+ expect(moreSurface('flights')).toEqual({
180
+ id: 'travel',
181
+ title: 'Travel',
182
+ host: 'travel-surface',
183
+ label: 'More flights in Travel',
184
+ });
185
+ expect(moreSurface('stays')?.label).toBe('More stays in Travel');
186
+ expect(moreSurface('products')).toEqual({
187
+ id: 'shopping',
188
+ title: 'Shopping',
189
+ host: 'shopping-surface',
190
+ label: 'More in Shopping',
191
+ });
192
+ expect(beyondLabel(7)).toBe('Search beyond these 7');
193
+ expect(beyondLabel(1)).toBe('Search beyond this one');
194
+ });
195
+
196
+ it('finds the environment the way the web chat does', () => {
197
+ expect(platformBase('yantra.app')).toBe('yantra.app');
198
+ expect(platformBase('idefront.yantra-app-v1.cdebase.dev')).toBe('yantra-app-v1.cdebase.dev');
199
+ expect(platformBase('localhost')).toBe('');
200
+ expect(platformBase('192.168.1.39')).toBe('');
201
+ });
202
+
203
+ it('opens the surface on this environment', () => {
204
+ expect(surfaceUrl('travel-surface', 'https://yantra.app')).toBe('https://travel-surface.yantra.app/');
205
+ expect(surfaceUrl('shopping-surface', 'https://idefront.yantra-app-v1.cdebase.dev/new?q=x')).toBe(
206
+ 'https://shopping-surface.yantra-app-v1.cdebase.dev/',
207
+ );
208
+ expect(surfaceUrl('travel-surface', 'http://localhost:3000')).toBe('');
209
+ expect(surfaceUrl('travel-surface', 'not a link')).toBe('');
210
+ expect(surfaceUrl('travel surface', 'https://yantra.app')).toBe('');
211
+ });
212
+ });
213
+
214
+ describe('what a row says', () => {
215
+ it('sets a time large with its AM or PM beside it', () => {
216
+ expect(splitClock('10:10 PM')).toEqual({ time: '10:10', half: 'PM' });
217
+ expect(splitClock('9:00 am')).toEqual({ time: '9:00', half: 'AM' });
218
+ expect(splitClock('22:10')).toEqual({ time: '22:10', half: '' });
219
+ expect(splitClock(undefined)).toEqual({ time: '–', half: '' });
220
+ });
221
+
222
+ it('heads a leg only when the day or the direction needs saying', () => {
223
+ expect(legWhen(false, 1, 0, 'Sun, Nov 22')).toBeUndefined();
224
+ expect(legWhen(true, 1, 0, 'Sun, Nov 22')).toBe('Sun, Nov 22');
225
+ expect(legWhen(false, 2, 0, 'Sun, Nov 22')).toBe('Outbound · Sun, Nov 22');
226
+ expect(legWhen(false, 2, 1, 'Sat, Nov 28')).toBe('Return · Sat, Nov 28');
227
+ });
228
+
229
+ it('names the condition a product title gives', () => {
230
+ expect(conditionOf('Apple MacBook Pro 14-inch M4 16GB 512GB Silver, Open Box, 1-Year Warranty')).toBe(
231
+ 'Open box',
232
+ );
233
+ expect(conditionOf('Pre-Owned Apple MacBook Pro 14" M4')).toBe('Pre-owned');
234
+ expect(conditionOf('Restored Apple 14-inch MacBook Pro M4')).toBe('Restored');
235
+ expect(conditionOf('Apple iPhone 15, Renewed')).toBe('Renewed');
236
+ expect(conditionOf('Refurbished Dell XPS 13')).toBe('Refurbished');
237
+ expect(conditionOf('Apple MacBook Pro 14-inch M4')).toBeUndefined();
238
+ });
239
+
240
+ it('tells a screen reader the whole flight', () => {
241
+ const said = describeFlight(flightsOf(FLIGHTS_REPLY).rows[2]);
242
+ expect(said).toContain('IndiGo');
243
+ expect(said).toContain('Cheapest');
244
+ expect(said).toContain('leaves BLR 10:40 PM');
245
+ expect(said).toContain('lands BOM 7:35 AM the next day');
246
+ expect(said).toContain('via MAA 5h 45m');
247
+ expect(said).toContain('$70');
248
+ });
249
+
250
+ it('tells a screen reader the whole product', () => {
251
+ const row = (takeResults(PRODUCTS_REPLY, 'm2').cards[0] as ListCard).rows[0];
252
+ expect(describeItem(row, conditionOf(row.title))).toBe(
253
+ 'Apple MacBook Pro 14-inch M4 16GB 512GB Silver, Open Box, 1-Year Warranty. Lucy’s pick. Cheapest. Open box. $1,399. Google',
254
+ );
255
+ });
256
+ });