feat: add individual post page (#4)
* chore: add markdown lint to ignore no h1 heading in markdown files * chore: update example settings * chore: update example development env file * fix: remove fixed 100% height on container * feat: add individual post page * chore: update README.md * feat: add links to headings in post and add copy button to code blocks * tests: add tests for get post async method * tests: remove heading for test blogs * fix: only add links to headings in markdown body * tests: add tests for post page * tests: add test to check for blog content * docs: add jsdoc comments * chore: fix incorrect env variable format in example * fix: don't render anything if blog post is null * fix: don't render anything until posts are fetched * chore: add docker compose file for prod
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
namespace Blog.Tests.EndToEnd;
|
||||
|
||||
[TestFixture]
|
||||
public class PostTests : BlogTest
|
||||
{
|
||||
private const string TestPostSlug = "test-blog";
|
||||
private const string TestPostTitle = "Test Blog";
|
||||
private const string TestPostDate = "January 1, 2021";
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenNavigatedTo_ItShouldDisplayCorrectPageTitle()
|
||||
{
|
||||
await Page.GotoAsync($"/{TestPostSlug}");
|
||||
var title = await Page.TitleAsync();
|
||||
title.Should().Be($"{TestPostTitle} - journal");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenNavigatedTo_ItShouldPostTitle()
|
||||
{
|
||||
await Page.GotoAsync($"/{TestPostSlug}");
|
||||
var heading = Page.GetByRole(AriaRole.Heading, new() { Name = TestPostTitle });
|
||||
await Expect(heading).ToBeVisibleAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenNavigatedTo_ItShouldDisplayPostDate()
|
||||
{
|
||||
await Page.GotoAsync($"/{TestPostSlug}");
|
||||
var date = Page.GetByText(TestPostDate);
|
||||
await Expect(date).ToBeVisibleAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenNavigatedTo_ItShouldDisplayContent()
|
||||
{
|
||||
await Page.GotoAsync($"/{TestPostSlug}");
|
||||
var content = Page.GetByRole(AriaRole.Article);
|
||||
await Expect(content).ToBeVisibleAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenNavigatedToAndPostDoesNotExist_ItShouldDisplay404()
|
||||
{
|
||||
await Page.GotoAsync("/non-existent-post");
|
||||
Page.Url.Should().Contain("/Error/404");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
# Test Blog
|
||||
|
||||
```json meta
|
||||
{
|
||||
"title": "Another Test Blog",
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Test Blog
|
||||
|
||||
```json meta
|
||||
{
|
||||
"title": "Test Blog",
|
||||
|
||||
Reference in New Issue
Block a user