Address Copilot fixes thrid

This commit is contained in:
Justin Chung
2026-05-28 10:10:27 -05:00
parent 5252a123b4
commit a8d65d320d
4 changed files with 53 additions and 5 deletions
@@ -10,11 +10,26 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
$systemConfigPath = (Get-PowerShellConfiguration -Scope AllUsers).Path
$userConfigPath = (Get-PowerShellConfiguration -Scope CurrentUser).Path
# The legacy $PSHOME config may exist (e.g., preview builds).
# Back it up so tests start clean. Also track it separately because
# writes go to the new platform location, not the legacy path.
$legacyConfigPath = Join-Path $PSHOME "powershell.config.json"
$legacyConfigExists = $false
if (($legacyConfigPath -ne $systemConfigPath) -and (Test-Path $legacyConfigPath)) {
$legacyConfigExists = $true
Move-Item $legacyConfigPath "$legacyConfigPath.backup" -Force -ErrorAction SilentlyContinue
}
$systemConfigDir = Split-Path $systemConfigPath
if (!(Test-Path $systemConfigDir)) {
$null = New-Item -ItemType Directory -Path $systemConfigDir -Force -ErrorAction SilentlyContinue
}
$userConfigDir = Split-Path $userConfigPath
if (!(Test-Path $userConfigDir)) {
$null = New-Item -ItemType Directory -Path $userConfigDir -Force -ErrorAction SilentlyContinue
}
$systemConfigExists = $false
if (Test-Path $systemConfigPath) {
$systemConfigExists = $true
@@ -33,6 +48,10 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
}
AfterAll {
if ($legacyConfigExists) {
Move-Item "$legacyConfigPath.backup" $legacyConfigPath -Force -ErrorAction SilentlyContinue
}
if ($systemConfigExists) {
Move-Item "$systemConfigPath.backup" $systemConfigPath -Force -ErrorAction SilentlyContinue
}
@@ -47,6 +66,9 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
AfterEach {
Remove-Item $systemConfigPath -Force -ErrorAction SilentlyContinue
Remove-Item $userConfigPath -Force -ErrorAction SilentlyContinue
if ($legacyConfigPath -ne $systemConfigPath) {
Remove-Item $legacyConfigPath -Force -ErrorAction SilentlyContinue
}
}
It "Enable-ExperimentalFeature will enable Experimental Feature for scope: <scope>" -TestCases @(
@@ -10,11 +10,23 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
$systemConfigPath = (Get-PowerShellConfiguration -Scope AllUsers).Path
$userConfigPath = (Get-PowerShellConfiguration -Scope CurrentUser).Path
$legacyConfigPath = Join-Path $PSHOME "powershell.config.json"
$legacyConfigExists = $false
if (($legacyConfigPath -ne $systemConfigPath) -and (Test-Path $legacyConfigPath)) {
$legacyConfigExists = $true
Move-Item $legacyConfigPath "$legacyConfigPath.backup" -Force -ErrorAction SilentlyContinue
}
$systemConfigDir = Split-Path $systemConfigPath
if (!(Test-Path $systemConfigDir)) {
$null = New-Item -ItemType Directory -Path $systemConfigDir -Force -ErrorAction SilentlyContinue
}
$userConfigDir = Split-Path $userConfigPath
if (!(Test-Path $userConfigDir)) {
$null = New-Item -ItemType Directory -Path $userConfigDir -Force -ErrorAction SilentlyContinue
}
$systemConfigExists = $false
if (Test-Path $systemConfigPath) {
$systemConfigExists = $true
@@ -34,6 +46,10 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
}
AfterAll {
if ($legacyConfigExists) {
Move-Item "$legacyConfigPath.backup" $legacyConfigPath -Force -ErrorAction SilentlyContinue
}
if ($systemConfigExists -and (Test-CanWriteToSystemConfigDir)) {
Move-Item "$systemConfigPath.backup" $systemConfigPath -Force -ErrorAction SilentlyContinue
}
@@ -51,6 +67,9 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows"
}
Remove-Item $userConfigPath -Force -ErrorAction SilentlyContinue
if ($legacyConfigPath -ne $systemConfigPath) {
Remove-Item $legacyConfigPath -Force -ErrorAction SilentlyContinue
}
}
Context "Feature disabled tests" {
@@ -6,8 +6,9 @@ Describe "Get-PowerShellConfiguration Tests" -Tags "CI" {
It "Returns both scopes when no -Scope is specified" {
$configs = Get-PowerShellConfiguration
$configs | Should -HaveCount 2
$configs[0].Scope | Should -Be "AllUsers"
$configs[1].Scope | Should -Be "CurrentUser"
$scopes = $configs.Scope
$scopes | Should -Contain "AllUsers"
$scopes | Should -Contain "CurrentUser"
}
It "Returns AllUsers scope when -Scope AllUsers is specified" {