Skip to main content

Test Coverage — open-cfmoto

Last updated: 2026-03-14


packages/cloud-client

Run: pnpm --filter @open-cfmoto/cloud-client test

75 tests total across 6 suites.

FileTest fileTestsCoverage
src/signing.tssrc/__tests__/signing.test.ts5MD5(SHA1) signature vector, nonce length/randomness, timestamp in unix ms, required headers, GET query signing (sorted + URL-encoded)
src/auth.tssrc/__tests__/auth.test.ts5Successful login token extraction, invalid credentials → CloudAuthError, getToken() pre-login null, login payload shape, MD5 password normalization
src/vehicle.tssrc/__tests__/vehicle.test.ts22getEncryptInfo parsing + errors, getVehicleDetail full data + virtual vehicle (no encryptInfo), signed headers, getVehicles position=2, getUserVehicles success + malformed response
src/user.tssrc/__tests__/user.test.ts13getProfile success + HTTP/API errors + invalid JSON, updateProfile body content + PUT method, updateAreaNo body + POST method + success=false
src/account.tssrc/__tests__/account.test.ts21register token extraction + MD5 password assertion + idcardType detection + missing-token error, sendCode/checkCode void + error paths, updatePassword both passwords MD5'd + Authorization header
src/ride.tssrc/__tests__/ride.test.ts19listRides pagination defaults (pageStart=1, pageSize=20) + optional filters in URL + empty list + data-not-array guard, getRide detail fields + id as query param (not path) + invalid JSON, deleteRide DELETE method + id in path + success=false

Status: complete unit coverage for all implemented API surface. All 75 tests passing.


packages/ble-protocol

Run: pnpm --filter @open-cfmoto/ble-protocol test

FileTest fileCoverage
src/codec.ts__tests__/codec.test.tsframe build/parse round-trips, CRC, header/end validation, invalid frame rejection
src/auth.ts__tests__/auth.test.tsfull auth handshake behavior (0x5A -> 0x5B -> 0x5C -> 0x5D), success/failure paths, timeout paths, AES-256/ECB/PKCS7 round-trip helper validation
src/keepalive.ts__tests__/keepalive.test.ts2s heartbeat interval, 4s watchdog timeout, notifyAck() watchdog reset, stop() timer cleanup
src/response-router.ts__tests__/response-router.test.tsdispatch by control code, handler register/unregister, invalid frames ignored
src/commands/index.ts__tests__/commands.test.tscommand builders for lock/unlock/find-car/indicators/units/speed-limit + boundary checks
src/cfmoto450.tssrc/__tests__/cfmoto450.test.tscloud connect flow ordering (login -> getEncryptInfo -> authenticate), no-credentials dev mode, error propagation on login/encryptInfo failures

Status: protocol unit coverage includes cloud-auth integration flow at connect-time.


apps/mobile

Run: cd apps/mobile && pnpm test

FileTest fileCoverage
src/stores/bike.store.tssrc/__tests__/bike-store.test.tsheartbeat ack state, command history FIFO + ack marking
src/stores/settings.store.tssrc/__tests__/settings-store.test.tsdefaults, MMKV persistence, non-persisted useMockBike
src/providers/CFMotoProvider.tsxsrc/__tests__/provider.test.tsxAndroid permission/init flow, iOS init path, cleanup destroy
src/hooks/index.tssrc/__tests__/hooks.test.tsconnect helpers, connection guards, command send helpers, heartbeat derived state, ride summary persistence
src/services/ble.service.ts + protocol integrationsrc/__tests__/integration/ble-service.test.tsconnect order, subscribe/write wiring, MTU request, disconnect cleanup, reconnect behavior, keepalive manager behavior (tested directly; protocol wiring pending)

Hardware-pending validation

Still requires real bike + real cloud-linked vehicle:

  • Cloud encryptInfo populated with real VIN-linked vehicle (vehicleId != -1)
  • End-to-end auth against TBox with real encryptValue + key
  • Keep-alive ACK code confirmation on hardware (0xEC vs potential fallback observations)
  • Lock/unlock encrypted payload acceptance by real TBox
  • MotoPlay boundary confirmation vs cloud telemetry path

See: docs/hardware-validation.md.