Summary#
Assert.RedrawsOnly(region) judges the LAST action the test took. It holds when everything outside region stayed as
it was: patched in place (a class, a word) is fine; taken off the screen and drawn again showing the same thing is not.
Moving between pages and tabs should change the content and nothing else — the top bar, the rail, the switcher and a
header shared by an object's tabs stay exactly as they are, not even a flicker.
Signature#
Ui.Click("Ship");
Assert.RedrawsOnly("Order 2"); // the last action redrew nothing outside the part labelled "Order 2"region names a part of the screen the way within: does — a container by its label:. Inside it the action may
change anything any way it likes.
Description#
The screen after a needless redraw looks exactly like the screen after a patch, so no assertion about the screen
can tell them apart — Assert.Visible passes on both. What differs is what happened in between, and that is what this
judges: the driver records every acting verb's changes to the page while it runs (Ui.Click, Ui.Press, Ui.Back,
Ui.Forward, Ui.Dismiss, Ui.Check, Ui.Select, Ui.Fill, Ui.Upload, Ui.Tick, Ui.AwaitChange, Ui.ReleaseServer).
It fails on, outside the region:
- an element removed and put back showing the same thing — the rail's rows rebuilt to move the highlight, a list
replacing every row to change one, a part remounted by its
key:(osy lintnames a key on a value the part's live reads already take:ui-key-on-a-value-its-live-reads-take, key: on a component call). The failure names the outermost part that came back the same, and the component that drew it. What was taken away is judged by what it SHOWED when the action began: a leaving page's parts are emptied as they are disposed, often after they are off the screen, so what is left of them at the end says nothing about what the person saw. "The same thing" is the same words doing the same thing — the same link or button, or the same editor: read-only words that come back inside an editor (a field's text turned into its Markdown editor on "Change") are a change, not a redraw; - content already on screen replaced by a loading placeholder (its
skeleton { }or a pending read's box) and then shown again — the flash of the parts that stay. A placeholder judges only what it stood in for: the words must have been absent behind it, so it was put up in their place BEFORE they were drawn again. Words a click swapped in on purpose — a read-only mode turned into an editing mode that draws the same text beside an editor whose own first read is pending — were on the page before that placeholder and are no flash; - a full page load — the action loaded the page instead of the router swapping it;
- a box that lost its scroll position, and focus lost with the element that held it.
Every navigation checks the layout without a line#
A page in a [Layout] renders inside its Outlet, and the router keeps the layout mounted across every route that
shares it — and every section layout two routes share. So every verb that moves the route (a link, a tab that is an
address, Ui.Back, Ui.Forward) fails when anything OUTSIDE the outlet of the deepest layout it kept was redrawn, or
lost its scroll or focus — the shell, and a section's header, must stay. A focused field on the page the move takes away goes
with that page (a form's field a submit navigates from) — not a lost focus; a field rebuilt on a page that stays is. So does
a button in a modal dialog the move closes ("Leave without saving?" → Save and leave), and a part of the screen that
looks like one of the closed dialog's rows (a phone's "More" sheet lists Settings → Billing, and the move draws the
section's own strip of the same links): the dialog going is not its rows put back. A navigation that
keeps no layout — into a different layout, or between routes with no [Layout] at all — rebuilds the whole screen by
design and is not judged without a line; Assert.RedrawsOnly after it judges it like any action.
Every action, navigating or not, also fails without a line when it:
- loads the page again to reach a route of this app in the same layout — the router could have swapped it in place.
A sign-in or sign-out (
Session.SignIn,Session.SignOut) is not judged: it loads the page on purpose, so that nothing the last person was shown stays on the screen of the next. Nor is a move to a page that takes a grant link in its route (/order/{link}, a parameter typed as a declared grant): it is always a full load, so the server verifies the link before the page exists. This rule is judged in the default tier only: under--pixelsthe verbs run inside the page, and a page load discards them together with the record of the action, so no load is judged there; - flashes content it keeps through a loading placeholder, anywhere on the screen (a navigation that kept no layout
is the exception above: it kept nothing). The failure names the placeholder — its markup and the component whose place it
stood in (
The placeholder: <div class="osy-pending" … data-osy-pending="consent"> inside Home) — so the read that put it up, or the row that was built and taken down again, is found without a debugger.
The failure reads like this:
Ui.Click("People") redrew the parts of the screen around the page — its layout: 'Overview' (<a> drawn by AdminRail)
was REDRAWN: taken off the screen and put back showing the same thing. It should have stayed as it was, or been
patched in place. A move to '/people' in the same layout changes only the routed page (the outlet).⚠ What is inside the outlet is the page's. The default judges only what is outside it. A header over tabs that
switch IN the page (a Tabs strip whose tabs change state, not the address) stays mounted, and a test says so with
Assert.RedrawsOnly("<the tab body>") after the tab click.
⭐ Route tabs: draw the head with a [Section] part. A tab that is an ADDRESS (Tab(to:), a PageHead's tabs:)
is its own route, and each tab's page draws the head over it. Draw it with a [Section] part ([Section] — a part that keeps its place across the pages that share it) —
the kit's tabbed heads (ConsolePageHead, PageBand, AreaHeader) are, so a page that uses them as it already does
needs nothing more. Pages that show the same tabs share ONE head: a tab switch MOVES it into the arriving page and
patches it, and its slots (the page's actions) are the arriving page's. A moved element — the same node, re-parented,
never rebuilt — is kept, not redrawn, so Assert.RedrawsOnly("<the tab body>") holds after the tab click.
⭐ And the view under the head: one section per object. When every tab's page draws the same view of one object
(its reads, its messages, a field), mark that view a [Section] keyed by the object's address ([[ui-section#tabbed-view]]):
a tab move then keeps it whole and redraws only the tab. ⚠ A view built again shows the same words as one kept, so
Assert.RedrawsOnly over a region that holds only the tab passes on both: what tells them apart is that the move read
nothing it did not need — Assert.AtMost(n, Cost.StatementsSince(mark)) beside it — and that a typed field outside the tab
still holds its words (Assert.Value).
A head built WITHOUT such a part (the app's own markup) goes in a section layout instead — a [Layout] that names its
parent layout, with the tab pages in its Outlet; ([[ui-routing#section-layouts]]). The router keeps it mounted
across the tabs, and the default then judges outside the outlet of the DEEPEST layout the navigation kept, so the
header and the tab strip are checked without a line. A header each tab's page draws for itself with neither passes the
default (the whole page swaps in one step once the arriving page has loaded), but Assert.RedrawsOnly over the tab
body fails on it, naming the header.
⚠ Pages with no [Layout] rebuild everything around their body. The router disposes the page and mounts the next
one, so a rail or top bar a frame component draws on every page is taken away and drawn again on every move, and
Assert.RedrawsOnly("<the body>") names it — even when the head is a [Section] part, which is the one thing such a
move keeps. Put the shell in a [Layout] (routes and pages) and it stays.
⚑ Ui.Visit opens a fresh page by definition and is never judged; Assert.RedrawsOnly straight after one refuses
("no action has run on this page since it opened"). Nothing recorded is never "nothing redrawn": when the
renderer could not watch the page while the action ran — it has no MutationObserver, or its observer stopped
reporting before the action ended (the driver checks, with a mark it puts on the page and takes off) —
Assert.RedrawsOnly fails and says so ("… was not recorded — …") instead of passing. A held server (Ui.HoldServer()) is a test standing ON the
loading state, so the placeholder rule does not fire while it holds.
Examples#
[Layout] [AllowAnonymous]
component Desk() {
render {
SidebarShell(new AppChrome { Product = "Larkspur", Home = "/", Nav = [
new NavItem { Label = "Clients", To = "/", Icon = Icons.Building },
new NavItem { Label = "Lamps", To = "/lamps", Icon = Icons.Building } ] }) { Outlet(); }
}
}
[Route("/")] [Layout(Desk)] [Title("Clients")] [Render(CSR)] [AllowAnonymous]
component ClientsPage() {
render { Text("Wren & Pike"); }
}
[Route("/lamps")] [Layout(Desk)] [Title("Lamps")] [Render(CSR)] [AllowAnonymous]
component LampsPage() {
int lit = 0;
action Light() { lit = lit + 1; }
render {
Stack(gap: 2) {
Text("North lamp");
Stack(label: "Count") { Text($"{lit} lit"); }
Button("Light one", onPress: Light);
}
}
}
[Test]
void the_shell_stays_and_a_press_changes_its_own_line() {
Ui.Visit("/");
Ui.Click("Lamps"); // a navigation: everything outside the outlet must stay — checked without a line
Assert.OnPage("/lamps");
Ui.Click("Light one");
Assert.Visible("1 lit");
Assert.RedrawsOnly("Count"); // the press redrew nothing but its own line
}See also#
- Ui — drive the app's UI from a test — the verbs this judges, and how a verb waits for a settled screen
- Layout assertions — is it actually usable on screen? — the claims about where things are drawn
- Ui.HoldServer — standing on a loading state on purpose