Page MenuHomePhabricator

[MEX][Score] Introduce basic test to confirm display of musical notation statements
Closed, ResolvedPublic

Description

There are currently no tests in Extension:Score. We'll want to cover at least basic adding and editing of statements with the musical-notation datatype with a test.

Since the datatype can already be displayed in wbui2025's view-mode, we can introduce tests and use it to confirm the display before changing the functionality.

Acceptance Criteria

  • there is one test for this extension
  • the test runs when changes are pushed to gerrit. Merging is blocked when this test is failing

Note: cypress likely is not compatible

Event Timeline

@ArthurTaylor mentioned in the parent task:

The task split looks pretty sensible, and we can go through in more detail when we do the task breakdown. The big concern I have is about the end-to-end testing - we would need a way to enable the Musical Notation datatype for Wikibase when the Score extension is loaded, and we would need there to be a live Shellbox for CI that has lilypond installed. I expect that both of these things will be hard to achieve with Quibble. We might have to make do with unit testing - still an improvement on the zero tests currently included in the Score extension.

For task breakdown: consider changing the title and acceptance criteria for this task to unit tests rather than e2e (cypress) tests

karapayneWMDE renamed this task from [MEX][Score] Introduce basic cypress test to confirm display of musical notation statements to [MEX][Score] Introduce basic test to confirm display of musical notation statements.Dec 16 2025, 10:22 AM
karapayneWMDE updated the task description. (Show Details)

Change #1224101 had a related patch set uploaded (by Mahmoud-abdelsattar; author: Mahmoud-abdelsattar):

[mediawiki/extensions/Score@master] Introduce basic tests for musical notations

https://gerrit.wikimedia.org/r/1224101

πŸ”„ Development Handover Summary

NOTE: 🟒 Move from "In Development" > "Ready for Peer Review"

πŸ“‹ Overview

Added PHPUnit test suite for the Score extension covering core classes and functionality. Tests focus on public method behavior, use data providers, and follow MediaWiki testing practices. The suite validates musical notation formatting, error handling, frontend JS, and the main Score rendering logic.

βœ… Work Completed

  • Created complete PHPUnit test suite with 5 test classes covering all major Score extension components.
  • Implemented ScoreFormatterTest.php for Wikibase musical notation datatype formatting (plain, wiki, HTML formats).
  • Implemented ScoreExceptionTest.php for exception hierarchy (ScoreException, ScoreDisabledException, ScoreBackendException).
  • Implemented LilypondErrorMessageBeautifierTest.php for LilyPond error message processing and beautification.
  • Implemented ScoreVeConfigTest.php for the frontend JS configuration generation.
  • Implemented ScoreTest.php for main Score class public methods and rendering logic.
  • Refactored tests to use data providers for better organization and maintainability.
  • Updated README.md with unit testing section and quick start guide.

πŸ”§ Technical Implementation Details

Changes made:

  • Created test directory structure matching source code organization (tests/phpunit/includes/).
  • Implemented tests using MediaWikiIntegrationTestCase for proper MediaWiki environment setup.
  • Used data providers extensively to reduce code duplication and improve test maintainability.
  • Configured tests to disable exec (wgScoreDisableExec = true) to isolate and to avoid external dependencies in unit tests.

Dependencies:

  • PHPUnit: ^9.6 (development dependency from core).
  • MediaWiki Core: Required for MediaWikiIntegrationTestCase base class.

πŸ§ͺ Testing/Technical Status

Completed:

  • Unit tests written and passing for all major classes.
  • Data providers implemented for comprehensive test coverage.
  • Test documentation updated (in README.md).
  • Code folllows MediaWiki testing best practices.
  • Tests are passing the CI build.

Known test limitations:

  • Tests run with exec disabled (wgScoreDisableExec = true) to avoid external tool dependencies .. actual rendering is not tested, only error handling.
  • Wikibase-related functionality in ScoreFormatter requires Wikibase extension to be installed (gracefully skipped if unavailable)

🚧 Remaining Work

High priority:

  • Add integration tests for actual score rendering (requires LilyPond/abc2ly tools)
  • Add tests for HTML format rendering in ScoreFormatter (currently only plain/wiki tested).

Medium priority:

  • Increase code coverage percentage (run coverage report to identify gaps).
  • Add performance tests for large score inputs.

πŸ› Known Issues

Non-critical:

  • Some tests may be skipped if Wikibase extension is not installed.

Edge cases:

  • Raw mode with ABC language is tested but behavior may need clarifcication in documentation.

πŸ”— Related Resources

Documentation:

  • extensions/Score/README.md .. Extension documentation with testing section.

Related Gerrit Patch(es):
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Score/+/1224101

🎯 Suggested Next Steps

  1. Run code coverage report to identify any untested code paths.
  2. Review test execution time and optimize if needed.

For reviewer:

  • Verify all test methods follow naming conventions and have proper @covers annotations.
  • Check that data providers are comprehensive and cover edge cases.
  • Ensure test isolation is properly maintained (no test dependencies).

For next developer:

  • Use existing test patterns when adding new test cases.
  • Remember to disable exec in unit tests to avoid external dependencies.

Handover Date: 13th January 2026
Last Updated By: Mahmoud
Status: Ready for Review .. Tests are completed and passing

hoo removed hoo as the assignee of this task.Jan 19 2026, 12:17 PM
hoo subscribed.

Moving this back to ready for development, as integration tests seem to also be in scope of this task.

Change #1224101 merged by jenkins-bot:

[mediawiki/extensions/Score@master] Introduce basic tests for musical notations

https://gerrit.wikimedia.org/r/1224101

The AC was covered in the merged patch, but as I mentioned in the handover summary, it still need an integration tests as a priority extra coverage, which is not a main requirement.