diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/NavigationTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/NavigationTests.cs index 69ab2b23..fff817d9 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/NavigationTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/NavigationTests.cs @@ -75,6 +75,27 @@ public class NavigationTests await ClickNavAndWait(page, linkText, expectedPath); } + // Maps each navigable route to the exact heading text rendered by that page. + private static readonly Dictionary 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) { // 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 PlaywrightFixture.WaitForPathAsync(page, expectedPath); 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) =>