test(e2e): assert destination renders, not just URL, in nav tests
This commit is contained in:
@@ -75,6 +75,27 @@ public class NavigationTests
|
|||||||
await ClickNavAndWait(page, linkText, expectedPath);
|
await ClickNavAndWait(page, linkText, expectedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maps each navigable route to the exact heading text rendered by that page.
|
||||||
|
private static readonly Dictionary<string, string> RouteHeadings = new()
|
||||||
|
{
|
||||||
|
["/admin/sites"] = "Site Management",
|
||||||
|
["/admin/api-keys"] = "API Key Management",
|
||||||
|
["/admin/ldap-mappings"] = "LDAP Group Mappings",
|
||||||
|
["/notifications/smtp"] = "SMTP Configuration",
|
||||||
|
["/notifications/lists"] = "Notification Lists",
|
||||||
|
["/notifications/report"] = "Notification Report",
|
||||||
|
["/notifications/kpis"] = "Notification KPIs",
|
||||||
|
["/design/templates"] = "Templates",
|
||||||
|
["/design/shared-scripts"] = "Shared Scripts",
|
||||||
|
["/design/connections"] = "Connections",
|
||||||
|
["/design/external-systems"] = "Integration Definitions",
|
||||||
|
["/deployment/topology"] = "Topology",
|
||||||
|
["/deployment/deployments"] = "Deployment Status",
|
||||||
|
["/monitoring/health"] = "Health Dashboard",
|
||||||
|
["/monitoring/event-logs"] = "Site Event Logs",
|
||||||
|
["/monitoring/parked-messages"] = "Parked Messages",
|
||||||
|
};
|
||||||
|
|
||||||
private static async Task ClickNavAndWait(IPage page, string linkText, string expectedPath)
|
private static async Task ClickNavAndWait(IPage page, string linkText, string expectedPath)
|
||||||
{
|
{
|
||||||
// Sections are collapsed by default — open them so the link is in the DOM.
|
// Sections are collapsed by default — open them so the link is in the DOM.
|
||||||
@@ -82,6 +103,13 @@ public class NavigationTests
|
|||||||
await page.Locator($"nav a:has-text('{linkText}')").ClickAsync();
|
await page.Locator($"nav a:has-text('{linkText}')").ClickAsync();
|
||||||
await PlaywrightFixture.WaitForPathAsync(page, expectedPath);
|
await PlaywrightFixture.WaitForPathAsync(page, expectedPath);
|
||||||
Assert.Contains(expectedPath, page.Url);
|
Assert.Contains(expectedPath, page.Url);
|
||||||
|
|
||||||
|
// Verify the destination page actually rendered its heading (catches 500s
|
||||||
|
// and blank renders that a URL-only check would miss).
|
||||||
|
var expectedHeading = RouteHeadings[expectedPath];
|
||||||
|
await Assertions.Expect(
|
||||||
|
page.Locator("h1, h4, h5", new() { HasText = expectedHeading })
|
||||||
|
).ToBeVisibleAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ILocatorAssertions Expect(ILocator locator) =>
|
private static ILocatorAssertions Expect(ILocator locator) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user