From 22a440bddfabbf84abc6ee25c8d6559658ecf0b3 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 6 Jun 2026 15:02:08 -0400 Subject: [PATCH] test(playwright): use label-anchored ExternalSystem form selectors (review fix) --- .../Design/ExternalSystemCrudTests.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs index d870f87b..489a8a86 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs @@ -35,12 +35,14 @@ public class ExternalSystemCrudTests await page.WaitForLoadStateAsync(LoadState.NetworkIdle); await Assertions.Expect(page.Locator("h4:has-text('Add External System')")).ToBeVisibleAsync(); - // Name and Endpoint URL are both input[type=text].form-control. Per - // ExternalSystemForm.razor, Name is the first text input and Endpoint URL - // is the second — select by order. - var textInputs = page.Locator("input[type=text].form-control"); - await textInputs.Nth(0).FillAsync(name); - await textInputs.Nth(1).FillAsync("https://example.invalid/api"); + // ExternalSystemForm.razor has THREE input[type=text].form-control fields + // (Name, Endpoint URL, and Auth Config JSON), so index-based selection is + // fragile. Anchor each fill to its own div.mb-3 wrapper via the field label + // so the selectors survive field reordering and uniquely match one element. + await page.Locator("div.mb-3:has(label:has-text('Name')) input[type=text].form-control") + .FillAsync(name); + await page.Locator("div.mb-3:has(label:has-text('Endpoint URL')) input[type=text].form-control") + .FillAsync("https://example.invalid/api"); await page.Locator("button.btn-success:has-text('Save')").ClickAsync();