feat: release OpsXShell 2.1.0 native Tauri edition
This commit is contained in:
1 parent
e9a0d21758
commit
a3dba0c6ed
311 files changed
+31748
-14897
No files matched your search
@@ -0,0 +1,91 @@
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import App from '../../src/app/App'
|
||||
import { useSessionStore } from '../../src/stores/sessionStore'
|
||||
import { mockDesktopApi } from '../setup'
|
||||
|
||||
describe('App foundation acceptance', () => {
|
||||
afterEach(() => {
|
||||
window.opsxApi = mockDesktopApi
|
||||
})
|
||||
|
||||
it('renders the application shell with the native desktop contract', async () => {
|
||||
render(<App />)
|
||||
|
||||
expect(await screen.findByRole('heading', { name: 'OpsXShell' })).toBeVisible()
|
||||
expect(mockDesktopApi.onMenuOpenSettings).toHaveBeenCalled()
|
||||
|
||||
const title = screen.getByText('OpsXShell', { selector: 'span' })
|
||||
expect(title.closest('header')).toHaveAttribute('data-tauri-drag-region')
|
||||
})
|
||||
|
||||
it('renders the shell while the native bridge is unavailable', async () => {
|
||||
Object.defineProperty(window, 'opsxApi', {
|
||||
configurable: true,
|
||||
value: undefined,
|
||||
writable: true,
|
||||
})
|
||||
|
||||
render(<App />)
|
||||
|
||||
expect(await screen.findByRole('heading', { name: 'OpsXShell' })).toBeVisible()
|
||||
})
|
||||
|
||||
it('opens quick connect with a queued ssh:// target', async () => {
|
||||
vi.clearAllMocks()
|
||||
window.opsxApi = mockDesktopApi
|
||||
vi.mocked(mockDesktopApi.takePendingSshLinks).mockResolvedValueOnce([
|
||||
{ host: 'opsbase.cn', port: 55555, username: 'root' },
|
||||
])
|
||||
|
||||
render(<App />)
|
||||
|
||||
expect(await screen.findByDisplayValue('root@opsbase.cn:55555')).toBeVisible()
|
||||
expect(mockDesktopApi.onSshLinkAvailable).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('delegates title-bar double click to a single native drag-region handler', async () => {
|
||||
vi.clearAllMocks()
|
||||
window.opsxApi = mockDesktopApi
|
||||
render(<App />)
|
||||
|
||||
const title = await screen.findByText('OpsXShell', { selector: 'span' })
|
||||
const titleBar = title.closest('header')
|
||||
expect(titleBar).toHaveAttribute('data-tauri-drag-region')
|
||||
expect(titleBar).not.toHaveClass('titlebar-drag')
|
||||
|
||||
fireEvent.doubleClick(titleBar!)
|
||||
expect(mockDesktopApi.toggleMaximize).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('writes exported sessions to the selected JSON file', async () => {
|
||||
vi.clearAllMocks()
|
||||
window.opsxApi = mockDesktopApi
|
||||
useSessionStore.setState({
|
||||
sessions: [
|
||||
{
|
||||
id: 'session-1',
|
||||
name: 'Production',
|
||||
host: 'prod.example.com',
|
||||
port: 22,
|
||||
username: 'root',
|
||||
authType: 'agent',
|
||||
},
|
||||
],
|
||||
})
|
||||
vi.mocked(mockDesktopApi.showSaveDialog).mockResolvedValueOnce({
|
||||
canceled: false,
|
||||
filePath: '/tmp/opsxshell-sessions.json',
|
||||
})
|
||||
render(<App />)
|
||||
|
||||
await waitFor(() => expect(mockDesktopApi.onMenuExportSessions).toHaveBeenCalled())
|
||||
const callback = vi.mocked(mockDesktopApi.onMenuExportSessions).mock.calls[0][0]
|
||||
await callback()
|
||||
|
||||
expect(mockDesktopApi.writeFile).toHaveBeenCalledWith(
|
||||
'/tmp/opsxshell-sessions.json',
|
||||
expect.stringContaining('"prod.example.com"')
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user