@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.
- package/.claude-flow/data/pending-insights.jsonl +43 -0
- package/.claude-flow/sessions/session-1794323376548.json +14 -0
- package/CHANGELOG.md +41 -0
- package/jest.config.cjs +22 -0
- package/lib/assets/home/loop-day.jpg +0 -0
- package/lib/assets/home/loop-day.mp4 +0 -0
- package/lib/assets/home/loop-time-back.jpg +0 -0
- package/lib/assets/home/loop-time-back.mp4 +0 -0
- package/lib/assets/home/loop-where.jpg +0 -0
- package/lib/assets/home/loop-where.mp4 +0 -0
- package/lib/assets/home/reel-gym.jpg +0 -0
- package/lib/assets/home/reel-gym.mp4 +0 -0
- package/lib/assets/home/reel-internet.jpg +0 -0
- package/lib/assets/home/reel-internet.mp4 +0 -0
- package/lib/assets/icon.png +0 -0
- package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/lib/assets/lottie/lucy-mark-call.json +1470 -0
- package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
- package/lib/assets/lottie/lucy-mark-details.json +1735 -0
- package/lib/assets/lottie/lucy-mark-email.json +1363 -0
- package/lib/assets/lottie/lucy-mark-message.json +1154 -0
- package/lib/assets/lottie/lucy-mark-search.json +1067 -0
- package/lib/assets/lottie/lucy-mark-think.json +1253 -0
- package/lib/assets/lottie/lucy-mark-write.json +1532 -0
- package/lib/assets/lottie/time-back.json +16458 -0
- package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/lib/assets/sounds/hours-back.m4a +0 -0
- package/lib/assets/sounds/meet-lucy.m4a +0 -0
- package/lib/assets/sounds/power-on.m4a +0 -0
- package/lib/assets/sounds/wind-back.m4a +0 -0
- package/lib/assets/sounds/youre-in.m4a +0 -0
- package/lib/chat/agent.js +358 -0
- package/lib/chat/agent.js.map +1 -0
- package/lib/chat/appFront.js +32 -0
- package/lib/chat/appFront.js.map +1 -0
- package/lib/chat/auth.js +370 -0
- package/lib/chat/auth.js.map +1 -0
- package/lib/chat/chores.js +360 -0
- package/lib/chat/chores.js.map +1 -0
- package/lib/chat/connectors.js +45 -0
- package/lib/chat/connectors.js.map +1 -0
- package/lib/chat/jobs.js +223 -0
- package/lib/chat/jobs.js.map +1 -0
- package/lib/chat/lucyMotion.js +6 -0
- package/lib/chat/lucyMotion.js.map +1 -0
- package/lib/chat/protocol.js +111 -0
- package/lib/chat/protocol.js.map +1 -0
- package/lib/chat/results.js +133 -0
- package/lib/chat/results.js.map +1 -0
- package/lib/chat/store.js +81 -0
- package/lib/chat/store.js.map +1 -0
- package/lib/chat/useDictation.js +168 -0
- package/lib/chat/useDictation.js.map +1 -0
- package/lib/chat/useLucyChat.js +451 -0
- package/lib/chat/useLucyChat.js.map +1 -0
- package/lib/chat/useMyComputer.js +32 -0
- package/lib/chat/useMyComputer.js.map +1 -0
- package/lib/chat/whereLucyWorks.js +52 -0
- package/lib/chat/whereLucyWorks.js.map +1 -0
- package/lib/chat/workspace.js +124 -0
- package/lib/chat/workspace.js.map +1 -0
- package/lib/components/AreaShot.js +289 -0
- package/lib/components/AreaShot.js.map +1 -0
- package/lib/components/Backdrops.js +262 -0
- package/lib/components/Backdrops.js.map +1 -0
- package/lib/components/BottomSheet.js +61 -0
- package/lib/components/BottomSheet.js.map +1 -0
- package/lib/components/ChatSheets.js +429 -0
- package/lib/components/ChatSheets.js.map +1 -0
- package/lib/components/ConnectorLogo.js +91 -0
- package/lib/components/ConnectorLogo.js.map +1 -0
- package/lib/components/CustomDrawer.js +534 -0
- package/lib/components/CustomDrawer.js.map +1 -0
- package/lib/components/IdeasPane.js +394 -0
- package/lib/components/IdeasPane.js.map +1 -0
- package/lib/components/ImessageSheet.js +261 -0
- package/lib/components/ImessageSheet.js.map +1 -0
- package/lib/components/KeyboardAvoider.js +29 -0
- package/lib/components/KeyboardAvoider.js.map +1 -0
- package/lib/components/Logo.js +81 -0
- package/lib/components/Logo.js.map +1 -0
- package/lib/components/LucyWorking.js +67 -0
- package/lib/components/LucyWorking.js.map +1 -0
- package/lib/components/Markdown.js +260 -0
- package/lib/components/Markdown.js.map +1 -0
- package/lib/components/Media.js +93 -0
- package/lib/components/Media.js.map +1 -0
- package/lib/components/MessagesAppIcon.js +23 -0
- package/lib/components/MessagesAppIcon.js.map +1 -0
- package/lib/components/MicButton.js +71 -0
- package/lib/components/MicButton.js.map +1 -0
- package/lib/components/ResultCards.js +974 -0
- package/lib/components/ResultCards.js.map +1 -0
- package/lib/components/SignInPrompt.js +148 -0
- package/lib/components/SignInPrompt.js.map +1 -0
- package/lib/components/SignedOut.js +38 -0
- package/lib/components/SignedOut.js.map +1 -0
- package/lib/components/TalkToLucyHero.js +487 -0
- package/lib/components/TalkToLucyHero.js.map +1 -0
- package/lib/components/TalkToLucySheet.js +182 -0
- package/lib/components/TalkToLucySheet.js.map +1 -0
- package/lib/components/WhereLucyWorks.js +277 -0
- package/lib/components/WhereLucyWorks.js.map +1 -0
- package/lib/components/WorkspaceSection.js +271 -0
- package/lib/components/WorkspaceSection.js.map +1 -0
- package/lib/components/YantraMark.js +13 -0
- package/lib/components/YantraMark.js.map +1 -0
- package/lib/components/drawerHeader.js +38 -0
- package/lib/components/drawerHeader.js.map +1 -0
- package/lib/components/lottieInstalled.js +6 -0
- package/lib/components/lottieInstalled.js.map +1 -0
- package/lib/components/ui.js +550 -0
- package/lib/components/ui.js.map +1 -0
- package/lib/components/useSignOut.js +7 -0
- package/lib/components/useSignOut.js.map +1 -0
- package/lib/components/viewport.js +121 -0
- package/lib/components/viewport.js.map +1 -0
- package/lib/components/voiceDial.js +10 -0
- package/lib/components/voiceDial.js.map +1 -0
- package/lib/compute.js +157 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.js +27 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/routes.js +15 -0
- package/lib/config/routes.js.map +1 -0
- package/lib/content.js +25 -0
- package/lib/content.js.map +1 -0
- package/lib/hooks/keyboardCover.js +39 -0
- package/lib/hooks/keyboardCover.js.map +1 -0
- package/lib/hooks/useKeyboard.js +121 -0
- package/lib/hooks/useKeyboard.js.map +1 -0
- package/lib/hooks/useReducedMotion.js +13 -0
- package/lib/hooks/useReducedMotion.js.map +1 -0
- package/lib/imessage/openMessages.js +25 -0
- package/lib/imessage/openMessages.js.map +1 -0
- package/lib/imessage/platform.js +12 -0
- package/lib/imessage/platform.js.map +1 -0
- package/lib/imessage/textLink.js +262 -0
- package/lib/imessage/textLink.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/live/card.js +28 -0
- package/lib/live/card.js.map +1 -0
- package/lib/live/liveActivity.js +144 -0
- package/lib/live/liveActivity.js.map +1 -0
- package/lib/module.js +3 -0
- package/lib/module.js.map +1 -0
- package/lib/offer/BlackFridayOffer.js +378 -0
- package/lib/offer/BlackFridayOffer.js.map +1 -0
- package/lib/offer/blackFriday.js +78 -0
- package/lib/offer/blackFriday.js.map +1 -0
- package/lib/offer/parts.js +624 -0
- package/lib/offer/parts.js.map +1 -0
- package/lib/offer/state.js +63 -0
- package/lib/offer/state.js.map +1 -0
- package/lib/push/push.js +142 -0
- package/lib/push/push.js.map +1 -0
- package/lib/push/usePushNotifications.js +39 -0
- package/lib/push/usePushNotifications.js.map +1 -0
- package/lib/routes.json +175 -0
- package/lib/screens/Account/index.js +209 -0
- package/lib/screens/Account/index.js.map +1 -0
- package/lib/screens/Chat/index.js +710 -0
- package/lib/screens/Chat/index.js.map +1 -0
- package/lib/screens/Chores/index.js +18 -0
- package/lib/screens/Chores/index.js.map +1 -0
- package/lib/screens/Connectors/index.js +17 -0
- package/lib/screens/Connectors/index.js.map +1 -0
- package/lib/screens/History/index.js +380 -0
- package/lib/screens/History/index.js.map +1 -0
- package/lib/screens/Home/index.js +2715 -0
- package/lib/screens/Home/index.js.map +1 -0
- package/lib/screens/Home/media.js +25 -0
- package/lib/screens/Home/media.js.map +1 -0
- package/lib/screens/Welcome/index.js +1066 -0
- package/lib/screens/Welcome/index.js.map +1 -0
- package/lib/talk/talkToLucy.js +139 -0
- package/lib/talk/talkToLucy.js.map +1 -0
- package/lib/theme/colors.js +29 -0
- package/lib/theme/colors.js.map +1 -0
- package/lib/theme/fonts.js +17 -0
- package/lib/theme/fonts.js.map +1 -0
- package/lib/theme/muse.js +134 -0
- package/lib/theme/muse.js.map +1 -0
- package/lib/utils/links.js +54 -0
- package/lib/utils/links.js.map +1 -0
- package/lib/utils/yantraLinks.js +68 -0
- package/lib/utils/yantraLinks.js.map +1 -0
- package/lib/welcome/flow.js +375 -0
- package/lib/welcome/flow.js.map +1 -0
- package/lib/welcome/haptics.js +125 -0
- package/lib/welcome/haptics.js.map +1 -0
- package/lib/welcome/parts.js +1996 -0
- package/lib/welcome/parts.js.map +1 -0
- package/lib/welcome/powerOn.js +29 -0
- package/lib/welcome/powerOn.js.map +1 -0
- package/lib/welcome/seen.js +41 -0
- package/lib/welcome/seen.js.map +1 -0
- package/lib/welcome/sound.js +110 -0
- package/lib/welcome/sound.js.map +1 -0
- package/package.json +66 -5
- package/rollup.config.mjs +42 -0
- package/src/.claude-flow/data/pending-insights.jsonl +19 -0
- package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
- package/src/__tests__/auth.test.ts +94 -0
- package/src/__tests__/blackFriday.test.ts +75 -0
- package/src/__tests__/cardTokens.test.ts +77 -0
- package/src/__tests__/chores.test.ts +188 -0
- package/src/__tests__/choresList.test.ts +100 -0
- package/src/__tests__/connectLink.test.ts +21 -0
- package/src/__tests__/content.test.ts +54 -0
- package/src/__tests__/dictation.test.ts +186 -0
- package/src/__tests__/envConfig.test.ts +14 -0
- package/src/__tests__/haptics.test.ts +202 -0
- package/src/__tests__/jobs.test.ts +130 -0
- package/src/__tests__/keyboardCover.test.ts +84 -0
- package/src/__tests__/liveCard.test.ts +39 -0
- package/src/__tests__/lockedPhone.test.ts +355 -0
- package/src/__tests__/lucyMotion.test.ts +34 -0
- package/src/__tests__/platform.test.ts +32 -0
- package/src/__tests__/powerOn.test.ts +62 -0
- package/src/__tests__/protocol.test.ts +125 -0
- package/src/__tests__/push.test.ts +111 -0
- package/src/__tests__/results.test.ts +256 -0
- package/src/__tests__/sound.test.ts +248 -0
- package/src/__tests__/talkToLucy.test.ts +205 -0
- package/src/__tests__/textLink.test.ts +91 -0
- package/src/__tests__/voiceDial.test.ts +53 -0
- package/src/__tests__/welcomeFlow.test.ts +157 -0
- package/src/__tests__/whereLucyWorks.test.ts +81 -0
- package/src/__tests__/yantraLinks.test.ts +96 -0
- package/src/assets/home/loop-day.jpg +0 -0
- package/src/assets/home/loop-day.mp4 +0 -0
- package/src/assets/home/loop-time-back.jpg +0 -0
- package/src/assets/home/loop-time-back.mp4 +0 -0
- package/src/assets/home/loop-where.jpg +0 -0
- package/src/assets/home/loop-where.mp4 +0 -0
- package/src/assets/home/reel-gym.jpg +0 -0
- package/src/assets/home/reel-gym.mp4 +0 -0
- package/src/assets/home/reel-internet.jpg +0 -0
- package/src/assets/home/reel-internet.mp4 +0 -0
- package/src/assets/icon.png +0 -0
- package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/src/assets/lottie/lucy-mark-call.json +1470 -0
- package/src/assets/lottie/lucy-mark-connect.json +2552 -0
- package/src/assets/lottie/lucy-mark-details.json +1735 -0
- package/src/assets/lottie/lucy-mark-email.json +1363 -0
- package/src/assets/lottie/lucy-mark-message.json +1154 -0
- package/src/assets/lottie/lucy-mark-search.json +1067 -0
- package/src/assets/lottie/lucy-mark-think.json +1253 -0
- package/src/assets/lottie/lucy-mark-write.json +1532 -0
- package/src/assets/lottie/time-back.json +16458 -0
- package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/src/assets/sounds/hours-back.m4a +0 -0
- package/src/assets/sounds/meet-lucy.m4a +0 -0
- package/src/assets/sounds/power-on.m4a +0 -0
- package/src/assets/sounds/wind-back.m4a +0 -0
- package/src/assets/sounds/youre-in.m4a +0 -0
- package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/chat/agent.ts +376 -0
- package/src/chat/appFront.ts +39 -0
- package/src/chat/auth.ts +433 -0
- package/src/chat/chores.ts +394 -0
- package/src/chat/connectors.ts +75 -0
- package/src/chat/jobs.ts +228 -0
- package/src/chat/lucyMotion.ts +33 -0
- package/src/chat/protocol.ts +192 -0
- package/src/chat/results.ts +224 -0
- package/src/chat/store.ts +87 -0
- package/src/chat/useDictation.ts +201 -0
- package/src/chat/useLucyChat.ts +458 -0
- package/src/chat/useMyComputer.ts +41 -0
- package/src/chat/whereLucyWorks.ts +97 -0
- package/src/chat/workspace.ts +127 -0
- package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
- package/src/components/AreaShot.tsx +239 -0
- package/src/components/Backdrops.tsx +323 -0
- package/src/components/BottomSheet.tsx +96 -0
- package/src/components/ChatSheets.tsx +565 -0
- package/src/components/ConnectorLogo.tsx +116 -0
- package/src/components/CustomDrawer.tsx +526 -0
- package/src/components/IdeasPane.tsx +318 -0
- package/src/components/ImessageSheet.tsx +280 -0
- package/src/components/KeyboardAvoider.tsx +45 -0
- package/src/components/Logo.tsx +97 -0
- package/src/components/LucyWorking.tsx +122 -0
- package/src/components/Markdown.tsx +219 -0
- package/src/components/Media.tsx +173 -0
- package/src/components/MessagesAppIcon.tsx +51 -0
- package/src/components/MicButton.tsx +92 -0
- package/src/components/ResultCards.tsx +1067 -0
- package/src/components/SignInPrompt.tsx +182 -0
- package/src/components/SignedOut.tsx +47 -0
- package/src/components/TalkToLucyHero.tsx +540 -0
- package/src/components/TalkToLucySheet.tsx +208 -0
- package/src/components/VoiceOrb.tsx +364 -0
- package/src/components/WhereLucyWorks.tsx +261 -0
- package/src/components/WorkspaceSection.tsx +307 -0
- package/src/components/YantraMark.tsx +30 -0
- package/src/components/drawerHeader.tsx +46 -0
- package/src/components/kit.tsx +309 -0
- package/src/components/lottieInstalled.ts +7 -0
- package/src/components/ui.tsx +700 -0
- package/src/components/useSignOut.ts +21 -0
- package/src/components/viewport.tsx +166 -0
- package/src/components/voiceDial.ts +45 -0
- package/src/compute.ts +168 -0
- package/src/config/env-config.ts +50 -0
- package/src/config/routes.ts +28 -0
- package/src/content.ts +217 -0
- package/src/hooks/keyboardCover.ts +70 -0
- package/src/hooks/useKeyboard.ts +135 -0
- package/src/hooks/useReducedMotion.ts +19 -0
- package/src/imessage/openMessages.ts +53 -0
- package/src/imessage/platform.ts +32 -0
- package/src/imessage/textLink.ts +307 -0
- package/src/index.ts +24 -0
- package/src/live/card.ts +62 -0
- package/src/live/liveActivity.ts +192 -0
- package/src/module.ts +8 -0
- package/src/offer/BlackFridayOffer.tsx +394 -0
- package/src/offer/blackFriday.ts +109 -0
- package/src/offer/parts.tsx +650 -0
- package/src/offer/state.ts +78 -0
- package/src/push/push.ts +171 -0
- package/src/push/usePushNotifications.ts +47 -0
- package/src/screens/Account/index.tsx +310 -0
- package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
- package/src/screens/Chat/index.tsx +891 -0
- package/src/screens/Chores/index.tsx +35 -0
- package/src/screens/Connectors/index.tsx +35 -0
- package/src/screens/History/index.tsx +346 -0
- package/src/screens/Home/index.tsx +2776 -0
- package/src/screens/Home/media.ts +31 -0
- package/src/screens/Welcome/index.tsx +1182 -0
- package/src/talk/talkToLucy.ts +187 -0
- package/src/theme/colors.ts +38 -0
- package/src/theme/fonts.ts +30 -0
- package/src/theme/muse.ts +86 -0
- package/src/utils/links.ts +84 -0
- package/src/utils/yantraLinks.ts +94 -0
- package/src/welcome/flow.ts +418 -0
- package/src/welcome/haptics.ts +179 -0
- package/src/welcome/parts.tsx +2160 -0
- package/src/welcome/powerOn.ts +84 -0
- package/src/welcome/seen.ts +68 -0
- package/src/welcome/sound.ts +173 -0
- package/tools/lottie/chat.motion +0 -0
- package/tools/lottie/cloud.motion +0 -0
- package/tools/lottie/generate.mjs +1209 -0
- package/tools/lottie/inter-glyphs.json +4416 -0
- package/tools/lottie/lucy-mark-calendar.motion +0 -0
- package/tools/lottie/lucy-mark-call.motion +0 -0
- package/tools/lottie/lucy-mark-connect.motion +0 -0
- package/tools/lottie/lucy-mark-details.motion +0 -0
- package/tools/lottie/lucy-mark-email.motion +0 -0
- package/tools/lottie/lucy-mark-message.motion +0 -0
- package/tools/lottie/lucy-mark-search.motion +0 -0
- package/tools/lottie/lucy-mark-think.motion +0 -0
- package/tools/lottie/lucy-mark-write.motion +0 -0
- package/tools/lottie/mark.json +1 -0
- package/tools/lottie/mine-none.motion +0 -0
- package/tools/lottie/mine-offline.motion +0 -0
- package/tools/lottie/mine-online.motion +0 -0
- package/tools/lottie/time-back.mjs +604 -0
- package/tools/sounds/render.mjs +730 -0
- package/tsconfig.json +17 -0
- package/README.md +0 -3
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// The welcome's sound (welcome/sound.ts), with expo-audio and the platform stubbed so its rules run in node: the
|
|
2
|
+
// ambient channel set before every cue, waiting for a file, a timeline joining late where the picture is, the fade on
|
|
3
|
+
// a skip, silence without the native module, and the files held to the beats they were rendered to.
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';
|
|
5
|
+
import { WIND_BACK } from '../welcome/flow';
|
|
6
|
+
import { POWER_ON } from '../welcome/powerOn';
|
|
7
|
+
|
|
8
|
+
type Sound = typeof import('../welcome/sound');
|
|
9
|
+
|
|
10
|
+
interface MockPlayer {
|
|
11
|
+
file: string;
|
|
12
|
+
isLoaded: boolean;
|
|
13
|
+
currentTime: number;
|
|
14
|
+
volume: number;
|
|
15
|
+
playing: boolean;
|
|
16
|
+
play: jest.Mock<() => void>;
|
|
17
|
+
pause: jest.Mock<() => void>;
|
|
18
|
+
seekTo: jest.Mock<(seconds: number) => Promise<void>>;
|
|
19
|
+
remove: jest.Mock<() => void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const START = 1_000_000;
|
|
23
|
+
const mockPlayers: MockPlayer[] = [];
|
|
24
|
+
const mockEvents: string[] = [];
|
|
25
|
+
/** A new player reports itself loaded this many ms after it is made. */
|
|
26
|
+
let mockLoadAfter = 0;
|
|
27
|
+
let mockModeFails = false;
|
|
28
|
+
let mockLinked = true;
|
|
29
|
+
const mockPlatform = { OS: 'ios' };
|
|
30
|
+
|
|
31
|
+
const mockAudio = {
|
|
32
|
+
createAudioPlayer: jest.fn((file: string) => {
|
|
33
|
+
const born = Date.now();
|
|
34
|
+
const p: MockPlayer = {
|
|
35
|
+
file,
|
|
36
|
+
get isLoaded() {
|
|
37
|
+
return Date.now() - born >= mockLoadAfter;
|
|
38
|
+
},
|
|
39
|
+
currentTime: 0,
|
|
40
|
+
volume: 1,
|
|
41
|
+
playing: false,
|
|
42
|
+
play: jest.fn(() => {
|
|
43
|
+
p.playing = true;
|
|
44
|
+
mockEvents.push(`play ${file}@${Date.now() - START} from ${p.currentTime}`);
|
|
45
|
+
}),
|
|
46
|
+
pause: jest.fn(() => {
|
|
47
|
+
p.playing = false;
|
|
48
|
+
mockEvents.push(`pause ${file}@${Date.now() - START}`);
|
|
49
|
+
}),
|
|
50
|
+
seekTo: jest.fn(async (seconds: number) => {
|
|
51
|
+
p.currentTime = seconds;
|
|
52
|
+
}),
|
|
53
|
+
remove: jest.fn(),
|
|
54
|
+
};
|
|
55
|
+
mockPlayers.push(p);
|
|
56
|
+
return p;
|
|
57
|
+
}),
|
|
58
|
+
setAudioModeAsync: jest.fn(async (mode: object) => {
|
|
59
|
+
mockEvents.push(`mode ${JSON.stringify(mode)}`);
|
|
60
|
+
if (mockModeFails) throw new Error('the session said no');
|
|
61
|
+
}),
|
|
62
|
+
setIsAudioActiveAsync: jest.fn(async (_active: boolean) => undefined),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
jest.mock('expo-modules-core', () => ({ requireOptionalNativeModule: () => (mockLinked ? {} : null) }), {
|
|
66
|
+
virtual: true,
|
|
67
|
+
});
|
|
68
|
+
jest.mock('expo-audio', () => mockAudio, { virtual: true });
|
|
69
|
+
jest.mock('react-native', () => ({ Platform: mockPlatform }), { virtual: true });
|
|
70
|
+
jest.mock('../assets/sounds/power-on.m4a', () => 'power-on');
|
|
71
|
+
jest.mock('../assets/sounds/wind-back.m4a', () => 'wind-back');
|
|
72
|
+
jest.mock('../assets/sounds/meet-lucy.m4a', () => 'meet-lucy');
|
|
73
|
+
jest.mock('../assets/sounds/hours-back.m4a', () => 'hours-back');
|
|
74
|
+
jest.mock('../assets/sounds/youre-in.m4a', () => 'youre-in');
|
|
75
|
+
|
|
76
|
+
/** A fresh copy of the module, so every test starts with no players. */
|
|
77
|
+
function fresh(): Sound {
|
|
78
|
+
let mod: Sound | undefined;
|
|
79
|
+
jest.isolateModules(() => {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
81
|
+
mod = require('../welcome/sound') as Sound;
|
|
82
|
+
});
|
|
83
|
+
return mod as Sound;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const played = () => mockEvents.filter((e) => e.startsWith('play '));
|
|
87
|
+
const playerFor = (file: string) => mockPlayers.find((p) => p.file === file) as MockPlayer;
|
|
88
|
+
const IOS_AMBIENT = {
|
|
89
|
+
playsInSilentMode: false,
|
|
90
|
+
interruptionMode: 'mixWithOthers',
|
|
91
|
+
allowsRecording: false,
|
|
92
|
+
shouldPlayInBackground: false,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
jest.useFakeTimers({ now: START });
|
|
97
|
+
mockPlayers.length = 0;
|
|
98
|
+
mockEvents.length = 0;
|
|
99
|
+
mockLoadAfter = 0;
|
|
100
|
+
mockModeFails = false;
|
|
101
|
+
mockLinked = true;
|
|
102
|
+
mockPlatform.OS = 'ios';
|
|
103
|
+
mockAudio.createAudioPlayer.mockClear();
|
|
104
|
+
mockAudio.setAudioModeAsync.mockClear();
|
|
105
|
+
mockAudio.setIsAudioActiveAsync.mockClear();
|
|
106
|
+
});
|
|
107
|
+
afterEach(() => {
|
|
108
|
+
jest.useRealTimers();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe("the welcome's sound", () => {
|
|
112
|
+
it('sets the ambient channel, then plays: the silent switch mutes it and other audio plays on', async () => {
|
|
113
|
+
const s = fresh();
|
|
114
|
+
s.play('meetLucy');
|
|
115
|
+
await jest.advanceTimersByTimeAsync(0);
|
|
116
|
+
expect(mockEvents).toEqual([`mode ${JSON.stringify(IOS_AMBIENT)}`, 'play meet-lucy@0 from 0']);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("on Android asks only to duck other audio for a moment, with Android's own keys", async () => {
|
|
120
|
+
mockPlatform.OS = 'android';
|
|
121
|
+
const s = fresh();
|
|
122
|
+
s.play('youreIn');
|
|
123
|
+
await jest.advanceTimersByTimeAsync(0);
|
|
124
|
+
expect(mockAudio.setAudioModeAsync).toHaveBeenCalledWith({
|
|
125
|
+
interruptionModeAndroid: 'duckOthers',
|
|
126
|
+
shouldPlayInBackground: false,
|
|
127
|
+
});
|
|
128
|
+
expect(played()).toEqual(['play youre-in@0 from 0']);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('sets the channel again before every cue, in case a video switched it to one that ignores the switch', async () => {
|
|
132
|
+
const s = fresh();
|
|
133
|
+
s.play('windBack');
|
|
134
|
+
await jest.advanceTimersByTimeAsync(500);
|
|
135
|
+
s.play('meetLucy');
|
|
136
|
+
await jest.advanceTimersByTimeAsync(0);
|
|
137
|
+
expect(mockEvents.map((e) => e.split(' ')[0])).toEqual(['mode', 'play', 'mode', 'play']);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("stays quiet if the channel can't be set", async () => {
|
|
141
|
+
mockModeFails = true;
|
|
142
|
+
const s = fresh();
|
|
143
|
+
s.play('powerOn');
|
|
144
|
+
await jest.advanceTimersByTimeAsync(500);
|
|
145
|
+
expect(played()).toEqual([]);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('waits for a file still loading, then plays a one-shot from its start', async () => {
|
|
149
|
+
mockLoadAfter = 130;
|
|
150
|
+
const s = fresh();
|
|
151
|
+
s.play('hoursBack');
|
|
152
|
+
await jest.advanceTimersByTimeAsync(300);
|
|
153
|
+
expect(played()).toEqual(['play hours-back@140 from 0']);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('joins a timeline that loaded late where the picture has got to, so the power-on stays in sync', async () => {
|
|
157
|
+
mockLoadAfter = 130;
|
|
158
|
+
const s = fresh();
|
|
159
|
+
s.play('powerOn');
|
|
160
|
+
await jest.advanceTimersByTimeAsync(300);
|
|
161
|
+
expect(playerFor('power-on').seekTo).toHaveBeenCalledWith(0.14);
|
|
162
|
+
expect(played()).toEqual(['play power-on@140 from 0.14']);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('starts a timeline that is ready on time, from its first sample', async () => {
|
|
166
|
+
const s = fresh();
|
|
167
|
+
s.prepare();
|
|
168
|
+
await jest.advanceTimersByTimeAsync(0);
|
|
169
|
+
mockEvents.length = 0;
|
|
170
|
+
s.play('powerOn');
|
|
171
|
+
await jest.advanceTimersByTimeAsync(0);
|
|
172
|
+
expect(playerFor('power-on').seekTo).not.toHaveBeenCalled();
|
|
173
|
+
expect(played()).toEqual(['play power-on@0 from 0']);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('gives up on a file that never loads', async () => {
|
|
177
|
+
mockLoadAfter = 60_000;
|
|
178
|
+
const s = fresh();
|
|
179
|
+
s.play('youreIn');
|
|
180
|
+
await jest.advanceTimersByTimeAsync(s.LOAD_MS * 2);
|
|
181
|
+
expect(played()).toEqual([]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('fades out and pauses when stopped, as a skipped power-on does', async () => {
|
|
185
|
+
const s = fresh();
|
|
186
|
+
const stop = s.play('powerOn');
|
|
187
|
+
await jest.advanceTimersByTimeAsync(400);
|
|
188
|
+
stop();
|
|
189
|
+
stop();
|
|
190
|
+
await jest.advanceTimersByTimeAsync(s.FADE_MS);
|
|
191
|
+
const p = playerFor('power-on');
|
|
192
|
+
expect(p.pause).toHaveBeenCalledTimes(1);
|
|
193
|
+
expect(p.volume).toBe(0.1);
|
|
194
|
+
expect(mockEvents.slice(-1)).toEqual([`pause power-on@${400 + s.FADE_MS}`]);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('replays from the start, and a fade from the take before never cuts the new one', async () => {
|
|
198
|
+
const s = fresh();
|
|
199
|
+
const stop = s.play('powerOn');
|
|
200
|
+
await jest.advanceTimersByTimeAsync(1200);
|
|
201
|
+
const p = playerFor('power-on');
|
|
202
|
+
p.currentTime = 1.2;
|
|
203
|
+
stop();
|
|
204
|
+
s.play('powerOn');
|
|
205
|
+
await jest.advanceTimersByTimeAsync(s.FADE_MS * 2);
|
|
206
|
+
expect(p.seekTo).toHaveBeenCalledWith(0);
|
|
207
|
+
expect(p.pause).not.toHaveBeenCalled();
|
|
208
|
+
expect(p.playing).toBe(true);
|
|
209
|
+
expect(p.volume).toBe(1);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('loads every cue ahead and wakes the channel, once; lets them all go as the welcome closes', async () => {
|
|
213
|
+
const s = fresh();
|
|
214
|
+
s.prepare();
|
|
215
|
+
s.prepare();
|
|
216
|
+
await jest.advanceTimersByTimeAsync(0);
|
|
217
|
+
expect(mockPlayers.map((p) => p.file)).toEqual([
|
|
218
|
+
'power-on',
|
|
219
|
+
'wind-back',
|
|
220
|
+
'meet-lucy',
|
|
221
|
+
'hours-back',
|
|
222
|
+
'youre-in',
|
|
223
|
+
]);
|
|
224
|
+
expect(mockAudio.setIsAudioActiveAsync).toHaveBeenCalledWith(true);
|
|
225
|
+
s.release();
|
|
226
|
+
mockPlayers.forEach((p) => expect(p.remove).toHaveBeenCalledTimes(1));
|
|
227
|
+
s.play('meetLucy');
|
|
228
|
+
expect(mockAudio.createAudioPlayer).toHaveBeenCalledTimes(6);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('stays silent, without failing, in a build without expo-audio', async () => {
|
|
232
|
+
mockLinked = false;
|
|
233
|
+
const s = fresh();
|
|
234
|
+
s.prepare();
|
|
235
|
+
s.play('powerOn')();
|
|
236
|
+
s.release();
|
|
237
|
+
await jest.advanceTimersByTimeAsync(500);
|
|
238
|
+
expect(mockAudio.createAudioPlayer).not.toHaveBeenCalled();
|
|
239
|
+
expect(mockAudio.setAudioModeAsync).not.toHaveBeenCalled();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('was rendered to the beats the picture keeps (re-render tools/sounds if these move)', () => {
|
|
243
|
+
const s = fresh();
|
|
244
|
+
const { ring, click, ignite, beats, sink, done } = POWER_ON;
|
|
245
|
+
expect(s.RENDERED_FOR.powerOn).toEqual({ ring, click, ignite, beats: [...beats], sink, done });
|
|
246
|
+
expect(s.RENDERED_FOR.windBack).toEqual(WIND_BACK);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Talk to Lucy, Clockbook's own control for the Action Button (talk/talkToLucy.ts): which iPhones are told about the
|
|
3
|
+
* Action Button and which about Control Center, when Account shows it, and a press reaching Home once.
|
|
4
|
+
*/
|
|
5
|
+
type NativeTalk = {
|
|
6
|
+
hasTalkToLucy?: () => boolean;
|
|
7
|
+
takeTalkRequest?: () => number;
|
|
8
|
+
addListener?: (event: string, listener: () => void) => { remove: () => void };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function load({
|
|
12
|
+
os = 'ios',
|
|
13
|
+
isPad = false,
|
|
14
|
+
native = null,
|
|
15
|
+
}: { os?: string; isPad?: boolean; native?: NativeTalk | null } = {}) {
|
|
16
|
+
jest.resetModules();
|
|
17
|
+
const app: { onChange?: (state: string) => void; remove: jest.Mock } = { remove: jest.fn() };
|
|
18
|
+
jest.doMock(
|
|
19
|
+
'react-native',
|
|
20
|
+
() => ({
|
|
21
|
+
Platform: { OS: os, isPad },
|
|
22
|
+
AppState: {
|
|
23
|
+
addEventListener: (_event: string, listener: (state: string) => void) => {
|
|
24
|
+
app.onChange = listener;
|
|
25
|
+
return { remove: app.remove };
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
{ virtual: true },
|
|
30
|
+
);
|
|
31
|
+
jest.doMock('expo-modules-core', () => ({ requireOptionalNativeModule: () => native }), { virtual: true });
|
|
32
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
|
|
33
|
+
const talk = require('../talk/talkToLucy') as typeof import('../talk/talkToLucy');
|
|
34
|
+
return { talk, app };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The native module with a press waiting `ageMs` ago (none when null), its event, and a way to press again. */
|
|
38
|
+
function pressModule(ageMs: number | null) {
|
|
39
|
+
let pending = ageMs === null ? 0 : (Date.now() - ageMs) / 1000;
|
|
40
|
+
const events: { listener?: () => void; remove: jest.Mock } = { remove: jest.fn() };
|
|
41
|
+
const native: NativeTalk = {
|
|
42
|
+
hasTalkToLucy: () => true,
|
|
43
|
+
takeTalkRequest: () => {
|
|
44
|
+
const at = pending;
|
|
45
|
+
pending = 0;
|
|
46
|
+
return at;
|
|
47
|
+
},
|
|
48
|
+
addListener: (_event, listener) => {
|
|
49
|
+
events.listener = listener;
|
|
50
|
+
return { remove: events.remove };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
native,
|
|
55
|
+
events,
|
|
56
|
+
press: () => {
|
|
57
|
+
pending = Date.now() / 1000;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('which iPhones have an Action Button', () => {
|
|
63
|
+
it('is the 15 Pro and every iPhone after it', () => {
|
|
64
|
+
const { talk } = load();
|
|
65
|
+
for (const model of ['iPhone16,1', 'iPhone16,2', 'iPhone17,1', 'iPhone17,5', 'iPhone18,3']) {
|
|
66
|
+
expect(talk.hasActionButton(model)).toBe(true);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('is not the 15, the 14, the SE, an iPad, or a model it cannot read', () => {
|
|
71
|
+
const { talk } = load();
|
|
72
|
+
for (const model of [
|
|
73
|
+
'iPhone15,4',
|
|
74
|
+
'iPhone15,5',
|
|
75
|
+
'iPhone15,2',
|
|
76
|
+
'iPhone14,6',
|
|
77
|
+
'iPad16,3',
|
|
78
|
+
'arm64',
|
|
79
|
+
'',
|
|
80
|
+
null,
|
|
81
|
+
undefined,
|
|
82
|
+
]) {
|
|
83
|
+
expect(talk.hasActionButton(model)).toBe(false);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('where Talk to Lucy goes', () => {
|
|
89
|
+
it('is the Action Button, or Control Center on an iPhone without one', () => {
|
|
90
|
+
const { talk } = load();
|
|
91
|
+
expect(talk.talkPlace('iPhone16,1')).toBe('action-button');
|
|
92
|
+
expect(talk.talkPlace('iPhone15,4')).toBe('control-center');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('tells a phone it cannot identify about the Action Button', () => {
|
|
96
|
+
const { talk } = load();
|
|
97
|
+
expect(talk.talkPlace(null)).toBe('action-button');
|
|
98
|
+
expect(talk.talkPlace('arm64')).toBe('action-button');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('says Control Center is a swipe up on an iPhone SE', () => {
|
|
102
|
+
const { talk } = load();
|
|
103
|
+
expect(talk.talkCopy('control-center', 'iPhone14,6').steps[0].body).toBe(
|
|
104
|
+
'Swipe up from the bottom edge of the screen.',
|
|
105
|
+
);
|
|
106
|
+
expect(talk.talkCopy('control-center', 'iPhone15,4').steps[0].body).toBe(
|
|
107
|
+
'Swipe down from the top-right corner of the screen.',
|
|
108
|
+
);
|
|
109
|
+
expect(talk.talkCopy('action-button', 'iPhone14,6')).toBe(talk.TALK_COPY['action-button']);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('names the control and never iMessage', () => {
|
|
113
|
+
const { talk } = load();
|
|
114
|
+
for (const place of ['action-button', 'control-center'] as const) {
|
|
115
|
+
const copy = JSON.stringify(talk.TALK_COPY[place]);
|
|
116
|
+
expect(copy).toContain(talk.TALK_TO_LUCY);
|
|
117
|
+
expect(copy).not.toMatch(/iMessage/);
|
|
118
|
+
}
|
|
119
|
+
expect(talk.TALK_COPY['action-button'].steps[0].path).toEqual(['Settings', 'Action Button']);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('when Account shows Talk to Lucy', () => {
|
|
124
|
+
it('shows on an iPhone whose build has the control', () => {
|
|
125
|
+
expect(load({ native: { hasTalkToLucy: () => true } }).talk.talkToLucyAvailable()).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('hides before iOS 18, in a build without it, on an iPad and on Android', () => {
|
|
129
|
+
expect(load({ native: { hasTalkToLucy: () => false } }).talk.talkToLucyAvailable()).toBe(false);
|
|
130
|
+
expect(load({ native: {} }).talk.talkToLucyAvailable()).toBe(false);
|
|
131
|
+
expect(load({ native: null }).talk.talkToLucyAvailable()).toBe(false);
|
|
132
|
+
expect(load({ isPad: true, native: { hasTalkToLucy: () => true } }).talk.talkToLucyAvailable()).toBe(false);
|
|
133
|
+
expect(load({ os: 'android', native: { hasTalkToLucy: () => true } }).talk.talkToLucyAvailable()).toBe(false);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('hides when the module throws', () => {
|
|
137
|
+
const native: NativeTalk = {
|
|
138
|
+
hasTalkToLucy: () => {
|
|
139
|
+
throw new Error('gone');
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
expect(load({ native }).talk.talkToLucyAvailable()).toBe(false);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('a press of Talk to Lucy', () => {
|
|
147
|
+
it('counts for a minute, with a little slack for the clock', () => {
|
|
148
|
+
const { talk } = load();
|
|
149
|
+
const now = 1_800_000_000_000;
|
|
150
|
+
expect(talk.freshTalkRequest(now - 1_000, now)).toBe(true);
|
|
151
|
+
expect(talk.freshTalkRequest(now - 59_000, now)).toBe(true);
|
|
152
|
+
expect(talk.freshTalkRequest(now - 61_000, now)).toBe(false);
|
|
153
|
+
expect(talk.freshTalkRequest(now + 2_000, now)).toBe(true);
|
|
154
|
+
expect(talk.freshTalkRequest(now + 10_000, now)).toBe(false);
|
|
155
|
+
expect(talk.freshTalkRequest(0, now)).toBe(false);
|
|
156
|
+
expect(talk.freshTalkRequest(Number.NaN, now)).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('is taken once', () => {
|
|
160
|
+
const { talk } = load({ native: pressModule(2_000).native });
|
|
161
|
+
expect(talk.takeTalkRequest()).toBe(true);
|
|
162
|
+
expect(talk.takeTalkRequest()).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('is dropped once it is stale', () => {
|
|
166
|
+
const { talk } = load({ native: pressModule(5 * 60_000).native });
|
|
167
|
+
expect(talk.takeTalkRequest()).toBe(false);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('opens listening once each: from a cold start, while the app was away, and while it is open', () => {
|
|
171
|
+
const m = pressModule(1_000);
|
|
172
|
+
const { talk, app } = load({ native: m.native });
|
|
173
|
+
const onTalk = jest.fn();
|
|
174
|
+
const stop = talk.watchTalkRequests(onTalk);
|
|
175
|
+
expect(onTalk).toHaveBeenCalledTimes(1);
|
|
176
|
+
|
|
177
|
+
app.onChange?.('active');
|
|
178
|
+
expect(onTalk).toHaveBeenCalledTimes(1);
|
|
179
|
+
|
|
180
|
+
m.press();
|
|
181
|
+
app.onChange?.('active');
|
|
182
|
+
expect(onTalk).toHaveBeenCalledTimes(2);
|
|
183
|
+
|
|
184
|
+
m.press();
|
|
185
|
+
m.events.listener?.();
|
|
186
|
+
m.events.listener?.();
|
|
187
|
+
expect(onTalk).toHaveBeenCalledTimes(3);
|
|
188
|
+
|
|
189
|
+
stop();
|
|
190
|
+
expect(app.remove).toHaveBeenCalled();
|
|
191
|
+
expect(m.events.remove).toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('does nothing without the module', () => {
|
|
195
|
+
const { talk } = load({ os: 'android' });
|
|
196
|
+
const onTalk = jest.fn();
|
|
197
|
+
talk.watchTalkRequests(onTalk)();
|
|
198
|
+
expect(onTalk).not.toHaveBeenCalled();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('brings Home to the top, listening', () => {
|
|
202
|
+
const { talk } = load();
|
|
203
|
+
expect(talk.listeningHome(42)).toEqual({ at: 42, listen: 42 });
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// textLink.ts asks the backend through chat/auth.ts (native storage): the pure helpers are what is tested here.
|
|
2
|
+
jest.mock('../chat/auth', () => ({ accountKey: jest.fn(), agentBackendUrl: jest.fn(), getChatToken: jest.fn() }));
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line import/first
|
|
5
|
+
import {
|
|
6
|
+
classifyError,
|
|
7
|
+
encodeHiddenCode,
|
|
8
|
+
firstText,
|
|
9
|
+
IMESSAGE_CHANNEL,
|
|
10
|
+
lineAddress,
|
|
11
|
+
LUCY_GREETING,
|
|
12
|
+
normalizeExpiry,
|
|
13
|
+
ownThread,
|
|
14
|
+
smsHref,
|
|
15
|
+
threadReach,
|
|
16
|
+
} from '../imessage/textLink';
|
|
17
|
+
|
|
18
|
+
const FRAME = '';
|
|
19
|
+
const D = ['', '', '', ''];
|
|
20
|
+
|
|
21
|
+
describe('encodeHiddenCode', () => {
|
|
22
|
+
it('frames four base-4 digits per byte, high bits first (the gateway wire format)', () => {
|
|
23
|
+
// 'A' = 0x41 = 01 00 00 01
|
|
24
|
+
expect(encodeHiddenCode('A')).toBe(FRAME + D[1] + D[0] + D[0] + D[1] + FRAME);
|
|
25
|
+
// 'z' = 0x7a = 01 11 10 10
|
|
26
|
+
expect(encodeHiddenCode('z')).toBe(FRAME + D[1] + D[3] + D[2] + D[2] + FRAME);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('is invisible: only default-ignorable characters', () => {
|
|
30
|
+
expect(encodeHiddenCode('abc-_123')).toMatch(/^[]+$/);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('smsHref', () => {
|
|
35
|
+
it('puts the body after ?& so both iOS and Android read it', () => {
|
|
36
|
+
expect(smsHref('lucy@icloud.com', 'Hi Lucy')).toBe('sms:lucy@icloud.com?&body=Hi%20Lucy');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('the line', () => {
|
|
41
|
+
const one = { channelType: IMESSAGE_CHANNEL, externalChatId: 'iMessage;-;+15550100', externalAccountId: 'u1' };
|
|
42
|
+
|
|
43
|
+
it('finds the person’s own thread, never a group or a workspace line', () => {
|
|
44
|
+
expect(ownThread([one])).toBe(one);
|
|
45
|
+
expect(ownThread([{ ...one, externalChatId: 'iMessage;+;chat123' }])).toBeUndefined();
|
|
46
|
+
expect(ownThread([{ ...one, externalAccountId: 'ws_9' }])).toBeUndefined();
|
|
47
|
+
expect(ownThread([{ ...one, channelType: 'whatsapp' }])).toBeUndefined();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('keeps a forwarded SMS/RCS thread on SMS', () => {
|
|
51
|
+
expect(threadReach(one)).toBe('imessage');
|
|
52
|
+
expect(threadReach({ ...one, externalChatId: 'SMS;-;+15550100' })).toBe('sms');
|
|
53
|
+
expect(threadReach({ ...one, externalChatId: 'RCS;-;+15550100' })).toBe('sms');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('lets an iPhone fall back to the number, never an Android phone to the Apple ID', () => {
|
|
57
|
+
expect(lineAddress({ imessage: 'h@icloud.com', sms: '+1555' }, 'imessage')).toBe('h@icloud.com');
|
|
58
|
+
expect(lineAddress({ imessage: null, sms: '+1555' }, 'imessage')).toBe('+1555');
|
|
59
|
+
expect(lineAddress({ imessage: 'h@icloud.com', sms: null }, 'sms')).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('firstText', () => {
|
|
64
|
+
it('is the greeting unless the person brought their own words', () => {
|
|
65
|
+
expect(firstText()).toBe(LUCY_GREETING);
|
|
66
|
+
expect(firstText(' ')).toBe(LUCY_GREETING);
|
|
67
|
+
expect(firstText(' Cancel my gym ')).toBe('Cancel my gym');
|
|
68
|
+
expect(firstText('x'.repeat(400))).toHaveLength(300);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('normalizeExpiry', () => {
|
|
73
|
+
const now = 1_000_000;
|
|
74
|
+
it('trusts the server within the code’s lifetime', () => {
|
|
75
|
+
expect(normalizeExpiry(now + 5 * 60_000, now)).toBe(now + 5 * 60_000);
|
|
76
|
+
});
|
|
77
|
+
it('never less than a minute, nor more than ten', () => {
|
|
78
|
+
expect(normalizeExpiry(now + 10_000, now)).toBe(now + 10 * 60_000);
|
|
79
|
+
expect(normalizeExpiry(now + 60 * 60_000, now)).toBe(now + 10 * 60_000);
|
|
80
|
+
expect(normalizeExpiry('nonsense', now)).toBe(now + 10 * 60_000);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('classifyError', () => {
|
|
85
|
+
it('tells a rate limit and a refused sign-in from a failure', () => {
|
|
86
|
+
expect(classifyError('Too many pairing tokens').kind).toBe('rate-limited');
|
|
87
|
+
expect(classifyError('jwt expired').kind).toBe('signed-out');
|
|
88
|
+
expect(classifyError('whatever', 'UNAUTHENTICATED').kind).toBe('signed-out');
|
|
89
|
+
expect(classifyError('boom').kind).toBe('failed');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, it } from '@jest/globals';
|
|
2
|
+
import { dialTicks, tailAt, tailRange, TICKS } from '../components/voiceDial';
|
|
3
|
+
|
|
4
|
+
/** Where an Animated interpolation with these ranges lands at `x`: straight lines between the points, as Animated draws. */
|
|
5
|
+
function interpolate({ inputRange, outputRange }: { inputRange: number[]; outputRange: number[] }, x: number): number {
|
|
6
|
+
for (let k = 1; k < inputRange.length; k++) {
|
|
7
|
+
if (x <= inputRange[k]) {
|
|
8
|
+
const [x0, x1] = [inputRange[k - 1], inputRange[k]];
|
|
9
|
+
const [y0, y1] = [outputRange[k - 1], outputRange[k]];
|
|
10
|
+
return y0 + ((y1 - y0) * (x - x0)) / (x1 - x0);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return outputRange[outputRange.length - 1];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('the voice orb dial', () => {
|
|
17
|
+
it('has sixty ticks clockwise from twelve, every fifth a long one', () => {
|
|
18
|
+
const ticks = dialTicks();
|
|
19
|
+
|
|
20
|
+
expect(ticks).toHaveLength(60);
|
|
21
|
+
expect(ticks.filter((t) => t.major)).toHaveLength(12);
|
|
22
|
+
expect(ticks[15]).toEqual({ i: 15, deg: 90, major: true });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('lights a tick as the running light passes it, then fades it over the tail', () => {
|
|
26
|
+
expect(tailAt(15, 0.25)).toBe(1);
|
|
27
|
+
expect(tailAt(15, 0.25 + 0.14)).toBeCloseTo(0.5);
|
|
28
|
+
expect(tailAt(15, 0.6)).toBe(0);
|
|
29
|
+
// The head has not reached it yet.
|
|
30
|
+
expect(tailAt(15, 0.2)).toBe(0);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('keeps a tail that runs past twelve glowing as the next lap begins', () => {
|
|
34
|
+
expect(tailAt(55, 0)).toBeCloseTo(1 - (1 - 55 / 60) / 0.28);
|
|
35
|
+
expect(tailAt(55, 0.5)).toBe(0);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('gives Animated the same curve, for every tick, all the way round', () => {
|
|
39
|
+
for (let i = 0; i < TICKS; i++) {
|
|
40
|
+
const range = tailRange(i);
|
|
41
|
+
for (let k = 1; k < range.inputRange.length; k++) {
|
|
42
|
+
expect(range.inputRange[k]).toBeGreaterThan(range.inputRange[k - 1]);
|
|
43
|
+
}
|
|
44
|
+
for (let step = 0; step <= 200; step++) {
|
|
45
|
+
const phase = step / 200;
|
|
46
|
+
const behind = (((phase - i / TICKS) % 1) + 1) % 1;
|
|
47
|
+
// The head itself is the one jump, from dark to full.
|
|
48
|
+
if (behind < 0.001 || behind > 0.999) continue;
|
|
49
|
+
expect(interpolate(range, phase)).toBeCloseTo(tailAt(i, phase), 3);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|