From 3e57c6b0548f7adaea411386093c07f5002e5a5a Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 7 Jun 2026 03:43:49 -0400 Subject: [PATCH] test(playwright): drop inert defensive teardown in Sites dup-identifier test (review fix) --- .../SiteCrudTests.cs | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs index d794f012..22ebffc1 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SiteCrudTests.cs @@ -215,36 +215,24 @@ public class SiteCrudTests var page = await _fixture.NewAuthenticatedPageAsync(); - try - { - await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/admin/sites/create"); - await page.WaitForLoadStateAsync(LoadState.NetworkIdle); + await page.GotoAsync($"{PlaywrightFixture.BaseUrl}/admin/sites/create"); + await page.WaitForLoadStateAsync(LoadState.NetworkIdle); - // Identifier collides with the seeded site-a; Name is distinct. Node addresses blank. - await page.Locator("label:has-text('Identifier') + input.form-control.form-control-sm").FillAsync("site-a"); - await page.Locator("label:has-text('Name') + input.form-control.form-control-sm").FillAsync(distinctName); + // Identifier collides with the seeded site-a; Name is distinct. Node addresses blank. + await page.Locator("label:has-text('Identifier') + input.form-control.form-control-sm").FillAsync("site-a"); + await page.Locator("label:has-text('Name') + input.form-control.form-control-sm").FillAsync(distinctName); - await page.ClickAsync("button.btn.btn-success.btn-sm:has-text('Save')"); + await page.ClickAsync("button.btn.btn-success.btn-sm:has-text('Save')"); - // The inline error surface must report the failed save and we must stay on /create. - // The full message is a raw DbUpdateException — assert only the "Save failed" prefix. - await Expect(page.Locator("div.text-danger.small.mt-2")).ToContainTextAsync("Save failed"); - await Assertions.Expect(page) - .ToHaveURLAsync(new System.Text.RegularExpressions.Regex("/admin/sites/create")); - } - finally - { - // Defensive: the failed create persists nothing, but if a stray site by the - // distinct name somehow exists, best-effort delete it (swallow not-found). - try - { - await CliRunner.DeleteSiteAsync(await CliRunner.ResolveSiteIdAsync(distinctName)); - } - catch - { - // Nothing persisted (expected) or cluster unreachable — ignore. - } - } + // The inline error surface must report the failed save and we must stay on /create. + // The full message is a raw DbUpdateException — assert only the "Save failed" prefix. + await Expect(page.Locator("div.text-danger.small.mt-2")).ToContainTextAsync("Save failed"); + await Assertions.Expect(page) + .ToHaveURLAsync(new System.Text.RegularExpressions.Regex("/admin/sites/create")); + + // No teardown: the SiteIdentifier unique index guarantees the create persisted nothing. + // A spuriously-persisted row would carry identifier "site-a" (not distinctName), and that + // cannot be auto-deleted without destroying the real seed — so there is nothing safe to sweep. } ///