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:
@@ -0,0 +1,161 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.VisualTree;
|
||||
using JdeScoping.ConfigManager.Views;
|
||||
|
||||
namespace JdeScoping.ConfigManager.Tests.Views;
|
||||
|
||||
/// <summary>
|
||||
/// UI tests for <see cref="MainWindow"/>.
|
||||
/// </summary>
|
||||
public class MainWindowTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies that the main window displays with the correct title.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ShowsWithCorrectTitle()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
window.Title.ShouldBe("JdeScoping ConfigManager");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window contains a TreeView for navigation.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ContainsTreeView()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
var treeView = window.FindDescendantOfType<TreeView>();
|
||||
treeView.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window contains a menu bar.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ContainsMenuBar()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
var menu = window.FindDescendantOfType<Menu>();
|
||||
menu.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window has the expected minimum size constraints.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_HasExpectedMinimumSize()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert - MinWidth=900, MinHeight=600 as defined in AXAML
|
||||
window.MinWidth.ShouldBe(900);
|
||||
window.MinHeight.ShouldBe(600);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window has the expected default size.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_HasExpectedDefaultSize()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert - Width=1200, Height=800 as defined in AXAML
|
||||
window.Width.ShouldBe(1200);
|
||||
window.Height.ShouldBe(800);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window contains toolbar buttons.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ContainsToolbarButtons()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
var buttons = window.GetVisualDescendants().OfType<Button>().ToList();
|
||||
buttons.Count.ShouldBeGreaterThan(0);
|
||||
|
||||
// Verify toolbar buttons exist with expected content
|
||||
buttons.Any(b => b.Content?.ToString() == "Open").ShouldBeTrue();
|
||||
buttons.Any(b => b.Content?.ToString() == "Save").ShouldBeTrue();
|
||||
buttons.Any(b => b.Content?.ToString() == "Undo").ShouldBeTrue();
|
||||
buttons.Any(b => b.Content?.ToString() == "Redo").ShouldBeTrue();
|
||||
buttons.Any(b => b.Content?.ToString() == "Validate").ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window contains a ContentControl for form display.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ContainsFormContentControl()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
var contentControl = window.FindDescendantOfType<ContentControl>();
|
||||
contentControl.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the main window contains a GridSplitter for resizing panels.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ContainsGridSplitter()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
var splitter = window.FindDescendantOfType<GridSplitter>();
|
||||
splitter.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the menu contains expected menu items.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void MainWindow_ContainsExpectedMenuItems()
|
||||
{
|
||||
// Arrange & Act
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// Assert
|
||||
var menuItems = window.GetVisualDescendants().OfType<MenuItem>().ToList();
|
||||
menuItems.Count.ShouldBeGreaterThan(0);
|
||||
|
||||
// Verify top-level menu items exist
|
||||
menuItems.Any(m => m.Header?.ToString() == "_File").ShouldBeTrue();
|
||||
menuItems.Any(m => m.Header?.ToString() == "_Edit").ShouldBeTrue();
|
||||
menuItems.Any(m => m.Header?.ToString() == "_Tools").ShouldBeTrue();
|
||||
menuItems.Any(m => m.Header?.ToString() == "_Pipelines").ShouldBeTrue();
|
||||
menuItems.Any(m => m.Header?.ToString() == "_Secure Stores").ShouldBeTrue();
|
||||
menuItems.Any(m => m.Header?.ToString() == "_Help").ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user