Skip to content

[Test] Add unit tests for js/utils/mb-dialog.js #6461

@eyeaadil

Description

@eyeaadil

What needs testing

js/utils/mb-dialog.js currently has no associated test suite in the repository.

Current coverage

Current test coverage for this file is 0% (there is no test file).

Proposed approach

I propose creating js/utils/tests/mb-dialog.test.js using the Jest framework and jsdom to write a comprehensive test suite. The approach will cover:

  • Toggling default vs custom dialog parameters for window.MBDialog.alert.
  • Testing the Promise-based interface and resolution flow of window.MBDialog.prompt.
  • Verifying DOM rendering, styling, and post-close cleanup for the overlay and frame.
  • Validating keyboard accessibility bindings (Escape to cancel, Enter to submit).
  • Verifying the theme initialization fallback chain (localStorage checking vs matchMedia preferred-color-scheme).
  • Verifying mouse dragging behavior on the dialog title bars.

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.

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