Skip to content

Commit 1aac90e

Browse files
committed
Fixed missing tags
1 parent 557f78f commit 1aac90e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

LinkDotNet.Blog.IntegrationTests/Web/Pages/IndexTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,30 @@ public async Task ShouldLoadPreviousBatchOnClick()
106106
blogPosts.Count.Should().Be(10);
107107
}
108108

109+
[Fact]
110+
public async Task ShouldLoadTags()
111+
{
112+
var publishedPost = new BlogPostBuilder()
113+
.WithTitle("Published")
114+
.IsPublished()
115+
.WithTags("C Sharp", "Tag2")
116+
.Build();
117+
await Repository.StoreAsync(publishedPost);
118+
using var ctx = new TestContext();
119+
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
120+
RegisterComponents(ctx);
121+
var cut = ctx.RenderComponent<Index>();
122+
cut.WaitForState(() => cut.FindAll(".blog-card").Any());
123+
124+
var tags = cut.FindComponent<ShortBlogPost>().FindAll(".goto-tag");
125+
126+
tags.Should().HaveCount(2);
127+
tags.Select(t => t.TextContent).Should().Contain("C Sharp");
128+
tags.Select(t => t.TextContent).Should().Contain("Tag2");
129+
tags.Select(t => t.Attributes.Single(a => a.Name == "href").Value).Should().Contain("/searchByTag/C%20Sharp");
130+
tags.Select(t => t.Attributes.Single(a => a.Name == "href").Value).Should().Contain("/searchByTag/Tag2");
131+
}
132+
109133
private static AppConfiguration CreateSampleAppConfiguration()
110134
{
111135
return new()

LinkDotNet.Blog.Web/Pages/Index.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434

3535
protected override async Task OnInitializedAsync()
3636
{
37-
currentPage = await blogPostRepository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: appConfiguration.BlogPostsPerPage);
37+
currentPage = await blogPostRepository.GetAllAsync(
38+
p => p.IsPublished,
39+
b => b.UpdatedDate,
40+
b => b.Tags,
41+
pageSize: appConfiguration.BlogPostsPerPage);
3842
}
3943

4044
private string GetAbsolutePreviewImageUrl()

0 commit comments

Comments
 (0)