diff --git a/LinkDotNet.Blog.IntegrationTests/Web/Pages/Admin/DraftBlogPostPageTests.cs b/LinkDotNet.Blog.IntegrationTests/Web/Pages/Admin/DraftBlogPostPageTests.cs index c4333e7b..07b31488 100644 --- a/LinkDotNet.Blog.IntegrationTests/Web/Pages/Admin/DraftBlogPostPageTests.cs +++ b/LinkDotNet.Blog.IntegrationTests/Web/Pages/Admin/DraftBlogPostPageTests.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; using Bunit; using FluentAssertions; using LinkDotNet.Blog.TestUtilities; @@ -23,6 +24,8 @@ public async Task ShouldOnlyShowPublishedPosts() ctx.JSInterop.Mode = JSRuntimeMode.Loose; ctx.Services.AddScoped(_ => BlogPostRepository); var cut = ctx.RenderComponent(); + cut.WaitForState(() => cut.FindAll(".blog-card").Any()); + var blogPosts = cut.FindComponents(); diff --git a/LinkDotNet.Blog.IntegrationTests/Web/Pages/IndexTests.cs b/LinkDotNet.Blog.IntegrationTests/Web/Pages/IndexTests.cs index 620aa887..55e72dfb 100644 --- a/LinkDotNet.Blog.IntegrationTests/Web/Pages/IndexTests.cs +++ b/LinkDotNet.Blog.IntegrationTests/Web/Pages/IndexTests.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; using Bunit; using FluentAssertions; using LinkDotNet.Blog.TestUtilities; @@ -26,6 +27,7 @@ public async Task ShouldShowAllBlogPostsWithLatestOneFirst() ctx.Services.AddScoped(_ => BlogPostRepository); ctx.Services.AddScoped(_ => CreateSampleAppConfiguration()); var cut = ctx.RenderComponent(); + cut.WaitForState(() => cut.FindAll(".blog-card").Any()); var blogPosts = cut.FindComponents(); @@ -46,6 +48,7 @@ public async Task ShouldOnlyShowPublishedPosts() ctx.Services.AddScoped(_ => BlogPostRepository); ctx.Services.AddScoped(_ => CreateSampleAppConfiguration()); var cut = ctx.RenderComponent(); + cut.WaitForState(() => cut.FindAll(".blog-card").Any()); var blogPosts = cut.FindComponents(); @@ -62,6 +65,7 @@ public async Task ShouldOnlyLoadTenEntities() ctx.Services.AddScoped(_ => BlogPostRepository); ctx.Services.AddScoped(_ => CreateSampleAppConfiguration()); var cut = ctx.RenderComponent(); + cut.WaitForState(() => cut.FindAll(".blog-card").Any()); var blogPosts = cut.FindComponents(); @@ -80,6 +84,7 @@ public async Task ShouldLoadNextBatchOnClick() cut.FindComponent().Find("li:last-child a").Click(); + cut.WaitForState(() => cut.FindAll(".blog-card").Count == 1); var blogPosts = cut.FindComponents(); blogPosts.Count.Should().Be(1); } @@ -93,6 +98,7 @@ public async Task ShouldLoadPreviousBatchOnClick() ctx.Services.AddScoped(_ => BlogPostRepository); ctx.Services.AddScoped(_ => CreateSampleAppConfiguration()); var cut = ctx.RenderComponent(); + cut.WaitForState(() => cut.FindAll(".blog-card").Any()); cut.FindComponent().Find("li:last-child a").Click(); cut.FindComponent().Find("li:first-child a").Click();