test(playwright): use label-anchored ExternalSystem form selectors (review fix)

This commit is contained in:
Joseph Doherty
2026-06-06 15:02:08 -04:00
parent 4cfe950232
commit 22a440bddf
@@ -35,12 +35,14 @@ public class ExternalSystemCrudTests
await page.WaitForLoadStateAsync(LoadState.NetworkIdle); await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await Assertions.Expect(page.Locator("h4:has-text('Add External System')")).ToBeVisibleAsync(); 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 has THREE input[type=text].form-control fields
// ExternalSystemForm.razor, Name is the first text input and Endpoint URL // (Name, Endpoint URL, and Auth Config JSON), so index-based selection is
// is the second — select by order. // fragile. Anchor each fill to its own div.mb-3 wrapper via the field label
var textInputs = page.Locator("input[type=text].form-control"); // so the selectors survive field reordering and uniquely match one element.
await textInputs.Nth(0).FillAsync(name); await page.Locator("div.mb-3:has(label:has-text('Name')) input[type=text].form-control")
await textInputs.Nth(1).FillAsync("https://example.invalid/api"); .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(); await page.Locator("button.btn-success:has-text('Save')").ClickAsync();