From 5acb16ca07ed18e0d82dfcbfc0c674660cd8a78f Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 3 Dec 2026 12:14:28 -0500 Subject: [PATCH] test(playwright): fix stale selectors after UI refactor (h1 headings, collapsed Topology/Audit disclosures, ParameterValueForm ids, method-select race) --- .../Audit/AuditConfigurationTests.cs | 2 +- .../Audit/AuditLogPageTests.cs | 22 ++++++++++++++----- .../Deployment/DebugViewTests.cs | 2 +- .../Deployment/DeploymentsRealtimeTests.cs | 4 ++-- .../Deployment/FlowDebuggerTests.cs | 8 +++++-- .../Deployment/TopologyPageHelper.cs | 4 ++++ .../Design/ApiMethodFormTests.cs | 2 +- .../Design/DataConnectionCrudTests.cs | 4 ++-- .../Design/ExternalSystemCrudTests.cs | 2 +- .../Design/M9SurfaceTests.cs | 6 ++--- .../Design/SharedScriptCrudTests.cs | 4 ++-- .../Monitoring/EventLogsTests.cs | 4 ++-- .../Monitoring/ParkedMessagesActionTests.cs | 2 +- .../Monitoring/ParkedMessagesTests.cs | 2 +- .../NavigationTests.cs | 4 ++-- .../Notifications/NotificationActionTests.cs | 10 ++++----- .../Notifications/NotificationKpisTests.cs | 2 +- .../NotificationListCrudTests.cs | 4 ++-- .../Notifications/SmsNotificationE2ETests.cs | 8 +++---- .../Notifications/SmtpConfigTests.cs | 8 +++---- .../PendingUpdatesTests.cs | 2 +- .../SiteCalls/SiteCallsPageTests.cs | 2 +- .../SiteCrudTests.cs | 4 ++-- 23 files changed, 66 insertions(+), 46 deletions(-) diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditConfigurationTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditConfigurationTests.cs index cba2f40b..38e71261 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditConfigurationTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditConfigurationTests.cs @@ -82,7 +82,7 @@ public class AuditConfigurationTests // Search is issued — the page only auto-fetches when arriving with a // ?bundleImportId= query param, which a bare visit lacks — so the // Entity Type filter is present and ready to drive the first query. - await Assertions.Expect(page.Locator("h4:has-text('Configuration Audit Log')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Configuration Audit Log')")).ToBeVisibleAsync(); await Assertions.Expect(page.Locator("#audit-filter-entity-type")).ToBeVisibleAsync(); // Filter by the unique marker so only this run's 3 rows remain, then diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditLogPageTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditLogPageTests.cs index f98041bf..6e121680 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditLogPageTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Audit/AuditLogPageTests.cs @@ -163,7 +163,7 @@ public class AuditLogPageTests // Apply channel AND target together. await page.Locator("[data-test='filter-channel-select']").SelectOptionAsync("ApiOutbound"); - await page.FillAsync("#audit-target", targetPrefix + "match"); + await FillAdvancedFilterAsync(page, "#audit-target", targetPrefix + "match"); await page.ClickAsync("[data-test='filter-apply']"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); @@ -193,7 +193,7 @@ public class AuditLogPageTests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/audit/log"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await page.FillAsync("#audit-execution-id", Guid.NewGuid().ToString()); + await FillAdvancedFilterAsync(page, "#audit-execution-id", Guid.NewGuid().ToString()); await page.ClickAsync("[data-test='filter-apply']"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); @@ -719,7 +719,7 @@ public class AuditLogPageTests // Page reachable for the multi-role user; the Notification Report page // is Deployment-gated, so this also covers that authorization path. Assert.Contains("/notifications/report", page.Url); - await Assertions.Expect(page.Locator("h4:has-text('Notification Report')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Notification Report')")).ToBeVisibleAsync(); // When there are notifications visible, the "View audit history" link // is rendered. When there are none, we just confirm the empty-state. @@ -829,7 +829,7 @@ public class AuditLogPageTests // Filter to the seeded row (contains-match), then Apply to populate the // grid — it stays empty until the user filters. - await page.FillAsync("#audit-target", targetPrefix + "dbrow"); + await FillAdvancedFilterAsync(page, "#audit-target", targetPrefix + "dbrow"); await page.ClickAsync("[data-test='filter-apply']"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); @@ -887,7 +887,7 @@ public class AuditLogPageTests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/audit/log"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await page.FillAsync("#audit-target", targetPrefix + "row"); + await FillAdvancedFilterAsync(page, "#audit-target", targetPrefix + "row"); await page.ClickAsync("[data-test='filter-apply']"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); @@ -912,4 +912,16 @@ public class AuditLogPageTests await AuditDataSeeder.DeleteByTargetPrefixAsync(targetPrefix); } } + + /// + /// Fills a filter that lives inside the collapsed "More filters" disclosure, + /// opening it first when needed. + /// + private static async Task FillAdvancedFilterAsync(IPage page, string selector, string value) + { + var more = page.Locator("details[data-test='filter-more']"); + if (!await more.EvaluateAsync("d => d.open")) + await more.Locator("summary").ClickAsync(); + await page.FillAsync(selector, value); + } } diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DebugViewTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DebugViewTests.cs index ad1eedcd..45483a54 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DebugViewTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DebugViewTests.cs @@ -70,7 +70,7 @@ public class DebugViewTests : IClassFixture await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/deployment/debug-view"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('Debug View')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Debug View')")).ToBeVisibleAsync(); // The data-test hooks must be served (proves the rebuild took). await Assertions.Expect(page.Locator("[data-test='debug-site-select']")).ToHaveCountAsync(1); await Assertions.Expect(page.Locator("[data-test='debug-instance-picker']")).ToHaveCountAsync(1); diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DeploymentsRealtimeTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DeploymentsRealtimeTests.cs index cc229c14..ba0da3d1 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DeploymentsRealtimeTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/DeploymentsRealtimeTests.cs @@ -62,7 +62,7 @@ public class DeploymentsRealtimeTests : IClassFixture var page = await _pw.NewAuthenticatedPageAsync(); await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/deployment/deployments"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('Deployment Status')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Deployment Status')")).ToBeVisibleAsync(); // Deploy over the CLI — this writes deployment records and raises StatusChanged, // which the page reloads on (push). No Refresh click here: the row appearing IS @@ -93,7 +93,7 @@ public class DeploymentsRealtimeTests : IClassFixture await page.WaitForLoadStateAsync(LoadState.NetworkIdle); // Confirm the page loaded before interacting (symmetric with Fact A) — a failed // load then surfaces as a clear heading-miss rather than a confusing Pause timeout. - await Assertions.Expect(page.Locator("h4:has-text('Deployment Status')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Deployment Status')")).ToBeVisibleAsync(); // Pause — the click round-trips over the circuit, so _autoRefresh is committed // false before the deploy below. The button flipping to "Resume" proves it. diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/FlowDebuggerTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/FlowDebuggerTests.cs index 0bd8edaf..a7b84d27 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/FlowDebuggerTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Deployment/FlowDebuggerTests.cs @@ -55,7 +55,7 @@ public class FlowDebuggerTests : IClassFixture // to Predicted and the method's ParameterValueForm (the same typed form the script // pane uses, inputs addressed by field id) appears. await Assertions.Expect(page.Locator("[data-test='flow-state']")).ToHaveTextAsync("Predicted", new() { Timeout = 15_000 }); - var input = page.Locator("#param-Text"); + var input = page.Locator("[data-param-path='Text']"); await Assertions.Expect(input).ToBeVisibleAsync(); // @bind commits on change (blur), so commit the value as its own circuit message before Run. @@ -136,7 +136,7 @@ public class FlowDebuggerTests : IClassFixture await Assertions.Expect(paramsCard.Or(noParamsNote)).ToBeVisibleAsync(new() { Timeout = 15_000 }); if (await paramsCard.IsVisibleAsync()) { - var workOrder = page.Locator("#param-WorkOrder"); + var workOrder = page.Locator("[data-param-path='WorkOrder']"); if (await workOrder.CountAsync() > 0) { await workOrder.FillAsync("WO-PW"); @@ -299,6 +299,10 @@ public class FlowDebuggerTests : IClassFixture await Assertions.Expect(select).ToBeVisibleAsync(); // The option list is loaded server-side on init; wait for our method to be present. await Assertions.Expect(select.Locator($"option[value='{MethodIdText}']")).ToHaveCountAsync(1, new() { Timeout = 15_000 }); + // The static-rendered . The select's // option values are the NotificationType enum names ("Email"/"Sms"); select by value. @@ -182,7 +182,7 @@ public class SmsNotificationE2ETests // Blazor enhanced navigation (SignalR round-trip) loads the edit form's data. await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('Edit Notification List')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Edit Notification List')")).ToBeVisibleAsync(); // CHANNEL-AWARE ASSERTION: SMS list → phone input present, email input absent. await Assertions.Expect(page.Locator("input[type=tel].form-control")).ToBeVisibleAsync(new() { Timeout = 10_000 }); @@ -226,7 +226,7 @@ public class SmsNotificationE2ETests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}{ListsUrl}/create"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('Add Notification List')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Add Notification List')")).ToBeVisibleAsync(); await page.Locator("input[type=text].form-control").First.FillAsync(name); await page.Locator("select.form-select").SelectOptionAsync(new SelectOptionValue { Value = "Sms" }); diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Notifications/SmtpConfigTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Notifications/SmtpConfigTests.cs index ae6fee74..a8a16619 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Notifications/SmtpConfigTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Notifications/SmtpConfigTests.cs @@ -63,7 +63,7 @@ public class SmtpConfigTests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}{SmtpUrl}"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('SMTP Configuration')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('SMTP Configuration')")).ToBeVisibleAsync(); // Open the form. Prefer the empty-state Add button (Host starts empty); otherwise // edit the first existing card (Host pre-filled — we clear it below). @@ -90,7 +90,7 @@ public class SmtpConfigTests // Cancel and confirm the form closed (Save button gone). Leaves config exactly as found. await page.Locator("button.btn-outline-secondary:has-text('Cancel')").ClickAsync(); await Assertions.Expect(page.Locator("button.btn-success:has-text('Save')")).ToHaveCountAsync(0); - await Assertions.Expect(page.Locator("h4:has-text('SMTP Configuration')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('SMTP Configuration')")).ToBeVisibleAsync(); } /// @@ -108,7 +108,7 @@ public class SmtpConfigTests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}{SmtpUrl}"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('SMTP Configuration')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('SMTP Configuration')")).ToBeVisibleAsync(); // Web-first: assert the page resolved to EITHER a config card (Credentials '(stored)' / // '(not set)') OR the empty-state, with retry so a slow Blazor init does not spuriously @@ -154,7 +154,7 @@ public class SmtpConfigTests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}{SmtpUrl}"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('SMTP Configuration')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('SMTP Configuration')")).ToBeVisibleAsync(); // Open the first card's Edit form. StartEdit reloads EVERY field (including the stored // credential, _credentials = smtp.Credentials), so re-saving untouched rewrites the diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/PendingUpdatesTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/PendingUpdatesTests.cs index 646ec7c0..9b00f78c 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/PendingUpdatesTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/PendingUpdatesTests.cs @@ -86,7 +86,7 @@ public class PendingUpdatesTests await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/admin/sites"); await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - await Assertions.Expect(page.Locator("h4:has-text('Site Management')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Site Management')")).ToBeVisibleAsync(); // One card per site; the badge hangs off the card's site-identifier line, so there must be // at least as many badges as cards. diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCalls/SiteCallsPageTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCalls/SiteCallsPageTests.cs index d2e08e7e..06b80fcc 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCalls/SiteCallsPageTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCalls/SiteCallsPageTests.cs @@ -99,7 +99,7 @@ public class SiteCallsPageTests await page.WaitForLoadStateAsync(LoadState.NetworkIdle); Assert.Contains(SiteCallsUrl, page.Url); - await Assertions.Expect(page.Locator("h4:has-text('Site Calls')")).ToBeVisibleAsync(); + await Assertions.Expect(page.Locator("h1:has-text('Site Calls')")).ToBeVisibleAsync(); // The filter card's Query button is the page's primary action. await Assertions.Expect(page.Locator("[data-test='site-calls-query']")).ToBeVisibleAsync(); } diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs index 020e3cbd..4fc34951 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs @@ -27,7 +27,7 @@ public class SiteCrudTests // Sites.razor renders the management page as a heading plus site cards // (not an HTML table) and an always-present "Add Site" action. - await Expect(page.Locator("h4:has-text('Site Management')")).ToBeVisibleAsync(); + await Expect(page.Locator("h1:has-text('Site Management')")).ToBeVisibleAsync(); await Expect(page.Locator("button:has-text('Add Site')")).ToBeVisibleAsync(); } @@ -59,7 +59,7 @@ public class SiteCrudTests await page.ClickAsync("button:has-text('Back')"); await PlaywrightFixture.WaitForPathAsync(page, "/admin/sites", excludePath: "/create"); - await Expect(page.Locator("h4:has-text('Site Management')")).ToBeVisibleAsync(); + await Expect(page.Locator("h1:has-text('Site Management')")).ToBeVisibleAsync(); } /// Verifies that the cancel button on the create page returns to the site list.