Skip to content

test: add unit tests for widgetWindows widget#5816

Merged
omsuneri merged 1 commit intosugarlabs:masterfrom
kh-ub-ayb:test/add-widget-windows-tests
Feb 19, 2026
Merged

test: add unit tests for widgetWindows widget#5816
omsuneri merged 1 commit intosugarlabs:masterfrom
kh-ub-ayb:test/add-widget-windows-tests

Conversation

@kh-ub-ayb
Copy link
Contributor

Summary

This pr adds a new unit test suite for the widgetWindows module, covering the WidgetWindow class and global widgetWindows utility functions with 79 comprehensive tests.

Changes

  • Added 79 new unit tests in js/widgets/__tests__/widgetWindows.test.js
  • No changes to source code

Test Coverage

Describe Block Tests Coverage
Constructor (via windowFor) 11 _visible, _maximized, _rolled, _dragging, _buttons initialization; DOM elements _frame, _body, _toolbar, _widget, _drag; position cache restore
_create helper 5 Creates element with tag, className, parent append, no-parent handling
_toggleClass helper 3 Add class, remove class, toggle back/forth
addButton 8 Returns wfbtItem div, img src/dimensions/title/alt, _buttons array tracking, toolbar vs custom parent append
addDivider 2 Returns wfbtHR div, appends to toolbar
addInputButton 4 Returns input element, initial value, toolbar vs custom parent
close 4 Calls onclose, removes mouseup/mousemove/mousedown listeners
destroy 4 Removes _frame and _overlayframe from DOM, clears openWindows entry, removes event listeners
sendToCenter 2 Returns this for chaining, fallback position for zero-dimension canvas
_maximize / _restore 10 Maximize: sets _maximized, viewport dimensions, top-left positioning, saves position, contract icon. Restore: resets _maximized, expand icon, restores saved position, auto dimensions, clears _savedPos
updateTitle 1 Updates title element innerHTML
takeFocus 3 Sets zIndex 10000, opacity 1, sibling zIndex reset
isMaximized 3 False initially, true after maximize, false after restore
Other public methods 13 setPosition (styles, min-top-64, caching, chaining), isVisible, show, clear, clearScreen, getWidgetBody, getWidgetFrame, _rollup, unroll
Global functions 6 windowFor create/reuse/key fallbacks, isOpen true/empty-string

Scope

  • Only js/widgets/__tests__/widgetWindows.test.js was added
  • No changes to source code

Verification

  • All 79 tests pass

@github-actions
Copy link
Contributor

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

@kh-ub-ayb
Copy link
Contributor Author

@walterbender @omsuneri please review

@omsuneri omsuneri merged commit 895b769 into sugarlabs:master Feb 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants