Files
openhuman/app/src/test/mockDefaultSkillStatusHooks.ts
T
Mega MindandGitHub 9118bfb5d6 Fix/skill start issue (#498)
* chore: update .gitignore and bump openhuman version to 0.52.2

- Added `overlay/src-tauri/target/` to .gitignore to prevent tracking of build artifacts.
- Updated the openhuman package version from 0.52.0 to 0.52.2 in Cargo.lock files for both the main and app/src-tauri directories.
- Enhanced entitlements for macOS Hardened Runtime to allow outbound HTTPS calls and server connections.
- Refactored registry operations to use rustls explicitly, improving network reliability on macOS.

* refactor(logging): improve debug message formatting in fetch_url_bytes function

- Updated the logging statement in the fetch_url_bytes function to enhance readability by formatting the debug message across multiple lines. This change improves clarity in log outputs, making it easier to track the number of bytes fetched from URLs.

* feat(skill-setup): enhance OAuth handling and skill status synchronization

- Introduced a managed OAuth auto-advance mechanism to ensure it runs only once per login attempt, improving user experience during authentication.
- Updated the SkillSetupWizard to handle skill runtime checks more effectively, ensuring that the skill starts correctly and transitions to the setup phase seamlessly.
- Enhanced the useSkillSnapshot hook to provide a synthesized offline snapshot when the skill is not yet running, preventing UI stalls during loading.
- Implemented background synchronization after OAuth completion to ensure users see fresh data immediately without blocking the UI.
- Added tests to validate the new behavior for skills setup completion and status retrieval without requiring the skill to be started first.

* refactor(skills): streamline setup_complete retrieval in handle_skills_status function

- Simplified the retrieval of the `setup_complete` variable by removing unnecessary line breaks, enhancing code readability and maintainability.
- This change improves the clarity of the function's logic without altering its functionality.

* refactor(skills): simplify success message and remove initial sync from OAuth flow

- Updated the success message in the SkillSetupWizard to remove references to background syncing, streamlining user communication.
- Removed the initial sync trigger from the SkillManager after OAuth completion, shifting the responsibility for data synchronization to the user interface or cron jobs.
- Adjusted comments in the desktopDeepLinkListener to reflect the new sync behavior, clarifying that initial data sync is no longer automatic.

* fix(pr-498): address CodeRabbit review and CI failures

- SkillSetupWizard: only show complete after startSetup succeeds; error on failures
- hooks: merge prior snapshot into offline fallback; use const arrow for helper
- E2E: reset skills_set_setup_complete in finally for isolation
- json_rpc_e2e: assert oauth/complete returns start() result; add minimal start()
- Skills page tests: mock screen-intelligence/autocomplete/voice hooks (CoreStateProvider)

Made-with: Cursor

* fix: address follow-up CodeRabbit (readiness poll, shared test mocks)

- SkillSetupWizard: waitForSkillRunning after startSkill before startSetup/auth RPC
- json_rpc_e2e: poll skills_status until running instead of fixed 400ms sleep
- Consolidate Skills page vi.mocks in test/mockDefaultSkillStatusHooks.ts

Made-with: Cursor

* fix: CodeRabbit — legacy OAuth awaits setSetupComplete, const waitForSkillRunning, mock base

- Legacy OAuth: await persistence before complete; error on failure; guard ref + reset on skillId
- waitForSkillRunning: const arrow per TS style
- mockDefaultSkillStatusHooks: offlineStatusBase spread for shared literals

Made-with: Cursor
2026-04-11 04:16:15 +05:30

37 lines
1.1 KiB
TypeScript

/**
* Shared Vitest mocks for screen-intelligence / autocomplete / voice status hooks.
* Import this module first in Skills page tests so `Skills` does not require `CoreStateProvider`.
*/
import { vi } from 'vitest';
/** Shared offline-shaped fields for skill status hook mocks (avoid drift across hooks). */
const offlineStatusBase = {
connectionStatus: 'offline' as const,
statusDot: 'bg-stone-400',
statusLabel: 'Offline',
statusColor: 'text-stone-500',
ctaLabel: 'Enable',
ctaVariant: 'sage' as const,
};
vi.mock('../features/screen-intelligence/useScreenIntelligenceSkillStatus', () => ({
useScreenIntelligenceSkillStatus: () => ({
...offlineStatusBase,
allPermissionsGranted: false,
platformUnsupported: false,
}),
}));
vi.mock('../features/autocomplete/useAutocompleteSkillStatus', () => ({
useAutocompleteSkillStatus: () => ({ ...offlineStatusBase, platformUnsupported: false }),
}));
vi.mock('../features/voice/useVoiceSkillStatus', () => ({
useVoiceSkillStatus: () => ({
...offlineStatusBase,
sttModelMissing: false,
voiceStatus: null,
serverStatus: null,
}),
}));