test(playwright): drop inert defensive teardown in Sites dup-identifier test (review fix)

This commit is contained in:
Joseph Doherty
2026-06-07 03:43:49 -04:00
parent 64222cf596
commit 3e57c6b054
@@ -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.
}
/// <summary>