test(configmanager): expand unit test coverage to 451 tests

Add comprehensive tests for services (ConnectionTestService, RuntimeConfigValidation),
ViewModels (PipelineEditor, dialogs, transformers), and Avalonia headless UI tests
for views and forms.
This commit is contained in:
Joseph Doherty
2026-01-27 07:24:55 -05:00
parent 227a749cdf
commit 937eb66ac8
14 changed files with 4053 additions and 62 deletions
@@ -0,0 +1,243 @@
using Avalonia.Controls;
using Avalonia.Headless.XUnit;
using Avalonia.VisualTree;
using JdeScoping.ConfigManager.Views.Dialogs;
namespace JdeScoping.ConfigManager.Tests.Views.Dialogs;
/// <summary>
/// UI tests for dialog views.
/// </summary>
public class DialogViewTests
{
/// <summary>
/// Verifies that NewStoreDialog renders with the expected input fields.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_RendersInputFields()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert - NewStoreDialog contains TextBoxes for store path and key file path
var textBoxes = dialog.GetVisualDescendants().OfType<TextBox>().ToList();
textBoxes.Count.ShouldBeGreaterThanOrEqualTo(2); // Store path and Key file path
// Verify section headers
var textBlocks = dialog.GetVisualDescendants().OfType<TextBlock>().ToList();
textBlocks.Any(tb => tb.Text == "Store Location").ShouldBeTrue();
textBlocks.Any(tb => tb.Text == "Key File").ShouldBeTrue();
}
/// <summary>
/// Verifies that NewStoreDialog has Browse and Generate buttons for key file.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_HasBrowseAndGenerateButtons()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
var buttons = dialog.GetVisualDescendants().OfType<Button>().ToList();
var buttonContents = buttons.Select(b => b.Content?.ToString()).ToList();
buttonContents.ShouldContain("Browse...");
buttonContents.ShouldContain("Generate");
}
/// <summary>
/// Verifies that NewStoreDialog has Create and Cancel buttons.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_HasCreateAndCancelButtons()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
var buttons = dialog.GetVisualDescendants().OfType<Button>().ToList();
var buttonContents = buttons.Select(b => b.Content?.ToString()).ToList();
buttonContents.ShouldContain("Create");
buttonContents.ShouldContain("Cancel");
}
/// <summary>
/// Verifies that NewStoreDialog has the correct title.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_HasCorrectTitle()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
dialog.Title.ShouldBe("Create New Secure Store");
}
/// <summary>
/// Verifies that NewStoreDialog has the expected size constraints.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_HasExpectedSize()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert - Width=550, Height=350, MinWidth=450, MinHeight=300
dialog.Width.ShouldBe(550);
dialog.Height.ShouldBe(350);
dialog.MinWidth.ShouldBe(450);
dialog.MinHeight.ShouldBe(300);
}
/// <summary>
/// Verifies that UnlockStoreDialog renders with key file input field.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_RendersKeyFileField()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert - UnlockStoreDialog contains TextBoxes for store path (read-only) and key file path
var textBoxes = dialog.GetVisualDescendants().OfType<TextBox>().ToList();
textBoxes.Count.ShouldBeGreaterThanOrEqualTo(2); // Store path and Key file path
// Verify section headers
var textBlocks = dialog.GetVisualDescendants().OfType<TextBlock>().ToList();
textBlocks.Any(tb => tb.Text == "Store File").ShouldBeTrue();
textBlocks.Any(tb => tb.Text == "Key File").ShouldBeTrue();
}
/// <summary>
/// Verifies that UnlockStoreDialog has a Browse button for key file.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_HasBrowseButton()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert
var buttons = dialog.GetVisualDescendants().OfType<Button>().ToList();
var buttonContents = buttons.Select(b => b.Content?.ToString()).ToList();
buttonContents.ShouldContain("Browse...");
}
/// <summary>
/// Verifies that UnlockStoreDialog has Unlock and Cancel buttons.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_HasUnlockAndCancelButtons()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert
var buttons = dialog.GetVisualDescendants().OfType<Button>().ToList();
var buttonContents = buttons.Select(b => b.Content?.ToString()).ToList();
buttonContents.ShouldContain("Unlock");
buttonContents.ShouldContain("Cancel");
}
/// <summary>
/// Verifies that UnlockStoreDialog has the correct title.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_HasCorrectTitle()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert
dialog.Title.ShouldBe("Unlock Secure Store");
}
/// <summary>
/// Verifies that UnlockStoreDialog has the expected size constraints.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_HasExpectedSize()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert - Width=500, Height=320, MinWidth=400, MinHeight=280
dialog.Width.ShouldBe(500);
dialog.Height.ShouldBe(320);
dialog.MinWidth.ShouldBe(400);
dialog.MinHeight.ShouldBe(280);
}
/// <summary>
/// Verifies that NewStoreDialog is not resizable.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_IsNotResizable()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
dialog.CanResize.ShouldBeFalse();
}
/// <summary>
/// Verifies that UnlockStoreDialog is not resizable.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_IsNotResizable()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert
dialog.CanResize.ShouldBeFalse();
}
/// <summary>
/// Verifies that NewStoreDialog contains a ScrollViewer.
/// </summary>
[AvaloniaFact]
public void NewStoreDialogView_ContainsScrollViewer()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
var scrollViewer = dialog.FindDescendantOfType<ScrollViewer>();
scrollViewer.ShouldNotBeNull();
}
/// <summary>
/// Verifies that UnlockStoreDialog contains a ScrollViewer.
/// </summary>
[AvaloniaFact]
public void UnlockStoreDialogView_ContainsScrollViewer()
{
// Arrange & Act
var dialog = new UnlockStoreDialog();
dialog.Show();
// Assert
var scrollViewer = dialog.FindDescendantOfType<ScrollViewer>();
scrollViewer.ShouldNotBeNull();
}
}