@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-alpha.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 (376) 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 +31 -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 +42 -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 +21 -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 +2711 -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 +179 -0
  214. package/src/__tests__/choresList.test.ts +100 -0
  215. package/src/__tests__/content.test.ts +54 -0
  216. package/src/__tests__/dictation.test.ts +186 -0
  217. package/src/__tests__/haptics.test.ts +202 -0
  218. package/src/__tests__/jobs.test.ts +130 -0
  219. package/src/__tests__/keyboardCover.test.ts +84 -0
  220. package/src/__tests__/liveCard.test.ts +39 -0
  221. package/src/__tests__/lockedPhone.test.ts +355 -0
  222. package/src/__tests__/lucyMotion.test.ts +34 -0
  223. package/src/__tests__/platform.test.ts +32 -0
  224. package/src/__tests__/powerOn.test.ts +62 -0
  225. package/src/__tests__/protocol.test.ts +125 -0
  226. package/src/__tests__/push.test.ts +111 -0
  227. package/src/__tests__/results.test.ts +256 -0
  228. package/src/__tests__/sound.test.ts +248 -0
  229. package/src/__tests__/talkToLucy.test.ts +205 -0
  230. package/src/__tests__/textLink.test.ts +91 -0
  231. package/src/__tests__/voiceDial.test.ts +53 -0
  232. package/src/__tests__/welcomeFlow.test.ts +157 -0
  233. package/src/__tests__/whereLucyWorks.test.ts +81 -0
  234. package/src/__tests__/yantraLinks.test.ts +96 -0
  235. package/src/assets/home/loop-day.jpg +0 -0
  236. package/src/assets/home/loop-day.mp4 +0 -0
  237. package/src/assets/home/loop-time-back.jpg +0 -0
  238. package/src/assets/home/loop-time-back.mp4 +0 -0
  239. package/src/assets/home/loop-where.jpg +0 -0
  240. package/src/assets/home/loop-where.mp4 +0 -0
  241. package/src/assets/home/reel-gym.jpg +0 -0
  242. package/src/assets/home/reel-gym.mp4 +0 -0
  243. package/src/assets/home/reel-internet.jpg +0 -0
  244. package/src/assets/home/reel-internet.mp4 +0 -0
  245. package/src/assets/icon.png +0 -0
  246. package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  247. package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
  248. package/src/assets/lottie/lucy-mark-call.json +1470 -0
  249. package/src/assets/lottie/lucy-mark-connect.json +2552 -0
  250. package/src/assets/lottie/lucy-mark-details.json +1735 -0
  251. package/src/assets/lottie/lucy-mark-email.json +1363 -0
  252. package/src/assets/lottie/lucy-mark-message.json +1154 -0
  253. package/src/assets/lottie/lucy-mark-search.json +1067 -0
  254. package/src/assets/lottie/lucy-mark-think.json +1253 -0
  255. package/src/assets/lottie/lucy-mark-write.json +1532 -0
  256. package/src/assets/lottie/time-back.json +16458 -0
  257. package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
  258. package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
  259. package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  260. package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  261. package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  262. package/src/assets/sounds/hours-back.m4a +0 -0
  263. package/src/assets/sounds/meet-lucy.m4a +0 -0
  264. package/src/assets/sounds/power-on.m4a +0 -0
  265. package/src/assets/sounds/wind-back.m4a +0 -0
  266. package/src/assets/sounds/youre-in.m4a +0 -0
  267. package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
  268. package/src/chat/agent.ts +376 -0
  269. package/src/chat/appFront.ts +39 -0
  270. package/src/chat/auth.ts +433 -0
  271. package/src/chat/chores.ts +394 -0
  272. package/src/chat/connectors.ts +65 -0
  273. package/src/chat/jobs.ts +228 -0
  274. package/src/chat/lucyMotion.ts +33 -0
  275. package/src/chat/protocol.ts +192 -0
  276. package/src/chat/results.ts +224 -0
  277. package/src/chat/store.ts +87 -0
  278. package/src/chat/useDictation.ts +201 -0
  279. package/src/chat/useLucyChat.ts +458 -0
  280. package/src/chat/useMyComputer.ts +41 -0
  281. package/src/chat/whereLucyWorks.ts +97 -0
  282. package/src/chat/workspace.ts +127 -0
  283. package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
  284. package/src/components/AreaShot.tsx +239 -0
  285. package/src/components/Backdrops.tsx +323 -0
  286. package/src/components/BottomSheet.tsx +96 -0
  287. package/src/components/ChatSheets.tsx +565 -0
  288. package/src/components/ConnectorLogo.tsx +116 -0
  289. package/src/components/CustomDrawer.tsx +526 -0
  290. package/src/components/IdeasPane.tsx +318 -0
  291. package/src/components/ImessageSheet.tsx +280 -0
  292. package/src/components/KeyboardAvoider.tsx +45 -0
  293. package/src/components/Logo.tsx +97 -0
  294. package/src/components/LucyWorking.tsx +122 -0
  295. package/src/components/Markdown.tsx +219 -0
  296. package/src/components/Media.tsx +173 -0
  297. package/src/components/MessagesAppIcon.tsx +51 -0
  298. package/src/components/MicButton.tsx +92 -0
  299. package/src/components/ResultCards.tsx +1067 -0
  300. package/src/components/SignInPrompt.tsx +182 -0
  301. package/src/components/SignedOut.tsx +47 -0
  302. package/src/components/TalkToLucyHero.tsx +540 -0
  303. package/src/components/TalkToLucySheet.tsx +208 -0
  304. package/src/components/VoiceOrb.tsx +364 -0
  305. package/src/components/WhereLucyWorks.tsx +261 -0
  306. package/src/components/WorkspaceSection.tsx +307 -0
  307. package/src/components/YantraMark.tsx +30 -0
  308. package/src/components/drawerHeader.tsx +46 -0
  309. package/src/components/kit.tsx +309 -0
  310. package/src/components/lottieInstalled.ts +7 -0
  311. package/src/components/ui.tsx +700 -0
  312. package/src/components/useSignOut.ts +21 -0
  313. package/src/components/viewport.tsx +166 -0
  314. package/src/components/voiceDial.ts +45 -0
  315. package/src/compute.ts +168 -0
  316. package/src/config/env-config.ts +37 -0
  317. package/src/config/routes.ts +28 -0
  318. package/src/content.ts +217 -0
  319. package/src/hooks/keyboardCover.ts +70 -0
  320. package/src/hooks/useKeyboard.ts +135 -0
  321. package/src/hooks/useReducedMotion.ts +19 -0
  322. package/src/imessage/openMessages.ts +53 -0
  323. package/src/imessage/platform.ts +32 -0
  324. package/src/imessage/textLink.ts +307 -0
  325. package/src/index.ts +24 -0
  326. package/src/live/card.ts +62 -0
  327. package/src/live/liveActivity.ts +192 -0
  328. package/src/module.ts +8 -0
  329. package/src/offer/BlackFridayOffer.tsx +394 -0
  330. package/src/offer/blackFriday.ts +109 -0
  331. package/src/offer/parts.tsx +650 -0
  332. package/src/offer/state.ts +78 -0
  333. package/src/push/push.ts +171 -0
  334. package/src/push/usePushNotifications.ts +47 -0
  335. package/src/screens/Account/index.tsx +310 -0
  336. package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
  337. package/src/screens/Chat/index.tsx +891 -0
  338. package/src/screens/Chores/index.tsx +35 -0
  339. package/src/screens/Connectors/index.tsx +35 -0
  340. package/src/screens/History/index.tsx +346 -0
  341. package/src/screens/Home/index.tsx +2773 -0
  342. package/src/screens/Home/media.ts +31 -0
  343. package/src/screens/Welcome/index.tsx +1182 -0
  344. package/src/talk/talkToLucy.ts +187 -0
  345. package/src/theme/colors.ts +38 -0
  346. package/src/theme/fonts.ts +30 -0
  347. package/src/theme/muse.ts +86 -0
  348. package/src/utils/links.ts +84 -0
  349. package/src/utils/yantraLinks.ts +94 -0
  350. package/src/welcome/flow.ts +418 -0
  351. package/src/welcome/haptics.ts +179 -0
  352. package/src/welcome/parts.tsx +2160 -0
  353. package/src/welcome/powerOn.ts +84 -0
  354. package/src/welcome/seen.ts +68 -0
  355. package/src/welcome/sound.ts +173 -0
  356. package/tools/lottie/chat.motion +0 -0
  357. package/tools/lottie/cloud.motion +0 -0
  358. package/tools/lottie/generate.mjs +1209 -0
  359. package/tools/lottie/inter-glyphs.json +4416 -0
  360. package/tools/lottie/lucy-mark-calendar.motion +0 -0
  361. package/tools/lottie/lucy-mark-call.motion +0 -0
  362. package/tools/lottie/lucy-mark-connect.motion +0 -0
  363. package/tools/lottie/lucy-mark-details.motion +0 -0
  364. package/tools/lottie/lucy-mark-email.motion +0 -0
  365. package/tools/lottie/lucy-mark-message.motion +0 -0
  366. package/tools/lottie/lucy-mark-search.motion +0 -0
  367. package/tools/lottie/lucy-mark-think.motion +0 -0
  368. package/tools/lottie/lucy-mark-write.motion +0 -0
  369. package/tools/lottie/mark.json +1 -0
  370. package/tools/lottie/mine-none.motion +0 -0
  371. package/tools/lottie/mine-offline.motion +0 -0
  372. package/tools/lottie/mine-online.motion +0 -0
  373. package/tools/lottie/time-back.mjs +604 -0
  374. package/tools/sounds/render.mjs +730 -0
  375. package/tsconfig.json +17 -0
  376. package/README.md +0 -3
