@elizaos/app-core 2.0.0-alpha.10
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/LICENSE +21 -0
- package/package.json +90 -0
- package/src/App.tsx +472 -0
- package/src/actions/character.test.ts +139 -0
- package/src/actions/character.ts +152 -0
- package/src/actions/chat-helpers.ts +100 -0
- package/src/actions/cloud.ts +59 -0
- package/src/actions/index.ts +12 -0
- package/src/actions/lifecycle.ts +175 -0
- package/src/actions/onboarding.ts +46 -0
- package/src/actions/triggers.ts +190 -0
- package/src/ambient.d.ts +16 -0
- package/src/api/client.ts +5516 -0
- package/src/api/index.ts +1 -0
- package/src/autonomy/index.ts +477 -0
- package/src/bridge/capacitor-bridge.ts +295 -0
- package/src/bridge/electrobun-rpc.ts +58 -0
- package/src/bridge/electrobun-runtime.ts +28 -0
- package/src/bridge/index.ts +5 -0
- package/src/bridge/native-plugins.ts +134 -0
- package/src/bridge/plugin-bridge.ts +352 -0
- package/src/bridge/storage-bridge.ts +162 -0
- package/src/chat/index.ts +250 -0
- package/src/coding/index.ts +43 -0
- package/src/components/AdvancedPageView.tsx +362 -0
- package/src/components/AgentActivityBox.tsx +49 -0
- package/src/components/ApiKeyConfig.tsx +224 -0
- package/src/components/AppsPageView.tsx +52 -0
- package/src/components/AppsView.tsx +293 -0
- package/src/components/AvatarLoader.tsx +86 -0
- package/src/components/AvatarSelector.tsx +223 -0
- package/src/components/BscTradePanel.tsx +549 -0
- package/src/components/BugReportModal.tsx +499 -0
- package/src/components/CharacterView.tsx +1645 -0
- package/src/components/ChatAvatar.test.ts +96 -0
- package/src/components/ChatAvatar.tsx +147 -0
- package/src/components/ChatComposer.tsx +330 -0
- package/src/components/ChatMessage.tsx +448 -0
- package/src/components/ChatModalView.test.tsx +118 -0
- package/src/components/ChatModalView.tsx +125 -0
- package/src/components/ChatView.tsx +992 -0
- package/src/components/CloudSourceControls.tsx +80 -0
- package/src/components/CodingAgentSettingsSection.tsx +536 -0
- package/src/components/CommandPalette.tsx +284 -0
- package/src/components/CompanionSceneHost.tsx +497 -0
- package/src/components/CompanionShell.tsx +31 -0
- package/src/components/CompanionView.tsx +109 -0
- package/src/components/ConfigPageView.tsx +758 -0
- package/src/components/ConfigSaveFooter.tsx +41 -0
- package/src/components/ConfirmModal.tsx +379 -0
- package/src/components/ConnectionFailedBanner.tsx +91 -0
- package/src/components/ConnectorsPageView.tsx +13 -0
- package/src/components/ConversationsSidebar.tsx +279 -0
- package/src/components/CustomActionEditor.tsx +1125 -0
- package/src/components/CustomActionsPanel.tsx +288 -0
- package/src/components/CustomActionsView.tsx +322 -0
- package/src/components/DatabasePageView.tsx +55 -0
- package/src/components/DatabaseView.tsx +814 -0
- package/src/components/ElizaCloudDashboard.tsx +1696 -0
- package/src/components/EmotePicker.tsx +529 -0
- package/src/components/ErrorBoundary.tsx +76 -0
- package/src/components/FineTuningView.tsx +1077 -0
- package/src/components/GameView.tsx +552 -0
- package/src/components/GameViewOverlay.tsx +133 -0
- package/src/components/GlobalEmoteOverlay.tsx +155 -0
- package/src/components/Header.test.tsx +413 -0
- package/src/components/Header.tsx +403 -0
- package/src/components/HeartbeatsView.tsx +1003 -0
- package/src/components/InventoryView.tsx +385 -0
- package/src/components/KnowledgeView.tsx +1128 -0
- package/src/components/LanguageDropdown.tsx +188 -0
- package/src/components/LifoMonitorPanel.tsx +196 -0
- package/src/components/LifoSandboxView.tsx +499 -0
- package/src/components/LoadingScreen.tsx +77 -0
- package/src/components/LogsPageView.tsx +17 -0
- package/src/components/LogsView.tsx +239 -0
- package/src/components/MediaGalleryView.tsx +433 -0
- package/src/components/MediaSettingsSection.tsx +893 -0
- package/src/components/MessageContent.tsx +815 -0
- package/src/components/OnboardingWizard.test.tsx +107 -0
- package/src/components/OnboardingWizard.tsx +189 -0
- package/src/components/PairingView.tsx +110 -0
- package/src/components/PermissionsSection.tsx +1186 -0
- package/src/components/PluginsPageView.tsx +9 -0
- package/src/components/PluginsView.tsx +3157 -0
- package/src/components/ProviderSwitcher.tsx +908 -0
- package/src/components/RestartBanner.tsx +76 -0
- package/src/components/RuntimeView.tsx +460 -0
- package/src/components/SaveCommandModal.tsx +211 -0
- package/src/components/SecretsView.tsx +569 -0
- package/src/components/SettingsView.tsx +825 -0
- package/src/components/ShellOverlays.tsx +41 -0
- package/src/components/ShortcutsOverlay.tsx +155 -0
- package/src/components/SkillsView.tsx +1435 -0
- package/src/components/StartupFailureView.tsx +63 -0
- package/src/components/StreamView.tsx +483 -0
- package/src/components/StripeEmbeddedCheckout.tsx +155 -0
- package/src/components/SubscriptionStatus.tsx +640 -0
- package/src/components/SystemWarningBanner.tsx +71 -0
- package/src/components/ThemeToggle.tsx +100 -0
- package/src/components/TrajectoriesView.tsx +526 -0
- package/src/components/TrajectoryDetailView.tsx +426 -0
- package/src/components/TriggersView.tsx +1 -0
- package/src/components/VectorBrowserView.tsx +1633 -0
- package/src/components/VoiceConfigView.tsx +675 -0
- package/src/components/VrmStage.test.ts +219 -0
- package/src/components/VrmStage.tsx +432 -0
- package/src/components/WhatsAppQrOverlay.tsx +230 -0
- package/src/components/__tests__/chainConfig.test.ts +220 -0
- package/src/components/apps/AppDetailPane.tsx +242 -0
- package/src/components/apps/AppsCatalogGrid.tsx +137 -0
- package/src/components/apps/extensions/HyperscapeAppDetailPanel.tsx +577 -0
- package/src/components/apps/extensions/registry.ts +16 -0
- package/src/components/apps/extensions/types.ts +9 -0
- package/src/components/apps/helpers.ts +44 -0
- package/src/components/avatar/VrmAnimationLoader.test.ts +164 -0
- package/src/components/avatar/VrmAnimationLoader.ts +151 -0
- package/src/components/avatar/VrmBlinkController.ts +118 -0
- package/src/components/avatar/VrmCameraManager.ts +407 -0
- package/src/components/avatar/VrmEngine.ts +2678 -0
- package/src/components/avatar/VrmFootShadow.ts +96 -0
- package/src/components/avatar/VrmViewer.tsx +421 -0
- package/src/components/avatar/__tests__/VrmCameraManager.test.ts +168 -0
- package/src/components/avatar/__tests__/VrmEngine.test.ts +1574 -0
- package/src/components/avatar/mixamoVRMRigMap.ts +62 -0
- package/src/components/avatar/retargetMixamoFbxToVrm.ts +144 -0
- package/src/components/avatar/retargetMixamoGltfToVrm.ts +119 -0
- package/src/components/chainConfig.ts +380 -0
- package/src/components/companion/CompanionHeader.tsx +47 -0
- package/src/components/companion/CompanionSceneHost.tsx +1 -0
- package/src/components/companion/VrmStage.tsx +2 -0
- package/src/components/companion/__tests__/walletUtils.test.ts +742 -0
- package/src/components/companion/walletUtils.ts +290 -0
- package/src/components/companion-shell-styles.test.ts +142 -0
- package/src/components/companion-shell-styles.ts +270 -0
- package/src/components/confirm-delete-control.tsx +69 -0
- package/src/components/conversations/ConversationListItem.tsx +185 -0
- package/src/components/conversations/conversation-utils.ts +151 -0
- package/src/components/format.ts +131 -0
- package/src/components/index.ts +94 -0
- package/src/components/inventory/CopyableAddress.tsx +41 -0
- package/src/components/inventory/InventoryToolbar.tsx +142 -0
- package/src/components/inventory/NftGrid.tsx +99 -0
- package/src/components/inventory/TokenLogo.tsx +71 -0
- package/src/components/inventory/TokensTable.tsx +216 -0
- package/src/components/inventory/constants.ts +170 -0
- package/src/components/inventory/index.ts +29 -0
- package/src/components/inventory/media-url.test.ts +38 -0
- package/src/components/inventory/media-url.ts +36 -0
- package/src/components/inventory/useInventoryData.ts +460 -0
- package/src/components/knowledge-upload-image.ts +215 -0
- package/src/components/labels.ts +46 -0
- package/src/components/onboarding/ActivateStep.tsx +30 -0
- package/src/components/onboarding/ConnectionStep.tsx +1530 -0
- package/src/components/onboarding/IdentityStep.tsx +147 -0
- package/src/components/onboarding/OnboardingPanel.tsx +39 -0
- package/src/components/onboarding/OnboardingStepNav.tsx +31 -0
- package/src/components/onboarding/PermissionsStep.tsx +20 -0
- package/src/components/onboarding/RpcStep.tsx +402 -0
- package/src/components/onboarding/WakeUpStep.tsx +184 -0
- package/src/components/permissions/PermissionIcon.tsx +25 -0
- package/src/components/permissions/StreamingPermissions.tsx +413 -0
- package/src/components/plugins/showcase-data.ts +481 -0
- package/src/components/shared/ShellHeaderControls.tsx +193 -0
- package/src/components/shared-companion-scene-context.ts +15 -0
- package/src/components/skeletons.tsx +88 -0
- package/src/components/stream/ActivityFeed.tsx +113 -0
- package/src/components/stream/AvatarPip.tsx +10 -0
- package/src/components/stream/ChatContent.tsx +126 -0
- package/src/components/stream/ChatTicker.tsx +55 -0
- package/src/components/stream/IdleContent.tsx +73 -0
- package/src/components/stream/StatusBar.tsx +469 -0
- package/src/components/stream/StreamSettings.tsx +506 -0
- package/src/components/stream/StreamTerminal.tsx +94 -0
- package/src/components/stream/StreamVoiceConfig.tsx +160 -0
- package/src/components/stream/helpers.ts +134 -0
- package/src/components/stream/overlays/OverlayLayer.tsx +75 -0
- package/src/components/stream/overlays/built-in/ActionTickerWidget.tsx +64 -0
- package/src/components/stream/overlays/built-in/AlertPopupWidget.tsx +87 -0
- package/src/components/stream/overlays/built-in/BrandingWidget.tsx +51 -0
- package/src/components/stream/overlays/built-in/CustomHtmlWidget.tsx +105 -0
- package/src/components/stream/overlays/built-in/PeonGlassWidget.tsx +265 -0
- package/src/components/stream/overlays/built-in/PeonHudWidget.tsx +247 -0
- package/src/components/stream/overlays/built-in/PeonSakuraWidget.tsx +278 -0
- package/src/components/stream/overlays/built-in/ThoughtBubbleWidget.tsx +77 -0
- package/src/components/stream/overlays/built-in/ViewerCountWidget.tsx +46 -0
- package/src/components/stream/overlays/built-in/index.ts +13 -0
- package/src/components/stream/overlays/registry.ts +22 -0
- package/src/components/stream/overlays/types.ts +90 -0
- package/src/components/stream/overlays/useOverlayLayout.ts +218 -0
- package/src/components/trajectory-format.ts +50 -0
- package/src/components/ui-badges.tsx +109 -0
- package/src/components/ui-switch.tsx +57 -0
- package/src/components/vector-browser-three.ts +27 -0
- package/src/config/config-catalog.ts +1092 -0
- package/src/config/config-field.tsx +1901 -0
- package/src/config/config-renderer.tsx +730 -0
- package/src/config/index.ts +11 -0
- package/src/config/ui-renderer.tsx +1751 -0
- package/src/config/ui-spec.ts +256 -0
- package/src/events/index.ts +89 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useBugReport.tsx +43 -0
- package/src/hooks/useCanvasWindow.ts +372 -0
- package/src/hooks/useChatAvatarVoice.ts +111 -0
- package/src/hooks/useContextMenu.ts +127 -0
- package/src/hooks/useKeyboardShortcuts.ts +86 -0
- package/src/hooks/useLifoSync.ts +143 -0
- package/src/hooks/useMemoryMonitor.ts +334 -0
- package/src/hooks/useRenderGuard.ts +43 -0
- package/src/hooks/useRetakeCapture.ts +67 -0
- package/src/hooks/useStreamPopoutNavigation.ts +27 -0
- package/src/hooks/useTimeout.ts +37 -0
- package/src/hooks/useVoiceChat.ts +1441 -0
- package/src/hooks/useWhatsAppPairing.ts +123 -0
- package/src/i18n/index.ts +76 -0
- package/src/i18n/locales/en.json +1194 -0
- package/src/i18n/locales/es.json +1194 -0
- package/src/i18n/locales/ko.json +1194 -0
- package/src/i18n/locales/pt.json +1194 -0
- package/src/i18n/locales/zh-CN.json +1194 -0
- package/src/i18n/messages.ts +21 -0
- package/src/index.ts +6 -0
- package/src/navigation/index.ts +282 -0
- package/src/navigation.test.ts +189 -0
- package/src/onboarding-config.test.ts +104 -0
- package/src/onboarding-config.ts +114 -0
- package/src/platform/browser-launch.test.ts +94 -0
- package/src/platform/browser-launch.ts +149 -0
- package/src/platform/index.ts +58 -0
- package/src/platform/init.ts +236 -0
- package/src/platform/lifo.ts +215 -0
- package/src/providers/index.ts +99 -0
- package/src/state/AppContext.tsx +5846 -0
- package/src/state/index.ts +6 -0
- package/src/state/internal.ts +86 -0
- package/src/state/onboarding-resume.test.ts +135 -0
- package/src/state/onboarding-resume.ts +263 -0
- package/src/state/parsers.test.ts +124 -0
- package/src/state/parsers.ts +308 -0
- package/src/state/persistence.ts +321 -0
- package/src/state/shell-routing.ts +32 -0
- package/src/state/types.ts +701 -0
- package/src/state/ui-preferences.ts +3 -0
- package/src/state/useApp.ts +23 -0
- package/src/state/vrm.ts +76 -0
- package/src/stories/AppMockProvider.tsx +32 -0
- package/src/stories/ChatEmptyState.stories.tsx +27 -0
- package/src/stories/ChatMessage.stories.tsx +115 -0
- package/src/stories/CompanionHeader.stories.tsx +74 -0
- package/src/stories/CompanionView.stories.tsx +33 -0
- package/src/stories/ConversationListItem.stories.tsx +102 -0
- package/src/stories/TypingIndicator.stories.tsx +28 -0
- package/src/styles/anime.css +6324 -0
- package/src/styles/base.css +196 -0
- package/src/styles/onboarding-game.css +738 -0
- package/src/styles/styles.css +2087 -0
- package/src/styles/xterm.css +241 -0
- package/src/types/index.ts +715 -0
- package/src/types/react-test-renderer.d.ts +45 -0
- package/src/utils/asset-url.ts +110 -0
- package/src/utils/assistant-text.ts +172 -0
- package/src/utils/clipboard.ts +41 -0
- package/src/utils/desktop-dialogs.ts +80 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/number-parsing.ts +125 -0
- package/src/utils/openExternalUrl.ts +20 -0
- package/src/utils/spoken-text.ts +65 -0
- package/src/utils/streaming-text.ts +120 -0
- package/src/voice/index.ts +1 -0
- package/src/voice/types.ts +197 -0
- package/src/wallet-rpc.ts +176 -0
- package/test/app/AppContext.pty-sessions.test.tsx +143 -0
- package/test/app/MessageContent.test.tsx +326 -0
- package/test/app/PermissionsOnboarding.test.tsx +356 -0
- package/test/app/PermissionsSection.test.tsx +573 -0
- package/test/app/advanced-trajectory-fine-tuning.e2e.test.ts +393 -0
- package/test/app/agent-activity-box.test.tsx +132 -0
- package/test/app/agent-transfer-lock.test.ts +274 -0
- package/test/app/api-client-electron-fallback.test.ts +139 -0
- package/test/app/api-client-timeout.test.ts +75 -0
- package/test/app/api-client-ws.test.ts +98 -0
- package/test/app/api-client.ws-max-reconnect.test.ts +139 -0
- package/test/app/api-client.ws-reconnect.test.ts +157 -0
- package/test/app/app-context-autonomy-events.test.ts +478 -0
- package/test/app/apps-page-view.test.ts +114 -0
- package/test/app/apps-view.test.ts +769 -0
- package/test/app/autonomous-workflows.e2e.test.ts +765 -0
- package/test/app/autonomy-events.test.ts +150 -0
- package/test/app/avatar-selector.test.tsx +52 -0
- package/test/app/bsc-trade-panel.test.tsx +134 -0
- package/test/app/bug-report-modal.test.tsx +353 -0
- package/test/app/character-customization.e2e.test.ts +1199 -0
- package/test/app/chat-advanced-features.e2e.test.ts +706 -0
- package/test/app/chat-composer.test.tsx +181 -0
- package/test/app/chat-language-header.test.ts +64 -0
- package/test/app/chat-message.test.tsx +222 -0
- package/test/app/chat-modal-view.test.tsx +191 -0
- package/test/app/chat-routine-filter.test.ts +96 -0
- package/test/app/chat-send-lock.test.ts +1465 -0
- package/test/app/chat-stream-api-client.test.tsx +390 -0
- package/test/app/chat-view-game-modal.test.tsx +661 -0
- package/test/app/chat-view.test.tsx +877 -0
- package/test/app/cloud-api.e2e.test.ts +258 -0
- package/test/app/cloud-login-flow.e2e.test.ts +494 -0
- package/test/app/cloud-login-lock.test.ts +411 -0
- package/test/app/command-palette.test.tsx +184 -0
- package/test/app/command-registry.test.ts +75 -0
- package/test/app/companion-greeting-wave.test.tsx +425 -0
- package/test/app/companion-stale-conversation.test.tsx +447 -0
- package/test/app/companion-view.test.tsx +686 -0
- package/test/app/confirm-delete-control.test.ts +79 -0
- package/test/app/confirm-modal.test.tsx +219 -0
- package/test/app/connectors-ui.e2e.test.ts +508 -0
- package/test/app/conversations-sidebar-game-modal.test.tsx +260 -0
- package/test/app/conversations-sidebar.test.tsx +160 -0
- package/test/app/custom-actions-smoke.test.ts +387 -0
- package/test/app/custom-avatar-api-client.test.ts +207 -0
- package/test/app/desktop-utils.test.ts +145 -0
- package/test/app/electrobun-rpc-bridge.test.ts +83 -0
- package/test/app/events.test.ts +88 -0
- package/test/app/export-import-flows.e2e.test.ts +700 -0
- package/test/app/fine-tuning-view.test.ts +471 -0
- package/test/app/game-view-auth-session.test.tsx +186 -0
- package/test/app/game-view.test.ts +444 -0
- package/test/app/global-emote-overlay.test.tsx +106 -0
- package/test/app/header-status.test.tsx +149 -0
- package/test/app/i18n.test.ts +152 -0
- package/test/app/inventory-bsc-view.test.ts +940 -0
- package/test/app/knowledge-ui.e2e.test.ts +762 -0
- package/test/app/knowledge-upload-helpers.test.ts +124 -0
- package/test/app/lifecycle-lock.test.ts +267 -0
- package/test/app/lifo-popout-utils.test.ts +208 -0
- package/test/app/lifo-safe-endpoint.test.ts +34 -0
- package/test/app/loading-screen.test.tsx +45 -0
- package/test/app/memory-monitor.test.ts +332 -0
- package/test/app/navigation.test.tsx +22 -0
- package/test/app/onboarding-finish-lock.test.ts +663 -0
- package/test/app/onboarding-language.test.tsx +160 -0
- package/test/app/onboarding-steps.test.tsx +375 -0
- package/test/app/open-external-url.test.ts +65 -0
- package/test/app/pages-navigation-smoke.e2e.test.ts +633 -0
- package/test/app/pairing-lock.test.ts +260 -0
- package/test/app/pairing-view.test.tsx +74 -0
- package/test/app/permissions-section.test.ts +432 -0
- package/test/app/plugin-bridge.test.ts +109 -0
- package/test/app/plugins-ui.e2e.test.ts +605 -0
- package/test/app/plugins-view-game-modal.test.tsx +650 -0
- package/test/app/plugins-view-toggle-restart.test.ts +129 -0
- package/test/app/provider-dropdown-default.test.tsx +302 -0
- package/test/app/restart-banner.test.tsx +197 -0
- package/test/app/retake-capture.test.ts +84 -0
- package/test/app/sandbox-api-client.test.ts +108 -0
- package/test/app/save-command-modal.test.tsx +109 -0
- package/test/app/secrets-view.test.tsx +92 -0
- package/test/app/settings-control-styles.test.tsx +142 -0
- package/test/app/settings-reset.e2e.test.ts +726 -0
- package/test/app/settings-sections.e2e.test.ts +614 -0
- package/test/app/shared-format.test.ts +44 -0
- package/test/app/shared-switch.test.ts +69 -0
- package/test/app/shell-mode-switching.e2e.test.ts +829 -0
- package/test/app/shell-mode-tab-memory.test.tsx +58 -0
- package/test/app/shell-overlays.test.tsx +50 -0
- package/test/app/shortcuts-overlay.test.tsx +111 -0
- package/test/app/sse-interruption.test.ts +122 -0
- package/test/app/startup-asset-missing.e2e.test.ts +126 -0
- package/test/app/startup-backend-missing.e2e.test.ts +118 -0
- package/test/app/startup-chat.e2e.test.ts +305 -0
- package/test/app/startup-conversation-restore.test.tsx +344 -0
- package/test/app/startup-failure-view.test.tsx +103 -0
- package/test/app/startup-onboarding.e2e.test.ts +618 -0
- package/test/app/startup-timeout.test.tsx +80 -0
- package/test/app/startup-token-401.e2e.test.ts +103 -0
- package/test/app/stream-helpers.test.ts +46 -0
- package/test/app/stream-popout-navigation.test.tsx +41 -0
- package/test/app/stream-status-bar.test.tsx +89 -0
- package/test/app/theme-toggle.test.tsx +33 -0
- package/test/app/training-api-client.test.ts +128 -0
- package/test/app/trajectories-view.test.tsx +220 -0
- package/test/app/triggers-api-client.test.ts +77 -0
- package/test/app/triggers-navigation.test.ts +113 -0
- package/test/app/triggers-view.e2e.test.ts +674 -0
- package/test/app/update-channel-lock.test.ts +259 -0
- package/test/app/vector-browser.async-cleanup.test.tsx +367 -0
- package/test/app/vector-browser.e2e.test.ts +653 -0
- package/test/app/vrm-stage.test.tsx +351 -0
- package/test/app/vrm-viewer.test.tsx +298 -0
- package/test/app/wallet-api-save-lock.test.ts +298 -0
- package/test/app/wallet-hooks.test.ts +405 -0
- package/test/app/wallet-ui-flows.e2e.test.ts +556 -0
- package/test/avatar/asset-url.test.ts +90 -0
- package/test/avatar/avatar-selector.test.ts +173 -0
- package/test/avatar/mixamo-vrm-rig-map.test.ts +111 -0
- package/test/avatar/voice-chat-streaming-text.test.ts +96 -0
- package/test/avatar/voice-chat.test.ts +391 -0
- package/test/ui/command-palette-commands.test.ts +57 -0
- package/test/ui/ui-renderer.test.ts +39 -0
- package/tsconfig.build.json +19 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TestRenderer from "react-test-renderer";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Mocks — MessageContent uses useApp() and client internally
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
vi.mock("@elizaos/app-core/state", () => ({
|
|
10
|
+
useApp: () => ({
|
|
11
|
+
agentStatus: { agentName: "Milady" },
|
|
12
|
+
setState: vi.fn(),
|
|
13
|
+
}),
|
|
14
|
+
getVrmPreviewUrl: () => null,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock("@elizaos/app-core/api", () => ({
|
|
18
|
+
client: {
|
|
19
|
+
getConfig: vi.fn(async () => ({})),
|
|
20
|
+
getPluginList: vi.fn(async () => []),
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
compilePatches,
|
|
26
|
+
findPatchRegions,
|
|
27
|
+
looksLikePatch,
|
|
28
|
+
MessageContent,
|
|
29
|
+
normalizePluginId,
|
|
30
|
+
tryParsePatch,
|
|
31
|
+
} from "../../src/components/MessageContent";
|
|
32
|
+
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Helpers
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
function renderText(text: string): string {
|
|
38
|
+
let tree!: TestRenderer.ReactTestRenderer;
|
|
39
|
+
TestRenderer.act(() => {
|
|
40
|
+
tree = TestRenderer.create(
|
|
41
|
+
React.createElement(MessageContent, {
|
|
42
|
+
message: { id: "m1", role: "assistant", text, timestamp: 1 },
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Collect all text content from the rendered tree
|
|
48
|
+
function collectText(node: TestRenderer.ReactTestInstance): string {
|
|
49
|
+
return node.children
|
|
50
|
+
.map((child) =>
|
|
51
|
+
typeof child === "string"
|
|
52
|
+
? child
|
|
53
|
+
: collectText(child as TestRenderer.ReactTestInstance),
|
|
54
|
+
)
|
|
55
|
+
.join("");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return collectText(tree.root).trim();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Tests — JSONL patch detection (the json-render renderer path)
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
describe("looksLikePatch", () => {
|
|
66
|
+
it("matches compact JSON patch", () => {
|
|
67
|
+
expect(looksLikePatch('{"op":"add","path":"/root","value":"x"}')).toBe(
|
|
68
|
+
true,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("matches spaced JSON patch (Claude output style)", () => {
|
|
73
|
+
expect(
|
|
74
|
+
looksLikePatch('{ "op": "add", "path": "/root", "value": "x" }'),
|
|
75
|
+
).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("rejects plain text", () => {
|
|
79
|
+
expect(looksLikePatch("Hello world")).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("rejects JSON without op field", () => {
|
|
83
|
+
expect(looksLikePatch('{"type":"Card","props":{}}')).toBe(false);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("rejects code fence lines", () => {
|
|
87
|
+
expect(looksLikePatch("```json")).toBe(false);
|
|
88
|
+
expect(looksLikePatch("```")).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("tryParsePatch", () => {
|
|
93
|
+
it("parses compact add patch", () => {
|
|
94
|
+
const p = tryParsePatch('{"op":"add","path":"/root","value":"card-1"}');
|
|
95
|
+
expect(p).not.toBeNull();
|
|
96
|
+
expect(p?.op).toBe("add");
|
|
97
|
+
expect(p?.path).toBe("/root");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("parses spaced add patch", () => {
|
|
101
|
+
const p = tryParsePatch(
|
|
102
|
+
'{ "op": "add", "path": "/root", "value": "card-1" }',
|
|
103
|
+
);
|
|
104
|
+
expect(p).not.toBeNull();
|
|
105
|
+
expect(p?.op).toBe("add");
|
|
106
|
+
expect(p?.path).toBe("/root");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("returns null for plain text", () => {
|
|
110
|
+
expect(tryParsePatch("Sure, here is your form:")).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("returns null for invalid JSON", () => {
|
|
114
|
+
expect(tryParsePatch('{"op":"add","path":"/root"')).toBeNull();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("compilePatches", () => {
|
|
119
|
+
it("builds a valid UiSpec from add patches", () => {
|
|
120
|
+
const patches = [
|
|
121
|
+
{ op: "add" as const, path: "/root", value: "card-1" },
|
|
122
|
+
{
|
|
123
|
+
op: "add" as const,
|
|
124
|
+
path: "/elements/card-1",
|
|
125
|
+
value: { type: "Card", props: { title: "Test" }, children: [] },
|
|
126
|
+
},
|
|
127
|
+
{ op: "add" as const, path: "/state/amount", value: 0 },
|
|
128
|
+
];
|
|
129
|
+
const spec = compilePatches(patches);
|
|
130
|
+
expect(spec).not.toBeNull();
|
|
131
|
+
expect(spec?.root).toBe("card-1");
|
|
132
|
+
expect(spec?.elements["card-1"]).toBeDefined();
|
|
133
|
+
expect(spec?.state.amount).toBe(0);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("returns null if /root is missing", () => {
|
|
137
|
+
const patches = [
|
|
138
|
+
{
|
|
139
|
+
op: "add" as const,
|
|
140
|
+
path: "/elements/card-1",
|
|
141
|
+
value: { type: "Card", props: {}, children: [] },
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
expect(compilePatches(patches)).toBeNull();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("ignores prototype-pollution path segments", () => {
|
|
148
|
+
const patches = [
|
|
149
|
+
{ op: "add" as const, path: "/root", value: "card-1" },
|
|
150
|
+
{
|
|
151
|
+
op: "add" as const,
|
|
152
|
+
path: "/elements/card-1",
|
|
153
|
+
value: { type: "Card", props: { title: "Safe" }, children: [] },
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
op: "add" as const,
|
|
157
|
+
path: "/state/__proto__/polluted",
|
|
158
|
+
value: true,
|
|
159
|
+
},
|
|
160
|
+
{ op: "add" as const, path: "/state/amount", value: 42 },
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
const spec = compilePatches(patches);
|
|
164
|
+
expect(spec).not.toBeNull();
|
|
165
|
+
expect(spec?.state.amount).toBe(42);
|
|
166
|
+
expect(Object.hasOwn(Object.prototype, "polluted")).toBe(false);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("findPatchRegions", () => {
|
|
171
|
+
it("detects bare compact JSONL patches", () => {
|
|
172
|
+
const text = [
|
|
173
|
+
"Sure, here you go:",
|
|
174
|
+
'{"op":"add","path":"/root","value":"card-1"}',
|
|
175
|
+
'{"op":"add","path":"/elements/card-1","value":{"type":"Card","props":{"title":"Hi"},"children":[]}}',
|
|
176
|
+
'{"op":"add","path":"/state","value":{}}',
|
|
177
|
+
].join("\n");
|
|
178
|
+
const regions = findPatchRegions(text);
|
|
179
|
+
expect(regions).toHaveLength(1);
|
|
180
|
+
expect(regions[0].spec.root).toBe("card-1");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("detects spaced JSONL patches (Claude output style)", () => {
|
|
184
|
+
const text = [
|
|
185
|
+
"Here is your dashboard:",
|
|
186
|
+
'{ "op": "add", "path": "/root", "value": "card-1" }',
|
|
187
|
+
'{ "op": "add", "path": "/elements/card-1", "value": { "type": "Card", "props": { "title": "Dashboard" }, "children": [] } }',
|
|
188
|
+
'{ "op": "add", "path": "/state", "value": {} }',
|
|
189
|
+
].join("\n");
|
|
190
|
+
const regions = findPatchRegions(text);
|
|
191
|
+
expect(regions).toHaveLength(1);
|
|
192
|
+
expect(regions[0].spec.root).toBe("card-1");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("detects patches inside a code fence", () => {
|
|
196
|
+
const text = [
|
|
197
|
+
"Here is the UI:",
|
|
198
|
+
"```json",
|
|
199
|
+
'{"op":"add","path":"/root","value":"card-1"}',
|
|
200
|
+
'{"op":"add","path":"/elements/card-1","value":{"type":"Card","props":{"title":"Fenced"},"children":[]}}',
|
|
201
|
+
'{"op":"add","path":"/state","value":{}}',
|
|
202
|
+
"```",
|
|
203
|
+
].join("\n");
|
|
204
|
+
const regions = findPatchRegions(text);
|
|
205
|
+
expect(regions).toHaveLength(1);
|
|
206
|
+
expect(regions[0].spec.root).toBe("card-1");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("returns empty array for plain text", () => {
|
|
210
|
+
expect(findPatchRegions("Hello! How can I help you today?")).toHaveLength(
|
|
211
|
+
0,
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("returns empty array if /root patch is missing", () => {
|
|
216
|
+
const text =
|
|
217
|
+
'{"op":"add","path":"/elements/card-1","value":{"type":"Card","props":{},"children":[]}}';
|
|
218
|
+
expect(findPatchRegions(text)).toHaveLength(0);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("flushes before malformed patch-like text after an empty line", () => {
|
|
222
|
+
const text = [
|
|
223
|
+
'{"op":"add","path":"/root","value":"card-1"}',
|
|
224
|
+
"",
|
|
225
|
+
'{"op":"add","path":"/elements/card-1"',
|
|
226
|
+
"hello",
|
|
227
|
+
].join("\n");
|
|
228
|
+
|
|
229
|
+
const regions = findPatchRegions(text);
|
|
230
|
+
expect(regions).toHaveLength(1);
|
|
231
|
+
expect(regions[0]?.raw).toBe(
|
|
232
|
+
'{"op":"add","path":"/root","value":"card-1"}',
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe("normalizePluginId", () => {
|
|
238
|
+
it("strips the plugin package prefix", () => {
|
|
239
|
+
expect(normalizePluginId("@elizaos/plugin-discord")).toBe("discord");
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("leaves plain plugin ids unchanged", () => {
|
|
243
|
+
expect(normalizePluginId("discord")).toBe("discord");
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it("leaves non-plugin scoped packages unchanged", () => {
|
|
247
|
+
expect(normalizePluginId("@scope/not-plugin-name")).toBe(
|
|
248
|
+
"@scope/not-plugin-name",
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
// Tests — XML stripping regression
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
|
|
257
|
+
describe("MessageContent — XML action stripping", () => {
|
|
258
|
+
it("strips <actions> XML from message text", () => {
|
|
259
|
+
const text =
|
|
260
|
+
'Here is my response <actions><action name="DO_THING"><params>{"key":"val"}</params></action></actions>';
|
|
261
|
+
const rendered = renderText(text);
|
|
262
|
+
expect(rendered).toBe("Here is my response");
|
|
263
|
+
expect(rendered).not.toContain("<actions>");
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it("strips <params> XML from message text", () => {
|
|
267
|
+
const text =
|
|
268
|
+
'Some text <params>{"repo":"https://github.com/test"}</params>';
|
|
269
|
+
const rendered = renderText(text);
|
|
270
|
+
expect(rendered).toBe("Some text");
|
|
271
|
+
expect(rendered).not.toContain("<params>");
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("renders empty for message containing only XML", () => {
|
|
275
|
+
const text =
|
|
276
|
+
'<actions><action name="START_CODING_TASK"><params>{"task":"fix bug"}</params></action></actions>';
|
|
277
|
+
const rendered = renderText(text);
|
|
278
|
+
expect(rendered).toBe("");
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("preserves message text with no XML", () => {
|
|
282
|
+
const text = "Hello, how can I help you today?";
|
|
283
|
+
const rendered = renderText(text);
|
|
284
|
+
expect(rendered).toBe("Hello, how can I help you today?");
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("shows only the <text> portion of structured response XML", () => {
|
|
288
|
+
const text =
|
|
289
|
+
"<response><thought>internal chain</thought><text>Hello world</text></response>";
|
|
290
|
+
const rendered = renderText(text);
|
|
291
|
+
expect(rendered).toBe("Hello world");
|
|
292
|
+
expect(rendered).not.toContain("internal chain");
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it("shows partial streamed <text> content without leaking wrapper XML", () => {
|
|
296
|
+
const text = "<response><thought>internal chain</thought><text>Hello world";
|
|
297
|
+
const rendered = renderText(text);
|
|
298
|
+
expect(rendered).toBe("Hello world");
|
|
299
|
+
expect(rendered).not.toContain("<response>");
|
|
300
|
+
expect(rendered).not.toContain("internal chain");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("renders nothing until structured response text starts", () => {
|
|
304
|
+
const text = "<response><thought>internal chain</thought>";
|
|
305
|
+
const rendered = renderText(text);
|
|
306
|
+
expect(rendered).toBe("");
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it("strips analysis XML blocks from displayed text", () => {
|
|
310
|
+
const text =
|
|
311
|
+
"Visible text <analysis>do not show this planning output</analysis> after";
|
|
312
|
+
const rendered = renderText(text);
|
|
313
|
+
expect(rendered.replace(/\s+/g, " ").trim()).toBe("Visible text after");
|
|
314
|
+
expect(rendered).not.toContain("planning output");
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it("strips single-star stage directions from displayed assistant text", () => {
|
|
318
|
+
const rendered = renderText("*waves warmly* Hello there.");
|
|
319
|
+
expect(rendered).toBe("Hello there.");
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("preserves bold markdown-style text", () => {
|
|
323
|
+
const rendered = renderText("**Saturday**: Sunny and warm.");
|
|
324
|
+
expect(rendered).toBe("**Saturday**: Sunny and warm.");
|
|
325
|
+
});
|
|
326
|
+
});
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for PermissionsOnboardingSection — platform-aware onboarding.
|
|
3
|
+
*
|
|
4
|
+
* Validates that the onboarding senses step renders correctly on
|
|
5
|
+
* Electron (desktop), Web (auto-continue), and Capacitor/mobile (streaming).
|
|
6
|
+
*/
|
|
7
|
+
// @vitest-environment jsdom
|
|
8
|
+
import React from "react";
|
|
9
|
+
import TestRenderer, { act } from "react-test-renderer";
|
|
10
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
11
|
+
|
|
12
|
+
// ── Hoisted mocks ─────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
const { mockUseApp, mockIsWeb, mockIsElectron, mockIsNative } = vi.hoisted(
|
|
15
|
+
() => ({
|
|
16
|
+
mockUseApp: vi.fn(),
|
|
17
|
+
mockIsWeb: vi.fn(() => false),
|
|
18
|
+
mockIsElectron: vi.fn(() => true),
|
|
19
|
+
mockIsNative: { value: false },
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
const {
|
|
23
|
+
mockGetPermissions,
|
|
24
|
+
mockInvokeDesktopBridgeRequest,
|
|
25
|
+
mockSubscribeDesktopBridgeEvent,
|
|
26
|
+
} = vi.hoisted(() => ({
|
|
27
|
+
mockGetPermissions: vi.fn(),
|
|
28
|
+
mockInvokeDesktopBridgeRequest: vi.fn(),
|
|
29
|
+
mockSubscribeDesktopBridgeEvent: vi.fn(),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
vi.mock("@elizaos/app-core/state", () => ({
|
|
33
|
+
useApp: () => mockUseApp(),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
vi.mock("@elizaos/app-core/platform", () => ({
|
|
37
|
+
hasRequiredOnboardingPermissions: vi.fn(() => true),
|
|
38
|
+
isWebPlatform: () => mockIsWeb(),
|
|
39
|
+
isElectronPlatform: () => mockIsElectron(),
|
|
40
|
+
get isNative() {
|
|
41
|
+
return mockIsNative.value;
|
|
42
|
+
},
|
|
43
|
+
isIOS: false,
|
|
44
|
+
isAndroid: false,
|
|
45
|
+
platform: "web",
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
vi.mock("@elizaos/app-core/api", () => ({
|
|
49
|
+
client: {
|
|
50
|
+
getPermissions: mockGetPermissions,
|
|
51
|
+
isShellEnabled: vi.fn().mockResolvedValue(true),
|
|
52
|
+
refreshPermissions: vi.fn(),
|
|
53
|
+
requestPermission: vi.fn(),
|
|
54
|
+
openPermissionSettings: vi.fn(),
|
|
55
|
+
setShellEnabled: vi.fn(),
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
vi.mock("@elizaos/app-core/bridge", () => ({
|
|
60
|
+
invokeDesktopBridgeRequest: mockInvokeDesktopBridgeRequest,
|
|
61
|
+
subscribeDesktopBridgeEvent: mockSubscribeDesktopBridgeEvent,
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
vi.mock("@elizaos/app-core/components/ui-badges", () => ({
|
|
65
|
+
StatusBadge: ({ label }: { label: string }) =>
|
|
66
|
+
React.createElement("span", { "data-testid": "status-badge" }, label),
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
vi.mock("@elizaos/app-core/components/ui-switch", () => ({
|
|
70
|
+
Switch: () => React.createElement("span", null, "switch"),
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
vi.mock("@elizaos/ui", () => ({
|
|
74
|
+
Button: ({
|
|
75
|
+
children,
|
|
76
|
+
onClick,
|
|
77
|
+
...rest
|
|
78
|
+
}: {
|
|
79
|
+
children: React.ReactNode;
|
|
80
|
+
onClick?: () => void;
|
|
81
|
+
}) =>
|
|
82
|
+
React.createElement(
|
|
83
|
+
"button",
|
|
84
|
+
{ type: "button", onClick, ...rest },
|
|
85
|
+
children,
|
|
86
|
+
),
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
vi.mock("lucide-react", () => ({
|
|
90
|
+
Camera: () => React.createElement("span", null, "📷"),
|
|
91
|
+
Check: () => React.createElement("span", null, "✓"),
|
|
92
|
+
CircleUserRound: () => React.createElement("span", null, "👤"),
|
|
93
|
+
Cloud: () => React.createElement("span", null, "☁"),
|
|
94
|
+
Mic: () => React.createElement("span", null, "🎤"),
|
|
95
|
+
Monitor: () => React.createElement("span", null, "🖥"),
|
|
96
|
+
MousePointer2: () => React.createElement("span", null, "🖱"),
|
|
97
|
+
Settings: () => React.createElement("span", null, "⚙"),
|
|
98
|
+
Smartphone: () => React.createElement("span", null, "📱"),
|
|
99
|
+
Terminal: () => React.createElement("span", null, "💻"),
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
import { PermissionsOnboardingSection } from "@elizaos/app-core/components/PermissionsSection";
|
|
103
|
+
|
|
104
|
+
// ── Helpers ───────────────────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
function baseContext(overrides?: Record<string, unknown>) {
|
|
107
|
+
return {
|
|
108
|
+
t: (k: string) => k,
|
|
109
|
+
plugins: [],
|
|
110
|
+
handlePluginToggle: vi.fn(),
|
|
111
|
+
...overrides,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function collectText(node: TestRenderer.ReactTestInstance): string {
|
|
116
|
+
return node.children
|
|
117
|
+
.map((child) => (typeof child === "string" ? child : collectText(child)))
|
|
118
|
+
.join(" ");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function findButtons(
|
|
122
|
+
root: TestRenderer.ReactTestInstance,
|
|
123
|
+
): TestRenderer.ReactTestInstance[] {
|
|
124
|
+
return root.findAllByType("button");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function findButtonsByAriaLabel(
|
|
128
|
+
root: TestRenderer.ReactTestInstance,
|
|
129
|
+
label: string,
|
|
130
|
+
): TestRenderer.ReactTestInstance[] {
|
|
131
|
+
return root.findAll(
|
|
132
|
+
(node) => node.type === "button" && node.props["aria-label"] === label,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function ensureNavigatorPermissionMocks(): void {
|
|
137
|
+
if (!navigator.permissions) {
|
|
138
|
+
Object.defineProperty(navigator, "permissions", {
|
|
139
|
+
value: { query: vi.fn() },
|
|
140
|
+
writable: true,
|
|
141
|
+
configurable: true,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!navigator.mediaDevices) {
|
|
146
|
+
Object.defineProperty(navigator, "mediaDevices", {
|
|
147
|
+
value: {
|
|
148
|
+
getUserMedia: vi.fn(),
|
|
149
|
+
enumerateDevices: vi.fn(),
|
|
150
|
+
},
|
|
151
|
+
writable: true,
|
|
152
|
+
configurable: true,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!navigator.mediaDevices.getUserMedia) {
|
|
157
|
+
Object.defineProperty(navigator.mediaDevices, "getUserMedia", {
|
|
158
|
+
value: vi.fn(),
|
|
159
|
+
writable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!navigator.mediaDevices.enumerateDevices) {
|
|
165
|
+
Object.defineProperty(navigator.mediaDevices, "enumerateDevices", {
|
|
166
|
+
value: vi.fn(),
|
|
167
|
+
writable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ====================================================================
|
|
174
|
+
|
|
175
|
+
describe("PermissionsOnboardingSection", () => {
|
|
176
|
+
beforeEach(() => {
|
|
177
|
+
ensureNavigatorPermissionMocks();
|
|
178
|
+
mockUseApp.mockReset();
|
|
179
|
+
mockIsWeb.mockReturnValue(false);
|
|
180
|
+
mockIsElectron.mockReturnValue(true);
|
|
181
|
+
mockIsNative.value = false;
|
|
182
|
+
mockGetPermissions.mockReset();
|
|
183
|
+
mockInvokeDesktopBridgeRequest.mockReset();
|
|
184
|
+
mockSubscribeDesktopBridgeEvent.mockReset();
|
|
185
|
+
mockGetPermissions.mockResolvedValue({
|
|
186
|
+
accessibility: { status: "granted", canRequest: false },
|
|
187
|
+
"screen-recording": { status: "granted", canRequest: false },
|
|
188
|
+
microphone: { status: "granted", canRequest: false },
|
|
189
|
+
camera: { status: "granted", canRequest: false },
|
|
190
|
+
shell: { status: "granted", canRequest: false },
|
|
191
|
+
});
|
|
192
|
+
mockInvokeDesktopBridgeRequest.mockImplementation(
|
|
193
|
+
async (options: { rpcMethod: string }) => {
|
|
194
|
+
if (options.rpcMethod === "permissionsGetAll") {
|
|
195
|
+
return {
|
|
196
|
+
accessibility: { status: "granted", canRequest: false },
|
|
197
|
+
"screen-recording": { status: "granted", canRequest: false },
|
|
198
|
+
microphone: { status: "granted", canRequest: false },
|
|
199
|
+
camera: { status: "granted", canRequest: false },
|
|
200
|
+
shell: { status: "granted", canRequest: false },
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (options.rpcMethod === "permissionsIsShellEnabled") {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (options.rpcMethod === "permissionsGetPlatform") {
|
|
207
|
+
return "darwin";
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
mockSubscribeDesktopBridgeEvent.mockImplementation(() => () => {});
|
|
213
|
+
vi.mocked(navigator.permissions.query).mockReset();
|
|
214
|
+
vi.mocked(navigator.mediaDevices.getUserMedia).mockReset();
|
|
215
|
+
vi.mocked(navigator.mediaDevices.enumerateDevices).mockReset();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("renders web auto-continue view when isWebPlatform() is true", async () => {
|
|
219
|
+
mockIsWeb.mockReturnValue(true);
|
|
220
|
+
mockIsElectron.mockReturnValue(false);
|
|
221
|
+
const onContinue = vi.fn();
|
|
222
|
+
mockUseApp.mockReturnValue(baseContext());
|
|
223
|
+
|
|
224
|
+
let tree: TestRenderer.ReactTestRenderer | undefined;
|
|
225
|
+
await act(async () => {
|
|
226
|
+
tree = TestRenderer.create(
|
|
227
|
+
React.createElement(PermissionsOnboardingSection, { onContinue }),
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const root = tree?.root;
|
|
232
|
+
const webView = root.findByProps({
|
|
233
|
+
"data-testid": "web-onboarding-permissions",
|
|
234
|
+
});
|
|
235
|
+
expect(webView).toBeDefined();
|
|
236
|
+
const text = collectText(root);
|
|
237
|
+
expect(text).toContain("Browser Permissions");
|
|
238
|
+
expect(text).toContain("Camera");
|
|
239
|
+
expect(text).toContain("Microphone");
|
|
240
|
+
|
|
241
|
+
// Should have a skip button
|
|
242
|
+
const buttons = findButtons(root);
|
|
243
|
+
const skipBtn = buttons.find((b) =>
|
|
244
|
+
collectText(b).includes("Skip for Now"),
|
|
245
|
+
);
|
|
246
|
+
expect(skipBtn).toBeDefined();
|
|
247
|
+
await act(async () => {
|
|
248
|
+
skipBtn?.props.onClick();
|
|
249
|
+
});
|
|
250
|
+
expect(onContinue).toHaveBeenCalledWith({ allowPermissionBypass: true });
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("renders mobile streaming permissions when isNative and not Electron", async () => {
|
|
254
|
+
mockIsWeb.mockReturnValue(false);
|
|
255
|
+
mockIsElectron.mockReturnValue(false);
|
|
256
|
+
mockIsNative.value = true;
|
|
257
|
+
const onContinue = vi.fn();
|
|
258
|
+
mockUseApp.mockReturnValue(baseContext());
|
|
259
|
+
|
|
260
|
+
let tree: TestRenderer.ReactTestRenderer | undefined;
|
|
261
|
+
await act(async () => {
|
|
262
|
+
tree = TestRenderer.create(
|
|
263
|
+
React.createElement(PermissionsOnboardingSection, { onContinue }),
|
|
264
|
+
);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const root = tree?.root;
|
|
268
|
+
const mobileView = root.findByProps({
|
|
269
|
+
"data-testid": "mobile-onboarding-permissions",
|
|
270
|
+
});
|
|
271
|
+
expect(mobileView).toBeDefined();
|
|
272
|
+
const text = collectText(root);
|
|
273
|
+
expect(text).toContain("Streaming Permissions");
|
|
274
|
+
expect(text).toContain("Camera");
|
|
275
|
+
expect(text).toContain("Microphone");
|
|
276
|
+
|
|
277
|
+
// Should have a skip button
|
|
278
|
+
expect(text).toContain("Skip for Now");
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("renders desktop permissions on Electron", async () => {
|
|
282
|
+
mockIsWeb.mockReturnValue(false);
|
|
283
|
+
mockIsElectron.mockReturnValue(true);
|
|
284
|
+
mockIsNative.value = false;
|
|
285
|
+
const onContinue = vi.fn();
|
|
286
|
+
mockUseApp.mockReturnValue(baseContext());
|
|
287
|
+
|
|
288
|
+
let tree: TestRenderer.ReactTestRenderer | undefined;
|
|
289
|
+
await act(async () => {
|
|
290
|
+
tree = TestRenderer.create(
|
|
291
|
+
React.createElement(PermissionsOnboardingSection, { onContinue }),
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const root = tree?.root;
|
|
296
|
+
const text = collectText(root);
|
|
297
|
+
// Should show system permissions title and grant UI
|
|
298
|
+
expect(text).toContain("System Permissions");
|
|
299
|
+
expect(text).toContain("Continue");
|
|
300
|
+
expect(mockInvokeDesktopBridgeRequest).toHaveBeenCalledWith({
|
|
301
|
+
rpcMethod: "permissionsGetAll",
|
|
302
|
+
ipcChannel: "permissions:getAll",
|
|
303
|
+
params: undefined,
|
|
304
|
+
});
|
|
305
|
+
expect(mockGetPermissions).not.toHaveBeenCalled();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("hides the camera grant button when renderer access is already granted", async () => {
|
|
309
|
+
mockIsWeb.mockReturnValue(false);
|
|
310
|
+
mockIsElectron.mockReturnValue(true);
|
|
311
|
+
mockIsNative.value = false;
|
|
312
|
+
const onContinue = vi.fn();
|
|
313
|
+
mockUseApp.mockReturnValue(baseContext());
|
|
314
|
+
mockInvokeDesktopBridgeRequest.mockImplementation(
|
|
315
|
+
async (options: { rpcMethod: string }) => {
|
|
316
|
+
if (options.rpcMethod === "permissionsGetAll") {
|
|
317
|
+
return {
|
|
318
|
+
accessibility: { status: "granted", canRequest: false },
|
|
319
|
+
"screen-recording": { status: "granted", canRequest: false },
|
|
320
|
+
microphone: { status: "granted", canRequest: false },
|
|
321
|
+
camera: { status: "not-determined", canRequest: true },
|
|
322
|
+
shell: { status: "granted", canRequest: false },
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (options.rpcMethod === "permissionsIsShellEnabled") {
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
if (options.rpcMethod === "permissionsGetPlatform") {
|
|
329
|
+
return "darwin";
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
vi.mocked(navigator.permissions.query).mockImplementation(
|
|
335
|
+
async ({ name }: { name: PermissionName }) =>
|
|
336
|
+
({
|
|
337
|
+
state: name === "camera" ? "granted" : "prompt",
|
|
338
|
+
}) as PermissionStatus,
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
let tree: TestRenderer.ReactTestRenderer | undefined;
|
|
342
|
+
await act(async () => {
|
|
343
|
+
tree = TestRenderer.create(
|
|
344
|
+
React.createElement(PermissionsOnboardingSection, { onContinue }),
|
|
345
|
+
);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const root = tree?.root;
|
|
349
|
+
expect(root).toBeDefined();
|
|
350
|
+
if (!root) {
|
|
351
|
+
throw new Error("PermissionsOnboardingSection root not rendered");
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
expect(findButtonsByAriaLabel(root, "Check Access Camera")).toHaveLength(0);
|
|
355
|
+
});
|
|
356
|
+
});
|