@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.
- package/.claude-flow/data/pending-insights.jsonl +43 -0
- package/.claude-flow/sessions/session-1794323376548.json +14 -0
- package/CHANGELOG.md +31 -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 +42 -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 +21 -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 +2711 -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 +179 -0
- package/src/__tests__/choresList.test.ts +100 -0
- package/src/__tests__/content.test.ts +54 -0
- package/src/__tests__/dictation.test.ts +186 -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 +65 -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 +37 -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 +2773 -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,100 @@
|
|
|
1
|
+
// fetchChores merges the backend's listing with the chores this phone recorded, read by id.
|
|
2
|
+
const store: Record<string, string> = {};
|
|
3
|
+
jest.mock(
|
|
4
|
+
'@react-native-async-storage/async-storage',
|
|
5
|
+
() => ({
|
|
6
|
+
__esModule: true,
|
|
7
|
+
default: {
|
|
8
|
+
getItem: async (k: string) => store[k] ?? null,
|
|
9
|
+
setItem: async (k: string, v: string) => {
|
|
10
|
+
store[k] = v;
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
{ virtual: true },
|
|
15
|
+
);
|
|
16
|
+
jest.mock('../chat/auth', () => ({
|
|
17
|
+
agentBackendUrl: async () => 'https://backend/graphql',
|
|
18
|
+
getChatToken: async () => 'token',
|
|
19
|
+
accountKey: () => 'me',
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line import/first
|
|
23
|
+
import { fetchChores, noteChoreVerdict, rememberChore } from '../chat/chores';
|
|
24
|
+
|
|
25
|
+
const details = (id: string) => ({
|
|
26
|
+
kind: 'surface-job',
|
|
27
|
+
surface: 'clockbook',
|
|
28
|
+
id,
|
|
29
|
+
title: `Chore ${id}`,
|
|
30
|
+
createdAt: Date.now(),
|
|
31
|
+
});
|
|
32
|
+
const answer = (data: unknown) => ({ ok: true, status: 200, json: async () => ({ data }) });
|
|
33
|
+
|
|
34
|
+
describe('fetchChores', () => {
|
|
35
|
+
it('shows a chore the listing missed, read back by its id, and forgets one that is gone', async () => {
|
|
36
|
+
await rememberChore('gone-1');
|
|
37
|
+
await rememberChore('srv-2');
|
|
38
|
+
(globalThis as { fetch: unknown }).fetch = jest.fn(async (_u: string, init: { body: string }) => {
|
|
39
|
+
const { query, variables } = JSON.parse(init.body);
|
|
40
|
+
if (query.includes('getSurfaceJobs')) return answer({ getSurfaceJobs: [] });
|
|
41
|
+
if (variables.id === 'srv-2')
|
|
42
|
+
return answer({
|
|
43
|
+
getSurfaceJob: { id: 'srv-2', status: 'IN_PROGRESS', source: { details: details('m2') } },
|
|
44
|
+
});
|
|
45
|
+
return answer({ getSurfaceJob: null });
|
|
46
|
+
});
|
|
47
|
+
const list = await fetchChores();
|
|
48
|
+
expect(list.working.map((c) => c.title)).toEqual(['Chore m2']);
|
|
49
|
+
expect(JSON.parse(store['clockbook.chores.ids:v1:me'])).toEqual(['srv-2']);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('shows a chore that ended here as done while the server still reads it running', async () => {
|
|
53
|
+
const started = Date.now() - 5 * 60_000;
|
|
54
|
+
await rememberChore('srv-3');
|
|
55
|
+
await noteChoreVerdict('srv-3', { state: 'succeeded', endedAt: Date.now() });
|
|
56
|
+
(globalThis as { fetch: unknown }).fetch = jest.fn(async (_u: string, init: { body: string }) => {
|
|
57
|
+
const { query } = JSON.parse(init.body);
|
|
58
|
+
if (query.includes('getSurfaceJobs'))
|
|
59
|
+
return answer({
|
|
60
|
+
getSurfaceJobs: [
|
|
61
|
+
{
|
|
62
|
+
id: 'srv-3',
|
|
63
|
+
status: 'IN_PROGRESS',
|
|
64
|
+
source: { details: { ...details('m3'), createdAt: started } },
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
return answer({ getSurfaceJob: null });
|
|
69
|
+
});
|
|
70
|
+
const list = await fetchChores();
|
|
71
|
+
expect(list.working).toHaveLength(0);
|
|
72
|
+
expect(list.done.map((c) => c.title)).toEqual(['Chore m3']);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('reads a finished chore once, then shows it from the phone without asking again', async () => {
|
|
76
|
+
await rememberChore('srv-4');
|
|
77
|
+
const asked: string[] = [];
|
|
78
|
+
const started = Date.now() - 5 * 60_000;
|
|
79
|
+
(globalThis as { fetch: unknown }).fetch = jest.fn(async (_u: string, init: { body: string }) => {
|
|
80
|
+
const { query, variables } = JSON.parse(init.body);
|
|
81
|
+
if (query.includes('getSurfaceJobs')) return answer({ getSurfaceJobs: [] });
|
|
82
|
+
asked.push(variables.id);
|
|
83
|
+
if (variables.id === 'srv-4')
|
|
84
|
+
return answer({
|
|
85
|
+
getSurfaceJob: {
|
|
86
|
+
id: 'srv-4',
|
|
87
|
+
status: 'COMPLETED',
|
|
88
|
+
source: { details: { ...details('m4'), createdAt: started, endedAt: Date.now() } },
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return answer({ getSurfaceJob: null });
|
|
92
|
+
});
|
|
93
|
+
await fetchChores();
|
|
94
|
+
expect(asked).toContain('srv-4');
|
|
95
|
+
asked.length = 0;
|
|
96
|
+
const again = await fetchChores();
|
|
97
|
+
expect(asked).not.toContain('srv-4');
|
|
98
|
+
expect(again.done.map((c) => c.title)).toContain('Chore m4');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AREAS, HERO_CHORES, MINUTES } from '../content';
|
|
2
|
+
|
|
3
|
+
// links.ts reads env-config only; expo-web-browser is a native module, so stub it for node.
|
|
4
|
+
jest.mock('expo-web-browser', () => ({ openBrowserAsync: jest.fn() }), { virtual: true });
|
|
5
|
+
jest.mock('react-native', () => ({ Linking: { openURL: jest.fn() } }), { virtual: true });
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line import/first
|
|
8
|
+
import { businessLink, chatLink, PROMPT_MAX } from '../utils/links';
|
|
9
|
+
|
|
10
|
+
describe('chatLink', () => {
|
|
11
|
+
it('opens the new-chat page with the chore pre-typed', () => {
|
|
12
|
+
expect(chatLink('Cancel my gym', 'https://app.clockbook.test')).toBe(
|
|
13
|
+
'https://app.clockbook.test/new?q=Cancel+my+gym',
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('opens it blank for an empty chore', () => {
|
|
18
|
+
expect(chatLink(' ', 'https://app.clockbook.test')).toBe('https://app.clockbook.test/new');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('cuts a prompt at the app cap', () => {
|
|
22
|
+
const q = new URL(chatLink('x'.repeat(PROMPT_MAX + 50), 'https://app.clockbook.test')).searchParams.get('q');
|
|
23
|
+
expect(q).toHaveLength(PROMPT_MAX);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('businessLink', () => {
|
|
28
|
+
it('joins a path onto the business site', () => {
|
|
29
|
+
expect(businessLink('/pricing', 'https://clockbook.com/business')).toBe(
|
|
30
|
+
'https://clockbook.com/business/pricing',
|
|
31
|
+
);
|
|
32
|
+
expect(businessLink('pricing', 'https://clockbook.com/business')).toBe(
|
|
33
|
+
'https://clockbook.com/business/pricing',
|
|
34
|
+
);
|
|
35
|
+
expect(businessLink('', 'https://clockbook.com/business')).toBe('https://clockbook.com/business');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('is empty when no business site is configured', () => {
|
|
39
|
+
expect(businessLink('/pricing', '')).toBe('');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('content', () => {
|
|
44
|
+
it('has every chore ready to hand over', () => {
|
|
45
|
+
[...HERO_CHORES, ...AREAS.flatMap((a) => a.chores)].forEach((c) => {
|
|
46
|
+
expect(c.label.trim()).not.toBe('');
|
|
47
|
+
expect(c.prompt.trim()).not.toBe('');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('adds up to the 38 minutes the page promises', () => {
|
|
52
|
+
expect(MINUTES.reduce((sum, m) => sum + m.min, 0)).toBe(38);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// useDictation reads the speech module optionally; stub that lookup so the hook's logic runs in node.
|
|
2
|
+
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
|
|
3
|
+
|
|
4
|
+
const listeners: Record<string, ((e: unknown) => void)[]> = {};
|
|
5
|
+
const speech = {
|
|
6
|
+
start: jest.fn(),
|
|
7
|
+
stop: jest.fn(),
|
|
8
|
+
abort: jest.fn(),
|
|
9
|
+
isRecognitionAvailable: jest.fn(() => true),
|
|
10
|
+
requestPermissionsAsync: jest.fn(async () => ({ granted: true })),
|
|
11
|
+
addListener: jest.fn((event: string, fn: (e: unknown) => void) => {
|
|
12
|
+
(listeners[event] ??= []).push(fn);
|
|
13
|
+
return { remove: () => (listeners[event] = (listeners[event] ?? []).filter((f) => f !== fn)) };
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
let linked = true;
|
|
17
|
+
jest.mock('expo-modules-core', () => ({ requireOptionalNativeModule: () => (linked ? speech : null) }), {
|
|
18
|
+
virtual: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// A tiny hook runner: React's hooks with refs/state kept between calls.
|
|
22
|
+
jest.mock(
|
|
23
|
+
'react',
|
|
24
|
+
() => {
|
|
25
|
+
const slots: unknown[] = [];
|
|
26
|
+
let i = 0;
|
|
27
|
+
return {
|
|
28
|
+
__reset: () => {
|
|
29
|
+
i = 0;
|
|
30
|
+
},
|
|
31
|
+
useState: (init: unknown) => {
|
|
32
|
+
const k = i++;
|
|
33
|
+
if (!(k in slots)) slots[k] = init;
|
|
34
|
+
return [slots[k], (v: unknown) => (slots[k] = v)];
|
|
35
|
+
},
|
|
36
|
+
useRef: (init: unknown) => {
|
|
37
|
+
const k = i++;
|
|
38
|
+
if (!(k in slots)) slots[k] = { current: init };
|
|
39
|
+
return slots[k];
|
|
40
|
+
},
|
|
41
|
+
useCallback: (fn: unknown) => fn,
|
|
42
|
+
useEffect: () => undefined,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
{ virtual: true },
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line import/first
|
|
49
|
+
import { dictationAvailable, levelOf, useDictation } from '../chat/useDictation';
|
|
50
|
+
|
|
51
|
+
const emit = (event: string, e: unknown) => (listeners[event] ?? []).forEach((fn) => fn(e));
|
|
52
|
+
|
|
53
|
+
describe('useDictation', () => {
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
linked = true;
|
|
56
|
+
Object.keys(listeners).forEach((k) => delete listeners[k]);
|
|
57
|
+
jest.clearAllMocks();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('is unavailable on a binary without the speech module', () => {
|
|
61
|
+
linked = false;
|
|
62
|
+
|
|
63
|
+
expect(dictationAvailable()).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('adds what is said to what was already typed, live', async () => {
|
|
67
|
+
const onText = jest.fn();
|
|
68
|
+
const d = useDictation({ onText, onProblem: jest.fn() });
|
|
69
|
+
await d.start('Call the dentist ');
|
|
70
|
+
|
|
71
|
+
expect(speech.start).toHaveBeenCalledWith(expect.objectContaining({ interimResults: true }));
|
|
72
|
+
|
|
73
|
+
emit('result', { results: [{ transcript: 'on Thursday' }] });
|
|
74
|
+
|
|
75
|
+
expect(onText).toHaveBeenLastCalledWith('Call the dentist on Thursday');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('keeps every part of a long message on Android, not just the last sentence', async () => {
|
|
79
|
+
const onText = jest.fn();
|
|
80
|
+
await useDictation({ onText, onProblem: jest.fn() }).start('');
|
|
81
|
+
// Android 13+ listens in parts: each final closes one, and what follows covers only the new words.
|
|
82
|
+
emit('result', { isFinal: false, results: [{ transcript: 'Book a table' }] });
|
|
83
|
+
emit('result', { isFinal: true, results: [{ transcript: 'Book a table for four.' }] });
|
|
84
|
+
|
|
85
|
+
expect(onText).toHaveBeenLastCalledWith('Book a table for four.');
|
|
86
|
+
|
|
87
|
+
emit('result', { isFinal: false, results: [{ transcript: 'Somewhere' }] });
|
|
88
|
+
|
|
89
|
+
expect(onText).toHaveBeenLastCalledWith('Book a table for four. Somewhere');
|
|
90
|
+
|
|
91
|
+
emit('result', { isFinal: true, results: [{ transcript: 'Somewhere quiet.' }] });
|
|
92
|
+
emit('result', { isFinal: false, results: [{ transcript: 'Friday at seven' }] });
|
|
93
|
+
|
|
94
|
+
expect(onText).toHaveBeenLastCalledWith('Book a table for four. Somewhere quiet. Friday at seven');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('keeps what was typed first, then every spoken part', async () => {
|
|
98
|
+
const onText = jest.fn();
|
|
99
|
+
await useDictation({ onText, onProblem: jest.fn() }).start('Remind me:');
|
|
100
|
+
emit('result', { isFinal: true, results: [{ transcript: 'call mum.' }] });
|
|
101
|
+
emit('result', { isFinal: true, results: [{ transcript: 'Buy milk.' }] });
|
|
102
|
+
|
|
103
|
+
expect(onText).toHaveBeenLastCalledWith('Remind me: call mum. Buy milk.');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("reads iOS 18's parts, each starting with a space, the same way", async () => {
|
|
107
|
+
const onText = jest.fn();
|
|
108
|
+
await useDictation({ onText, onProblem: jest.fn() }).start('');
|
|
109
|
+
emit('result', { isFinal: true, results: [{ transcript: 'First part.' }] });
|
|
110
|
+
emit('result', { isFinal: false, results: [{ transcript: ' Second' }] });
|
|
111
|
+
emit('result', { isFinal: true, results: [{ transcript: ' Second part.' }] });
|
|
112
|
+
// iOS 18 then closes with an empty final: nothing changes.
|
|
113
|
+
emit('result', { isFinal: true, results: [] });
|
|
114
|
+
|
|
115
|
+
expect(onText).toHaveBeenLastCalledWith('First part. Second part.');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('reads one growing transcript and its single final (iOS before 18)', async () => {
|
|
119
|
+
const onText = jest.fn();
|
|
120
|
+
await useDictation({ onText, onProblem: jest.fn() }).start('');
|
|
121
|
+
emit('result', { isFinal: false, results: [{ transcript: 'Pick up' }] });
|
|
122
|
+
emit('result', { isFinal: false, results: [{ transcript: 'Pick up the dry cleaning.' }] });
|
|
123
|
+
emit('result', { isFinal: false, results: [{ transcript: 'Pick up the dry cleaning. Then the kids.' }] });
|
|
124
|
+
emit('result', { isFinal: true, results: [{ transcript: 'Pick up the dry cleaning. Then the kids.' }] });
|
|
125
|
+
|
|
126
|
+
expect(onText).toHaveBeenLastCalledWith('Pick up the dry cleaning. Then the kids.');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('starts afresh each time it listens', async () => {
|
|
130
|
+
const onText = jest.fn();
|
|
131
|
+
const d = useDictation({ onText, onProblem: jest.fn() });
|
|
132
|
+
await d.start('');
|
|
133
|
+
emit('result', { isFinal: true, results: [{ transcript: 'Old words.' }] });
|
|
134
|
+
await d.start('Typed.');
|
|
135
|
+
emit('result', { isFinal: false, results: [{ transcript: 'New words' }] });
|
|
136
|
+
|
|
137
|
+
expect(onText).toHaveBeenLastCalledWith('Typed. New words');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('asks for Settings when permission is refused, and does not listen', async () => {
|
|
141
|
+
speech.requestPermissionsAsync.mockResolvedValueOnce({ granted: false });
|
|
142
|
+
const onProblem = jest.fn();
|
|
143
|
+
await useDictation({ onText: jest.fn(), onProblem }).start('');
|
|
144
|
+
|
|
145
|
+
expect(onProblem).toHaveBeenCalledWith('denied');
|
|
146
|
+
expect(speech.start).not.toHaveBeenCalled();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('treats silence as the end, not a failure', async () => {
|
|
150
|
+
const onProblem = jest.fn();
|
|
151
|
+
await useDictation({ onText: jest.fn(), onProblem }).start('');
|
|
152
|
+
emit('error', { error: 'no-speech' });
|
|
153
|
+
|
|
154
|
+
expect(onProblem).not.toHaveBeenCalled();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('hears how loud the voice is when asked, and falls to nothing when listening ends', async () => {
|
|
158
|
+
const onLevel = jest.fn();
|
|
159
|
+
await useDictation({ onText: jest.fn(), onProblem: jest.fn(), onLevel }).start('');
|
|
160
|
+
|
|
161
|
+
expect(speech.start).toHaveBeenCalledWith(
|
|
162
|
+
expect.objectContaining({ volumeChangeEventOptions: { enabled: true, intervalMillis: 100 } }),
|
|
163
|
+
);
|
|
164
|
+
emit('volumechange', { value: 4.25 });
|
|
165
|
+
expect(onLevel).toHaveBeenLastCalledWith(0.5);
|
|
166
|
+
emit('end', {});
|
|
167
|
+
expect(onLevel).toHaveBeenLastCalledWith(0);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('leaves loudness off unless asked', async () => {
|
|
171
|
+
await useDictation({ onText: jest.fn(), onProblem: jest.fn() }).start('');
|
|
172
|
+
|
|
173
|
+
expect(speech.start).toHaveBeenCalledWith(
|
|
174
|
+
expect.not.objectContaining({ volumeChangeEventOptions: expect.anything() }),
|
|
175
|
+
);
|
|
176
|
+
expect(listeners.volumechange ?? []).toHaveLength(0);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('reads loudness as nothing for silence, about half for speech and at most full', () => {
|
|
180
|
+
expect(levelOf(-2)).toBe(0);
|
|
181
|
+
expect(levelOf(undefined)).toBe(0);
|
|
182
|
+
expect(levelOf(Number.NaN)).toBe(0);
|
|
183
|
+
expect(levelOf(4.25)).toBe(0.5);
|
|
184
|
+
expect(levelOf(10)).toBe(1);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// Clockbook's haptic language (welcome/haptics.ts), with expo-haptics and the platform stubbed so its rules run in
|
|
2
|
+
// node: what each feel plays, the gap between them, ticks kept to the iPhone, and when the schedules land.
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';
|
|
4
|
+
|
|
5
|
+
type Haptics = typeof import('../welcome/haptics');
|
|
6
|
+
|
|
7
|
+
const mockPlayed: { kind: string; at: number }[] = [];
|
|
8
|
+
const mockHaptics = {
|
|
9
|
+
ImpactFeedbackStyle: { Light: 'light', Medium: 'medium', Heavy: 'heavy', Soft: 'soft', Rigid: 'rigid' },
|
|
10
|
+
NotificationFeedbackType: { Success: 'success', Warning: 'warning', Error: 'error' },
|
|
11
|
+
selectionAsync: jest.fn(async () => {
|
|
12
|
+
mockPlayed.push({ kind: 'tick', at: Date.now() });
|
|
13
|
+
}),
|
|
14
|
+
impactAsync: jest.fn(async (style: string) => {
|
|
15
|
+
mockPlayed.push({ kind: style, at: Date.now() });
|
|
16
|
+
}),
|
|
17
|
+
notificationAsync: jest.fn(async (type: string) => {
|
|
18
|
+
mockPlayed.push({ kind: type, at: Date.now() });
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
const mockPlatform = { OS: 'ios' };
|
|
22
|
+
const mockVibration = { vibrate: jest.fn(), cancel: jest.fn() };
|
|
23
|
+
let mockLinked = true;
|
|
24
|
+
|
|
25
|
+
jest.mock('expo-modules-core', () => ({ requireOptionalNativeModule: () => (mockLinked ? {} : null) }), {
|
|
26
|
+
virtual: true,
|
|
27
|
+
});
|
|
28
|
+
jest.mock('expo-haptics', () => mockHaptics, { virtual: true });
|
|
29
|
+
jest.mock('react-native', () => ({ Platform: mockPlatform, Vibration: mockVibration }), { virtual: true });
|
|
30
|
+
|
|
31
|
+
const START = 1_000_000;
|
|
32
|
+
|
|
33
|
+
/** A fresh copy of the module, so the gap between haptics starts clear in every test. */
|
|
34
|
+
function fresh(): Haptics {
|
|
35
|
+
let mod: Haptics | undefined;
|
|
36
|
+
jest.isolateModules(() => {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
38
|
+
mod = require('../welcome/haptics') as Haptics;
|
|
39
|
+
});
|
|
40
|
+
return mod as Haptics;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** What played, and when (ms into the test). */
|
|
44
|
+
const played = () => mockPlayed.map((p) => `${p.kind}@${p.at - START}`);
|
|
45
|
+
const tickTimes = () => mockPlayed.filter((p) => p.kind === 'tick').map((p) => p.at - START);
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
jest.useFakeTimers({ now: START });
|
|
49
|
+
mockPlayed.length = 0;
|
|
50
|
+
mockPlatform.OS = 'ios';
|
|
51
|
+
mockLinked = true;
|
|
52
|
+
mockVibration.vibrate.mockClear();
|
|
53
|
+
mockVibration.cancel.mockClear();
|
|
54
|
+
});
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
jest.useRealTimers();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('the haptic language', () => {
|
|
60
|
+
it('plays each feel through expo-haptics: tap light, click rigid, release soft, thud medium', () => {
|
|
61
|
+
const h = fresh();
|
|
62
|
+
h.tap();
|
|
63
|
+
jest.advanceTimersByTime(50);
|
|
64
|
+
h.click();
|
|
65
|
+
jest.advanceTimersByTime(50);
|
|
66
|
+
h.release();
|
|
67
|
+
jest.advanceTimersByTime(50);
|
|
68
|
+
h.thud();
|
|
69
|
+
jest.advanceTimersByTime(50);
|
|
70
|
+
h.success();
|
|
71
|
+
jest.advanceTimersByTime(50);
|
|
72
|
+
h.tick();
|
|
73
|
+
expect(played()).toEqual(['light@0', 'rigid@50', 'soft@100', 'medium@150', 'success@200', 'tick@250']);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('never plays two within GAP_MS of each other, unless the newer is stronger', () => {
|
|
77
|
+
const h = fresh();
|
|
78
|
+
h.tap();
|
|
79
|
+
h.tap();
|
|
80
|
+
h.tick();
|
|
81
|
+
h.thud();
|
|
82
|
+
jest.advanceTimersByTime(h.GAP_MS - 1);
|
|
83
|
+
h.tap();
|
|
84
|
+
jest.advanceTimersByTime(1);
|
|
85
|
+
h.tap();
|
|
86
|
+
expect(played()).toEqual(['light@0', 'medium@0', `light@${h.GAP_MS}`]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('keeps ticks to the iPhone: on Android they would be motor buzzes, so only presses and landings play', () => {
|
|
90
|
+
mockPlatform.OS = 'android';
|
|
91
|
+
const h = fresh();
|
|
92
|
+
h.tick();
|
|
93
|
+
h.ticks(14, 75, 60);
|
|
94
|
+
h.writing(12, 62);
|
|
95
|
+
h.reel(6, 2400, 1300, (t) => t);
|
|
96
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
97
|
+
h.tap();
|
|
98
|
+
jest.advanceTimersByTime(100);
|
|
99
|
+
h.thud();
|
|
100
|
+
expect(played()).toEqual(['light@0', 'medium@100']);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("feels Lucy's writing every third word, at most four times a line", () => {
|
|
104
|
+
const h = fresh();
|
|
105
|
+
h.writing(14, 62, 120);
|
|
106
|
+
jest.advanceTimersByTime(2000);
|
|
107
|
+
expect(tickTimes()).toEqual([120, 306, 492, 678]);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('starts a short line with a tick and adds one every third word', () => {
|
|
111
|
+
const h = fresh();
|
|
112
|
+
h.writing(5, 62);
|
|
113
|
+
jest.advanceTimersByTime(1000);
|
|
114
|
+
expect(tickTimes()).toEqual([0, 186]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('ticks as a reel passes each row, slowing as it slows, and leaves the landing to the thud', () => {
|
|
118
|
+
const h = fresh();
|
|
119
|
+
const easeOut = (t: number) => 1 - (1 - t) ** 3;
|
|
120
|
+
h.reel(6, 2400, 1300, easeOut);
|
|
121
|
+
jest.advanceTimersByTime(5000);
|
|
122
|
+
const at = tickTimes();
|
|
123
|
+
expect(at).toHaveLength(5);
|
|
124
|
+
expect(at[0]).toBeGreaterThan(1300);
|
|
125
|
+
expect(at[4]).toBeLessThan(1300 + 2400);
|
|
126
|
+
const gaps = at.slice(1).map((t, i) => t - at[i]);
|
|
127
|
+
gaps.slice(1).forEach((gap, i) => expect(gap).toBeGreaterThan(gaps[i]));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('finds when an easing reaches a point', () => {
|
|
131
|
+
const h = fresh();
|
|
132
|
+
expect(h.reach((t) => t, 0.5)).toBeCloseTo(0.5, 5);
|
|
133
|
+
expect(h.reach((t) => t * t, 0.25)).toBeCloseTo(0.5, 5);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('cancels the ticks still to come', () => {
|
|
137
|
+
const h = fresh();
|
|
138
|
+
const stop = h.ticks(4, 100);
|
|
139
|
+
jest.advanceTimersByTime(150);
|
|
140
|
+
stop();
|
|
141
|
+
jest.advanceTimersByTime(1000);
|
|
142
|
+
expect(tickTimes()).toEqual([0, 100]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('stays silent, without failing, in a build without expo-haptics', () => {
|
|
146
|
+
mockLinked = false;
|
|
147
|
+
const h = fresh();
|
|
148
|
+
expect(() => {
|
|
149
|
+
h.tap();
|
|
150
|
+
h.thud();
|
|
151
|
+
h.success();
|
|
152
|
+
h.tick();
|
|
153
|
+
}).not.toThrow();
|
|
154
|
+
expect(played()).toEqual([]);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('plays the power-on as written: taps building to heavy, a click, a burst of heavy hits, then the heartbeat', () => {
|
|
158
|
+
const h = fresh();
|
|
159
|
+
h.powerOn();
|
|
160
|
+
jest.advanceTimersByTime(2000);
|
|
161
|
+
expect(played()).toEqual([
|
|
162
|
+
'light@0',
|
|
163
|
+
'light@160',
|
|
164
|
+
'light@300',
|
|
165
|
+
'medium@420',
|
|
166
|
+
'medium@520',
|
|
167
|
+
'medium@605',
|
|
168
|
+
'heavy@675',
|
|
169
|
+
'heavy@735',
|
|
170
|
+
'heavy@785',
|
|
171
|
+
'heavy@830',
|
|
172
|
+
'rigid@900',
|
|
173
|
+
'heavy@1000',
|
|
174
|
+
'heavy@1025',
|
|
175
|
+
'heavy@1050',
|
|
176
|
+
'heavy@1075',
|
|
177
|
+
'heavy@1100',
|
|
178
|
+
'heavy@1250',
|
|
179
|
+
'medium@1450',
|
|
180
|
+
]);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("gives Android full-strength buzzes on the click, the thoom and the heartbeat, through React Native's Vibration", () => {
|
|
184
|
+
mockPlatform.OS = 'android';
|
|
185
|
+
const h = fresh();
|
|
186
|
+
const stop = h.powerOn();
|
|
187
|
+
expect(mockVibration.vibrate).toHaveBeenCalledWith([900, 40, 60, 140, 110, 60, 140, 45]);
|
|
188
|
+
jest.advanceTimersByTime(2000);
|
|
189
|
+
expect(played()).toEqual([]);
|
|
190
|
+
stop();
|
|
191
|
+
expect(mockVibration.cancel).toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('stops the power-on where it is when it is skipped', () => {
|
|
195
|
+
const h = fresh();
|
|
196
|
+
const stop = h.powerOn();
|
|
197
|
+
jest.advanceTimersByTime(950);
|
|
198
|
+
stop();
|
|
199
|
+
jest.advanceTimersByTime(2000);
|
|
200
|
+
expect(played()).toHaveLength(11);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// jobs.ts posts to Yantra's backend with Lucy's token: stub the auth helpers and fetch for node.
|
|
2
|
+
jest.mock('../chat/auth', () => ({
|
|
3
|
+
agentBackendUrl: async () => 'https://backend/graphql',
|
|
4
|
+
getChatToken: async () => 'token',
|
|
5
|
+
}));
|
|
6
|
+
jest.mock('../chat/chores', () => ({
|
|
7
|
+
CLOCKBOOK_SURFACE: 'clockbook',
|
|
8
|
+
rememberChore: async () => undefined,
|
|
9
|
+
noteChoreVerdict: async () => undefined,
|
|
10
|
+
setChoreProgress: () => undefined,
|
|
11
|
+
}));
|
|
12
|
+
// This phone's tokens: the push token it registered, and the card token each chore's Lock Screen card reported.
|
|
13
|
+
const phone = {
|
|
14
|
+
pushToken: null as string | null,
|
|
15
|
+
cards: new Map<string, string>(),
|
|
16
|
+
cardListeners: [] as ((chore: string, token: string) => void)[],
|
|
17
|
+
};
|
|
18
|
+
jest.mock('../push/push', () => ({ registeredPushToken: () => phone.pushToken }));
|
|
19
|
+
jest.mock('../live/liveActivity', () => ({
|
|
20
|
+
cardTokenFor: async (chore: string) => phone.cards.get(chore),
|
|
21
|
+
onCardToken: (l: (chore: string, token: string) => void) => {
|
|
22
|
+
phone.cardListeners.push(l);
|
|
23
|
+
return () => undefined;
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line import/first
|
|
28
|
+
import { choreTitle, readChore, recordChore, settleChore } from '../chat/jobs';
|
|
29
|
+
|
|
30
|
+
type Body = { query: string; variables: Record<string, any> };
|
|
31
|
+
let bodies: Body[] = [];
|
|
32
|
+
const answer = (data: unknown) => ({ ok: true, status: 200, json: async () => ({ data }) });
|
|
33
|
+
|
|
34
|
+
function stubFetch(reply: (body: Body) => unknown) {
|
|
35
|
+
bodies = [];
|
|
36
|
+
(globalThis as { fetch: unknown }).fetch = jest.fn(async (_url: string, init: { body: string }) => {
|
|
37
|
+
const body = JSON.parse(init.body) as Body;
|
|
38
|
+
bodies.push(body);
|
|
39
|
+
return reply(body);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('chore records', () => {
|
|
44
|
+
it('records a message as a running Clockbook chore and hands back the job the agent reports to', async () => {
|
|
45
|
+
stubFetch(() => answer({ recordSurfaceJob: { id: 'r1', status: 'IN_PROGRESS', reportToken: 'tok' } }));
|
|
46
|
+
const rec = await recordChore({ id: 'm1', prompt: 'Book my dentist for Thursday', sessionId: 's1' }).now;
|
|
47
|
+
expect(rec).toEqual({ remoteId: 'r1', job: { task_id: 'r1', report_token: 'tok' } });
|
|
48
|
+
const job = bodies[0].variables.job;
|
|
49
|
+
expect(bodies[0].query).toContain('recordSurfaceJob');
|
|
50
|
+
expect(job).toMatchObject({
|
|
51
|
+
id: 'm1',
|
|
52
|
+
surface: 'clockbook',
|
|
53
|
+
lane: 'chore',
|
|
54
|
+
state: 'running',
|
|
55
|
+
title: 'Book my dentist for Thursday',
|
|
56
|
+
brief: 'Book my dentist for Thursday',
|
|
57
|
+
handle: { sessionId: 's1' },
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('goes without a record when the backend refuses', async () => {
|
|
62
|
+
stubFetch(() => ({ ok: false, status: 400, json: async () => ({ errors: [{ message: 'nope' }] }) }));
|
|
63
|
+
await expect(recordChore({ id: 'm2', prompt: 'x' }).now).resolves.toBeNull();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('reads a finished chore with what Lucy said', async () => {
|
|
67
|
+
stubFetch(() =>
|
|
68
|
+
answer({
|
|
69
|
+
getSurfaceJob: { status: 'COMPLETED', source: { details: { result: { text: 'Booked, 3 pm.' } } } },
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
await expect(readChore('r1')).resolves.toEqual({ state: 'succeeded', text: 'Booked, 3 pm.' });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('reads a running and a failed chore', async () => {
|
|
76
|
+
stubFetch(() => answer({ getSurfaceJob: { status: 'IN_PROGRESS', source: { details: {} } } }));
|
|
77
|
+
await expect(readChore('r1')).resolves.toEqual({ state: 'running' });
|
|
78
|
+
stubFetch(() => answer({ getSurfaceJob: { status: 'BLOCKED', source: { details: { error: 'No slot' } } } }));
|
|
79
|
+
await expect(readChore('r1')).resolves.toEqual({ state: 'failed', error: 'No slot' });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('marks a placed reply delivered when it settles', async () => {
|
|
83
|
+
stubFetch(() => answer({ updateSurfaceJob: true }));
|
|
84
|
+
await settleChore('r1', { state: 'succeeded' });
|
|
85
|
+
expect(bodies[0].variables).toMatchObject({ id: 'r1', patch: { state: 'succeeded', delivered: true } });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('titles a chore by its first line', () => {
|
|
89
|
+
expect(choreTitle('**Cancel** my gym\nthey say call')).toBe('Cancel my gym');
|
|
90
|
+
expect(choreTitle(' ')).toBe('A chore for Lucy');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('names this phone on the record: its registered push token, and the chore card’s token when it has one', async () => {
|
|
94
|
+
phone.pushToken = 'ExponentPushToken[phone-1]';
|
|
95
|
+
phone.cards.set('board-1', 'ab'.repeat(32));
|
|
96
|
+
stubFetch(() => answer({ recordSurfaceJob: { id: 'job-1', status: 'IN_PROGRESS' } }));
|
|
97
|
+
await recordChore({ id: 'reply-1', prompt: 'Call Luigi', board: 'board-1' }).now;
|
|
98
|
+
expect(bodies[0].variables.job).toMatchObject({
|
|
99
|
+
pushToken: 'ExponentPushToken[phone-1]',
|
|
100
|
+
cardToken: 'ab'.repeat(32),
|
|
101
|
+
handle: { boardId: 'board-1' },
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('a phone not registered for push, or a card with no token yet, is left off', async () => {
|
|
106
|
+
phone.pushToken = null;
|
|
107
|
+
phone.cards.clear();
|
|
108
|
+
stubFetch(() => answer({ recordSurfaceJob: { id: 'job-2', status: 'IN_PROGRESS' } }));
|
|
109
|
+
await recordChore({ id: 'reply-2', prompt: 'Hi' }).now;
|
|
110
|
+
expect(bodies[0].variables.job).not.toHaveProperty('pushToken');
|
|
111
|
+
expect(bodies[0].variables.job).not.toHaveProperty('cardToken');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('a card token reported after the record was written is put on that chore’s records', async () => {
|
|
115
|
+
phone.cards.clear();
|
|
116
|
+
stubFetch((body) =>
|
|
117
|
+
body.query.includes('recordSurfaceJob')
|
|
118
|
+
? answer({ recordSurfaceJob: { id: 'job-3', status: 'IN_PROGRESS' } })
|
|
119
|
+
: answer({ updateSurfaceJob: true }),
|
|
120
|
+
);
|
|
121
|
+
await recordChore({ id: 'reply-3', prompt: 'Find flights', board: 'board-3' }).now;
|
|
122
|
+
phone.cardListeners.forEach((l) => l('board-3', 'cd'.repeat(32)));
|
|
123
|
+
phone.cardListeners.forEach((l) => l('board-other', 'ef'.repeat(32)));
|
|
124
|
+
await new Promise((r) => {
|
|
125
|
+
setImmediate(r);
|
|
126
|
+
});
|
|
127
|
+
const patches = bodies.filter((b) => b.query.includes('updateSurfaceJob')).map((b) => b.variables);
|
|
128
|
+
expect(patches).toEqual([{ id: 'job-3', patch: { cardToken: 'cd'.repeat(32) } }]);
|
|
129
|
+
});
|
|
130
|
+
});
|