test(portal): deflake cron conversation-grouping sidebar tests#1576
Merged
Conversation
Seed the persisted Scheduled-group collapse state to expanded and wait for the async OnAfterRenderAsync render to settle, instead of clicking the group toggle. The toggle click raced the async localStorage read (which re-collapses the group on a continuation), intermittently dropping the cron item from the group body and failing CI on main. The conversation-grouping behaviour under test is unchanged; only the test now renders deterministically regardless of continuation timing. Closes #1573
This was referenced Jun 23, 2026
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.
Closes #1573
Summary
mainBuild & Test was red on a single flaky bUnit test in the SignalR Blazor client conversation-grouping suite. This PR makes the affected tests deterministic. No production code changes — the fix is test-only.Investigation — not a regression
#1573 named
feat(cron): add opt-in DeleteAfterRun (#1571)as the likely culprit. It is not:#1571touches only 5 files, all inBotNexus.Cron(CronJob.cs,CronOptions.cs,CronScheduler.cs,SqliteCronStore.cs, + its test) — zero BlazorClient /MainLayout.razor/.razorfiles. It cannot introduce a deterministic regression in a Blazor-client render test.MainLayout'sIsUserFacingConversation/IsCronConversationpredicates and the conversation-list grouping are correct at HEAD4eb4ae9d— the virtual-kind cron conversation is correctly classified.4eb4ae9d(5× the isolatedCronConversations_VirtualKind_RenderedInScheduledGroup, 4× the wholeConversationGroupingTestsclass). It only fails under CI scheduler timing.Root cause — async OnAfterRender re-collapse race
MainLayout.OnAfterRenderAsync(firstRender)readslocalStorage["botnexus-cron-collapsed"]and sets_cronGroupCollapsed = cronStored != "false". Under the bUnit Loose JS mock an unseeded read returnsnull→ the Scheduled group stays collapsed, and the tests re-expanded it with acron-group-toggleclick. Because the localStorage read runs on an async continuation, it can fire after the toggle click and re-collapse the group (followed byStateHasChanged()), dropping the cron item from the group body and intermittently failing theAssert.Contains(...). Thecronconv:-prefix sibling and the cron-API variant are exposed to the same race.Fix
For the three cron-grouping tests:
localStorage.getItem("botnexus-cron-collapsed")→"false"(newExpandScheduledGroupByDefault()helper, mirroring the establishedlocalStorage.getItemsetup pattern inMainLayoutTests), soOnAfterRenderAsynclands on expanded deterministically and there is no re-collapse to race.cut.WaitForAssertion(...), which retries until the async render (including the cron→conversation-id HTTP load in the assigned-conversation test) has settled.ConversationAssignedToCronJob_RenderedInScheduledGroupno longer needsawait Task.Delay(100); converted fromasync Tasktovoid.The behaviour under test is unchanged — the cron conversation must appear inside the Scheduled group.
ScheduledGroup_CollapsedByDefaultis intentionally left untouched (it relies on the default-collapsed state).Verification
dotnet buildof the test project: 0 warnings, 0 errors.ConversationGroupingTestsrun 6× → 8/8 PASS each (was racing before).scripts/repo/test-impacted.ps1: All impacted tests passed —BlazorClient.Tests606/606, plusArchitecture.Tests+Scenarios.Testssafety nets.Merge Notes
Standalone, test-only, single file (
tests/.../ConversationGroupingTests.cs). No file overlap with the only other open PR (#1572, mobileask_user). Safe to merge in any order; merging this turnsmainBuild & Test green.