chore: migrate tests from tests-ui/ to colocate with source files (#7811)

## Summary

Migrates all unit tests from `tests-ui/` to colocate with their source
files in `src/`, improving discoverability and maintainability.

## Changes

- **What**: Relocated all unit tests to be adjacent to the code they
test, following the `<source>.test.ts` naming convention
- **Config**: Updated `vitest.config.ts` to remove `tests-ui` include
pattern and `@tests-ui` alias
- **Docs**: Moved testing documentation to `docs/testing/` with updated
paths and patterns

## Review Focus

- Migration patterns documented in
`temp/plans/migrate-tests-ui-to-src.md`
- Tests use `@/` path aliases instead of relative imports
- Shared fixtures placed in `__fixtures__/` directories

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7811-chore-migrate-tests-from-tests-ui-to-colocate-with-source-files-2da6d73d36508147a4cce85365dee614)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Alexander Brown
2026-01-05 16:32:24 -08:00
committed by GitHub
parent 832588c7a9
commit 10feb1fd5b
272 changed files with 483 additions and 1239 deletions

View File

@@ -0,0 +1,166 @@
import { createPinia, setActivePinia } from 'pinia'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
import type { BottomPanelExtension } from '@/types/extensionTypes'
// Mock dependencies
vi.mock('@/composables/bottomPanelTabs/useShortcutsTab', () => ({
useShortcutsTab: () => [
{
id: 'shortcuts-essentials',
title: 'Essentials',
component: {},
type: 'vue',
targetPanel: 'shortcuts'
},
{
id: 'shortcuts-view-controls',
title: 'View Controls',
component: {},
type: 'vue',
targetPanel: 'shortcuts'
}
]
}))
vi.mock('@/composables/bottomPanelTabs/useTerminalTabs', () => ({
useLogsTerminalTab: () => ({
id: 'logs',
title: 'Logs',
component: {},
type: 'vue',
targetPanel: 'terminal'
}),
useCommandTerminalTab: () => ({
id: 'command',
title: 'Command',
component: {},
type: 'vue',
targetPanel: 'terminal'
})
}))
vi.mock('@/stores/commandStore', () => ({
useCommandStore: () => ({
registerCommand: vi.fn()
})
}))
vi.mock('@/utils/envUtil', () => ({
isElectron: () => false
}))
describe('useBottomPanelStore', () => {
beforeEach(() => {
setActivePinia(createPinia())
})
it('should initialize with empty panels', () => {
const store = useBottomPanelStore()
expect(store.activePanel).toBeNull()
expect(store.bottomPanelVisible).toBe(false)
expect(store.bottomPanelTabs).toEqual([])
expect(store.activeBottomPanelTab).toBeNull()
})
it('should register bottom panel tabs', () => {
const store = useBottomPanelStore()
const tab: BottomPanelExtension = {
id: 'test-tab',
title: 'Test Tab',
component: {},
type: 'vue',
targetPanel: 'terminal'
}
store.registerBottomPanelTab(tab)
expect(store.panels.terminal.tabs.find((t) => t.id === 'test-tab')).toEqual(
tab
)
expect(store.panels.terminal.activeTabId).toBe('test-tab')
})
it('should toggle panel visibility', () => {
const store = useBottomPanelStore()
const tab: BottomPanelExtension = {
id: 'test-tab',
title: 'Test Tab',
component: {},
type: 'vue',
targetPanel: 'shortcuts'
}
store.registerBottomPanelTab(tab)
// Panel should be hidden initially
expect(store.activePanel).toBeNull()
// Toggle should show panel
store.togglePanel('shortcuts')
expect(store.activePanel).toBe('shortcuts')
expect(store.bottomPanelVisible).toBe(true)
// Toggle again should hide panel
store.togglePanel('shortcuts')
expect(store.activePanel).toBeNull()
expect(store.bottomPanelVisible).toBe(false)
})
it('should switch between panel types', () => {
const store = useBottomPanelStore()
const terminalTab: BottomPanelExtension = {
id: 'terminal-tab',
title: 'Terminal',
component: {},
type: 'vue',
targetPanel: 'terminal'
}
const shortcutsTab: BottomPanelExtension = {
id: 'shortcuts-tab',
title: 'Shortcuts',
component: {},
type: 'vue',
targetPanel: 'shortcuts'
}
store.registerBottomPanelTab(terminalTab)
store.registerBottomPanelTab(shortcutsTab)
// Show terminal panel
store.togglePanel('terminal')
expect(store.activePanel).toBe('terminal')
expect(store.activeBottomPanelTab?.id).toBe('terminal-tab')
// Switch to shortcuts panel
store.togglePanel('shortcuts')
expect(store.activePanel).toBe('shortcuts')
expect(store.activeBottomPanelTab?.id).toBe('shortcuts-tab')
})
it('should toggle specific tabs', () => {
const store = useBottomPanelStore()
const tab: BottomPanelExtension = {
id: 'specific-tab',
title: 'Specific Tab',
component: {},
type: 'vue',
targetPanel: 'shortcuts'
}
store.registerBottomPanelTab(tab)
// Toggle specific tab should show it
store.toggleBottomPanelTab('specific-tab')
expect(store.activePanel).toBe('shortcuts')
expect(store.panels.shortcuts.activeTabId).toBe('specific-tab')
// Toggle same tab again should hide panel
store.toggleBottomPanelTab('specific-tab')
expect(store.activePanel).toBeNull()
})
})