test: improve unit test coverage for legobricks.js#7733
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7733 +/- ##
==========================================
+ Coverage 56.80% 56.85% +0.05%
==========================================
Files 172 172
Lines 57683 57683
==========================================
+ Hits 32767 32798 +31
+ Misses 24916 24885 -31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@walterbender PTAL !! |
|
@NAME-ASHWANIYADAV _generateRowsFromPitchBlocks, _collectNotesToPlay, and _mergeConsecutiveColorSegments are still untested despite being key parts of the workflow. I'd also recommend adding a test that exercises _addColorSegment's initialization path, which currently exposes a production bug (this.this). Once those are covered, this should be in good shape. |
There was a problem hiding this comment.
The new tests are a great step forward. You've covered the main functions and helpers really well.
I agree with vanshika there is a need of test for how "addColorSegment" starts up. That's the exact place where the "this.this" bug would show up if a row needs to be created from scratch ..
Thanks for the review @vanshika2720! Just to clarify - and on
Total tests are now 112 (was 108). All passing! |
Thanks @Chaitu7032! Agreed - I've added the The test confirms that the |
|
just a small change this.this.matrixData to this.metrixData and then flip the test from .toThrow(TypeError) to a real assertion that the new entry gets created correctly. neat picking after that good to go |
|
This PR has merge conflicts with 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
|
8de4451 to
2760671
Compare
Description
legobricks.jsis one of the largest widget files (119KB / 3150 lines) but had limited test coverage (46 tests). This PR adds 62 new tests (total: 108) covering previously untested methods and edge cases.PR Category
Changes Made
New test suites for previously untested methods:
_generateRowsFromPitchBlocks(5 tests) - pitch row generation, frequency-based sorting, solfege display name conversion, drum block filtering, default row fallback_collectNotesToPlay(5 tests) - null/empty colorData handling, background vs active note detection, note value assignment by duration, multi-row pitch collection_mergeConsecutiveColorSegments(6 tests) - same-color merging, gray variant merging, non-gray rejection, zero/one segment handling, multi-row independenceExtended edge-case coverage for existing methods:
_getColorFamily(10 tests) - all 10 hue ranges: orange, yellow, cyan, purple, magenta, pink, red wrap-around, gray mid-lightness, boundary values_rgbToHsl(6 tests) - green, blue, mid-gray, yellow, cyan, low-lightness_convertRowToPitch(6 tests) - flat notes (Db, Eb, Bb), sharps (F#), all 7 natural notes, multi-digit octaves_getColorHex(1 test) - all 12 known color codes in a single assertion_getContrastColor(2 tests) - all 5 light colors, all 7 dark colors_shouldMergeColors(3 tests) - all gray pairs, non-gray distinct pairs, gray vs non-gray_colorsAreSimilar(6 tests) - both null, low-saturation, close HSL values, large sat/light differences, hue wrap-around_filterSmallSegments(4 tests) - empty input, single element, all-large segments, consecutive small absorption_analyzeColumnBoundaries(3 tests) - no colorSegments, deduplication, 500ms merge thresholdaddRowBlock(2 tests) - triple duplicates, correct rowMap indexing_getColorFamilyByName(2 tests) - all 12 known colors, hue property verificationTesting Performed
npx jest js/widgets/__tests__/legobricks.test.js --verboselocallyChecklist
npm run lintandnpx prettier --check .with no errors.