Repository navigation
fix(hottesting): mock state and list-state inputs where the state is read - #3216
Conversation
|
|
|
@rajamatt, thanks for tracking this down: the state-input swap did break when the swap moved to the shared Why. Building a What changed. A state input now keeps its own One known limit. A state built over another member feed (for example Could you check that this works for your case in studio.live (unoplatform/studio.live#4074)? In particular, does any model you preview build a state over another member feed, where the limit above would bite? |
- add TasksModel: a service-dependent IListState input and a feed derived from it - the list state carries mocked items through the view model, re-swaps, pins Loading and Error, restores its own loader, keeps an edit, and accepts another list state as its mock - a scalar state input read directly carries the mocked value and keeps an edit - all but the derived-feed test fail on the current code: the state still reads the real, null-injected loader Co-Authored-By: Claude Opus 5.5 <[email protected]>
- every reader of a state reads the state's own subscription, directly or through the context's subscription to the state; SwapFeed swapped only the latter, and SwapListFeed swapped the context's subscription to the list state, which the list state's own reads (its bindable's included) never go through - a state input's own subscription now reads a state over the mock, and the member's writes are redirected to that state, so edits apply over the mock and the real loader never runs - a list state is swapped through the state it wraps; a mock that is the member itself restores its own updates - StateImpl exposes its subscription and ListStateImpl the state it wraps; ListStateImpl.HotSwap had no caller left and is removed Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Spec 013 architecture: a state input is swapped at the state's own subscription, over a state built on the mock that also takes the member's writes Co-Authored-By: Claude Opus 5.5 <[email protected]>
- re-applying the same mock to a list or scalar state input must drop an earlier edit; both fail on the current code, which reuses the state built over that mock instance - an edit through a mocked list state reaches the feed derived from it - a scalar state input re-swapped carries the new value - WaitForMessage joins WaitForData in the shared recorder helpers and reads the count once per pass, so a message recorded after the check is not skipped Co-Authored-By: Claude Opus 5.5 <[email protected]>
- each swap of a state input reads a state built for that swap only, so it starts over
from its mock even when the instance is reused ({Model}Mock.Empty) or given to two members
- the state built by the previous swap is disposed once nothing reads it
- a mock that is itself a state still takes the writes directly; any other IState
no longer hits an InvalidCastException
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- architecture: an edit of a state built over a feed input stays local; a state input's edit reaches its derived feeds, and its mock state lives for one swap - history v19 explains the move and why v16's lock-ordering objection no longer applies, with the remaining limits; D6 names the state input's anchor - testing.md notes how a mocked state input behaves Co-Authored-By: Claude Opus 5.5 <[email protected]>
- the note sat right before the IMPORTANT admonition, and two blockquotes split by a blank line fail markdownlint (MD028); it is now a plain paragraph Co-Authored-By: Claude Opus 5.5 <[email protected]>
The swap of a state input built a state over the mock for each swap and read it through the state's own subscription. That is a second replacement point next to the shared FeedSubscription hot reload uses, plus a process-wide table of the built states and a fire-and-forget dispose. A state input now keeps its own UpdateFeed, and what is swapped is the feed its updates apply on, through the context's subscription to it. The bindable and the feeds derived from the state see the mock with the edits over it. SetMock clears the state's updates through UpdateFeed.Clear, so re-applying the same mock starts over from it. The tests of this PR are kept unchanged; spec 013 v19, architecture and testing.md describe the new swap. Limit: a state built over another member feed shares that feed's subscription, so mocking the state also mocks that feed.
- Clear drops the active updates; once the source has completed, a compacted update is undone only if it can roll itself back, so a state's own edit stays applied - clearing is meant for a source still running, like a mocked one Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Clear reverts every active update and the feed shows its source again - a state over a source still running shows that source again once its updates are cleared, which is what SetMock relies on Co-Authored-By: Claude Opus 5.5 <[email protected]>
d52eb28 to
d243e1d
Compare
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
@Mergifyio backport servicing/7.4 |
✅ Backports have been createdDetails
Cherry-pick of 78d351f has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
GitHub Issue (If applicable): related to https://github.com/unoplatform/studio.live/issues/4074
PR Type
What is the current behavior?
A model input declared as a state is not mocked where the state itself is read:
IListState<T>(ListState.Async(this, …)), the usual shape for a list edited elsewhere:{Vm}Mock.CreatewithListFeedMock.Value(...)never reaches the view-model. The list's only message has no data and aNullReferenceExceptionfrom the real loader, which runs against the null-injected service. Every preview of that list shows the error template.IState<T>: feeds derived from the state see the mock, but reading the state itself, as its binding does, runs the real loader.Cause: every reader of a state ends up at the state's own subscription, over its
UpdateFeed.SwapFeedswapped only the context's subscription to the state, which no reader goes through.SwapListFeedswapped the context's subscription keyed on theListStateImpl, which the list state's own reads, its bindable's included, never go through either. This was a regression of spec 013 v17.What is the new behavior?
UpdateFeedreads, at the context's subscription to it. That subscription is already swappable under mocking, and hot reload uses the same mechanism.SetMockclears the state's updates (UpdateFeed.Clear), so the state starts over from its mock, even when the same mock is re-applied ({Model}Mock.Emptyis a single shared instance).Reviewer's guide
MockingService.SwapStateSource.UpdateFeed.Cleardrops the active updates, andUpdateFeed.Sourceexposes the feed the updates apply on;StateImpl.SourceandStateImpl.ClearUpdatesexpose them on the state;ListStateImpl.Implementationexposes the state a list state wraps.0f8e3dadb(a state built over the mock for each swap) is superseded by7cb36e01b.a43842163, adds tests only: 9 of its 10 tests fail without the fix, with no data and aNullReferenceException. They cover a list state carrying mocked items, re-swap, Loading and Error, restore, an edit kept over the mock, another list state as the mock, and a scalar state read directly. The 10th, a feed derived from a list state, already passed and is kept because the fix changes the path it reads through;3e9da13a4adds re-applying the same mock drops an earlier edit (list and scalar), an edit reaches the derived feed, and a scalar re-swap;d243e1d6ecoversUpdateFeed.ClearandStateImpl.ClearUpdatesdirectly.testing.md.PR Checklist
Given_GeneratedMock,Given_SingleProjectMock,Given_UpdateFeed).SetMockstarts a state input over from its mock; before, the edit was dropped from what the page showed.mainwith fix(hottesting): give mocked view models a messenger #3214:Uno.Extensions.Reactive.Tests, 1486 pass, 19 skipped;Uno.HotTesting.Reactive.Tests, 38 pass; mocking,UpdateFeedand hot-reload tests stable over 3 runs). UI runtime tests not run locally, and not yet checked in a Studio preview.Other information
mainafter fix(hottesting): give mocked view models a messenger #3214: spec 013 history now reads v18 (fix(hottesting): give mocked view models a messenger #3214), then v19.servicing/7.4, exceptUpdateFeed.cs, which differs by one line outside the changed hunks.🤖 Generated with Claude Code