Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ describe('FloatingPanes (live DOM)', () => {

const before = card()!.style.left
const toggle = card()!.querySelector('button')!
const chevron = () => toggle.querySelector('i')!

// Expanded: down chevron (fold). Collapsed: up chevron (restore).
expect(chevron().className).toContain('codicon-chevron-down')

// The button is inside the drag handle — [data-floating-no-drag] must
// stop it starting a drag.
Expand All @@ -182,6 +186,7 @@ describe('FloatingPanes (live DOM)', () => {

expect(document.querySelector('[data-testid="hud-body"]')).toBeNull()
expect(card()!.style.height).toBe('')
expect(chevron().className).toContain('codicon-chevron-up')
})

it('renders one card per floating contribution', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function FloatingPane({ pane }: { pane: Contribution }) {
onClick={toggleCollapsed}
type="button"
>
<Codicon name={collapsed ? 'chevron-down' : 'chevron-up'} size="0.75rem" />
<Codicon name={collapsed ? 'chevron-up' : 'chevron-down'} size="0.75rem" />
</button>
</header>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { act, type ReactNode } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, describe, expect, it, vi } from 'vitest'

import { registry } from '@/contrib/registry'

import type { GroupNode } from '../model'

import { TreeGroup } from './tree-group'

let root: null | Root = null
let container: HTMLDivElement | null = null
let disposePane: (() => void) | null = null

function render(ui: ReactNode) {
if (!container) {
container = globalThis.document.createElement('div')
globalThis.document.body.append(container)
root = createRoot(container)
}

act(() => {
root!.render(ui)
})
}

function terminalGroup(minimized: boolean): GroupNode {
return {
active: 'terminal',
headerHidden: false,
id: 'terminal-zone',
minimized,
panes: ['terminal'],
type: 'group'
}
}

const toggle = (label: string) =>
globalThis.document.querySelector<HTMLButtonElement>(
`[data-tree-group="terminal-zone"] button[aria-label="${label}"]`
)!

afterEach(() => {
if (root) {
act(() => root!.unmount())
}

container?.remove()
disposePane?.()
root = null
container = null
disposePane = null
vi.unstubAllGlobals()
})

describe('TreeGroup', () => {
it('points the docked-zone chevron in the collapse or restore action direction', () => {
disposePane = registry.register({
area: 'panes',
data: { height: '12rem' },
id: 'terminal',
render: () => <div>Terminal</div>,
title: 'Terminal'
})
// jsdom does not implement CSS.escape, which the real tab-strip effect uses.
vi.stubGlobal('CSS', { escape: (value: string) => value })

render(<TreeGroup node={terminalGroup(false)} parentAxis="column" />)

expect(toggle('Minimize').querySelector('i')!.className).toContain('codicon-chevron-down')

render(<TreeGroup node={terminalGroup(true)} parentAxis="column" />)

expect(toggle('Restore').querySelector('i')!.className).toContain('codicon-chevron-up')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export function TreeGroup({
onPointerDown={e => e.stopPropagation()}
type="button"
>
<Codicon name={node.minimized ? 'chevron-down' : 'chevron-up'} size="0.75rem" />
<Codicon name={node.minimized ? 'chevron-up' : 'chevron-down'} size="0.75rem" />
</button>
)}
<StripDropCaret groupId={node.id} stripRef={stripRef} />
Expand Down