Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/IdLE.Core/Private/ConvertTo-IdlePlanExportObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ function ConvertTo-IdlePlanExportObject {
)

foreach ($name in $Names) {
if ($Object -is [System.Collections.IDictionary]) {
if ($Object.Contains($name)) {
return $Object[$name]
}
continue
}
$prop = $Object.PSObject.Properties[$name]
if ($null -ne $prop) {
return $prop.Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ function ConvertTo-IdleWorkflowStepPreconditionSettings {
)
}

Assert-IdleConditionPathsResolvable -Condition ([hashtable]$rawPrecondition) -Context $PlanningContext -StepName $StepName -Source 'Precondition' -AllowMissingRequestContextPaths -WarningSink (Get-IdlePropertyValue -Object $PlanningContext.Plan -Name 'Warnings')
$warningSink = $null
$planObj = $PlanningContext.Plan
if ($null -ne $planObj) {
if ($planObj -is [System.Collections.IDictionary]) {
if ($planObj.Contains('Warnings')) { $warningSink = $planObj['Warnings'] }
} else {
$wProp = $planObj.PSObject.Properties['Warnings']
if ($null -ne $wProp) { $warningSink = $wProp.Value }
}
}
Assert-IdleConditionPathsResolvable -Condition ([hashtable]$rawPrecondition) -Context $PlanningContext -StepName $StepName -Source 'Precondition' -AllowMissingRequestContextPaths -WarningSink $warningSink
$normalized.Precondition = Copy-IdleDataObject -Value $rawPrecondition
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/IdLE.Core/Private/Test-IdleWorkflowSchema.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Test-IdleWorkflowSchema {
$ErrorList.Add("'$StepPath.Precondition' must be a hashtable (condition node).")
}
else {
foreach ($schemaError in (Test-IdleConditionSchema -Condition ([hashtable]$Step.Precondition) -StepName $StepPath)) {
foreach ($schemaError in (Test-IdleConditionSchema -Condition ([hashtable]$Step.Precondition) -StepName $null)) {
$ErrorList.Add("'$StepPath.Precondition' has invalid condition schema: $schemaError")
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Core/Assert-IdleConditionPathsResolvable.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Describe 'Assert-IdleConditionPathsResolvable' {

$context = @{
Plan = @{ LifecycleEvent = 'Joiner' }
Request = @{ Intent = @{ OffboardingDate = '2026-02-30' }; Context = @{}; IdentityKeys = @{} }
Request = @{ Intent = @{ OffboardingDate = '2026-02-28' }; Context = @{}; IdentityKeys = @{} }
}

{
Expand All @@ -35,7 +35,7 @@ Describe 'Assert-IdleConditionPathsResolvable' {

$context = @{
Plan = @{ LifecycleEvent = 'Joiner' }
Request = @{ Intent = @{ OffboardingDate = '2026-02-30' }; Context = @{}; IdentityKeys = @{} }
Request = @{ Intent = @{ OffboardingDate = '2026-02-28' }; Context = @{}; IdentityKeys = @{} }
}

{
Expand All @@ -53,7 +53,7 @@ Describe 'Assert-IdleConditionPathsResolvable' {

$context = @{
Plan = @{ LifecycleEvent = 'Joiner' }
Request = @{ Intent = @{ OffboardingDate = '2026-02-30' }; Context = @{}; IdentityKeys = @{} }
Request = @{ Intent = @{ OffboardingDate = '2026-02-28' }; Context = @{}; IdentityKeys = @{} }
}

{
Expand All @@ -71,7 +71,7 @@ Describe 'Assert-IdleConditionPathsResolvable' {

$context = @{
Plan = @{ LifecycleEvent = 'Joiner' }
Request = @{ Intent = @{ OffboardingDate = '2026-02-30' }; Context = @{}; IdentityKeys = @{} }
Request = @{ Intent = @{ OffboardingDate = '2026-02-28' }; Context = @{}; IdentityKeys = @{} }
}

{
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Export-IdlePlan.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Describe 'Export-IdlePlan' {
}
}


Context 'Planning warnings export' {
It 'includes planning warnings in exported plan for CI checks' {
$cid = '22222222-2222-2222-2222-222222222222'

Expand Down
8 changes: 4 additions & 4 deletions tests/Core/Test-IdleWorkflowSchema.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Describe 'Workflow schema validation - Condition/Precondition DSL parity' {
}

$errors = Test-IdleWorkflowSchema -Workflow $workflow
@($errors | Where-Object { $_ -like "*Steps[0].Condition*invalid condition schema*" }).Count | Should -BeGreaterThan 0
@($errors | Where-Object { $_ -like "*Steps``[0``].Condition*invalid condition schema*" }).Count | Should -BeGreaterThan 0
}

It 'rejects invalid Condition DSL nodes in OnFailureSteps at definition validation time' {
Expand All @@ -41,7 +41,7 @@ Describe 'Workflow schema validation - Condition/Precondition DSL parity' {
}

$errors = Test-IdleWorkflowSchema -Workflow $workflow
@($errors | Where-Object { $_ -like "*OnFailureSteps[0].Condition*invalid condition schema*" }).Count | Should -BeGreaterThan 0
@($errors | Where-Object { $_ -like "*OnFailureSteps``[0``].Condition*invalid condition schema*" }).Count | Should -BeGreaterThan 0
}

It 'rejects invalid Precondition DSL node at definition validation time' {
Expand All @@ -58,7 +58,7 @@ Describe 'Workflow schema validation - Condition/Precondition DSL parity' {
}

$errors = Test-IdleWorkflowSchema -Workflow $workflow
@($errors | Where-Object { $_ -like "*Steps[0].Precondition*invalid condition schema*" }).Count | Should -BeGreaterThan 0
@($errors | Where-Object { $_ -like "*Steps``[0``].Precondition*invalid condition schema*" }).Count | Should -BeGreaterThan 0
}

It 'accepts valid precondition using the same condition DSL' {
Expand All @@ -81,7 +81,7 @@ Describe 'Workflow schema validation - Condition/Precondition DSL parity' {
}

$errors = Test-IdleWorkflowSchema -Workflow $workflow
$errors.Count | Should -Be 0
@($errors).Count | Should -Be 0
}
}
}