mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
* test(coverage): raise 9 critical modules to ≥80% line coverage Pushes unit test coverage to meet issue #530's 80% target on 9 modules: socket (17% → 80%), credentials (46% → 81%), composio (55% → 81%), memory (75% → 80%), tools (73% → 83%), plus previously-passing cron, context, learning, embeddings. Additions span ~400+ new tests across 44 files: - Pure-function tests for types, schemas, parsers, URL builders, and error-classification helpers. - Mock-backend integration tests using axum for HTTP-dependent code (composio client + ops, socket ws_loop against a local WebSocket server). - End-to-end RPC handler tests using tempdir + OPENHUMAN_WORKSPACE env override (credentials, memory, config, cron). Also fixes 4 pre-existing flaky tests on macOS dev machines by pinning absolute paths (/bin/ls, /bin/sleep, /bin/sh, /usr/bin/touch) in cron scheduler tests so sh -lc does not pick up homebrew-shadowed binaries that macOS SIP refuses to execute, and relaxing a screen_intelligence capture-permission hang assertion. Remaining work: voice, config, screen_intelligence, channels, local_ai still below 80% (62%, 61%, 54%, 68%, 35% respectively). * test(coverage): add config module tests (62% → ~71%) Adds tests for: - config/ops.rs: env_flag_enabled, core_rpc_url_from_env, snapshot_config_json, workspace_onboarding_flag_exists/_set, set_browser_allow_all, agent_server_status - config/schemas.rs: catalog parity, all 21 registered schema keys, helpers - config/schema/proxy.rs: normalize_*, parse_proxy_scope, parse_proxy_enabled, validate_proxy_url, service_selector_matches, ProxyConfig defaults - config/schema/load.rs: apply_env_overrides for api_key, model, temperature, reasoning_enabled, web_search.*, storage.*; resolve_config_dir_for_workspace - config/settings_cli.rs: settings_section_json all sections (model/memory/runtime/browser/unknown) * test(coverage): config reaches 80.49%, socket back to 80.10% - config/ops.rs: apply_model/memory/runtime/browser/analytics/screen_intelligence_settings roundtrips via in-memory Config; load_and_apply_dictation/voice_server_settings activation-mode validation; get_dictation/voice_server/onboarding readers; workspace_onboarding_flag_set/resolve error and happy paths. - config/schema/load.rs: apply_env_overrides coverage for OPENHUMAN_MODEL, OPENHUMAN_TEMPERATURE (range clamp), OPENHUMAN_REASONING_ENABLED, OPENHUMAN_WEB_SEARCH_*, OPENHUMAN_STORAGE_* env branches. - config/schema/proxy.rs: normalize_* helpers, parse_proxy_scope/enabled, ProxyConfig defaults, validate_proxy_url schemes + hosts, service_selector_matches wildcards. - config/schemas.rs: every registered controller key, namespace parity. - config/settings_cli.rs: all section projections (model/memory/runtime/browser/unknown). - Shared `TEST_ENV_LOCK` at config::mod level so config::ops and config::schema::load test modules serialize OPENHUMAN_WORKSPACE mutations. - socket: a couple more schema assertions to keep module at 80%+. * test(coverage): channels partial push (68.12% → 68.91%) - channels/controllers/schemas.rs: every registered key resolves, required input coverage for describe/send_message/telegram_login_check. - channels/providers/web.rs: catalog parity, chat/cancel schema required inputs, unknown fallback, key_for, event_session_id_for stability, normalize_model_override trimming/empty, broadcast channel subscribe, field-builder helpers. - channels/providers/discord/api.rs: auth_header prefix, BotPermissionCheck serde with empty/full missing_permissions lists, permission bit flags are single-bit and distinct. Channels remains below the 80% issue target — the bulk of remaining uncovered code lives in telegram/channel.rs (574 lines), ops.rs (462), lark.rs (433) and runtime/startup.rs (350), which depend on live HTTP / socket / runtime bootstrap state that would require extensive mock infrastructure to exercise from unit tests. * test(coverage): partial push on local_ai (34→45%), screen_intelligence (54→62%), voice (62→63%) - local_ai/schemas.rs: catalog parity, every registered key resolves, field-builder helpers, deserialize_params happy/error, download_force optional. - local_ai/ops.rs: local-ai-disabled error paths for prompt/vision_prompt/ embed/summarize/transcribe/tts/chat; empty-messages rejection; suggestions return empty when disabled (graceful degradation). - local_ai/install.rs: find_system_ollama_binary env-override happy/missing/ empty cases; PATH-based lookup stub. - screen_intelligence/schemas.rs: catalog parity, all 15 registered keys resolve to non-unknown, unknown fallback. - screen_intelligence/ops.rs: accessibility_status/doctor_cli_json/ capture_image_ref/stop_session/vision_recent error-free behaviour. - voice/server.rs: truncate_for_log ellipsis + multibyte; try_global_server after init; additional hallucination-pattern coverage. Remaining gap on these modules lives almost entirely in: - local_ai/service/ollama_admin.rs (625 lines) — real HTTP + Ollama subprocess - local_ai/service/{assets,public_infer,vision_embed}.rs — same - voice/{server,audio_capture}.rs deep paths — audio hardware - screen_intelligence/{engine,processing_worker}.rs — active capture session * test(coverage): channels providers (+0.9%) — qq ensure_https, lark parsers - qq: ensure_https accept/reject, QQ_API_BASE/AUTH_URL constants, constructor. - lark: parse_post_content zh_cn/en_us fallback + links/mentions; invalid JSON returns None; strip_at_placeholders for @_user_N tokens; group should_respond_in_group mention gating. * test(coverage): push all 4 remaining modules - discord/api.rs: list_bot_guilds_at_base/list_guild_channels_at_base test seams with mock axum server; parse happy-path, error status, channel filter+sort, empty list. - channels/controllers/ops.rs: parse_allowed_users for string CSV/array/ newline/@-prefix/case-insensitive dedup/non-string; credential_provider; list_channels/describe_channel; connect_channel unknown-channel and non-object credentials. - local_ai/ollama_api.rs: `ollama_base_url()` honours OPENHUMAN_OLLAMA_BASE_URL env var so tests can point at mock servers; DEFAULT_OLLAMA_BASE_URL preserved. - local_ai/service/public_infer.rs: mock-backend tests for inference/prompt happy path, non-success status, suggest_questions parsing, disabled- local-ai short-circuits for summarize/prompt/suggest_questions/ inline_complete. - voice/schemas.rs: overlay_notify cancelled→released, unknown state errors, missing state errors, server_start handler, TranscribeParams + TtsParams deserialize happy/error paths, server_start all-optional invariant, description completeness. * test(coverage): local_ai HTTP mock tests (49→53%) - ollama_api: ollama_base_url() helper now used by ollama_admin/has_model + ollama_healthy (in addition to public_infer + vision_embed). - public_infer: inference against mock /api/generate happy/error/empty; suggest_questions parses line-separated output; disabled short-circuits for summarize/prompt/suggest/inline_complete. - vision_embed: mock /api/embed with /api/tags preflight; empty-input rejection; disabled short-circuits for embed and vision_prompt. - ollama_admin: has_model matches exact + prefixed tags; errors on 5xx /api/tags; ollama_healthy true on 200 and false on unreachable URL. * test(coverage): more local_ai + voice gains - local_ai/ollama_admin: diagnostics against mock Ollama (unreachable + missing models + all models present), list_models happy/error paths. - voice/dictation_listener: start_if_enabled early-returns for disabled/ empty-hotkey/unparseable-hotkey; normalize_hotkey_for_rdev coverage for Shift+Alt, lowercase, function keys, whitespace trimming. * test(coverage): local_ai schemas handlers + voice flakiness fix - local_ai/schemas: handle_device_profile; handle_presets tier+device shape; handle_apply_preset invalid/custom/valid paths; handle_set_ollama_path nonexistent/empty-to-clear paths. - voice/schemas: relax server_status/stop assertion to tolerate other tests in the same binary having initialised the global voice server (it's a OnceLock, so state is shared across the whole test process). * test(coverage): channels incremental push (71→73%) - presentation.rs: split_sentences, group_sentences, merge_short, segment_delay monotonic/bounded, is_structured_content detection, segment_for_delivery edge cases. - runtime/dispatch.rs: contains_any, starts_with_any, full coverage of select_acknowledgment_reaction across all 7 categories + deterministic + empty/single-char inputs. - commands.rs: doctor_channels with telegram/discord/slack/imessage/ multiple-config branches. - discord/api: check_channel_permissions mock-server tests — admin bypass, all-missing, everyone-allow, channel overwrite deny, member lookup failure. Added check_channel_permissions_at_base seam. - lark: should_refresh_last_recv, LarkChannel::new, is_user_allowed wildcard/empty allowlist, parse_event_payload edge cases (unsupported type / empty sender / missing event / post type). - email_channel: is_sender_allowed full matrix (empty/wildcard/exact/ @-prefix/bare-domain/subdomain-confusion), strip_html empty/tags-only/ unclosed/whitespace collapse. - voice/schemas: tolerate event interleaving in broadcast-channel test (schema bus is process-global). * test(coverage): address review findings — assertions, determinism, observability Tighten assertions so regressions surface: - credentials/ops: assert decrypt migrate path returns Ok - credentials/session_support: assert trimmed profile name directly - computer/mouse: check Err branch in single-axis scroll tests - filesystem/git_operations: assert exact error substrings and verify `git init` success before each test - channels/controllers/ops: exact credential_provider key + concrete parse_allowed_users expectation with accurate normalisation note; merged the three duplicate list/describe tests into existing coverage - tools/impl/browser/screenshot: cfg-branched support-matrix assertions - tools/impl/agent: replace misleading stub test with one that actually exercises dispatch_subagent's graceful-failure paths - local_ai/install: cfg-branched build_install_command expectations - local_ai/service/public_infer: exercise empty-response reject path via inference() (allow_empty=false) and assert the error - screen_intelligence: only take the macOS slow-path skip on macOS Test determinism: - local_ai/install: serialise env mutations via a module Mutex and RAII EnvGuard that restores prior values on drop - composio/ops: poll TCP readiness with backoff before returning the mock-backend URL - memory/global: bind TempDir at test scope so its workspace outlives any lazy-init reference Consistency: - local_ai/service/ollama_admin: route every Ollama HTTP call and the diagnostics URL through ollama_base_url(); drop the stale OLLAMA_BASE_URL import so /api/pull, /api/tags (runner check), /api/show, and the health message all honour the env override Observability: - local_ai/service/vision_embed: tracing::debug at entry/response and tracing::error on send/non-success - local_ai/service/ollama_admin::list_models: entry/response/parse logging including raw body on parse failure - channels/providers/discord/api: tracing::debug with endpoint, status, body, and context before every non-success bail! New coverage: - channels/providers/lark: anchor href-only fallback in parse_post_content - local_ai/ollama_api: five-case env-override suite for ollama_base_url (unset / normal / trimmed / trailing slashes / empty|whitespace) Miscellaneous: - voice/server: OnceCell-backed comment (was OnceLock); drop duplicate initial-status test; supply the HallucinationMode argument to two stale hallucination tests so the crate type-checks
Tauri + React + Typescript
This template should help get you started developing with Tauri, React and Typescript in Vite.