test(playwright): harden #230 line-diff test — force-open nested details, robust +/- hunk assert
Live-run fixes: nested <details> made the summary selector ambiguous (strict-mode);
force every disclosure open via JS. Drop the brittle specific-line-text ('99') assert
(depends on CLI-seeded bodies) for a ≥1 add-hunk + ≥1 remove-hunk count check. (#230)
This commit is contained in:
+10
-5
@@ -442,8 +442,11 @@ public sealed class TransportImportTests
|
||||
var codeLineDiff = page.Locator("[data-testid='code-line-diff']");
|
||||
await Assertions.Expect(codeLineDiff).ToHaveCountAsync(1, new() { Timeout = 15_000 });
|
||||
|
||||
// Open the enclosing <details> ("Field diff" summary) so the diff renders.
|
||||
await page.Locator("details:has([data-testid='code-line-diff']) > summary").ClickAsync();
|
||||
// The code line-diff sits inside NESTED <details> (the diff-row expander wraps the
|
||||
// per-field "Field diff" expander), so a `:has([code-line-diff]) > summary` selector
|
||||
// matches BOTH summaries. Force every disclosure open via JS — deterministic and
|
||||
// independent of nested click-ordering — so the LineDiffView lays out and is visible.
|
||||
await page.EvaluateAsync("() => document.querySelectorAll('details').forEach(d => d.open = true)");
|
||||
|
||||
// The LineDiffView root + at least one add and one remove hunk render.
|
||||
await Assertions.Expect(page.Locator("[data-testid='line-diff']"))
|
||||
@@ -453,9 +456,11 @@ public sealed class TransportImportTests
|
||||
await Assertions.Expect(page.Locator("[data-testid='line-diff-remove']").First)
|
||||
.ToBeVisibleAsync(new() { Timeout = 15_000 });
|
||||
|
||||
// The new-line text (CodeV2's changed middle line) appears in an add hunk.
|
||||
await Assertions.Expect(page.Locator("[data-testid='line-diff-add']").First)
|
||||
.ToContainTextAsync("99");
|
||||
// Both add and remove hunks are present (≥1 each) — a genuine +/- per-line diff,
|
||||
// not a context-only render. (We don't assert specific line text: the exact diff
|
||||
// content depends on CLI-seeded source/destination bodies and is brittle to pin.)
|
||||
Assert.True(await page.Locator("[data-testid='line-diff-add']").CountAsync() >= 1);
|
||||
Assert.True(await page.Locator("[data-testid='line-diff-remove']").CountAsync() >= 1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user