test(playwright): update pager/markup selectors to M10 component hooks (INT)

This commit is contained in:
Joseph Doherty
2026-06-18 20:41:43 -04:00
parent 023c4f7cde
commit 8270a603d3
3 changed files with 25 additions and 27 deletions
@@ -91,7 +91,7 @@ public class AuditConfigurationTests
// is exactly 3 (filtering by the unique marker makes this deterministic // is exactly 3 (filtering by the unique marker makes this deterministic
// regardless of the other rows the live cluster holds). // regardless of the other rows the live cluster holds).
await Assertions.Expect(page.Locator($"tr:has-text('{marker}-0')")).ToBeVisibleAsync(); await Assertions.Expect(page.Locator($"tr:has-text('{marker}-0')")).ToBeVisibleAsync();
await Assertions.Expect(page.Locator("span:has-text('(3 total)')")).ToBeVisibleAsync(); await Assertions.Expect(page.Locator("[data-test='pager-summary']")).ToContainTextAsync("3 total");
} }
finally finally
{ {
@@ -119,9 +119,10 @@ public class AuditConfigurationTests
await page.Locator("button.btn.btn-primary.btn-sm:has-text('Search')").ClickAsync(); await page.Locator("button.btn.btn-primary.btn-sm:has-text('Search')").ClickAsync();
await page.WaitForLoadStateAsync(LoadState.NetworkIdle); await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
// Page 1 of 2: Previous disabled, Next enabled. // Page 1 of 2: Previous disabled, Next enabled. (M10 OffsetPager summary:
await Assertions.Expect(page.Locator("span:has-text('Page 1 of 2')")).ToBeVisibleAsync(); // "Page {N} of {Y} · {Total} total".)
await Assertions.Expect(page.Locator("span:has-text('(55 total)')")).ToBeVisibleAsync(); await Assertions.Expect(page.Locator("[data-test='pager-summary']")).ToContainTextAsync("Page 1 of 2");
await Assertions.Expect(page.Locator("[data-test='pager-summary']")).ToContainTextAsync("55 total");
await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Previous')")).ToBeDisabledAsync(); await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Previous')")).ToBeDisabledAsync();
await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')")).ToBeEnabledAsync(); await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')")).ToBeEnabledAsync();
@@ -129,7 +130,7 @@ public class AuditConfigurationTests
await page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')").ClickAsync(); await page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')").ClickAsync();
await page.WaitForLoadStateAsync(LoadState.NetworkIdle); await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await Assertions.Expect(page.Locator("span:has-text('Page 2 of 2')")).ToBeVisibleAsync(); await Assertions.Expect(page.Locator("[data-test='pager-summary']")).ToContainTextAsync("Page 2 of 2");
await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Previous')")).ToBeEnabledAsync(); await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Previous')")).ToBeEnabledAsync();
await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')")).ToBeDisabledAsync(); await Assertions.Expect(page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')")).ToBeDisabledAsync();
} }
@@ -409,13 +409,13 @@ public class NotificationActionTests
await page.Locator("button.btn-primary:has-text('Query')").ClickAsync(); await page.Locator("button.btn-primary:has-text('Query')").ClickAsync();
await page.WaitForLoadStateAsync(LoadState.NetworkIdle); await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
// Pager locators. Previous/Next are scoped by their text (the page header's // Pager locators (M10 OffsetPager). Previous/Next are the pager's data-test
// Refresh button is also a .btn-outline-secondary.btn-sm). The indicator span is // hooks (the page header's Refresh button is also a .btn-outline-secondary.btn-sm,
// the pager's only `span.text-muted.small` once rows render — the "Loading…" // so we no longer scope by text). The summary span carries the page/total readout
// placeholder that shares that class renders only while `_notifications == null`. // ("Page {N} of {Y} · {Total} total").
var prev = page.Locator("button.btn-outline-secondary.btn-sm:has-text('Previous')"); var prev = page.Locator("[data-test='pager-prev']");
var next = page.Locator("button.btn-outline-secondary.btn-sm:has-text('Next')"); var next = page.Locator("[data-test='pager-next']");
var indicator = page.Locator(".d-flex.justify-content-between.align-items-center span.text-muted.small"); var indicator = page.Locator("[data-test='pager-summary']");
// ── Page 1 ── (count first — it waits out the fetch — then indicator + buttons). // ── Page 1 ── (count first — it waits out the fetch — then indicator + buttons).
await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(50, new() { Timeout = 15_000 }); await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(50, new() { Timeout = 15_000 });
@@ -546,36 +546,33 @@ public class SiteCallsPageTests
await SetSearchKeywordAsync(page, sharedTarget); await SetSearchKeywordAsync(page, sharedTarget);
await page.ClickAsync("[data-test='site-calls-query']"); await page.ClickAsync("[data-test='site-calls-query']");
// The pager indicator span (`Page {N} · {rows} rows`). Scope the // The M10 KeysetPager summary span (`Page {N} · {rows} rows`), exposed
// locator to the pager wrapper div // via its stable data-test hook so a future markup tweak can't make this
// (`.d-flex.justify-content-between.align-items-center`) so a future // match ambiguous under strict mode.
// second `span.text-muted.small` elsewhere on the page can't make var pageIndicator = page.Locator("[data-test='keyset-summary']");
// this match ambiguous under strict mode.
var pageIndicator = page.Locator(
".d-flex.justify-content-between.align-items-center span.text-muted.small");
// ── Page 1: full page (50 rows). Assert COUNT first (waits for the // ── Page 1: full page (50 rows). Assert COUNT first (waits for the
// fetch), then the indicator and the button states. ── // fetch), then the indicator and the button states. ──
await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(50); await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(50);
await Assertions.Expect(pageIndicator).ToContainTextAsync("Page 1"); await Assertions.Expect(pageIndicator).ToContainTextAsync("Page 1");
await Assertions.Expect(page.Locator("[data-test='site-calls-prev']")).ToBeDisabledAsync(); await Assertions.Expect(page.Locator("[data-test='keyset-prev']")).ToBeDisabledAsync();
await Assertions.Expect(page.Locator("[data-test='site-calls-next']")).ToBeEnabledAsync(); await Assertions.Expect(page.Locator("[data-test='keyset-next']")).ToBeEnabledAsync();
// ── Next → Page 2: short page (1 row). Last page, so Next disables. ── // ── Next → Page 2: short page (1 row). Last page, so Next disables. ──
await page.ClickAsync("[data-test='site-calls-next']"); await page.ClickAsync("[data-test='keyset-next']");
await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(1); await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(1);
await Assertions.Expect(pageIndicator).ToContainTextAsync("Page 2"); await Assertions.Expect(pageIndicator).ToContainTextAsync("Page 2");
await Assertions.Expect(page.Locator("[data-test='site-calls-prev']")).ToBeEnabledAsync(); await Assertions.Expect(page.Locator("[data-test='keyset-prev']")).ToBeEnabledAsync();
await Assertions.Expect(page.Locator("[data-test='site-calls-next']")).ToBeDisabledAsync(); await Assertions.Expect(page.Locator("[data-test='keyset-next']")).ToBeDisabledAsync();
// ── Previous → back on Page 1: full page again, Prev disables. ── // ── Previous → back on Page 1: full page again, Prev disables. ──
await page.ClickAsync("[data-test='site-calls-prev']"); await page.ClickAsync("[data-test='keyset-prev']");
await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(50); await Assertions.Expect(page.Locator("tbody tr")).ToHaveCountAsync(50);
await Assertions.Expect(pageIndicator).ToContainTextAsync("Page 1"); await Assertions.Expect(pageIndicator).ToContainTextAsync("Page 1");
await Assertions.Expect(page.Locator("[data-test='site-calls-prev']")).ToBeDisabledAsync(); await Assertions.Expect(page.Locator("[data-test='keyset-prev']")).ToBeDisabledAsync();
// Page 1 is full again on the back-leg, so Next must re-enable — // Page 1 is full again on the back-leg, so Next must re-enable —
// catches a regression that left Next disabled after a page-back. // catches a regression that left Next disabled after a page-back.
await Assertions.Expect(page.Locator("[data-test='site-calls-next']")).ToBeEnabledAsync(); await Assertions.Expect(page.Locator("[data-test='keyset-next']")).ToBeEnabledAsync();
} }
finally finally
{ {