Finder-launched terminals now inherit a login PATH so tools like ollama resolve, destructive SFTP/editor actions require confirmation, and terminal search plus window dragging work again. SSH forwards and RDP sessions keep listeners and survive reconnect without FastPath crashes. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { fitContextMenuToViewport } from '../../../src/components/sftp/contextMenuPosition'
|
|
|
|
describe('fitContextMenuToViewport', () => {
|
|
it('keeps the menu below/right of the click when there is room', () => {
|
|
expect(fitContextMenuToViewport(100, 80, 180, 200, 1000, 800)).toEqual({
|
|
left: 100,
|
|
top: 80,
|
|
})
|
|
})
|
|
|
|
it('flips above the click when near the bottom edge', () => {
|
|
// Click near bottom; menu taller than remaining space → open upward.
|
|
expect(fitContextMenuToViewport(200, 540, 180, 280, 1000, 600)).toEqual({
|
|
left: 200,
|
|
top: 260, // 540 - 280
|
|
})
|
|
})
|
|
|
|
it('clamps into the viewport when flipped menu would still overflow', () => {
|
|
expect(fitContextMenuToViewport(900, 540, 360, 400, 997, 592)).toEqual({
|
|
left: 540, // 900 - 360 (flip left of click)
|
|
top: 140, // 540 - 400 (flip above click), still within [8, 184]
|
|
})
|
|
})
|
|
|
|
it('keeps an oversized menu inside the top-left margin', () => {
|
|
expect(fitContextMenuToViewport(20, 20, 400, 600, 320, 480)).toEqual({
|
|
left: 8,
|
|
top: 8,
|
|
})
|
|
})
|
|
|
|
it('flips left of the click when near the right edge', () => {
|
|
expect(fitContextMenuToViewport(920, 100, 200, 120, 1000, 800)).toEqual({
|
|
left: 720, // 920 - 200
|
|
top: 100,
|
|
})
|
|
})
|
|
})
|