diff --git a/src/classes/public/Repositories/GitHubCustomProperty.ps1 b/src/classes/public/Repositories/GitHubCustomProperty.ps1 index e00f7e4d0..12ec3b533 100644 --- a/src/classes/public/Repositories/GitHubCustomProperty.ps1 +++ b/src/classes/public/Repositories/GitHubCustomProperty.ps1 @@ -2,14 +2,19 @@ class GitHubCustomProperty { # The name of the custom property. [string] $Name - # The value of the custom property. - [string] $Value + # The value of the custom property. Can be a string or an array of strings for multi-select properties. + [object] $Value GitHubCustomProperty() {} GitHubCustomProperty([PSCustomObject] $Object) { $this.Name = $Object.property_name ?? $Object.propertyName ?? $Object.Name - $this.Value = $Object.value ?? $Object.Value + $rawValue = $Object.value ?? $Object.Value + if ($rawValue -is [System.Collections.IEnumerable] -and $rawValue -isnot [string]) { + $this.Value = [string[]]$rawValue + } else { + $this.Value = $rawValue + } } [string] ToString() { diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index dab477d5a..d61c3bdaf 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -19,6 +19,43 @@ [CmdletBinding()] param() +Describe 'GitHubCustomProperty' { + It 'Preserves array value for multi-select properties' { + $obj = [PSCustomObject]@{ + property_name = 'SubscribeTo' + value = @('Custom Instructions', 'License', 'Prompts') + } + $prop = [GitHubCustomProperty]::new($obj) + $prop.Name | Should -Be 'SubscribeTo' + $prop.Value | Should -BeOfType [string] + $prop.Value | Should -HaveCount 3 + $prop.Value[0] | Should -Be 'Custom Instructions' + $prop.Value[1] | Should -Be 'License' + $prop.Value[2] | Should -Be 'Prompts' + } + + It 'Keeps scalar string value as string' { + $obj = [PSCustomObject]@{ + property_name = 'Type' + value = 'Module' + } + $prop = [GitHubCustomProperty]::new($obj) + $prop.Name | Should -Be 'Type' + $prop.Value | Should -Be 'Module' + $prop.Value | Should -BeOfType [string] + } + + It 'Handles GraphQL-style property names' { + $obj = [PSCustomObject]@{ + propertyName = 'Environment' + value = 'production' + } + $prop = [GitHubCustomProperty]::new($obj) + $prop.Name | Should -Be 'Environment' + $prop.Value | Should -Be 'production' + } +} + Describe 'Auth' { $authCases = . "$PSScriptRoot/Data/AuthCases.ps1"