Skip to content

test(logo): improve unit test coverage for Logo execution engine#7746

Merged
walterbender merged 1 commit into
sugarlabs:masterfrom
vanshika2720:test/logo-coverage-improvements
Jul 7, 2026
Merged

test(logo): improve unit test coverage for Logo execution engine#7746
walterbender merged 1 commit into
sugarlabs:masterfrom
vanshika2720:test/logo-coverage-improvements

Conversation

@vanshika2720

Copy link
Copy Markdown
Contributor

Summary

This PR improves the unit test coverage for logo.js by adding comprehensive tests for previously untested logic and important edge cases. No production code is modified.

Changes Made

Added tests for safePluginExecute()

  • Successful function execution
  • Error handling and recovery
  • Unary, binary, and constant math plugin patterns
  • Parameter plugin pattern
  • Arbitrary code execution rejection

Expanded parseArg() coverage

  • dectofrac with null and non-number child values
  • Hue block outside status matrix
  • returnValue with empty and populated stacks
  • evalArgDict dispatch
  • Unknown block fallback handling

Added dispatchTurtleSignals() tests

  • All dispatch factor threshold branches:
    • > 100
    • > 50
    • > 25
    • > 12.5
    • ≤ 12.5
  • Zero-step-time clamping

Added timer manager tests

  • Getter behavior
  • clearAll()
  • getStats()
  • setGuardedTimeout() when:
    • guard allows execution
    • guard suppresses execution

Added doStopTurtles() tests

  • Delayed timeout cleanup
  • Timer manager cleanup
  • Debug logging when timers are cancelled

Added runLogoCommands() tests

  • evalOnStartList plugin execution
  • Listener cleanup
  • Drum block handling in startBlocks

Added runFromBlockNow() tests

  • MAX_ITERATIONS guard
  • evalFlowDict plugin dispatch
  • Null-value argument block handling

Added constructor compatibility tests

  • Activity facade delegation
  • Empty collection initialization
  • Initial state verification

Added miscellaneous edge-case tests

  • Empty stepQueue
  • Multiple turtle initialization
  • clearNoteParams() state reset

Coverage Improvement (logo.js)

Metric Before After
Statements 82.53% 87.66%
Branches 68.66% 72.18%
Functions 72.13% 80.32%
Lines 82.93% 88.10%

Testing Performed

  • Ran npx jest js/tests/logo.test.js
  • Ran the full Jest test suite to ensure no regressions
  • Verified ESLint and Prettier pass

Checklist

  • Tests added for new and existing behavior
  • No production code changes
  • Full test suite passes
  • ESLint and Prettier pass
  • Existing functionality remains unchanged
  • Tests

