Skip to content

test(ui): cover services (auth/sessions/samples/assets/fragments/imageAssets/pluginAssets/logs/health/plugins/config) and stores (schema/permission/nodePosition/plugin)#468

Open
staging-devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1779042232-cov-phase3-ui-services-stores
Open

Conversation

@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor

@staging-devin-ai-integration staging-devin-ai-integration Bot commented May 17, 2026

Summary

Phase 3 coverage initiative — Stream D. Test-only PR adding co-located *.test.ts files 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.ts co-located file):

  • ui/src/services/auth.tsfetchAuthMe, loginWithToken, logout, listTokens, createApiToken, revokeToken, createMoqToken (request shape, error branches, default subscribe/publish arrays, URL-encoding of jti).
  • ui/src/services/sessions.tslistSessions, createSession (name-trimming + null coercion), startPreview (omit-undefined body fields, URL-encoded session id), stopPreview; AbortSignal forwarding.
  • ui/src/services/samples.tslistSamples, listDynamicSamples, listAllSamples (dedupe by id), saveSample, deleteSample.
  • ui/src/services/assets.tslistAudioAssets, uploadAudioAsset, deleteAudioAsset, and the useAudioAssets / useUploadAudioAsset / useDeleteAudioAsset hooks (invalidation spy on queryClient.invalidateQueries).
  • ui/src/services/fragments.tsdecodeFragmentMetadata parser quirks (tag trimming, | in description, empty tags), samplesToFragments filter, 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-encoded typeId/id, plus useUploadPluginAsset (rejects on empty typeId, invalidates ['pluginAssets', typeId] on success).
  • ui/src/services/logs.tsfetchLogs query-string serialization (including offset=0), specific 404 error message ("Log file not available"), createLogStream SSE URL construction with withCredentials.
  • ui/src/services/health.ts — happy path, build_hash vs buildHash fallback, missing-field "unknown" defaults, AbortSignal forwarding.
  • ui/src/services/plugins.ts — upload (FormData['plugin']) and delete (?keep_file=true flag, URL-encoded kind), status N fallback in error messages.
  • ui/src/services/config.tsmoq_gateway_urlmoqGatewayUrl mapping 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 /packets and /nodes failure 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 the getCurrentPermissions deny-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, flip isLoaded); removePlugin (no-op on unknown kind); ensurePluginsLoaded (single-flight dedup, retry after failure); reloadPlugins.

Style anchors followed

Verification

  • cd ui && bun run test1005 tests pass across 64 files.
  • just lint-ui → clean (prettier + eslint + tsc); only pre-existing warnings in unrelated files.

Review & Testing Checklist for Human

  • Spot-check that the test cases reflect intended contracts of the services/stores rather than over-fitting current implementation details (e.g. status-code substrings in error messages, null license defaults).
  • Confirm the 409-handling test in imageAssets.test.ts matches the intent of the upload-fallback in imageAssets.ts:48-57 (sanitized-name match against listed assets).

Notes

Link to Devin session: https://staging.itsdev.in/sessions/3aa2ee1bed044416aa11fc3c30ab483c
Requested by: @streamer45


Devin Review

Status Commit
🕐 Outdated c2d581d (HEAD is 2197d1c)

Run Devin Review

Open in Devin Review (Staging)

…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>
@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.19%. Comparing base (fad6274) to head (2197d1c).
⚠️ Report is 1 commits behind head on main.

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              
Flag Coverage Δ
backend 65.02% <ø> (+0.03%) ⬆️
ui 76.92% <ø> (+1.84%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 84.29% <ø> (ø)
engine 75.71% <ø> (ø)
api 84.73% <ø> (ø)
nodes 67.48% <ø> (+0.07%) ⬆️
server 57.16% <ø> (ø)
plugin-native 70.93% <ø> (ø)
plugin-wasm 6.37% <ø> (ø)
ui-services 78.01% <ø> (+3.27%) ⬆️
ui-components 60.49% <ø> (ø)
see 17 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor Author

@staging-devin-ai-integration staging-devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review (Staging)
Debug

Playground

Comment thread ui/src/stores/schemaStore.test.ts Outdated

await expect(ensureSchemasLoaded()).rejects.toThrow();

// Second attempt with successful responses should re-fetch.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
// Second attempt with successful responses should re-fetch.
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant