Repository navigation
feat(UIRoot): close() awaits a real shutdown; test roots close after their tests; 3.1.8 - #62
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…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>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
initializeTestUIRoot()insetUpAlland never close the root, so nothing waits for pending renders, async contents or timers.UIRoot.close()didn't wait either. It ranclear(force: true), calledpurgeRoot(...)(the step that disposes components) and the closedrefresh(...)without awaiting them, and returnedtruesynchronously.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 declaredFutureOr<bool>; every caller already awaits it, and nothing overridescloseOperations()). Completes once shut down:closeOperations()(defaultclear), awaited;dispose(), so subclass cleanups likeUIMultiSelection's run) and theirUIAsyncContents stopped, also auto refresh (newUIComponent.stopUIAsyncContents());purgeRoot(...), awaited;renderClosed()), awaited; thenonClose.New
UIRoot.whenIdle({timeout, quietTime}): waits until no component is rendering, no async content is still loading for the first time (newUIComponent.hasPendingUIAsyncContent; a loaded auto-refresh content doesn't count, it never finishes), and no render inquietTime(newUIComponent.lastRenderTime). Returnsfalseon 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)registersaddTearDown(when inside a test orsetUpAll): oncewhenIdle,close(). From asetUpAllit runs after all the tests of thatsetUpAll's group (package:test semantics), from a test after that test, and before the group's owntearDownAlls. Already-closed roots (e.g.testUI's, the core integration test's) are skipped. README example updated (notearDownAllneeded).3.1.8 (3.1.7 is tagged), with its CHANGELOG section.
Tests
bones_ui_root_close_test.dart: whenclose()returns, components are disposed, an auto refresh is stopped, an openUIMultiSelectionpanel is gone, the root is rendered closed (onCloseafter it); a pending async content is stopped and not rendered later;whenIdlewhile loading / once loaded / with a loaded auto refresh.bones_ui_test_tools_teardown_test.dart: a group's root is open during the group and closed (components disposed) after it;closeOnTearDown: falsekeeps it open; a root initialized in a test is closed after it.bones_ui_components_b_test.dart: the removed-UIMultiSelectiontest 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 formatclean; 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