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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.3.2] 2025-05-31

### Added

- Added tests for different private commands.

### Fixed

- Fixed for loop used to scroll which was using wrong variable.

## [0.3.1] 2025-05-30

### Added

- Add VIM (i.e. `hjkl`) navigation support.

Check warning on line 22 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / ci / Run Linters

Unknown word (hjkl) Suggestions: (hulk, hail, hake, haku, hall)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion PesterExplorer/PesterExplorer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PesterExplorer.psm1'

# Version number of this module.
ModuleVersion = '0.3.1'
ModuleVersion = '0.3.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
9 changes: 4 additions & 5 deletions PesterExplorer/Private/Get-PreviewPanel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function Get-PreviewPanel {
Get-SpectreEscapedText |
Format-SpectrePanel @formatSpectrePanelSplat
} else {
Write-Debug "Selected item is a Pester object: $($object.Name)"
Write-Debug "Selected item '$($object.Name)'is a Pester object: $($object.GetType().Name)"
$data = Format-PesterTreeHash -Object $object
Write-Debug $($data|ConvertTo-Json -Depth 10)
$formatSpectrePanelSplat = @{
Expand All @@ -151,7 +151,6 @@ function Get-PreviewPanel {
$results += $object.StandardOutput |
Get-SpectreEscapedText |
Format-SpectrePanel @formatSpectrePanelSplat

}

# Print errors if they exist.
Expand Down Expand Up @@ -200,21 +199,21 @@ function Get-PreviewPanel {
# If the scroll position is not zero, add a "back" item
$reducedList += "[grey]...[/]"
}
for ($i = $scrollPosition; $i -le $array.Count; $i++) {
for ($i = $scrollPosition; $i -lt $results.Count; $i++) {
$itemHeight = Get-SpectreRenderableSize $results[$i]
$totalHeight += $itemHeight.Height
if ($totalHeight -gt $PreviewHeight) {
if($i -eq $scrollPosition) {
# If the first item already exceeds the height, stop here
Write-Debug "First item exceeds preview height. Stopping."
Write-Debug "First item exceeds preview height. Stopping. Total Height: $totalHeight, Preview Height: $PreviewHeight"
$reducedList += ":police_car_light:The next item is too large to display! Please resize your terminal.:police_car_light:" |
Format-SpectreAligned -HorizontalAlignment Center -VerticalAlignment Middle |
Format-SpectrePanel -Header ":police_car_light: [red]Warning[/]" -Color 'red' -Border Double
break
}
# If the total height exceeds the preview height, stop adding items
Write-Debug "Total height exceeded preview height. Stopping at item $i."
$reducedList += "[blue]...more.[/] [grey]Switch to Panel and scroll with keys.[/]"
$reducedList += "[blue]...more. Switch to Panel and scroll with keys.[/]"
break
}
$reducedList += $results[$i]
Expand Down
18 changes: 9 additions & 9 deletions tests/Get-PreviewPanel.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Describe 'Get-PreviewPanel' {
BeforeAll {
. (Join-Path $PSScriptRoot 'Helpers.ps1')
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest

Check warning on line 4 in tests/Get-PreviewPanel.tests.ps1

View workflow job for this annotation

GitHub Actions / ci / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
Expand All @@ -14,7 +14,7 @@

InModuleScope $env:BHProjectName {
$script:ContainerWidth = 80
$script:ContainerHeight = 100
$script:ContainerHeight = 200
$size = [Spectre.Console.Size]::new($containerWidth, $containerHeight)
$script:renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
Expand Down Expand Up @@ -77,15 +77,17 @@
It 'should print warning when the screen is too small' {
InModuleScope $env:BHProjectName {
$Items = Get-ListFromObject -Object $script:run.Containers[0].Blocks[0].Order[0]
$size = [Spectre.Console.Size]::new(80, 10)
$height = 5
$size = [Spectre.Console.Size]::new(80, $height)
$renderOptions = [Spectre.Console.Rendering.RenderOptions]::new(
[Spectre.Console.AnsiConsole]::Console.Profile.Capabilities,
$size
)
$getPreviewPanelSplat = @{
Items = $Items
SelectedItem = 'Test1'
PreviewHeight = 5
ScrollPosition = 1
PreviewHeight = $height
PreviewWidth = $script:ContainerWidth
}
$panel = Get-PreviewPanel @getPreviewPanelSplat
Expand All @@ -100,14 +102,12 @@
$getPreviewPanelSplat = @{
Items = $Items
SelectedItem = 'Test1'
PreviewHeight = 100
PreviewWidth = 100
PreviewHeight = $script:ContainerHeight
PreviewWidth = $script:ContainerWidth
}
Mock -CommandName 'Get-SpectreEscapedText' -Verifiable
$panel = Get-PreviewPanel @getPreviewPanelSplat
#global:Get-RenderedText -panel $panel -renderOptions $renderOptions -containerWidth 100 |
# Should -BeLike 'Passed'
Should -Invoke Get-SpectreEscapedText -Exactly 1 -Scope It
global:Get-RenderedText -panel $panel -renderOptions $script:renderOptions -containerWidth $script:ContainerWidth |
Should -BeLike '*$true | Should -Be $true*'
}
}
}
Loading