Skip to content

Commit 8921169

Browse files
committed
fix(e2e): make imported replay assertions deterministic
1 parent 94e8db7 commit 8921169

File tree

2 files changed

+13
-39
lines changed

2 files changed

+13
-39
lines changed

Picea.Abies.Conduit.Testing.E2E/HealthTests.cs

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -144,45 +144,15 @@ public async Task BrowserRuntime_ImportedTimelineReplay_ShouldApplySnapshots()
144144
await _page.GetByRole(AriaRole.Button, new() { Name = "Import" }).ClickAsync());
145145
await chooser.SetFilesAsync(exportedPath);
146146

147-
// Import can restore either first or last timeline position depending on adapter behavior.
148-
// Wait until at least one replay control becomes enabled, then assert replay behavior.
149-
var backButton = _page.GetByRole(AriaRole.Button, new() { Name = "Back" });
150-
var stepButton = _page.GetByRole(AriaRole.Button, new() { Name = "Step" });
151-
var backEnabled = false;
152-
var stepEnabled = false;
153-
for (var i = 0; i < 60; i++)
154-
{
155-
backEnabled = await backButton.IsEnabledAsync();
156-
stepEnabled = await stepButton.IsEnabledAsync();
157-
if (backEnabled || stepEnabled)
158-
{
159-
break;
160-
}
161-
162-
await Task.Delay(500);
163-
}
164-
165-
await Assert.That(backEnabled || stepEnabled).IsTrue();
166-
167-
if (backEnabled)
168-
{
169-
await backButton.ClickAsync();
170-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign up", new() { Timeout = 10000 });
147+
var timelineItems = _page.Locator("[data-sequence]");
148+
await Expect(timelineItems.First).ToBeVisibleAsync(new() { Timeout = 15000 });
149+
await Expect(timelineItems.Nth(1)).ToBeVisibleAsync(new() { Timeout = 15000 });
171150

172-
await Expect(stepButton).ToBeEnabledAsync(new() { Timeout = 10000 });
173-
await stepButton.ClickAsync();
174-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
175-
}
176-
else
177-
{
178-
await Expect(stepButton).ToBeEnabledAsync(new() { Timeout = 10000 });
179-
await stepButton.ClickAsync();
180-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
151+
await timelineItems.First.ClickAsync();
152+
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign up", new() { Timeout = 10000 });
181153

182-
await Expect(backButton).ToBeEnabledAsync(new() { Timeout = 10000 });
183-
await backButton.ClickAsync();
184-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign up", new() { Timeout = 10000 });
185-
}
154+
await timelineItems.Nth(1).ClickAsync();
155+
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
186156
}
187157

188158
private static ILocatorAssertions Expect(ILocator locator) =>

Picea.Abies.Conduit.Testing.E2E/Server/FeedServerTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,14 @@ public async Task ServerRuntime_ImportedTimelineReplay_ShouldApplySnapshots()
150150
await _page.GetByRole(AriaRole.Button, new() { Name = "Import" }).ClickAsync());
151151
await chooser.SetFilesAsync(exportedPath);
152152

153-
await _page.Locator("button:has-text('Back')").ClickAsync();
153+
var timelineItems = _page.Locator("[data-sequence]");
154+
await Expect(timelineItems.First).ToBeVisibleAsync(new() { Timeout = 15000 });
155+
await Expect(timelineItems.Nth(1)).ToBeVisibleAsync(new() { Timeout = 15000 });
156+
157+
await timelineItems.First.ClickAsync();
154158
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign up", new() { Timeout = 10000 });
155159

156-
await _page.Locator("button:has-text('Step')").ClickAsync();
160+
await timelineItems.Nth(1).ClickAsync();
157161
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
158162
}
159163

0 commit comments

Comments
 (0)