Skip to content

test(ui): cover yamlAutocompletion, fragmentUtils, jsonStream, nodeIssues, samplePipelineOrdering, mse, deepEqual#471

Open
staging-devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1779042222-cov-phase3-ui-utils
Open

test(ui): cover yamlAutocompletion, fragmentUtils, jsonStream, nodeIssues, samplePipelineOrdering, mse, deepEqual#471
staging-devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1779042222-cov-phase3-ui-utils

Conversation

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

Summary

Phase 3 coverage initiative — Stream E (UI utils, pure logic). Test-only PR; no production code touched.

Adds Vitest unit tests for seven previously-uncovered modules in ui/src/utils/. Style mirrors PR #440 / #441 (describe/it, table-driven where natural) and PR #425 (vi.stubGlobal + vi.unstubAllGlobals for DOM globals).

Module Lines Tests added What's covered
deepEqual.ts 41 34 primitives (incl. Object.is semantics for NaN and -0), arrays (lengths, order, nesting, sparse), plain objects (key sets, nesting, null-prototype, {a: undefined} vs {}), non-plain objects (Map/Date/class instances, function ref identity)
jsonStream.ts 70 16 extractJsonValues framing: single, concatenated }{, partial-trailing-remainder, nested objects/arrays, braces inside strings, escaped quotes/backslashes, top-level arrays, leading garbage, empty input
nodeIssues.ts 73 25 shortSessionId (dash split, no-dash whole-string return, empty-first-segment 8-char fallback), formatIssueDetails (null/undefined → null, JSON shape, 180-char truncation + ellipsis, circular-ref returns null), formatIssueSummary (with/without details), summarizeNodeIssues severity ordering (Failed < Degraded < Recovering < Stopped, then nodeId)
samplePipelineOrdering.ts 50 16 compareSamplePipelinesByName (Intl numeric collation, id tiebreaker), orderSamplePipelinesSystemFirst (partition + sort, no mutation), matchesSamplePipelineQuery (empty/whitespace queries, name/description/id substring, case-insensitive, trim)
mse.ts 41 12 normalizeMimeType (opus/vp9/AAC-LC/AVC baseline injection, pass-through when codecs= already present), canUseMseForMimeType with vi.stubGlobal('MediaSource', …) covering: missing global, supported, unsupported, missing isTypeSupported, pre-codec'd type
fragmentUtils.ts 164 14 generateNodeId sequential ids, fragmentToReactFlow (1-to-1 node/edge count, audioGain type selection, grid layout math, NodeDefinition wiring, missing-def fallback, missing-needs-warn path via mocked logger), extractFragment (selection set, needs scalar vs array forms, omits needs with no deps, label/kind fallbacks), round-trip through both
yamlAutocompletion.ts 452 30 Captures the override completion source via a vi.hoisted mock of @codemirror/autocomplete, then drives it with synthetic EditorState + CompletionContext: mode: (dynamic/oneshot filter), kind: (NodeDefinition listing, categories detail), needs: (scalar form + array - element form + js-yaml-throws regex fallback), params: name completions (description + default detail), params: value completions (enum / boolean / number-with-default+range / string-default with quoted label and unquoted apply), and the fall-through-to-null path

Total: 147 new tests. Local: 1011/1011 passing (bun run test:run), just lint-ui clean for new files (the 6 remaining warnings predate this PR and are in AssetLibrary.tsx, ConfigurableNode.tsx, InspectorPane.tsx, DesignView.tsx, StreamView.tsx).

All new files have SPDX headers. No new dependencies.

Notes

Review & Testing Checklist for Human

Risk: green (test-only, isolated to new files).

  • Skim ui/src/utils/yamlAutocompletion.test.ts — confirm the mock-and-capture approach is acceptable repo-wide (the alternative would be exposing the completion source as a named export, but that would be a production-code change and this PR is test-only).
  • Confirm the deepEqual(-0, 0) === false assertion matches the intended Object.is semantics of deepEqual (the implementation uses Object.is, which treats -0 and +0 as distinct).
  • CI green on the codecov UI flag.

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

…sues, samplePipelineOrdering, mse, deepEqual

Add pure-logic unit tests for seven previously-uncovered ui/src/utils
modules, following the style of PRs #440/#441/#425:

- deepEqual: primitives, arrays, plain/nested objects, NaN, functions,
  Map/Date/class instances (non-plain).
- jsonStream: extractJsonValues framing for single, concatenated,
  partial, nested, string-with-braces, escape-sequence inputs.
- nodeIssues: shortSessionId fallbacks, formatIssueDetails (null,
  truncation at 180 chars, circular ref), formatIssueSummary,
  summarizeNodeIssues severity ordering.
- samplePipelineOrdering: Intl.Collator name+id comparison, system-first
  partitioning, query trimming + substring matching.
- mse: normalizeMimeType for opus/vp9/AAC/AVC and pass-through;
  canUseMseForMimeType with vi.stubGlobal MediaSource.
- fragmentUtils: generateNodeId sequence, fragmentToReactFlow node
  shape, grid layout, edge stitching, missing-dep warn path,
  extractFragment selection + needs scalar/array forms, round-trip.
- yamlAutocompletion: mock @codemirror/autocomplete via vi.hoisted to
  capture the override completion source, then drive it with synthetic
  EditorState/CompletionContext for mode:, kind:, needs: scalar/array,
  params name/value (enum/boolean/number/string) completions, plus the
  js-yaml regex fallback path.

Phase 3 coverage initiative — Stream E.
Parent session: https://staging.itsdev.in/sessions/a088e863cbbd473b9be4a57529fc674b

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.14%. Comparing base (fad6274) to head (9bc2d44).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #471      +/-   ##
==========================================
+ Coverage   65.91%   66.14%   +0.22%     
==========================================
  Files         217      220       +3     
  Lines       57530    57816     +286     
  Branches     1597     1683      +86     
==========================================
+ Hits        37922    38241     +319     
+ Misses      19602    19569      -33     
  Partials        6        6              
Flag Coverage Δ
backend 65.01% <ø> (+0.01%) ⬆️
ui 76.77% <ø> (+1.69%) ⬆️

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.45% <ø> (+0.04%) ⬆️
server 57.16% <ø> (ø)
plugin-native 70.93% <ø> (ø)
plugin-wasm 6.37% <ø> (ø)
ui-services 74.73% <ø> (ø)
ui-components 60.49% <ø> (ø)
see 9 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.

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