import assert from 'node:assert/strict' import { promises as fs } from 'node:fs' import { resolve } from 'node:path' import { computeNotificationsPanelPosition } from '../src/renderer/src/components/NotificationsPanel' import { computeProjectMenuPosition } from '../src/renderer/src/projects/ProjectMenu' async function main(): Promise { const notificationPosition = computeNotificationsPanelPosition( { left: 240, right: 272, top: 854, bottom: 886 }, { width: 300, height: 380 }, { width: 1336, height: 902 } ) assert.deepEqual(notificationPosition, { left: 8, top: 466 }) const rightEdgePosition = computeNotificationsPanelPosition( { left: 1200, right: 1232, top: 600, bottom: 632 }, { width: 300, height: 280 }, { width: 1280, height: 720 } ) assert.deepEqual(rightEdgePosition, { left: 932, top: 312 }) const shortViewportPosition = computeNotificationsPanelPosition( { left: 120, right: 152, top: 690, bottom: 720 }, { width: 300, height: 380 }, { width: 360, height: 720 } ) assert.equal(shortViewportPosition.left, 8) assert.equal(shortViewportPosition.top, 302) const sourceProjectMenuPosition = computeProjectMenuPosition( { left: 100, right: 271, top: 266 }, { width: 162, height: 64 }, { width: 1336, height: 902 } ) assert.deepEqual(sourceProjectMenuPosition, { left: 275, top: 258 }) const narrowProjectMenuPosition = computeProjectMenuPosition( { left: 20, right: 200, top: 80 }, { width: 162, height: 64 }, { width: 320, height: 240 } ) assert.equal(narrowProjectMenuPosition.left, 4) assert.equal(narrowProjectMenuPosition.top, 72) const sidebar = await fs.readFile( resolve('src/renderer/src/components/Sidebar.tsx'), 'utf8' ) assert.match(sidebar, /onContextMenu=\{\(event\) => \{[\s\S]*?openTaskMenu\(session, event\.currentTarget, \{ left: event\.clientX, top: event\.clientY \}\)/) assert.match(sidebar, /event\.key === 'ContextMenu' \|\| \(event\.shiftKey && event\.key === 'F10'\)/) assert.match(sidebar, /aria-haspopup="dialog"/) assert.match(sidebar, / { console.error(error) process.exitCode = 1 })