Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Web/Features/BlogPosts/Edit/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ else if (_model is not null)
}
else
{
_model = null;
Navigation.NavigateTo("/blog");
return;
}
Comment on lines 87 to 91
}
else
Expand Down
23 changes: 23 additions & 0 deletions tests/Web.Tests.Bunit/Features/EditAclTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ public EditAclTests()
Services.AddSingleton<AuthenticationStateProvider>(_authProvider);
}

[Fact]
public void EditRedirectsToBlogWhenPostNotFound()
{
// Arrange
var sender = Substitute.For<ISender>();
var postId = Guid.NewGuid();

sender.Send(Arg.Any<GetBlogPostByIdQuery>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(Result.Ok<BlogPostDto?>(null)));

Services.AddSingleton(sender);

var navigation = Services.GetRequiredService<NavigationManager>();

// Act
RenderWithUser<Edit>(
CreatePrincipalWithSub("auth0|some-user", ["Author"]),
parameters => parameters.Add(p => p.Id, postId));

// Assert
navigation.Uri.Should().EndWith("/blog");
}

[Fact]
public void EditRedirectsToBlogWhenAuthorIsNotPostOwner()
{
Expand Down
Loading