test(ui): cover yamlAutocompletion, fragmentUtils, jsonStream, nodeIssues, samplePipelineOrdering, mse, deepEqual#471
Open
staging-devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…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>
Contributor
Author
🤖 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 #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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.unstubAllGlobalsfor DOM globals).deepEqual.tsObject.issemantics forNaNand-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.tsextractJsonValuesframing: single, concatenated}{, partial-trailing-remainder, nested objects/arrays, braces inside strings, escaped quotes/backslashes, top-level arrays, leading garbage, empty inputnodeIssues.tsshortSessionId(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),summarizeNodeIssuesseverity ordering (Failed < Degraded < Recovering < Stopped, then nodeId)samplePipelineOrdering.tscompareSamplePipelinesByName(Intl numeric collation, id tiebreaker),orderSamplePipelinesSystemFirst(partition + sort, no mutation),matchesSamplePipelineQuery(empty/whitespace queries, name/description/id substring, case-insensitive, trim)mse.tsnormalizeMimeType(opus/vp9/AAC-LC/AVC baseline injection, pass-through whencodecs=already present),canUseMseForMimeTypewithvi.stubGlobal('MediaSource', …)covering: missing global, supported, unsupported, missingisTypeSupported, pre-codec'd typefragmentUtils.tsgenerateNodeIdsequential ids,fragmentToReactFlow(1-to-1 node/edge count,audioGaintype 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 bothyamlAutocompletion.tsvi.hoistedmock of@codemirror/autocomplete, then drives it with syntheticEditorState+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 unquotedapply), and the fall-through-to-null pathTotal: 147 new tests. Local: 1011/1011 passing (
bun run test:run),just lint-uiclean for new files (the 6 remaining warnings predate this PR and are inAssetLibrary.tsx,ConfigurableNode.tsx,InspectorPane.tsx,DesignView.tsx,StreamView.tsx).All new files have SPDX headers. No new dependencies.
Notes
yamlAutocompletionmock pattern usesvi.hoistedto share state with the (hoisted)vi.mockfactory — same pattern used elsewhere in the repo for similar capture-the-callback scenarios.Review & Testing Checklist for Human
Risk: green (test-only, isolated to new files).
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).deepEqual(-0, 0) === falseassertion matches the intendedObject.issemantics ofdeepEqual(the implementation usesObject.is, which treats-0and+0as distinct).Link to Devin session: https://staging.itsdev.in/sessions/d3d99542ef1b4daa81e29a9aaffdc353
Requested by: @streamer45