@@ -0,0 +1,84 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import { keyboardCover, RestHeight, windowShrinksGuess } from '../hooks/keyboardCover';
3
+
4
+ describe('keyboardCover', () => {
5
+ it('covers nothing while the keyboard is down', () => {
6
+ expect(keyboardCover({ keyboard: 0, navBar: 24, madeBySystem: 0 })).toBe(0);
7
+ });
8
+
9
+ it('covers the keyboard and the navigation bar under it when the window keeps its height (edge to edge)', () => {
10
+ expect(keyboardCover({ keyboard: 312, navBar: 24, madeBySystem: 0 })).toBe(336);
11
+ });
12
+
13
+ it('covers nothing when the system shrank the window by the keyboard (Android 15 and older)', () => {
14
+ // The phone in the report: padding by the keyboard again pushed the composer up under the header.
15
+ expect(keyboardCover({ keyboard: 300, navBar: 0, madeBySystem: 300 })).toBe(0);
16
+ });
17
+
18
+ it('covers only what the system left when it made part of the room', () => {
19
+ expect(keyboardCover({ keyboard: 300, navBar: 24, madeBySystem: 200 })).toBe(124);
20
+ });
21
+
22
+ it('never goes below nothing', () => {
23
+ expect(keyboardCover({ keyboard: 300, navBar: 0, madeBySystem: 350 })).toBe(0);
24
+ });
25
+ });
26
+
27
+ describe('the view height with the keyboard down (RestHeight)', () => {
28
+ it('counts from the latest height, not a taller first layout (Android 16: the status bar inset arrives late)', () => {
29
+ const rest = new RestHeight();
30
+ rest.seen(855.2, 0);
31
+ rest.seen(806.5, 50);
32
+
33
+ // Ten seconds later the keyboard comes up: the window did not shrink, so no room was made.
34
+ expect(rest.base(312.4, 10_000)).toBe(806.5);
35
+ });
36
+
37
+ it('takes a shrink of the keyboard height just before its event as the keyboard (the layout came first)', () => {
38
+ const rest = new RestHeight();
39
+ rest.seen(806.5, 0);
40
+ rest.seen(494.1, 10_000);
41
+
42
+ expect(rest.base(312.4, 10_005)).toBe(806.5);
43
+ });
44
+
45
+ it('keeps a shrink of another size, even just before the keyboard', () => {
46
+ const rest = new RestHeight();
47
+ rest.seen(855.2, 0);
48
+ rest.seen(806.5, 50);
49
+
50
+ expect(rest.base(312.4, 100)).toBe(806.5);
51
+ });
52
+
53
+ it('keeps a shrink of the keyboard height that came long before it', () => {
54
+ const rest = new RestHeight();
55
+ rest.seen(806.5, 0);
56
+ rest.seen(494.1, 1_000);
57
+
58
+ expect(rest.base(312.4, 5_000)).toBe(494.1);
59
+ });
60
+
61
+ it('ignores a layout of the same height', () => {
62
+ const rest = new RestHeight();
63
+ rest.seen(806.5, 0);
64
+ rest.seen(494.1, 1_000);
65
+ rest.seen(494.1, 10_000);
66
+
67
+ expect(rest.base(312.4, 10_005)).toBe(494.1);
68
+ });
69
+ });
70
+
71
+ describe('whether the window shrinks, before the view is measured', () => {
72
+ it('guesses it shrinks for an app not drawn under the system bars (Android 15 and older here)', () => {
73
+ expect(windowShrinksGuess(null, { top: 0, bottom: 0 })).toBe(true);
74
+ });
75
+
76
+ it('guesses it keeps its height for an app drawn edge to edge (Android 16)', () => {
77
+ expect(windowShrinksGuess(null, { top: 48.8, bottom: 24 })).toBe(false);
78
+ });
79
+
80
+ it('goes by what the window did last time once it has been seen', () => {
81
+ expect(windowShrinksGuess(false, { top: 0, bottom: 0 })).toBe(false);
82
+ expect(windowShrinksGuess(true, { top: 48.8, bottom: 24 })).toBe(true);
83
+ });
84
+ });
@@ -0,0 +1,39 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import { callStarts, cardKind, cardSummary, cardTitle, minutesSpent } from '../live/card';
3
+
4
+ describe('live card', () => {
5
+ it('reads the chore’s kind from what was asked, and keeps a call a call', () => {
6
+ expect(cardKind('Call Arjun the plumber about Saturday')).toBe('call');
7
+ expect(cardKind('Find me a white cotton t-shirt under 1000')).toBe('shop');
8
+ expect(cardKind('Plan five dinners for this week')).toBe('general');
9
+ expect(cardKind('Looking it up', 'call')).toBe('call');
10
+ expect(cardKind('Making a call', 'shop')).toBe('call');
11
+ });
12
+
13
+ it('restarts the timer when the call itself starts', () => {
14
+ expect(callStarts('Making a call')).toBe(true);
15
+ expect(callStarts('On hold with Northwave')).toBe(true);
16
+ expect(callStarts('Looking it up')).toBe(false);
17
+ });
18
+
19
+ it('keeps the title to one line', () => {
20
+ expect(cardTitle(' Call Arjun ')).toBe('Call Arjun');
21
+ expect(cardTitle('')).toBe('A chore for Lucy');
22
+ const long = cardTitle('Cancel my gym membership, they say I have to call or come in person');
23
+ expect(long.length).toBeLessThanOrEqual(44);
24
+ expect(long.endsWith('…')).toBe(true);
25
+ });
26
+
27
+ it('ends on the first sentence of Lucy’s reply, without markup or a question card', () => {
28
+ expect(cardSummary('**Done.** It’s cancelled with no fee.')).toBe('Done.');
29
+ expect(cardSummary('Booked for Saturday at 10. [ASK_USER]{"questions":[]}[/ASK_USER]')).toBe(
30
+ 'Booked for Saturday at 10.',
31
+ );
32
+ expect(cardSummary('See [the receipt](https://x.test/r) in your email')).toBe('See the receipt in your email');
33
+ });
34
+
35
+ it('counts at least a minute back', () => {
36
+ expect(minutesSpent(1000, 1010)).toBe(1);
37
+ expect(minutesSpent(0, 26 * 60 + 10)).toBe(26);
38
+ });
39
+ });
@@ -0,0 +1,355 @@
1
+ /**
2
+ * A locked phone: the app goes to the background and iOS shuts the keychain. Lucy's chat must not take that for a
3
+ * sign-out, and the reply in flight must carry on once the phone is unlocked (the screenshot this guards: "Sign in to
4
+ * chat with Lucy." on a reply sent just before the phone was locked).
5
+ */
6
+ import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';
7
+
8
+ const appState = { current: 'active' as string, listeners: new Set<(s: string) => void>() };
9
+ jest.mock(
10
+ 'react-native',
11
+ () => ({
12
+ Platform: { OS: 'ios' },
13
+ AppState: {
14
+ get currentState() {
15
+ return appState.current;
16
+ },
17
+ addEventListener: (_type: string, fn: (s: string) => void) => {
18
+ appState.listeners.add(fn);
19
+ return { remove: () => appState.listeners.delete(fn) };
20
+ },
21
+ },
22
+ }),
23
+ { virtual: true },
24
+ );
25
+ const keychain = new Map<string, string>();
26
+ const shut = { now: false };
27
+ const refuse = () => Promise.reject(new Error('User interaction is not allowed.'));
28
+ jest.mock(
29
+ 'expo-secure-store',
30
+ () => ({
31
+ getItemAsync: jest.fn((k: string) => (shut.now ? refuse() : Promise.resolve(keychain.get(k) ?? null))),
32
+ setItemAsync: jest.fn((k: string, v: string) =>
33
+ shut.now ? refuse() : Promise.resolve(keychain.set(k, v)).then(() => undefined),
34
+ ),
35
+ deleteItemAsync: jest.fn((k: string) =>
36
+ shut.now ? refuse() : Promise.resolve(keychain.delete(k)).then(() => undefined),
37
+ ),
38
+ }),
39
+ { virtual: true },
40
+ );
41
+ // protocol.ts reads the web chat's prompt from the browser package's build: only its helpers matter here.
42
+ jest.mock<typeof import('../chat/protocol')>('../chat/protocol', () => ({
43
+ CONTINUE_PROMPT: 'continue',
44
+ SYSTEM_PROMPT: 'system',
45
+ joinOutput: (a: string, b: string) => a + b,
46
+ statusLine: (s: string) => s,
47
+ toolLine: (n: string) => n,
48
+ visibleOutput: (t: string) => t,
49
+ }));
50
+ jest.mock('@react-native-async-storage/async-storage', () => ({ getItem: jest.fn(() => Promise.resolve(null)) }), {
51
+ virtual: true,
52
+ });
53
+
54
+ const setAppState = (s: string) => {
55
+ appState.current = s;
56
+ [...appState.listeners].forEach((l) => l(s));
57
+ };
58
+ const lock = () => {
59
+ setAppState('inactive');
60
+ setAppState('background');
61
+ shut.now = true;
62
+ };
63
+ const unlock = () => {
64
+ shut.now = false;
65
+ setAppState('active');
66
+ };
67
+ const b64 = (o: object) => Buffer.from(JSON.stringify(o)).toString('base64url');
68
+ const jwt = (claims: object) => `${b64({ alg: 'none' })}.${b64(claims)}.sig`;
69
+ const inAYear = Math.floor(Date.now() / 1000) + 365 * 86400;
70
+ const ID_TOKEN = jwt({ sub: 'auth0|me', exp: inAYear });
71
+ const CHAT_TOKEN = jwt({ sub: 'cdecli|me', exp: inAYear });
72
+ const flush = () =>
73
+ new Promise((r) => {
74
+ setImmediate(r);
75
+ });
76
+
77
+ beforeEach(() => {
78
+ jest.resetModules();
79
+ keychain.clear();
80
+ shut.now = false;
81
+ appState.current = 'active';
82
+ appState.listeners.clear();
83
+ keychain.set('id_token', ID_TOKEN);
84
+ keychain.set('clockbook.lucy.token', JSON.stringify({ token: CHAT_TOKEN, owner: 'auth0|me' }));
85
+ });
86
+
87
+ describe('the chat token on a locked phone', () => {
88
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, global-require
89
+ const load = () => require('../chat/auth') as typeof import('../chat/auth');
90
+
91
+ it('keeps using the tokens it read before the lock', async () => {
92
+ const auth = load();
93
+
94
+ await expect(auth.getChatToken()).resolves.toBe(CHAT_TOKEN);
95
+
96
+ lock();
97
+
98
+ await expect(auth.getChatToken()).resolves.toBe(CHAT_TOKEN);
99
+ });
100
+
101
+ it('says locked, never signed-out, when it has read nothing yet', async () => {
102
+ const auth = load();
103
+ lock();
104
+ const err = await auth.getChatToken().catch((e) => e);
105
+
106
+ expect(err).toBeInstanceOf(auth.ChatAuthError);
107
+ expect(err.kind).toBe('locked');
108
+ expect(auth.isLockedOut(err)).toBe(true);
109
+ });
110
+
111
+ it('is signed out only when the open keychain has no session', async () => {
112
+ const auth = load();
113
+ await auth.getChatToken();
114
+ keychain.delete('id_token');
115
+ const err = await auth.getChatToken().catch((e) => e);
116
+
117
+ expect(err.kind).toBe('signed-out');
118
+
119
+ // ...and what it remembered is gone with the session: a lock now says locked, not the old account.
120
+ lock();
121
+
122
+ expect((await auth.getChatToken().catch((e) => e)).kind).toBe('locked');
123
+ });
124
+
125
+ it('never mints with a remembered Auth0 token (it may have lapsed since): waits for the unlock', async () => {
126
+ const auth = load();
127
+ await auth.getChatToken();
128
+ const realFetch = globalThis.fetch;
129
+ const fetchSpy = jest.fn();
130
+ (globalThis as { fetch: unknown }).fetch = fetchSpy;
131
+ lock();
132
+ const err = await auth.getChatToken({ fresh: true }).catch((e) => e);
133
+ (globalThis as { fetch: unknown }).fetch = realFetch;
134
+
135
+ expect(err.kind).toBe('locked');
136
+ expect(fetchSpy).not.toHaveBeenCalled();
137
+ });
138
+
139
+ it('untilUnlocked runs the step again once the app is in front', async () => {
140
+ const auth = load();
141
+ lock();
142
+ let settled: string | null = null;
143
+ auth.untilUnlocked(() => auth.getChatToken()).then((t) => {
144
+ settled = t;
145
+ });
146
+ await flush();
147
+ await flush();
148
+
149
+ expect(settled).toBeNull();
150
+
151
+ unlock();
152
+ for (let i = 0; i < 5 && !settled; i += 1) await flush();
153
+
154
+ expect(settled).toBe(CHAT_TOKEN);
155
+ });
156
+
157
+ it('untilUnlocked lets every other failure through at once', async () => {
158
+ const auth = load();
159
+ keychain.delete('id_token');
160
+ const err = await auth.untilUnlocked(() => auth.getChatToken()).catch((e) => e);
161
+
162
+ expect(err.kind).toBe('signed-out');
163
+ });
164
+
165
+ it('untilUnlocked stops waiting when the turn is stopped', async () => {
166
+ const auth = load();
167
+ lock();
168
+ const stop = new AbortController();
169
+ const waiting = auth.untilUnlocked(() => auth.getChatToken(), stop.signal).catch((e) => e);
170
+ await flush();
171
+ stop.abort();
172
+
173
+ expect((await waiting).message).toBe('Stopped');
174
+ });
175
+ });
176
+
177
+ describe('a reply in flight when the phone locks', () => {
178
+ /** One reply line: what the test writes arrives on it; it can drop (a network error) or just go quiet. */
179
+ type Line = { turnId: string; write: (s: string) => void; drop: () => void; end: () => void };
180
+ let lines: Line[];
181
+
182
+ beforeEach(() => {
183
+ lines = [];
184
+ jest.doMock(
185
+ 'expo/fetch',
186
+ () => ({
187
+ fetch: jest.fn((_url: string, init: { body: string; signal: AbortSignal }) => {
188
+ const turnId = JSON.parse(init.body).turn_id as string;
189
+ let controller!: ReadableStreamDefaultController<Uint8Array>;
190
+ const body = new ReadableStream<Uint8Array>({
191
+ start(c) {
192
+ controller = c;
193
+ },
194
+ });
195
+ const enc = new TextEncoder();
196
+ const line: Line = {
197
+ turnId,
198
+ write: (s) => controller.enqueue(enc.encode(s)),
199
+ drop: () => controller.error(new TypeError('The network connection was lost.')),
200
+ end: () => controller.close(),
201
+ };
202
+ init.signal.addEventListener('abort', () => {
203
+ try {
204
+ controller.error(new DOMException('aborted', 'AbortError'));
205
+ } catch {
206
+ // closed already
207
+ }
208
+ });
209
+ lines.push(line);
210
+ return Promise.resolve({ ok: true, status: 200, body });
211
+ }),
212
+ }),
213
+ { virtual: true },
214
+ );
215
+ });
216
+
217
+ afterEach(() => jest.dontMock('../chat/auth'));
218
+
219
+ const sse = (event: string, data: object) => `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
220
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, global-require
221
+ const load = () => require('../chat/agent') as typeof import('../chat/agent');
222
+ const handlers = () => ({ onText: jest.fn(), onStatus: jest.fn(), onSession: jest.fn() });
223
+ const until = async (pred: () => boolean) => {
224
+ for (let i = 0; i < 50 && !pred(); i += 1) await flush();
225
+
226
+ expect(pred()).toBe(true);
227
+ };
228
+
229
+ it('a line lost while locked is picked up after the unlock: the same turn, followed to its end', async () => {
230
+ const { sendTurn } = load();
231
+ const h = handlers();
232
+ const reply = sendTurn('hello', 's1', h, new AbortController().signal);
233
+ await until(() => lines.length === 1);
234
+ lines[0].write(sse('delta', { text: 'Best pick' }));
235
+ await until(() => h.onText.mock.calls.length === 1);
236
+ lock();
237
+ lines[0].drop();
238
+ // Locked: nothing is sent again, nothing fails.
239
+ for (let i = 0; i < 10; i += 1) await flush();
240
+
241
+ expect(lines).toHaveLength(1);
242
+
243
+ unlock();
244
+ await until(() => lines.length === 2);
245
+
246
+ expect(lines[1].turnId).toBe(lines[0].turnId);
247
+
248
+ lines[1].write(sse('delta', { text: 'Best pick for Mon Nov 23' }) + sse('done', {}));
249
+ lines[1].end();
250
+
251
+ await expect(reply).resolves.toBe('Best pick for Mon Nov 23');
252
+ });
253
+
254
+ it('a reply sent from a locked phone it cannot sign in from waits for the unlock, then goes', async () => {
255
+ jest.doMock<typeof import('../chat/auth')>('../chat/auth', () => {
256
+ const actual = jest.requireActual('../chat/auth');
257
+ return {
258
+ ...actual,
259
+ getChatToken: jest.fn(() =>
260
+ shut.now
261
+ ? Promise.reject(new actual.ChatAuthError('locked', 'locked'))
262
+ : Promise.resolve(CHAT_TOKEN),
263
+ ),
264
+ agentUrl: () => 'https://agent.test',
265
+ agentBackendUrl: () => Promise.resolve('https://backend.test/graphql'),
266
+ };
267
+ });
268
+ const { sendTurn } = load();
269
+ lock();
270
+ const reply = sendTurn('hello', 's1', handlers(), new AbortController().signal);
271
+ for (let i = 0; i < 10; i += 1) await flush();
272
+
273
+ expect(lines).toHaveLength(0);
274
+
275
+ unlock();
276
+ await until(() => lines.length === 1);
277
+ lines[0].write(sse('delta', { text: 'Hi' }) + sse('done', {}));
278
+ lines[0].end();
279
+
280
+ await expect(reply).resolves.toBe('Hi');
281
+ });
282
+
283
+ it('stopping while it waits for the unlock stops the turn', async () => {
284
+ const { sendTurn, TurnError } = load();
285
+ const stop = new AbortController();
286
+ const reply = sendTurn('hello', 's1', handlers(), stop.signal).catch((e) => e);
287
+ await until(() => lines.length === 1);
288
+ lock();
289
+ lines[0].drop();
290
+ for (let i = 0; i < 5; i += 1) await flush();
291
+ stop.abort();
292
+ const err = await reply;
293
+
294
+ expect(err).toBeInstanceOf(TurnError);
295
+ expect(err.kind).toBe('stopped');
296
+ });
297
+ });
298
+
299
+ describe('watchLine', () => {
300
+ beforeEach(() => jest.useFakeTimers());
301
+
302
+ afterEach(() => jest.useRealTimers());
303
+
304
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, global-require
305
+ const load = () => require('../chat/agent') as typeof import('../chat/agent');
306
+
307
+ it('keeps a line that is heard from, and lets one go silent in front for SILENT_MS', () => {
308
+ const { watchLine, SILENT_MS } = load();
309
+ const w = watchLine(new AbortController().signal);
310
+ jest.advanceTimersByTime(SILENT_MS - 5_000);
311
+ w.heard();
312
+ jest.advanceTimersByTime(SILENT_MS - 5_000);
313
+
314
+ expect(w.dead()).toBe(false);
315
+
316
+ jest.advanceTimersByTime(10_000);
317
+
318
+ expect(w.dead()).toBe(true);
319
+ expect(w.signal.aborted).toBe(true);
320
+
321
+ w.end();
322
+ });
323
+
324
+ it('back in front after missing a keepalive: what a live line held arrives in the grace, else it is let go', () => {
325
+ const { watchLine, BACK_GRACE_MS } = load();
326
+ const live = watchLine(new AbortController().signal);
327
+ const dead = watchLine(new AbortController().signal);
328
+ lock();
329
+ jest.advanceTimersByTime(30_000);
330
+
331
+ expect(live.dead() || dead.dead()).toBe(false);
332
+
333
+ unlock();
334
+ live.heard();
335
+ jest.advanceTimersByTime(BACK_GRACE_MS + 1_000);
336
+
337
+ expect(live.dead()).toBe(false);
338
+ expect(dead.dead()).toBe(true);
339
+
340
+ live.end();
341
+ dead.end();
342
+ });
343
+
344
+ it('a stopped turn ends its line without calling it dead', () => {
345
+ const { watchLine } = load();
346
+ const stop = new AbortController();
347
+ const w = watchLine(stop.signal);
348
+ stop.abort();
349
+
350
+ expect(w.signal.aborted).toBe(true);
351
+ expect(w.dead()).toBe(false);
352
+
353
+ w.end();
354
+ });
355
+ });
@@ -0,0 +1,34 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import { LUCY_MOTIONS, motionFor } from '../chat/lucyMotion';
3
+
4
+ describe('motionFor', () => {
5
+ it.each([
6
+ ['Making a call', 'call'],
7
+ ['Checking the calendar', 'calendar'],
8
+ ['Looking through email', 'email'],
9
+ ['Looking it up', 'search'],
10
+ ['Sending a message', 'message'],
11
+ ['Working through the details', 'details'],
12
+ ['Working on it', 'details'],
13
+ ])('plays its own motion for "%s"', (words, motion) => {
14
+ expect(motionFor(words)).toBe(motion);
15
+ });
16
+
17
+ it('starts on thinking and writes when she writes', () => {
18
+ expect(motionFor('Thinking')).toBe('think');
19
+ expect(motionFor('Writing')).toBe('write');
20
+ });
21
+
22
+ it('treats reconnecting and waiting its turn as connecting', () => {
23
+ expect(motionFor('Reconnecting')).toBe('connect');
24
+ expect(motionFor('Waiting for the last message to finish')).toBe('connect');
25
+ });
26
+
27
+ it('falls back to thinking on words it does not know', () => {
28
+ expect(motionFor('Compacting context')).toBe('think');
29
+ });
30
+
31
+ it('only names motions that exist', () => {
32
+ expect(LUCY_MOTIONS).toContain(motionFor('Checking the calendar'));
33
+ });
34
+ });
@@ -0,0 +1,32 @@
1
+ /** Texting Lucy is said for the phone in the hand: Messages on Android, iMessage on an iPhone. */
2
+ const STEPS = [
3
+ { title: 'Sign in', body: 'A minute, and it sets up your account if you are new.' },
4
+ { title: 'Open Messages', body: 'Tap Text Lucy on iMessage. Messages opens with “Hi Lucy” ready.' },
5
+ ];
6
+
7
+ function load(os: 'ios' | 'android') {
8
+ jest.resetModules();
9
+ jest.doMock('react-native', () => ({ Platform: { OS: os } }), { virtual: true });
10
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
11
+ return require('../imessage/platform') as typeof import('../imessage/platform');
12
+ }
13
+
14
+ describe('texting Lucy on Android', () => {
15
+ it('names Messages, never iMessage', () => {
16
+ const p = load('android');
17
+ expect(p.MESSAGES_APP).toBe('Messages');
18
+ expect(p.TEXT_LUCY).toBe('Text Lucy on Messages');
19
+ expect(p.TEXT_FROM).toBe('your phone');
20
+ expect(p.textSteps(STEPS)[1].body).toBe('Tap Text Lucy on Messages. Messages opens with “Hi Lucy” ready.');
21
+ expect(JSON.stringify(p.textSteps(STEPS))).not.toContain('iMessage');
22
+ });
23
+ });
24
+
25
+ describe('texting Lucy on an iPhone', () => {
26
+ it('keeps the web’s iMessage words', () => {
27
+ const p = load('ios');
28
+ expect(p.MESSAGES_APP).toBe('iMessage');
29
+ expect(p.TEXT_LUCY).toBe('Text Lucy on iMessage');
30
+ expect(p.textSteps(STEPS)).toEqual(STEPS);
31
+ });
32
+ });
@@ -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
+ });