Skip to content

feat(UIRoot): close() awaits a real shutdown; test roots close after their tests; 3.1.8 - #62

Merged
gmpassos merged 4 commits into
masterfrom
feat/uiroot-close-shutdown
Oct 20, 2026
Merged

gmpassos merged 4 commits into
masterfrom
feat/uiroot-close-shutdown

Conversation

@gmpassos

Copy link
Copy Markdown
Contributor

Why

Test files ended with the framework still busy, which showed up on CI (#61): run in parallel, coverage missed 32 lines, all late async work (async contents, loadings, calendar events), and timing tests flaked. Two causes:

  • 20 of the 22 browser test files call initializeTestUIRoot() in setUpAll and never close the root, so nothing waits for pending renders, async contents or timers.
  • UIRoot.close() didn't wait either. It ran clear(force: true), called purgeRoot(...) (the step that disposes components) and the closed refresh(...) without awaiting them, and returned true synchronously. clear() only removes elements: components kept their timers, async contents kept loading and auto-refreshing (keeping their components "valid" in the tree, so never purged or disposed).

Changes

UIRoot.close() (still declared FutureOr<bool>; every caller already awaits it, and nothing overrides closeOperations()). Completes once shut down:

  1. closeOperations() (default clear), awaited;
  2. its components disposed (dispose(), so subclass cleanups like UIMultiSelection's run) and their UIAsyncContents stopped, also auto refresh (new UIComponent.stopUIAsyncContents());
  3. purgeRoot(...), awaited;
  4. the closed render (renderClosed()), awaited; then onClose.

New UIRoot.whenIdle({timeout, quietTime}): waits until no component is rendering, no async content is still loading for the first time (new UIComponent.hasPendingUIAsyncContent; a loaded auto-refresh content doesn't count, it never finishes), and no render in quietTime (new UIComponent.lastRenderTime). Returns false on timeout, never throws.

UIAsyncContent.stop(): a refresh already scheduled is now ignored too (it still loaded once more). reset() still loads again, as an existing test expects.

Test tools: initializeTestUIRoot(..., closeOnTearDown: true) registers addTearDown (when inside a test or setUpAll): once whenIdle, close(). From a setUpAll it runs after all the tests of that setUpAll's group (package:test semantics), from a test after that test, and before the group's own tearDownAlls. Already-closed roots (e.g. testUI's, the core integration test's) are skipped. README example updated (no tearDownAll needed).

3.1.8 (3.1.7 is tagged), with its CHANGELOG section.

Tests

  • New bones_ui_root_close_test.dart: when close() returns, components are disposed, an auto refresh is stopped, an open UIMultiSelection panel is gone, the root is rendered closed (onClose after it); a pending async content is stopped and not rendered later; whenIdle while loading / once loaded / with a loaded auto refresh.
  • New bones_ui_test_tools_teardown_test.dart: a group's root is open during the group and closed (components disposed) after it; closeOnTearDown: false keeps it open; a root initialized in a test is closed after it.
  • bones_ui_components_b_test.dart: the removed-UIMultiSelection test uses a 3s selection delay, far beyond the 250ms visibility check (it flaked on CI when throttled timers ran the shorter delay first).

Locally: dart analyze / dart format clean; the new files and the affected ones (components a/b, core integration, test chain, fields, dialog) pass on dart2js and dart2wasm; the full-suite runs were stopped to test on CI.

Follow-up

With test files ending idle, the coverage lost in parallel should come back: once this is released, #61's shards can try several files at a time again (and compare coverage).

🤖 Generated with Claude Code

…their tests; 3.1.8

- `UIRoot.close`: completes once shut down: the close operations; its
  components disposed and their `UIAsyncContent`s stopped (also auto
  refresh, new `UIComponent.stopUIAsyncContents`); its tree purged and
  its closed render, both awaited (they were fire-and-forget); then
  `onClose`.
- New `UIRoot.whenIdle({timeout, quietTime})`: no component rendering, no
  async content loading for the first time (new
  `UIComponent.hasPendingUIAsyncContent`), no render in `quietTime` (new
  `UIComponent.lastRenderTime`).
- `UIAsyncContent.stop`: a refresh already scheduled is ignored too
  (`reset` still loads again).
- Test tools: `initializeTestUIRoot` shuts its root down after its tests
  (new `closeOnTearDown`, default true): once idle, closed. Test files
  ended with renders, async contents and timers pending: in parallel the
  coverage missed late lines and timing tests flaked.
- Tests: new `bones_ui_root_close_test.dart` and
  `bones_ui_test_tools_teardown_test.dart`; the removed UIMultiSelection
  test with a selection delay far beyond the visibility check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.02%. Comparing base (f4b440b) to head (0ed643b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
+ Coverage   92.95%   93.02%   +0.07%     
==========================================
  Files          34       34              
  Lines        9483     9537      +54     
==========================================
+ Hits         8815     8872      +57     
+ Misses        668      665       -3     
Flag Coverage Δ
unittests 93.02% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

gmpassos and others added 3 commits October 19, 2026 19:29
…the uncovered paths

- A purged component whose `dispose` throws is logged and doesn't stop
  the others nor `purgeRoot` (now awaited by `close`).
- Tests: a failing dispose; `whenIdle` with the root's own async content;
  a test root never idle is closed after the idle timeout (codecov/patch
  missed these paths).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flaky removed-component test on CI was a real bug: removed under the
pointer, the browser fires a `mouseleave` before the visibility check,
and that hide notified the removed component's pending selection
(`onSelect` / `onChange`). Any hide with the input out of the document
now cancels it instead.

Test: a removed component under the pointer (a `mouseleave` before the
visibility check) notifies nothing; it fails on 3.1.7. The other test's
selection delay is back to 800ms (the timer theory was wrong).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…recated)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gmpassos
gmpassos merged commit ab42e6b into master Oct 20, 2026
5 checks passed
@gmpassos
gmpassos deleted the feat/uiroot-close-shutdown branch October 20, 2026 04:28
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.

1 participant