From de857f087117a1c2222435881886284fa9d326e9 Mon Sep 17 00:00:00 2001 From: Jesse Liberty Date: Sun, 27 Sep 2026 07:31:55 -0400 Subject: [PATCH] fix: update RunCommandDialog to display about information and remove copy functionality --- BlogWriter.Web.Tests/HelpDialogTestHelpers.cs | 4 -- BlogWriter.Web.Tests/RunCommandDialogTests.cs | 37 +++++-------------- .../Components/RunCommandDialog.razor | 33 +++-------------- 3 files changed, 14 insertions(+), 60 deletions(-) diff --git a/BlogWriter.Web.Tests/HelpDialogTestHelpers.cs b/BlogWriter.Web.Tests/HelpDialogTestHelpers.cs index dcf70a7..4b8cf69 100644 --- a/BlogWriter.Web.Tests/HelpDialogTestHelpers.cs +++ b/BlogWriter.Web.Tests/HelpDialogTestHelpers.cs @@ -1,5 +1,4 @@ using Bunit; -using Microsoft.JSInterop; namespace BlogWriter.Web.Tests; @@ -8,7 +7,4 @@ internal static class HelpDialogTestHelpers public static void AllowDialogOpen(BunitContext context) => context.JSInterop.SetupVoid("blogWriterDialog.show", _ => true); - public static void FailClipboardCopy(BunitContext context) => - context.JSInterop.SetupVoid("navigator.clipboard.writeText", _ => true) - .SetException(new JSException("Clipboard permission denied.")); } diff --git a/BlogWriter.Web.Tests/RunCommandDialogTests.cs b/BlogWriter.Web.Tests/RunCommandDialogTests.cs index 3b7c195..afc58c7 100644 --- a/BlogWriter.Web.Tests/RunCommandDialogTests.cs +++ b/BlogWriter.Web.Tests/RunCommandDialogTests.cs @@ -8,39 +8,20 @@ public sealed class RunCommandDialogTests : BunitContext public RunCommandDialogTests() => JSInterop.Mode = JSRuntimeMode.Loose; [Fact] - public void Dialog_ShowsExactRunCommandAndAccessibleModal() + public void Dialog_ShowsAboutTextAndAccessibleModal() { HelpDialogTestHelpers.AllowDialogOpen(this); IRenderedComponent cut = Render(); - Assert.Equal(RunCommandDialog.CommandText, cut.Find(".run-command-text").TextContent); - Assert.Contains(RunCommandDialog.HttpsPort, cut.Find(".run-command-port").TextContent); + Assert.Contains("About BlogWriter", cut.Markup); + Assert.Contains("BlogWriter", cut.Markup); + Assert.Contains("An open source program", cut.Markup); + Assert.Contains("(c) Copyright 2026 Jesse Liberty", cut.Markup); + Assert.Contains("See License", cut.Markup); Assert.Equal("dialog", cut.Find("dialog").GetAttribute("role")); Assert.Equal("true", cut.Find("dialog").GetAttribute("aria-modal")); - Assert.Equal("Copy", cut.Find(".dialog-actions button").TextContent.Trim()); - } - - [Fact] - public void Dialog_CopyReportsSuccess() - { - HelpDialogTestHelpers.AllowDialogOpen(this); - IRenderedComponent cut = Render(); - - cut.Find(".dialog-actions button").Click(); - - Assert.Contains("Command copied", cut.Markup); - } - - [Fact] - public void Dialog_CopyFailureKeepsCommandVisibleAndReportsFailure() - { - HelpDialogTestHelpers.AllowDialogOpen(this); - HelpDialogTestHelpers.FailClipboardCopy(this); - IRenderedComponent cut = Render(); - - cut.Find(".dialog-actions button").Click(); - - Assert.Contains(RunCommandDialog.CommandText, cut.Markup); - Assert.Contains("Copying was not available", cut.Markup); + Assert.DoesNotContain("Copy", cut.FindAll(".dialog-actions button").Select(button => button.TextContent)); + Assert.DoesNotContain("HTTPS port", cut.Markup); + Assert.Equal("Close", cut.Find(".dialog-actions button").TextContent.Trim()); } } diff --git a/BlogWriter.Web/Components/RunCommandDialog.razor b/BlogWriter.Web/Components/RunCommandDialog.razor index 493cd95..2799b7f 100644 --- a/BlogWriter.Web/Components/RunCommandDialog.razor +++ b/BlogWriter.Web/Components/RunCommandDialog.razor @@ -3,34 +3,24 @@
-

Developer help

-

Run Blog Writer

-

Use this command in the repository terminal:

- @CommandText -

HTTPS port: @HttpsPort

- @if (!string.IsNullOrWhiteSpace(CopyMessage)) - { -

@CopyMessage

- } +

About BlogWriter

+

BlogWriter

+

An open source program

+

(c) Copyright 2026 Jesse Liberty

+

See License

-
@code { - public const string CommandText = "dotnet run --project BlogWriter.Web/BlogWriter.Web.csproj --launch-profile https"; - public const string HttpsPort = "7056"; - private ElementReference _dialog; private bool _opened; [Parameter] public EventCallback Closed { get; set; } - private string? CopyMessage { get; set; } - protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) @@ -40,19 +30,6 @@ } } - private async Task CopyAsync() - { - try - { - await JS.InvokeVoidAsync("navigator.clipboard.writeText", CommandText); - CopyMessage = "Command copied."; - } - catch (JSException) - { - CopyMessage = "Copying was not available. Select the command above to copy it manually."; - } - } - private async Task Close() => await Closed.InvokeAsync(); public async ValueTask DisposeAsync()