Skip to content
Merged
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
47 changes: 47 additions & 0 deletions tests/Invoke-IdlePlan.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ BeforeAll {
Error = $null
}
}

# Legacy step handler without Context parameter for backwards compatibility testing
function global:Invoke-IdleTestLegacyStep {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateNotNull()]
[object] $Step
)

return [pscustomobject]@{
PSTypeName = 'IdLE.StepResult'
Name = [string]$Step.Name
Type = [string]$Step.Type
Status = 'Completed'
Error = $null
}
}
}

AfterAll {
Expand All @@ -126,6 +144,7 @@ AfterAll {
Remove-Item -Path 'Function:\Invoke-IdleTestEmitStep' -ErrorAction SilentlyContinue
Remove-Item -Path 'Function:\Invoke-IdleTestFailStep' -ErrorAction SilentlyContinue
Remove-Item -Path 'Function:\Invoke-IdleTestAcquireAuthSessionStep' -ErrorAction SilentlyContinue
Remove-Item -Path 'Function:\Invoke-IdleTestLegacyStep' -ErrorAction SilentlyContinue
}

Describe 'Invoke-IdlePlan' {
Expand Down Expand Up @@ -692,4 +711,32 @@ Describe 'Invoke-IdlePlan' {
$callLog.Options['Mode'] | Should -Be 'Auto'
$callLog.Options['CacheKey'] | Should -Be 'unit-test'
}

It 'supports step handlers without Context parameter (backwards compatibility)' {
$wfPath = Join-Path -Path $TestDrive -ChildPath 'legacy.psd1'
Set-Content -Path $wfPath -Encoding UTF8 -Value @'
@{
Name = 'Legacy'
LifecycleEvent = 'Joiner'
Steps = @(
@{ Name = 'LegacyStep'; Type = 'IdLE.Step.Legacy' }
)
}
'@

$req = New-IdleLifecycleRequest -LifecycleEvent 'Joiner'
$plan = New-IdlePlan -WorkflowPath $wfPath -Request $req

$providers = @{
StepRegistry = @{
'IdLE.Step.Legacy' = 'Invoke-IdleTestLegacyStep'
}
}

$result = Invoke-IdlePlan -Plan $plan -Providers $providers

$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
$result.Steps[0].Name | Should -Be 'LegacyStep'
}
}