Skip to content

Commit 2030f5b

Browse files
committed
test: harden flaky conduit E2E assertions
1 parent 7713046 commit 2030f5b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Picea.Abies.Conduit.Testing.E2E/AppHost/AppHostServerRegressionTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ public async Task DeleteArticle_AsAuthor_ShouldRemoveItFromGlobalFeed()
7272
await _page.WaitForSelectorAsync("text='Delete Article'", new() { Timeout = 15000 });
7373
await _page.GetByText("Delete Article").First.ClickAsync();
7474

75-
await _page.WaitForURLAsync("**/");
75+
await _page.WaitForFunctionAsync(
76+
"() => window.location.pathname === '/'",
77+
null,
78+
new() { Timeout = 30000 });
79+
await _page.WaitForSelectorAsync(
80+
".home-page, .feed-toggle, .article-preview",
81+
new() { Timeout = 30000 });
7682
await _seeder.WaitForArticleDeletedAsync(article.Slug);
7783
await Expect(_page.Locator(".article-preview").Filter(new() { HasText = article.Title }))
7884
.ToHaveCountAsync(0, new() { Timeout = 10000 });

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ await Expect(_page.Locator($".card .card-block p:text-is('{comment.Body}')"))
109109
await _page.Locator(".card .card-footer .mod-options i.ion-trash-a").First
110110
.DispatchEventAsync("click");
111111

112-
await Expect(_page.Locator($"text={comment.Body}")).ToHaveCountAsync(0,
112+
await Expect(_page.Locator($".card .card-block p:text-is('{comment.Body}')")).ToHaveCountAsync(0,
113113
new() { Timeout = 10000 });
114114
}
115115

@@ -151,7 +151,7 @@ await route.FulfillAsync(new RouteFulfillOptions
151151

152152
await _page.Locator(".card .card-footer .mod-options i.ion-trash-a").First.DispatchEventAsync("click");
153153

154-
await Expect(_page.Locator($"text={comment.Body}")).ToHaveCountAsync(0,
154+
await Expect(_page.Locator($".card .card-block p:text-is('{comment.Body}')")).ToHaveCountAsync(0,
155155
new() { Timeout = 10000 });
156156
}
157157

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public async Task Login_WithInvalidCredentials_ShouldShowErrors()
7878
await _page.GetByPlaceholder("Password").FillAndWaitForPatch("wrongpassword");
7979
await _page.GetByRole(AriaRole.Button, new() { Name = "Sign in" }).ClickAsync();
8080

81-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
81+
await Expect(_page.Locator(".auth-page h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
8282
await Expect(_page.Locator(".navbar a[href='/settings']")).ToHaveCountAsync(0, new() { Timeout = 10000 });
8383
}
8484

@@ -98,7 +98,7 @@ public async Task Logout_FromSettings_ShouldClearSessionAndNavigateToHome()
9898
.ClickAsync();
9999

100100
await _page.NavigateInApp("/settings");
101-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
101+
await Expect(_page.Locator(".auth-page h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
102102
await Expect(_page.Locator(".navbar a[href='/settings']")).ToHaveCountAsync(0, new() { Timeout = 10000 });
103103
}
104104

@@ -119,7 +119,7 @@ public async Task Login_WithWrongPasswordAfterRegister_ShouldShowError()
119119
await _page.GetByPlaceholder("Password").FillAndWaitForPatch("wrongpassword");
120120
await _page.GetByRole(AriaRole.Button, new() { Name = "Sign in" }).ClickAsync();
121121

122-
await Expect(_page.Locator("h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
122+
await Expect(_page.Locator(".auth-page h1")).ToContainTextAsync("Sign in", new() { Timeout = 10000 });
123123
await Expect(_page.Locator(".navbar a[href='/settings']")).ToHaveCountAsync(0, new() { Timeout = 10000 });
124124
}
125125

0 commit comments

Comments
 (0)