test(ui): cover services (auth/sessions/samples/assets/fragments/imageAssets/pluginAssets/logs/health/plugins/config) and stores (schema/permission/nodePosition/plugin)#468
Conversation
…eAssets/pluginAssets/logs/health/plugins/config) and stores (schema/permission/nodePosition/plugin) Phase 3 coverage initiative — Stream D. Adds co-located *.test.ts files for 11 service modules and 4 zustand stores, following the style anchors from PR #439 (services) and PRs #441 / #446 (stores): - mock ./base so fetchApi is a thin wrapper around fetch, asserting request URL + method + body shape and a non-2xx error branch per service. - exercise public actions/setters on each store and verify final state + derived selectors (e.g. getCurrentPermissions deny-all fallback, syncPluginSchemas single-flight + reload-on-missing). - React Query hook tests use a per-test QueryClient with a spy on invalidateQueries to assert cache invalidation on successful mutations. No production code changes. Signed-off-by: Staging-Devin AI <166158716+staging-devin-ai-integration[bot]@users.noreply.github.com> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #468 +/- ##
==========================================
+ Coverage 65.91% 66.19% +0.28%
==========================================
Files 217 231 +14
Lines 57530 57977 +447
Branches 1597 1690 +93
==========================================
+ Hits 37922 38380 +458
+ Misses 19602 19591 -11
Partials 6 6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
|
||
| await expect(ensureSchemasLoaded()).rejects.toThrow(); | ||
|
|
||
| // Second attempt with successful responses should re-fetch. |
There was a problem hiding this comment.
🟡 Added comment narrates the retry setup instead of explaining why
The new comment only describes the immediately following test setup (mockSchemaFetch followed by ensureSchemasLoaded) and does not document a non-obvious constraint. AGENTS.md makes the comment guidelines mandatory and explicitly bans line narration / comments that explain how obvious code works, so this added comment should be removed or replaced with a true rationale if one is needed.
| // Second attempt with successful responses should re-fetch. |
Was this helpful? React with 👍 or 👎 to provide feedback.
Debug
There was a problem hiding this comment.
Good catch — removed the line-narration comment in 2197d1c. The mockSchemaFetch call followed by the successful ensureSchemasLoaded assertion is self-explanatory.
Devin Review flagged the comment as line narration per AGENTS.md comment guidelines; the assertion below makes the intent clear. Signed-off-by: Staging-Devin AI <166158716+staging-devin-ai-integration[bot]@users.noreply.github.com> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
Summary
Phase 3 coverage initiative — Stream D. Test-only PR adding co-located
*.test.tsfiles for 11 UI service modules and 4 zustand stores. No production code changes.Parent session: https://staging.itsdev.in/sessions/a088e863cbbd473b9be4a57529fc674b
Services covered (each gets a
*.test.tsco-located file):ui/src/services/auth.ts—fetchAuthMe,loginWithToken,logout,listTokens,createApiToken,revokeToken,createMoqToken(request shape, error branches, defaultsubscribe/publisharrays, URL-encoding ofjti).ui/src/services/sessions.ts—listSessions,createSession(name-trimming + null coercion),startPreview(omit-undefined body fields, URL-encoded session id),stopPreview; AbortSignal forwarding.ui/src/services/samples.ts—listSamples,listDynamicSamples,listAllSamples(dedupe by id),saveSample,deleteSample.ui/src/services/assets.ts—listAudioAssets,uploadAudioAsset,deleteAudioAsset, and theuseAudioAssets/useUploadAudioAsset/useDeleteAudioAssethooks (invalidation spy onqueryClient.invalidateQueries).ui/src/services/fragments.ts—decodeFragmentMetadataparser quirks (tag trimming,|in description, empty tags),samplesToFragmentsfilter, YAML round-trip,saveFragment(encodes tags into description),deleteFragment.ui/src/services/imageAssets.ts— list/upload/delete, the 409-reuse fallback (matches sanitized filename against existing assets), and the hooks with cache-invalidation assertions.ui/src/services/pluginAssets.ts— list/upload/delete with URL-encodedtypeId/id, plususeUploadPluginAsset(rejects on emptytypeId, invalidates['pluginAssets', typeId]on success).ui/src/services/logs.ts—fetchLogsquery-string serialization (includingoffset=0), specific 404 error message ("Log file not available"),createLogStreamSSE URL construction withwithCredentials.ui/src/services/health.ts— happy path,build_hashvsbuildHashfallback, missing-field"unknown"defaults, AbortSignal forwarding.ui/src/services/plugins.ts— upload (FormData['plugin']) and delete (?keep_file=trueflag, URL-encoded kind),status Nfallback in error messages.ui/src/services/config.ts—moq_gateway_url→moqGatewayUrlmapping and missing-field handling.Stores covered:
ui/src/stores/schemaStore.ts— initial state + setters;ensureSchemasLoaded(single-flight dedup, error short-circuit, retry after failure, both/packetsand/nodesfailure branches);reloadSchemas;syncPluginSchemas(no-op when all kinds present, reload when missing, concurrent dedup).ui/src/stores/permissionStore.ts— initial state, each public setter/action's effect,reset(), and thegetCurrentPermissionsdeny-all fallback selector.ui/src/stores/nodePositionStore.ts— initial state,updateNodePosition(creates session, preserves other nodes, overwrites, isolates sessions),getNodePositions(empty default),clearSession(targeted removal, no-op for unknown session).ui/src/stores/pluginStore.ts— initial state + setters;upsertPlugin(prepend new, replace by kind, flipisLoaded);removePlugin(no-op on unknown kind);ensurePluginsLoaded(single-flight dedup, retry after failure);reloadPlugins.Style anchors followed
fontAssets) —vi.mock('./base')to makefetchApia thin wrapper aroundfetch; assert URL, method, headers, body, parsed response; cover a non-2xx branch.telemetryStore) and PR test(ui/streamStoreHelpers): cover performConnect, watch/mic warnings, status sync #446 (streamStoreHelpers) — call action functions directly and assert final store state.QueryClientand avi.spyOn(queryClient, 'invalidateQueries')to verify cache invalidation on successful mutations.Verification
cd ui && bun run test→ 1005 tests pass across 64 files.just lint-ui→ clean (prettier + eslint + tsc); only pre-existing warnings in unrelated files.Review & Testing Checklist for Human
nulllicense defaults).imageAssets.test.tsmatches the intent of the upload-fallback inimageAssets.ts:48-57(sanitized-name match against listed assets).Notes
agent_docs/coverage.md(Stream D guidance).*.test.tsfiles were added.Link to Devin session: https://staging.itsdev.in/sessions/3aa2ee1bed044416aa11fc3c30ab483c
Requested by: @streamer45
Devin Review
c2d581d(HEAD is2197d1c)