Skip to content

Test: expand musicutils core coverage#6474

Merged
walterbender merged 5 commits intosugarlabs:masterfrom
sapnilbiswas:musicutils-core-tests
Apr 18, 2026
Merged

Test: expand musicutils core coverage#6474
walterbender merged 5 commits intosugarlabs:masterfrom
sapnilbiswas:musicutils-core-tests

Conversation

@sapnilbiswas
Copy link
Copy Markdown
Contributor

@sapnilbiswas sapnilbiswas commented Apr 2, 2026

Summary

Adds focused unit tests for musicutils.js core constants and mode utilities.

Changes

  • added new js/__tests__/utils/musicutils.test.js covering note names, solfege names, accidentals, and mode definitions
  • expanded js/utils/__tests__/musicutils.test.js to cover additional core lookup and mode-mapping branches
  • increased js/utils/musicutils.js statement coverage to 63.68%

Testing

  • npm test -- --coverage --runTestsByPath js/utils/__tests__/musicutils.test.js js/__tests__/utils/musicutils.test.js --collectCoverageFrom=js/utils/musicutils.js
  • npm test -- --json --outputFile=jest-results.json

PR category

  • Tests - Adds or updates test coverage

Fixes #6471

@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 Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

✅ All Jest tests passed! This PR is ready to merge.

@sapnilbiswas sapnilbiswas force-pushed the musicutils-core-tests branch from e751d6c to ea0ca4b Compare April 2, 2026 22:50
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

✅ All Jest tests passed! This PR is ready to merge.

Copy link
Copy Markdown
Contributor

@vanshika2720 vanshika2720 left a comment

Choose a reason for hiding this comment

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

@sapnilbiswas Some behaviors are being tested in multiple ways (VM + jest.requireActual), which adds redundancy and complexity. Also, globals aren’t cleaned up between tests.

Please simplify to one approach

@github-actions github-actions Bot added size/L Large: 250-499 lines changed and removed size/XL Extra large: 500-999 lines changed labels Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

✅ All Jest tests passed! This PR is ready to merge.

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

Thanks, @vanshika2720, for the review. I have tried reducing the redundancy in the test

Copy link
Copy Markdown
Contributor

@vanshika2720 vanshika2720 left a comment

Choose a reason for hiding this comment

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

@sapnilbiswas Thanks for the update and improved coverage! A few things still need attention:

Some duplicate test blocks — please clean those up
Mixed testing approaches — consider using a single consistent method
Globals aren’t cleaned between tests — add proper teardown
A few assertions are a bit brittle

Copilot AI review requested due to automatic review settings April 5, 2026 11:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

✅ All Jest tests passed! This PR is ready to merge.

@github-actions github-actions Bot added size/XL Extra large: 500-999 lines changed and removed size/L Large: 250-499 lines changed labels Apr 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

✅ All Jest tests passed! This PR is ready to merge.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands Jest unit test coverage for js/utils/musicutils.js, focusing on core music constants, scale/mode utilities, and additional lookup/mapping branches to reduce the risk of silent regressions in foundational music logic.

Changes:

  • Added a new test file to validate core constants (note names, solfege, accidentals, and mode definitions).
  • Expanded existing musicutils tests with additional cases for lookup fallbacks and mode/scale-mapping branches.
  • Increased coverage for js/utils/musicutils.js (per PR description).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
js/utils/__tests__/musicutils.test.js Adds helper-based global overrides and new test cases to hit additional fallback/mode-mapping branches.
js/__tests__/utils/musicutils.test.js Introduces focused tests for core music constants and mode definitions by loading constants from musicutils.js.
Comments suppressed due to low confidence (1)

