Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageVersion Include="AngleSharp.Css" Version="1.0.0-beta.216" />
<PackageVersion Include="FluentValidation" Version="12.1.1" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.1" />
<!-- Markdown -->
<!-- Markdown editor -->
<PackageVersion Include="Markdig" Version="0.44.0" />
<PackageVersion Include="PSC.Blazor.Components.MarkdownEditor" Version="10.0.7" />
<!-- CQRS/Mediator -->
Expand Down
7 changes: 6 additions & 1 deletion src/Web/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
<ResourcePreloader />
<link rel="stylesheet" href="css/tailwind.css" />
<link rel="stylesheet" href="@Assets["Web.styles.css"]" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="_content/PSC.Blazor.Components.MarkdownEditor/css/easymde.min.css" />
<link rel="stylesheet" href="_content/PSC.Blazor.Components.MarkdownEditor/css/markdowneditor.css" />
<ImportMap />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
Expand All @@ -113,7 +116,9 @@
<Routes @rendermode="InteractiveServer" />
<ReconnectModal />
<script src="js/theme.js"></script>
<script src="_content/RTBlazorfied/js/RTBlazorfied.js"></script>
<script src="_content/PSC.Blazor.Components.MarkdownEditor/js/easymde.min.js"></script>
<script src="_content/PSC.Blazor.Components.MarkdownEditor/js/markdownEditor.js"></script>
<script src="js/text-editor-helpers.js"></script>
<script src="@Assets["_framework/blazor.web.js"]"></script>
</body>

Expand Down
2 changes: 1 addition & 1 deletion src/Web/Components/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
@using MyBlog.Web.Components.Layout
@using MyBlog.Web.Components.Shared
@using MyBlog.Web.Components.Theme
@using RichTextBlazorfied
@using PSC.Blazor.Components.MarkdownEditor
6 changes: 4 additions & 2 deletions src/Web/Features/BlogPosts/Create/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
<InputText class="form-input" @bind-Value="_model.Title" />
</div>
<div class="form-group">
<label class="form-label">Content</label>
<RTBlazorfied @bind-Value="_model.Content" Height="400px" />
<label class="form-label">Markdown</label>
<TextEditor Content="@_model.Content"
ContentChanged="@(v => _model.Content = v)"
AlignmentOptionsEnabled="false" />
</div>
<div class="form-group">
<label class="form-label flex items-center gap-2">
Expand Down
4 changes: 2 additions & 2 deletions src/Web/Features/BlogPosts/Edit/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ else if (_model is not null)
<InputText class="form-input" @bind-Value="_model.Title" />
</div>
<div class="form-group">
<label class="form-label">Content</label>
<RTBlazorfied @bind-Value="_model.Content" Height="400px" />
<label class="form-label">Content <span class="text-xs text-gray-500 dark:text-gray-400 font-normal">(Markdown)</span></label>
<TextEditor @bind-Content="_model.Content" AlignmentOptionsEnabled="false" />
</div>
<div class="form-group">
<label class="form-label flex items-center gap-2">
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Features/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@using MediatR
@using MyBlog.Web.Data
@using MyBlog.Web.Components.Shared
@using RichTextBlazorfied
@using PSC.Blazor.Components.MarkdownEditor
1 change: 0 additions & 1 deletion src/Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<PackageReference Include="HtmlSanitizer" />
<PackageReference Include="Markdig" />
<PackageReference Include="MediatR" />
<PackageReference Include="RTBlazorfied" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="MongoDB.EntityFrameworkCore" />
<PackageReference Include="PSC.Blazor.Components.MarkdownEditor" />
Expand Down
13 changes: 7 additions & 6 deletions tests/Web.Tests.Bunit/Components/RazorSmokeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public RazorSmokeTests()
Services.AddAuthorizationCore();
Services.AddSingleton<IAuthorizationService, TestAuthorizationService>();
Services.AddSingleton<AuthenticationStateProvider>(_authProvider);
Services.AddSingleton(Substitute.For<IFileStorage>());
}

[Fact]
Expand Down Expand Up @@ -333,7 +334,7 @@ public void CreatePostRendersForm()
heading.TextContent.Trim().Should().Be("Create Post");
heading.GetAttribute("class").Should().Contain("text-primary-900").And.Contain("dark:text-primary-50");
cut.FindAll("input").Count.Should().BeGreaterThanOrEqualTo(1);
cut.FindComponent<RichTextBlazorfied.RTBlazorfied>();
cut.FindComponent<TextEditor>();
}

