Skip to content

[Test] Lack of Test Coverage for LegoWidget Core Logic in legobricks.js #6344

@DhyaniKavya

Description

@DhyaniKavya

What needs testing?
->The LegoWidget implementation in js/widgets/legobricks.js, specifically its core logic methods:

-_calculateFallbackFrequency()
-addRowBlock()
-clearBlocks()

These functions handle frequency computation, block management, and internal state reset, and are critical to the widget’s functionality.

Current coverage:-
->There is currently no test coverage for legobricks.js.
-> The file (~3000+ lines) is one of the largest in the codebase and remains completely untested, making it a major coverage gap in the js/widgets directory.

Proposed approach:-
-> Introduce initial unit tests focusing on deterministic, non-UI logic:
-> Test _calculateFallbackFrequency() using known pitch references (e.g., A4 ≈ 440 Hz), multiple pitch values, and edge octaves
-> Test addRowBlock() to verify correct insertion and duplicate handling logic
-> Test clearBlocks() to ensure all internal state is reset properly

Keep the scope minimal and focused on core logic, avoiding UI rendering or complex integrations. Follow existing testing patterns used in other widget test files.

Checklist:-

  • I have read and followed the project's code of conduct.
  • I have checked that no existing tests cover this area.
  • I have checked that there is no open PR for the tests I am submitting.
  • I have reviewed docs/TESTING.md for testing patterns.

📚 See Testing Guide for how to write block tests.

🙋🏾🙋🏼 Questions: Community Matrix Server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions