BeforeAll { Import-Module "$PSScriptRoot/../src/Manifest.psm1" -Force } Describe 'Manifest resolution' { It 'resolves the checked-in example in profile order' { $result = Resolve-MachineManifest -RepositoryRoot "$PSScriptRoot/.." -Machine 'example-desktop' $result.packages.Count | Should -Be 13 $result.configs.Count | Should -Be 7 $result.packages[0].id | Should -Be 'Git.Git' $result.packages.id | Should -Contain 'XnSoft.XnViewMP' $result.packages.id | Should -Contain 'Zoom.Zoom' $result.packages.id | Should -Contain 'Nextcloud.NextcloudDesktop' $result.packages.id | Should -Contain 'Notepad++.Notepad++' $result.packages.id | Should -Contain 'HandBrake.HandBrake' $result.packages.id | Should -Contain 'GIMP.GIMP' $result.packages.id | Should -Contain 'KDE.Krita' $result.packages.id | Should -Contain 'TheDocumentFoundation.LibreOffice' $result.packages.id | Should -Contain 'Waterfox.Waterfox' $result.packages.id | Should -Contain 'Meltytech.Shotcut' $result.packages.id | Should -Not -Contain 'clsid2.mpc-hc' $result.packages.id | Should -Not -Contain 'cpvalente.ontime' } It 'lets later profiles replace and disable earlier items' { $root = Join-Path $TestDrive 'repo' New-Item -ItemType Directory "$root/profiles", "$root/machines" | Out-Null '{"schemaVersion":1,"name":"one","packages":[{"id":"A.B","source":"winget","update":"latest"}],"configs":[]}' | Set-Content "$root/profiles/one.json" '{"schemaVersion":1,"name":"two","packages":[{"id":"A.B","source":"winget","enabled":false}],"configs":[]}' | Set-Content "$root/profiles/two.json" '{"schemaVersion":1,"name":"test","profiles":["one","two"],"packages":[],"configs":[]}' | Set-Content "$root/machines/test.json" (Resolve-MachineManifest -RepositoryRoot $root -Machine test).packages.Count | Should -Be 0 } It 'rejects duplicate JSON properties' { $path = Join-Path $TestDrive 'duplicate.json' '{"schemaVersion":1,"name":"test","name":"again","packages":[],"configs":[]}' | Set-Content $path { Read-ManifestFile -Path $path -Kind profile } | Should -Throw '*Duplicate JSON key*' } It 'rejects unknown fields' { $path = Join-Path $TestDrive 'unknown.json' '{"schemaVersion":1,"name":"test","surprise":true}' | Set-Content $path { Read-ManifestFile -Path $path -Kind profile } | Should -Throw '*Unknown field*' } }