[Fact]
Expand Down Expand Up @@ -367,8 +368,8 @@ public async Task CreatePostSubmitsAndNavigatesToBlogWhenCommandSucceeds()
var cut = RenderWithUser<Create>(CreatePrincipal("Alice", ["Author"]));

cut.FindAll("input")[0].Change("My title");
var editor = cut.FindComponent<RichTextBlazorfied.RTBlazorfied>();
await cut.InvokeAsync(() => editor.Instance.ValueChanged.InvokeAsync("Hello world"));
var textEditor = cut.FindComponent<TextEditor>();
await cut.InvokeAsync(() => textEditor.Instance.ContentChanged.InvokeAsync("Hello world"));
cut.Find("form").Submit();

// Assert
Expand All @@ -392,8 +393,8 @@ public async Task CreatePostShowsDismissibleErrorWhenCommandFails()
var cut = RenderWithUser<Create>(CreatePrincipal("Alice", ["Author"]));

cut.FindAll("input")[0].Change("My title");
var editor = cut.FindComponent<RichTextBlazorfied.RTBlazorfied>();
await cut.InvokeAsync(() => editor.Instance.ValueChanged.InvokeAsync("Hello world"));
var textEditor = cut.FindComponent<TextEditor>();
await cut.InvokeAsync(() => textEditor.Instance.ContentChanged.InvokeAsync("Hello world"));
cut.Find("form").Submit();

// Assert
Expand Down Expand Up @@ -421,7 +422,7 @@ public void EditPostLoadsExistingPost()
// Assert
cut.Markup.Should().Contain("Edit Post");
cut.Markup.Should().Contain("Existing title");
cut.FindComponent<RichTextBlazorfied.RTBlazorfied>();
cut.FindComponent<TextEditor>().Instance.Content.Should().Be("Existing content");
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions tests/Web.Tests.Bunit/Features/EditAclTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public EditAclTests()
Services.AddAuthorizationCore();
Services.AddSingleton<IAuthorizationService, TestAuthorizationService>();
Services.AddSingleton<AuthenticationStateProvider>(_authProvider);
Services.AddSingleton(Substitute.For<IFileStorage>());
}

[Fact]
Expand Down
7 changes: 5 additions & 2 deletions tests/Web.Tests.Bunit/Features/RichTextEditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
using Microsoft.Extensions.DependencyInjection;

using MyBlog.Domain.Abstractions;
using MyBlog.Web.Components.Shared;
using MyBlog.Web.Features.BlogPosts.Create;
using MyBlog.Web.Features.BlogPosts.Edit;
using MyBlog.Web.Infrastructure.FileStorage;

using Web.Testing;

Expand All @@ -31,6 +33,7 @@ public RichTextEditorTests()
Services.AddAuthorizationCore();
Services.AddSingleton<IAuthorizationService, TestAuthorizationService>();
Services.AddSingleton<AuthenticationStateProvider>(_authProvider);
Services.AddSingleton(Substitute.For<IFileStorage>());
}

[Fact]
Expand All @@ -46,7 +49,7 @@ public void EditorRendersOnCreatePage()
Task.FromResult(new AuthenticationState(CreatePrincipal("Alice", ["Author"])))));

// Assert
cut.FindComponent<RichTextBlazorfied.RTBlazorfied>();
cut.FindComponent<TextEditor>();
}

[Fact]
Expand All @@ -72,7 +75,7 @@ public void EditorRendersOnEditPage()
});

// Assert
cut.FindComponent<RichTextBlazorfied.RTBlazorfied>();
cut.FindComponent<TextEditor>();
}

private static ClaimsPrincipal CreatePrincipal(string name, string[] roles)
Expand Down
1 change: 1 addition & 0 deletions tests/Web.Tests.Bunit/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
global using MyBlog.Domain.Interfaces;
global using MyBlog.Domain.ValueObjects;
global using MyBlog.Web.Data;
global using MyBlog.Web.Infrastructure.FileStorage;

global using NSubstitute;
global using NSubstitute.ExceptionExtensions;
Loading