feat(centralui): hide OffsetPager on a single page, opt-in — NotificationReport enabled (M10 residual)

DECISION: a pager whose only two controls are permanently disabled is noise, so
the conventional behaviour ships — the bar is hidden when the result set is a
single page. NotificationReport, which raised the finding, opts in.

RATIONALE for opt-in rather than default-on. OffsetPager is shared, and its
summary span ("Page N of Y · T total") doubles as the ONLY total-count readout
on ConfigurationAuditLog — auto-hiding there would silently delete the result
count for every query returning under a page, and the existing Playwright
fixture asserts "3 total" on exactly such a query. So the behaviour lives in the
shared component (reusable for the next consumer) behind HideWhenSinglePage,
default false, which keeps every current consumer byte-identical.

The guard fires only when single-page-ness is POSITIVELY established:
PageCount <= 1 AND Page <= 1 AND !HasNextPage. A null TotalCount means the host
cannot count, so the bar renders — the controls never vanish while a further
page still exists.

NotificationReport's own Playwright pagination test seeds 51 rows (2 pages) and
is unaffected. 5 new bUnit tests cover hide-on-single-page, hide-on-empty,
show-on-multi-page, show-when-TotalCount-unknown, and the default-off path.
This commit is contained in:
Joseph Doherty
2026-08-01 11:26:55 -04:00
parent a506b19d17
commit 316153dc98
3 changed files with 104 additions and 3 deletions
@@ -90,6 +90,85 @@ public class OffsetPagerTests : BunitContext
Assert.Contains("230 total", summary.TextContent);
}
// ── HideWhenSinglePage_HidesBar_OnSinglePage ──────────────────────────────
[Fact]
public void HideWhenSinglePage_HidesBar_OnSinglePage()
{
var cut = Render<OffsetPager>(ps => ps
.Add(p => p.Page, 1)
.Add(p => p.PageSize, 50)
.Add(p => p.TotalCount, 12)
.Add(p => p.HasNextPage, false)
.Add(p => p.HideWhenSinglePage, true));
Assert.Empty(cut.FindAll("[data-test='pager-prev']"));
Assert.Empty(cut.FindAll("[data-test='pager-next']"));
Assert.Empty(cut.FindAll("[data-test='pager-summary']"));
}
// ── HideWhenSinglePage_HidesBar_OnEmptyResult ─────────────────────────────
[Fact]
public void HideWhenSinglePage_HidesBar_OnEmptyResult()
{
var cut = Render<OffsetPager>(ps => ps
.Add(p => p.Page, 1)
.Add(p => p.PageSize, 50)
.Add(p => p.TotalCount, 0)
.Add(p => p.HasNextPage, false)
.Add(p => p.HideWhenSinglePage, true));
Assert.Empty(cut.FindAll("[data-test='pager-summary']"));
}
// ── HideWhenSinglePage_ShowsBar_WhenMultiplePages ─────────────────────────
[Fact]
public void HideWhenSinglePage_ShowsBar_WhenMultiplePages()
{
var cut = Render<OffsetPager>(ps => ps
.Add(p => p.Page, 1)
.Add(p => p.PageSize, 50)
.Add(p => p.TotalCount, 120)
.Add(p => p.HasNextPage, true)
.Add(p => p.HideWhenSinglePage, true));
Assert.Contains("Page 1 of 3", cut.Find("[data-test='pager-summary']").TextContent);
}
// ── HideWhenSinglePage_ShowsBar_WhenTotalCountUnknown ─────────────────────
// TotalCount is null (the host cannot count), so single-page-ness is not
// provable — the bar must stay so the user can still reach a further page.
[Fact]
public void HideWhenSinglePage_ShowsBar_WhenTotalCountUnknown()
{
var cut = Render<OffsetPager>(ps => ps
.Add(p => p.Page, 1)
.Add(p => p.PageSize, 50)
.Add(p => p.HasNextPage, false)
.Add(p => p.HideWhenSinglePage, true));
Assert.NotNull(cut.Find("[data-test='pager-summary']"));
}
// ── HideWhenSinglePage_Off_KeepsBarVisible_OnSinglePage ───────────────────
// Default (opt-out) behaviour: consumers that use the summary as their only
// "N total" readout keep the bar on a single page.
[Fact]
public void HideWhenSinglePage_Off_KeepsBarVisible_OnSinglePage()
{
var cut = Render<OffsetPager>(ps => ps
.Add(p => p.Page, 1)
.Add(p => p.PageSize, 50)
.Add(p => p.TotalCount, 3)
.Add(p => p.HasNextPage, false));
Assert.Contains("3 total", cut.Find("[data-test='pager-summary']").TextContent);
}
// ── BothDisabled_WhenDisabled ─────────────────────────────────────────────
[Fact]