js/utils/tests/musicutils.test.js:1137

  • This withGlobalOverrides setup looks unused: getCustomNote references DOUBLEFLAT/DOUBLESHARP/FLAT/SHARP from the module scope in musicutils.js, not from global. Removing the override would reduce noise and avoid implying these symbols are configurable via globals.
    it("should handle array input by taking first element", () => {
        expect(getCustomNote(["C", "other"])).toBe("C");
        expect(getCustomNote(["D#", "other"])).toBe("D♯");
    });
    it("should convert double flat notation", () => {
        expect(getCustomNote("Cbb")).toBe("C𝄫");
        expect(getCustomNote("Dbb")).toBe("D𝄫");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/utils/__tests__/musicutils.test.js Outdated
Comment thread js/utils/__tests__/musicutils.test.js Outdated
Comment thread js/utils/__tests__/musicutils.test.js Outdated
Comment thread js/__tests__/utils/musicutils.test.js Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

✅ All Jest tests passed! This PR is ready to merge.

Copy link
Copy Markdown
Contributor

@vanshika2720 vanshika2720 left a comment

Choose a reason for hiding this comment

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

@sapnilbiswas Looks much cleaner, thanks!
but still above issue remains

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

✅ All Jest tests passed! This PR is ready to merge.

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

Thank you for the follow-up review. I did one more small cleanup pass that only focused on making things consistent:

  • made the last global-heavy setup blocks in js/utils/__tests__/musicutils.test.js use the shared override helper.
  • kept the claims and coverage the same
  • stayed away from any changes to the production code or bigger refactors

Checked again locally after the update:

  • full Jest suite passes (125 suites and 4028 tests)
  • The targeted coverage for musicutils.js is still above the goal for the issue, which is 68.56% statements and 60.73% branches.

When you have a chance, please look again.

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

Please let me know if something specifically needed

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

@walterbender Sir can you please review my PR and let me know if there is anything i am missing at

Copy link
Copy Markdown
Contributor

@vanshika2720 vanshika2720 left a comment

Choose a reason for hiding this comment

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

Hi @sapnilbiswas, this PR seems to be a duplicate of #6470. We should probably consolidate our efforts there to keep the PR history clean!

@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@sapnilbiswas sapnilbiswas marked this pull request as draft April 18, 2026 08:53
@sapnilbiswas sapnilbiswas force-pushed the musicutils-core-tests branch from 70347d5 to 5e86191 Compare April 18, 2026 08:58
@github-actions github-actions Bot added size/M Medium: 50-249 lines changed and removed size/XXL XXL: 1000+ lines changed labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Copy Markdown
Contributor

Merge conflicts resolved. Ready for review.

@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions github-actions Bot added size/L Large: 250-499 lines changed and removed size/M Medium: 50-249 lines changed labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

@Ashutoshx7 @vanshika2720 I have tried resolving all the scope creep and making it clean. Could you please help me with reviewing it

@sapnilbiswas sapnilbiswas marked this pull request as ready for review April 18, 2026 09:19
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Ashutoshx7
Copy link
Copy Markdown
Contributor

@Ashutoshx7 @vanshika2720 I have tried resolving all the scope creep and making it clean. Could you please help me with reviewing it

reviewing it right away

@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Ashutoshx7
Copy link
Copy Markdown
Contributor

are u stil working on this
i can see the recent commit

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

are u stil working on this i can see the recent commit

I am done with it. You can go ahead with reviewing

@Ashutoshx7
Copy link
Copy Markdown
Contributor

This PR is extremely clean, addresses redundancy in the test suite as requested during review, and follows all repository patterns. I am 100% confident that this is ready for merge.
@walterbender
and we can close #6470

@sapnilbiswas
Copy link
Copy Markdown
Contributor Author

This PR is extremely clean, addresses redundancy in the test suite as requested during review, and follows all repository patterns. I am 100% confident that this is ready for merge. @walterbender and we can close #6470

Thanks @Ashutoshx7 for reviewing this

@walterbender walterbender merged commit 5ad1c71 into sugarlabs:master Apr 18, 2026
10 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/L Large: 250-499 lines changed tests Adds or updates test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Add Unit Tests for musicutils.js — Core Music Constants & Utilities Are Untested

5 participants