@github-actions github-actions Bot added tests Adds or updates test coverage size/XL Extra large: 500-999 lines changed area/javascript Changes to JS source files area/tests Changes to test files labels Jul 5, 2026
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.70%. Comparing base (a138477) to head (18d057c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7746      +/-   ##
==========================================
+ Coverage   56.60%   56.70%   +0.09%     
==========================================
  Files         172      172              
  Lines       57675    57675              
==========================================
+ Hits        32645    32702      +57     
+ Misses      25030    24973      -57     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with master.

Please rebase your branch:

# Add upstream remote (one-time setup)
git remote add upstream https://github.com/sugarlabs/musicblocks.git

# Fetch latest master and rebase
git fetch upstream
git rebase upstream/master

# Resolve any conflicts, then:
git push --force-with-lease origin YOUR_BRANCH

Tip: Enable "Allow edits from maintainers" on this PR so we can auto-rebase for you next time. This only grants access to your PR branch. Your fork's other branches are not affected.

@github-actions github-actions Bot added needs-rebase size/XXL XXL: 1000+ lines changed and removed size/XL Extra large: 500-999 lines changed labels Jul 5, 2026
@vanshika2720 vanshika2720 force-pushed the test/logo-coverage-improvements branch from 93b7d53 to d46cf95 Compare July 5, 2026 20:59
@vanshika2720 vanshika2720 force-pushed the test/logo-coverage-improvements branch from d46cf95 to b3f678f Compare July 5, 2026 21:09
@github-actions github-actions Bot added size/XL Extra large: 500-999 lines changed size/XXL XXL: 1000+ lines changed and removed size/XXL XXL: 1000+ lines changed size/XL Extra large: 500-999 lines changed labels Jul 5, 2026
@vanshika2720 vanshika2720 force-pushed the test/logo-coverage-improvements branch from 5d3a111 to a70cb43 Compare July 6, 2026 18:57
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with master.

Please rebase your branch:

# Add upstream remote (one-time setup)
git remote add upstream https://github.com/sugarlabs/musicblocks.git

# Fetch latest master and rebase
git fetch upstream
git rebase upstream/master

# Resolve any conflicts, then:
git push --force-with-lease origin YOUR_BRANCH

Tip: Enable "Allow edits from maintainers" on this PR so we can auto-rebase for you next time. This only grants access to your PR branch. Your fork's other branches are not affected.

@github-actions github-actions Bot added area/css Changes to CSS/SASS style files area/docs Changes to documentation area/i18n Changes to localization files labels Jul 6, 2026
@vanshika2720 vanshika2720 force-pushed the test/logo-coverage-improvements branch from a70cb43 to 78690bf Compare July 6, 2026 19:06
@github-actions github-actions Bot removed area/css Changes to CSS/SASS style files area/docs Changes to documentation area/i18n Changes to localization files needs-rebase labels Jul 6, 2026
Adds 112 tests covering previously untested branches across the Logo
execution engine. All tests are in js/__tests__/logo.test.js; no
production code is modified.

Coverage additions
- Queue constructor: null args, empty array args
- Logo constructor: all property initialisations, widget defaults,
  empty dictionaries, Notation/Synth/StatusMatrix construction
- Logo getters/setters: turtleDelay, notation, setCameraID
- Logo clearNoteParams: singer fields reset, per-turtle scope
- Logo safePluginExecute: normal execution, error catching, whitelisted
  math patterns (unary / binary / constants / parameter plugin), blocked
  arbitrary string code
- Logo plugin registration: evalFlowDict, evalArgDict, evalParameterDict,
  evalOnStartList, evalOnStopList
- Logo prepSynths / resetSynth: instrument copy across turtles, volume
  reset, synth engine start
- Logo doStopTurtles: stopTurtle flag, block/highlight teardown, cursor
  reset, clearTimeout for pending timers, timerManager.clearAll, Transport
  cancellation and audio-stream cleanup with two-turtle scenarios
- Logo runLogoCommands: startHere / startBlocks dispatch, evalOnStartList
  hooks, cursor fallback, listener removal from stage, drum-block
  inclusion, already-running guard, action-block registration
- Logo runFromBlock: step-mode queuing, timeout scheduling, Transport
  schedule / fallback paths
- Logo runFromBlockNow: stopTurtle guard, _iterationBudget MAX_ITERATIONS
  guard, profiling on/off via performanceTracker, evalFlowDict dispatch,
  embedded-graphics scheduling, flow-plugin execution, unhighlight queue
  processing, parameter-block updates, empty-queue termination
- Logo clearTurtleRun: clearTimeout resume, Transport event cancel,
  no-op when nothing pending
- Logo parseArg: number/string/named-box/action-box/colour return types,
  error paths, StatusMatrix field registration
- Logo dispatchTurtleSignals: EmbeddedGraphicsScheduler delegation,
  dispatch-factor thresholds (NOTEDIV steps) via test.each
- Logo timerManager: clearAll / getStats / setGuardedTimeout API
- Logo updateNotation / notationMIDI / initMediaDevices / processShow

Test structure
- Flat per-feature describe blocks with nested sub-describes where a
  single feature has multiple distinct behaviours
- Shared helpers: setupLogoEnv(), createMockTurtle(), createMockActivity(),
  createTwoTurtleActivity(), makeFlowBlock(), makeNumArgBlock()
- No implementation-detail assertions (private fields, internal queues,
  timer IDs); tests verify externally observable behaviour only

Signed-off-by: Vanshika <pahalvanshikaa@gmail.com>
@vanshika2720 vanshika2720 force-pushed the test/logo-coverage-improvements branch from 78690bf to 18d057c Compare July 6, 2026 19:16
@vanshika2720 vanshika2720 marked this pull request as ready for review July 6, 2026 19:19
@vanshika2720

Copy link
Copy Markdown
Contributor Author

@walterbender

@walterbender

Copy link
Copy Markdown
Member

Wow. A big improvement. Thx.

@walterbender walterbender merged commit 760a08d into sugarlabs:master Jul 7, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/javascript Changes to JS source files area/tests Changes to test files size/XXL XXL: 1000+ lines changed tests Adds or updates test coverage

Projects

Development

Successfully merging this pull request may close these issues.

2 participants