tests/Integration/Cassiel.Integration.Tests.ps1
|
# Integration Tests for Cassiel Compatibility BeforeAll { # Import the module $modulePath = Join-Path $PSScriptRoot ".." "HermesConsoleUI.psm1" Import-Module $modulePath -Force } Describe "Cassiel Integration - Show-ConsoleMenu API Compatibility" { Context "Required Parameters for Cassiel" { It "Should support -Header parameter" { $cmd = Get-Command Show-ConsoleMenu $cmd.Parameters.ContainsKey('Header') | Should -Be $true } It "Should support -ReturnIndex parameter" { $cmd = Get-Command Show-ConsoleMenu $cmd.Parameters.ContainsKey('ReturnIndex') | Should -Be $true } It "Should support -Title parameter" { $cmd = Get-Command Show-ConsoleMenu $cmd.Parameters.ContainsKey('Title') | Should -Be $true } It "Should support -Options parameter" { $cmd = Get-Command Show-ConsoleMenu $cmd.Parameters.ContainsKey('Options') | Should -Be $true } } Context "Cassiel Menu Pattern Simulation" { BeforeAll { Mock Read-ConsoleChoice { param($MaxChoice) return 1 # Simulate selecting first option } -ModuleName HermesConsoleUI } It "Should handle Cassiel main menu pattern" { $opciones = @( "Auditoría (Ver resultados, ejecutar escaneos)", "Hardening (Aplicar políticas L1-L5)", "Aplicaciones (Gestión de Python y Entornos)", "Limpieza (Sistema y Reportes)", "Configuración (Preferencias y Ajustes)", "Integraciones (Enviar datos a Samael)" ) $title = "MENU PRINCIPAL - CASSIEL SECURITY" $header = "Seleccione el módulo de operación:" $choice = Show-ConsoleMenu -Title $title -Options $opciones -Header $header -ReturnIndex -NoClear $choice | Should -BeOfType [Int32] $choice | Should -BeGreaterOrEqual 0 } It "Should handle menu with headers and separators" { $opciones = @( "[CATEGORIA 1]", "Opción 1.1", "Opción 1.2", "---", "[CATEGORIA 2]", "Opción 2.1" ) $choice = Show-ConsoleMenu -Title "Test Menu" -Options $opciones -Header "Selecciona:" -ReturnIndex -NoClear $choice | Should -BeOfType [Int32] } } Context "Return Value Compatibility" { BeforeAll { Mock Read-ConsoleChoice { return 2 } -ModuleName HermesConsoleUI } It "With -ReturnIndex should return selected index" { $options = @("A", "B", "C") $result = Show-ConsoleMenu -Title "Test" -Options $options -ReturnIndex -NoClear $result | Should -Be 2 } It "Without -ReturnIndex should return count" { $options = @("A", "B", "C") $result = Show-ConsoleMenu -Title "Test" -Options $options -NoClear $result | Should -Be 3 } } } Describe "Cassiel Integration - Module Loading" { It "Module should be loadable" { $module = Get-Module HermesConsoleUI $module | Should -Not -BeNullOrEmpty } It "Module version should be 2.1.0 or higher" { $module = Get-Module HermesConsoleUI $module.Version | Should -BeGreaterOrEqual ([version]"2.1.0") } It "Should export Show-ConsoleMenu function" { $module = Get-Module HermesConsoleUI $module.ExportedFunctions.Keys | Should -Contain "Show-ConsoleMenu" } } Describe "Cassiel Integration - Other Required Functions" { It "Should export Write-ConsoleTitle" { Get-Command Write-ConsoleTitle -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty } It "Should export Write-ConsoleStatus" { Get-Command Write-ConsoleStatus -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty } It "Should export Read-ConsoleChoice" { Get-Command Read-ConsoleChoice -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty } } AfterAll { Remove-Module HermesConsoleUI -Force -ErrorAction SilentlyContinue } |