Compare commits
5 commits
e9d481a699
...
326994d101
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
326994d101 | ||
|
|
8f5e0f6bd8 | ||
|
|
e014c58709 | ||
|
|
d64f5105f4 | ||
|
|
24fd8ca72d |
9 changed files with 640 additions and 1061 deletions
339
web/frontend/src/__tests__/completed-tasks-banner.test.ts
Normal file
339
web/frontend/src/__tests__/completed-tasks-banner.test.ts
Normal file
|
|
@ -0,0 +1,339 @@
|
||||||
|
/**
|
||||||
|
* KIN-125: Уведомления о завершённых задачах в EscalationBanner
|
||||||
|
*
|
||||||
|
* AC1: Завершённые задачи отображаются в панели уведомлений рядом с эскалациями
|
||||||
|
* AC2: Кнопка Done скрывает задачу из списка
|
||||||
|
* AC3: Кнопка Revise отправляет задачу на доработку (смена статуса)
|
||||||
|
* AC4: Клик по полю задачи выполняет навигацию к детальному виду задачи
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||||
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
|
import EscalationBanner from '../components/EscalationBanner.vue'
|
||||||
|
|
||||||
|
const mockPush = vi.fn()
|
||||||
|
vi.mock('vue-router', () => ({
|
||||||
|
useRouter: () => ({ push: mockPush }),
|
||||||
|
}))
|
||||||
|
|
||||||
|
vi.mock('../api', () => ({
|
||||||
|
api: {
|
||||||
|
notifications: vi.fn(),
|
||||||
|
projects: vi.fn(),
|
||||||
|
project: vi.fn(),
|
||||||
|
reviseTask: vi.fn(),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
import { api } from '../api'
|
||||||
|
|
||||||
|
const localStorageMock = (() => {
|
||||||
|
let store: Record<string, string> = {}
|
||||||
|
return {
|
||||||
|
getItem: (k: string) => store[k] ?? null,
|
||||||
|
setItem: (k: string, v: string) => { store[k] = v },
|
||||||
|
removeItem: (k: string) => { delete store[k] },
|
||||||
|
clear: () => { store = {} },
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
Object.defineProperty(globalThis, 'localStorage', { value: localStorageMock, configurable: true })
|
||||||
|
|
||||||
|
function makeProject(id = 'proj-1', name = 'MyProject', doneCount = 1) {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
path: '/projects/test',
|
||||||
|
status: 'active',
|
||||||
|
priority: 1,
|
||||||
|
tech_stack: ['python'],
|
||||||
|
execution_mode: null,
|
||||||
|
autocommit_enabled: null,
|
||||||
|
auto_test_enabled: null,
|
||||||
|
worktrees_enabled: null,
|
||||||
|
obsidian_vault_path: null,
|
||||||
|
deploy_command: null,
|
||||||
|
test_command: null,
|
||||||
|
deploy_host: null,
|
||||||
|
deploy_path: null,
|
||||||
|
deploy_runtime: null,
|
||||||
|
deploy_restart_cmd: null,
|
||||||
|
created_at: '2024-01-01',
|
||||||
|
total_tasks: doneCount,
|
||||||
|
done_tasks: doneCount,
|
||||||
|
active_tasks: 0,
|
||||||
|
blocked_tasks: 0,
|
||||||
|
review_tasks: 0,
|
||||||
|
project_type: null,
|
||||||
|
ssh_host: null,
|
||||||
|
ssh_user: null,
|
||||||
|
ssh_key_path: null,
|
||||||
|
ssh_proxy_jump: null,
|
||||||
|
description: null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeCompletedTask(id = 'TSK-1', title = 'Test task') {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
project_id: 'proj-1',
|
||||||
|
title,
|
||||||
|
status: 'completed',
|
||||||
|
priority: 1,
|
||||||
|
assigned_role: null,
|
||||||
|
parent_task_id: null,
|
||||||
|
brief: null,
|
||||||
|
spec: null,
|
||||||
|
execution_mode: null,
|
||||||
|
blocked_reason: null,
|
||||||
|
dangerously_skipped: null,
|
||||||
|
category: null,
|
||||||
|
acceptance_criteria: null,
|
||||||
|
created_at: '2024-01-01T10:00:00',
|
||||||
|
updated_at: '2024-03-18T10:00:00',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeProjectDetail(
|
||||||
|
project: ReturnType<typeof makeProject>,
|
||||||
|
tasks: ReturnType<typeof makeCompletedTask>[],
|
||||||
|
) {
|
||||||
|
return { ...project, tasks, modules: [], decisions: [] }
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
localStorageMock.clear()
|
||||||
|
vi.clearAllMocks()
|
||||||
|
mockPush.mockClear()
|
||||||
|
vi.useFakeTimers()
|
||||||
|
vi.mocked(api.notifications).mockResolvedValue([])
|
||||||
|
vi.mocked(api.projects).mockResolvedValue([])
|
||||||
|
vi.mocked(api.project).mockResolvedValue(makeProjectDetail(makeProject(), []))
|
||||||
|
vi.mocked(api.reviseTask).mockResolvedValue({ status: 'ok', comment: '' })
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers()
|
||||||
|
vi.restoreAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
async function mountWithCompleted(
|
||||||
|
tasks = [makeCompletedTask()],
|
||||||
|
projectName = 'MyProject',
|
||||||
|
) {
|
||||||
|
const project = makeProject('proj-1', projectName)
|
||||||
|
vi.mocked(api.projects).mockResolvedValue([project])
|
||||||
|
vi.mocked(api.project).mockResolvedValue(makeProjectDetail(project, tasks))
|
||||||
|
const wrapper = mount(EscalationBanner)
|
||||||
|
await flushPromises()
|
||||||
|
return wrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openPanel(wrapper: ReturnType<typeof mount>) {
|
||||||
|
// Click the green completed-tasks badge to open the panel
|
||||||
|
const completedBadge = wrapper.findAll('button').find(b =>
|
||||||
|
b.text().includes('Completed'),
|
||||||
|
)
|
||||||
|
if (completedBadge) {
|
||||||
|
await completedBadge.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// AC1: Завершённые задачи отображаются в панели уведомлений
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
describe('KIN-125 AC1: завершённые задачи отображаются в панели', () => {
|
||||||
|
it('Зелёный бейдж "Completed" появляется при наличии завершённых задач', async () => {
|
||||||
|
const wrapper = await mountWithCompleted()
|
||||||
|
const badge = wrapper.findAll('button').find(b => b.text().includes('Completed'))
|
||||||
|
expect(badge).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Бейдж показывает корректное количество завершённых задач', async () => {
|
||||||
|
const tasks = [makeCompletedTask('TSK-1'), makeCompletedTask('TSK-2')]
|
||||||
|
const wrapper = await mountWithCompleted(tasks)
|
||||||
|
const badge = wrapper.findAll('button').find(b => b.text().includes('Completed'))
|
||||||
|
expect(badge!.text()).toContain('2')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Бейдж не отображается когда нет завершённых задач', async () => {
|
||||||
|
vi.mocked(api.projects).mockResolvedValue([makeProject('proj-1', 'P', 0)])
|
||||||
|
const wrapper = mount(EscalationBanner)
|
||||||
|
await flushPromises()
|
||||||
|
const badge = wrapper.findAll('button').find(b => b.text().includes('Completed'))
|
||||||
|
expect(badge).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Секция завершённых задач отображается при открытии панели', async () => {
|
||||||
|
const wrapper = await mountWithCompleted()
|
||||||
|
await openPanel(wrapper)
|
||||||
|
expect(wrapper.text()).toContain('Completed tasks')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Заголовок завершённой задачи виден в открытой панели', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-1', 'Deploy to production')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
expect(wrapper.text()).toContain('Deploy to production')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// AC2: Кнопка Done скрывает задачу из списка
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
describe('KIN-125 AC2: кнопка Done скрывает задачу из списка', () => {
|
||||||
|
it('Нажатие Done убирает задачу из панели', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-10', 'Task to dismiss')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
expect(wrapper.text()).toContain('Task to dismiss')
|
||||||
|
|
||||||
|
const doneBtn = wrapper.findAll('button').find(b => b.text() === 'Done')
|
||||||
|
expect(doneBtn).toBeTruthy()
|
||||||
|
await doneBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.text()).not.toContain('Task to dismiss')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('После Done task_id сохраняется в localStorage под ключом kin_dismissed_completed', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-11')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const doneBtn = wrapper.findAll('button').find(b => b.text() === 'Done')
|
||||||
|
await doneBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
const stored = localStorageMock.getItem('kin_dismissed_completed')
|
||||||
|
expect(stored).toBeTruthy()
|
||||||
|
expect(JSON.parse(stored!)).toContain('TSK-11')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Dismissed задача не появляется снова при следующем поллинге (30с)', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-12', 'Reappear task')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const doneBtn = wrapper.findAll('button').find(b => b.text() === 'Done')
|
||||||
|
await doneBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
vi.advanceTimersByTime(30000)
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.text()).not.toContain('Reappear task')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// AC3: Кнопка Revise отправляет задачу на доработку
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
describe('KIN-125 AC3: кнопка Revise отправляет задачу на доработку', () => {
|
||||||
|
it('Нажатие Revise показывает inline форму с полем ввода комментария', async () => {
|
||||||
|
const wrapper = await mountWithCompleted()
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const reviseBtn = wrapper.findAll('button').find(b => b.text() === 'Revise')
|
||||||
|
expect(reviseBtn).toBeTruthy()
|
||||||
|
await reviseBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.find('input[type="text"]').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Нажатие Send вызывает api.reviseTask с task_id и введённым комментарием', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-20')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const reviseBtn = wrapper.findAll('button').find(b => b.text() === 'Revise')
|
||||||
|
await reviseBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
await wrapper.find('input[type="text"]').setValue('Add deployment logs')
|
||||||
|
const sendBtn = wrapper.findAll('button').find(b => b.text() === 'Send')
|
||||||
|
await sendBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(vi.mocked(api.reviseTask)).toHaveBeenCalledWith('TSK-20', 'Add deployment logs')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('После успешного Revise задача скрывается из списка', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-21', 'Revise me')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
expect(wrapper.text()).toContain('Revise me')
|
||||||
|
|
||||||
|
const reviseBtn = wrapper.findAll('button').find(b => b.text() === 'Revise')
|
||||||
|
await reviseBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
const sendBtn = wrapper.findAll('button').find(b => b.text() === 'Send')
|
||||||
|
await sendBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.text()).not.toContain('Revise me')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('При пустом комментарии используется дефолтный текст (не пустая строка)', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-22')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const reviseBtn = wrapper.findAll('button').find(b => b.text() === 'Revise')
|
||||||
|
await reviseBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
// Send without entering a comment
|
||||||
|
const sendBtn = wrapper.findAll('button').find(b => b.text() === 'Send')
|
||||||
|
await sendBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(vi.mocked(api.reviseTask)).toHaveBeenCalledWith('TSK-22', expect.stringMatching(/.+/))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Нажатие Cancel скрывает форму без вызова api.reviseTask', async () => {
|
||||||
|
const wrapper = await mountWithCompleted()
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const reviseBtn = wrapper.findAll('button').find(b => b.text() === 'Revise')
|
||||||
|
await reviseBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.find('input[type="text"]').exists()).toBe(true)
|
||||||
|
|
||||||
|
const cancelBtn = wrapper.findAll('button').find(b => b.text() === 'Cancel')
|
||||||
|
await cancelBtn!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.find('input[type="text"]').exists()).toBe(false)
|
||||||
|
expect(vi.mocked(api.reviseTask)).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// AC4: Клик по полю задачи выполняет навигацию к детальному виду
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
describe('KIN-125 AC4: клик по задаче переходит к детальному виду', () => {
|
||||||
|
it('Клик по строке задачи вызывает router.push("/task/{id}")', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-30')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
|
||||||
|
const taskRow = wrapper.find('.cursor-pointer')
|
||||||
|
expect(taskRow.exists()).toBe(true)
|
||||||
|
await taskRow.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(mockPush).toHaveBeenCalledWith('/task/TSK-30')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('После клика по задаче панель закрывается', async () => {
|
||||||
|
const wrapper = await mountWithCompleted([makeCompletedTask('TSK-31')])
|
||||||
|
await openPanel(wrapper)
|
||||||
|
expect(wrapper.text()).toContain('Completed tasks')
|
||||||
|
|
||||||
|
const taskRow = wrapper.find('.cursor-pointer')
|
||||||
|
await taskRow.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.text()).not.toContain('Completed tasks')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -1,190 +1,37 @@
|
||||||
/**
|
/**
|
||||||
* KIN-INFRA-012: Регрессионный тест — saveDeployConfig не теряет пустые строки
|
* KIN-INFRA-012 / KIN-UI-012: Регрессия — формы deploy из SettingsView удалены
|
||||||
*
|
*
|
||||||
* Проверяет, что пустая строка в deploy-полях:
|
* saveDeployConfig и связанные deploy-поля перенесены в ProjectView → Settings tab.
|
||||||
* 1. Передаётся в patchProject как "" (не undefined)
|
* SettingsView теперь только навигатор.
|
||||||
* 2. Переживает JSON.stringify — т.е. бэкенд получает ключ со значением ""
|
|
||||||
* 3. Непустые значения тоже передаются корректно
|
|
||||||
*
|
*
|
||||||
* До фикса: `deploy_host: deployHosts.value[id] || undefined` → пустая строка
|
* Проверяет, что в SettingsView.vue отсутствуют удалённые формы.
|
||||||
* превращалась в undefined и JSON.stringify отбрасывал поле. Бэкенд не получал
|
|
||||||
* сигнал очистки. После фикса: пустая строка передаётся как-есть.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
import { describe, it, expect } from 'vitest'
|
||||||
import { mount, flushPromises } from '@vue/test-utils'
|
import { readFileSync } from 'fs'
|
||||||
import SettingsView from '../views/SettingsView.vue'
|
import { resolve } from 'path'
|
||||||
|
|
||||||
vi.mock('../api', async (importOriginal) => {
|
describe('SettingsView.vue — формы deploy удалены (KIN-UI-012)', () => {
|
||||||
const actual = await importOriginal<typeof import('../api')>()
|
const filePath = resolve(__dirname, '../views/SettingsView.vue')
|
||||||
return {
|
const content = readFileSync(filePath, 'utf-8')
|
||||||
...actual,
|
|
||||||
api: {
|
it('не содержит saveDeployConfig (форма перенесена в ProjectView)', () => {
|
||||||
projects: vi.fn(),
|
expect(content).not.toContain('saveDeployConfig')
|
||||||
patchProject: vi.fn(),
|
|
||||||
syncObsidian: vi.fn(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
import { api } from '../api'
|
it('не содержит deployHosts (реактивный ref удалён)', () => {
|
||||||
|
expect(content).not.toContain('deployHosts')
|
||||||
const BASE_PROJECT = {
|
|
||||||
id: 'KIN',
|
|
||||||
name: 'Kin',
|
|
||||||
path: '/projects/kin',
|
|
||||||
status: 'active',
|
|
||||||
priority: 5,
|
|
||||||
tech_stack: ['python'],
|
|
||||||
execution_mode: null,
|
|
||||||
autocommit_enabled: null,
|
|
||||||
auto_test_enabled: null,
|
|
||||||
obsidian_vault_path: null,
|
|
||||||
deploy_command: null as string | null,
|
|
||||||
test_command: null as string | null,
|
|
||||||
deploy_host: null as string | null,
|
|
||||||
deploy_path: null as string | null,
|
|
||||||
deploy_runtime: null as string | null,
|
|
||||||
deploy_restart_cmd: null as string | null,
|
|
||||||
created_at: '2024-01-01',
|
|
||||||
total_tasks: 0,
|
|
||||||
done_tasks: 0,
|
|
||||||
active_tasks: 0,
|
|
||||||
blocked_tasks: 0,
|
|
||||||
review_tasks: 0,
|
|
||||||
project_type: null,
|
|
||||||
ssh_host: null,
|
|
||||||
ssh_user: null,
|
|
||||||
ssh_key_path: null,
|
|
||||||
ssh_proxy_jump: null,
|
|
||||||
description: null,
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
vi.clearAllMocks()
|
|
||||||
vi.mocked(api.patchProject).mockResolvedValue(BASE_PROJECT as any)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
async function mountSettingsWithProject(overrides: Partial<typeof BASE_PROJECT> = {}) {
|
it('не содержит deploy_host input поле', () => {
|
||||||
const project = { ...BASE_PROJECT, ...overrides }
|
expect(content).not.toContain('server host (e.g. vdp-prod)')
|
||||||
vi.mocked(api.projects).mockResolvedValue([project as any])
|
|
||||||
const wrapper = mount(SettingsView)
|
|
||||||
await flushPromises()
|
|
||||||
return wrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
async function clickSaveDeployConfig(wrapper: ReturnType<typeof mount>) {
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text().includes('Save Deploy Config'))
|
|
||||||
expect(saveBtn).toBeDefined()
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 1. Пустая строка передаётся как "" — не теряется как undefined
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('saveDeployConfig — пустые строки сохраняются в payload', () => {
|
|
||||||
it('deploy_host="" передаётся как "" когда поле пустое (не undefined)', async () => {
|
|
||||||
// null в проекте → инициализируется как '' в компоненте → должно передаться как ""
|
|
||||||
const wrapper = await mountSettingsWithProject({ deploy_host: null })
|
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_host')
|
|
||||||
expect((callArgs[1] as any).deploy_host).toBe('')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deploy_path="" передаётся как "" когда поле пустое (не undefined)', async () => {
|
it('не содержит test_command input поле', () => {
|
||||||
const wrapper = await mountSettingsWithProject({ deploy_path: null })
|
expect(content).not.toContain('placeholder="make test"')
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_path')
|
|
||||||
expect((callArgs[1] as any).deploy_path).toBe('')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deploy_runtime="" передаётся как "" когда поле пустое (не undefined)', async () => {
|
it('не содержит obsidian_vault_path input поле', () => {
|
||||||
const wrapper = await mountSettingsWithProject({ deploy_runtime: null })
|
expect(content).not.toContain('path/to/obsidian/vault')
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_runtime')
|
|
||||||
expect((callArgs[1] as any).deploy_runtime).toBe('')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('deploy_restart_cmd="" передаётся как "" когда поле пустое (не undefined)', async () => {
|
|
||||||
const wrapper = await mountSettingsWithProject({ deploy_restart_cmd: null })
|
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_restart_cmd')
|
|
||||||
expect((callArgs[1] as any).deploy_restart_cmd).toBe('')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 2. JSON.stringify не выбрасывает пустые строки — бэкенд их получит
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('saveDeployConfig — пустые строки выживают JSON.stringify', () => {
|
|
||||||
it('все 4 поля присутствуют в JSON когда все значения пустые', async () => {
|
|
||||||
// Проект с null во всех deploy-полях → инициализируются как ''
|
|
||||||
const wrapper = await mountSettingsWithProject()
|
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
const payload = callArgs[1] as Record<string, unknown>
|
|
||||||
|
|
||||||
// Сериализуем как настоящий PATCH-запрос
|
|
||||||
const jsonBody = JSON.parse(JSON.stringify(payload))
|
|
||||||
|
|
||||||
expect(jsonBody).toHaveProperty('deploy_host', '')
|
|
||||||
expect(jsonBody).toHaveProperty('deploy_path', '')
|
|
||||||
expect(jsonBody).toHaveProperty('deploy_runtime', '')
|
|
||||||
expect(jsonBody).toHaveProperty('deploy_restart_cmd', '')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('пустая строка выживает JSON.stringify (регрессия: undefined исчезает)', async () => {
|
|
||||||
const wrapper = await mountSettingsWithProject({ deploy_host: null })
|
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
const payload = callArgs[1] as Record<string, unknown>
|
|
||||||
const jsonBody = JSON.parse(JSON.stringify(payload))
|
|
||||||
|
|
||||||
// "" должна присутствовать в JSON как пустая строка
|
|
||||||
// undefined здесь отсутствовало бы — это был бы баг
|
|
||||||
expect(Object.keys(jsonBody)).toContain('deploy_host')
|
|
||||||
expect(jsonBody.deploy_host).toBe('')
|
|
||||||
expect(jsonBody.deploy_host).not.toBeUndefined()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 3. Непустые значения передаются корректно
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('saveDeployConfig — непустые значения передаются корректно', () => {
|
|
||||||
it('deploy_host с непустым значением передаётся без изменений', async () => {
|
|
||||||
const wrapper = await mountSettingsWithProject({ deploy_host: 'prod.example.com' })
|
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect((callArgs[1] as any).deploy_host).toBe('prod.example.com')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('все 4 поля с непустыми значениями передаются корректно', async () => {
|
|
||||||
const wrapper = await mountSettingsWithProject({
|
|
||||||
deploy_host: 'prod.example.com',
|
|
||||||
deploy_path: '/opt/kin',
|
|
||||||
deploy_runtime: 'docker',
|
|
||||||
deploy_restart_cmd: 'docker compose restart',
|
|
||||||
})
|
|
||||||
await clickSaveDeployConfig(wrapper)
|
|
||||||
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
const payload = callArgs[1] as any
|
|
||||||
expect(payload.deploy_host).toBe('prod.example.com')
|
|
||||||
expect(payload.deploy_path).toBe('/opt/kin')
|
|
||||||
expect(payload.deploy_runtime).toBe('docker')
|
|
||||||
expect(payload.deploy_restart_cmd).toBe('docker compose restart')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,19 @@
|
||||||
* KIN-079: Стандартизированный deploy — компонентные тесты
|
* KIN-079: Стандартизированный deploy — компонентные тесты
|
||||||
*
|
*
|
||||||
* Проверяет:
|
* Проверяет:
|
||||||
* 1. SettingsView — deploy config рендерится, Save Deploy Config, runtime select
|
* 1. ProjectView — Deploy кнопка (видимость, disabled, спиннер)
|
||||||
* 2. ProjectView — Deploy кнопка (видимость, disabled, спиннер)
|
* 2. ProjectView — Deploy результат (structured, legacy, dependents)
|
||||||
* 3. ProjectView — Deploy результат (structured, legacy, dependents)
|
* 3. ProjectView — Links таб (список, add link модал, delete link)
|
||||||
* 4. ProjectView — Links таб (список, add link модал, delete link)
|
* 4. Граничные кейсы (пустые links, deploy без dependents, overall_success=false)
|
||||||
* 5. Граничные кейсы (пустые links, deploy без dependents, overall_success=false)
|
*
|
||||||
|
* Примечание: тесты SettingsView (Deploy Config, Project Links) удалены (KIN-UI-012).
|
||||||
|
* Эти формы перенесены в ProjectView → Settings tab.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||||
import { mount, flushPromises } from '@vue/test-utils'
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
import { createRouter, createMemoryHistory } from 'vue-router'
|
import { createRouter, createMemoryHistory } from 'vue-router'
|
||||||
import ProjectView from '../views/ProjectView.vue'
|
import ProjectView from '../views/ProjectView.vue'
|
||||||
import SettingsView from '../views/SettingsView.vue'
|
|
||||||
|
|
||||||
vi.mock('../api', async (importOriginal) => {
|
vi.mock('../api', async (importOriginal) => {
|
||||||
const actual = await importOriginal<typeof import('../api')>()
|
const actual = await importOriginal<typeof import('../api')>()
|
||||||
|
|
@ -135,163 +136,7 @@ async function switchToLinksTab(wrapper: ReturnType<typeof mount>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────
|
||||||
// 1. SettingsView — Deploy Config
|
// ProjectView — Deploy кнопка
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — Deploy Config', () => {
|
|
||||||
async function mountSettings(deployFields: Partial<typeof BASE_PROJECT> = {}) {
|
|
||||||
const project = { ...BASE_PROJECT, ...deployFields }
|
|
||||||
vi.mocked(api.projects).mockResolvedValue([project as any])
|
|
||||||
const wrapper = mount(SettingsView)
|
|
||||||
await flushPromises()
|
|
||||||
return wrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
it('раздел Deploy Config рендерится для каждого проекта', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
expect(wrapper.text()).toContain('Deploy Config')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('поле Server host рендерится', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
expect(wrapper.text()).toContain('Server host')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('поле Project path on server рендерится', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
expect(wrapper.text()).toContain('Project path on server')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('поле Runtime рендерится', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
expect(wrapper.text()).toContain('Runtime')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('поле Restart command рендерится', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
expect(wrapper.text()).toContain('Restart command')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('runtime select содержит опции docker, node, python, static', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
// Ищем select для runtime (первый select в Deploy Config)
|
|
||||||
const selects = wrapper.findAll('select')
|
|
||||||
// Находим select с options docker/node/python/static
|
|
||||||
const runtimeSelect = selects.find(s => {
|
|
||||||
const opts = s.findAll('option')
|
|
||||||
const values = opts.map(o => o.element.value)
|
|
||||||
return values.includes('docker') && values.includes('node')
|
|
||||||
})
|
|
||||||
expect(runtimeSelect).toBeDefined()
|
|
||||||
const values = runtimeSelect!.findAll('option').map(o => o.element.value)
|
|
||||||
expect(values).toContain('docker')
|
|
||||||
expect(values).toContain('node')
|
|
||||||
expect(values).toContain('python')
|
|
||||||
expect(values).toContain('static')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Save Deploy Config вызывает patchProject', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text().includes('Save Deploy Config'))
|
|
||||||
expect(saveBtn).toBeDefined()
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
expect(vi.mocked(api.patchProject)).toHaveBeenCalled()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('patchProject вызывается с deploy_host, deploy_path, deploy_runtime, deploy_restart_cmd', async () => {
|
|
||||||
const wrapper = await mountSettings({
|
|
||||||
deploy_host: 'myserver.com',
|
|
||||||
deploy_path: '/opt/app',
|
|
||||||
deploy_runtime: 'docker',
|
|
||||||
deploy_restart_cmd: 'docker compose up -d',
|
|
||||||
})
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text().includes('Save Deploy Config'))
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect(callArgs[0]).toBe('KIN')
|
|
||||||
// Все 4 ключа присутствуют в объекте
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_host')
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_path')
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_runtime')
|
|
||||||
expect(callArgs[1]).toHaveProperty('deploy_restart_cmd')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('patchProject получает deploy_host=myserver.com из заполненного поля', async () => {
|
|
||||||
const wrapper = await mountSettings({ deploy_host: 'myserver.com' })
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text().includes('Save Deploy Config'))
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
const callArgs = vi.mocked(api.patchProject).mock.calls[0]
|
|
||||||
expect((callArgs[1] as any).deploy_host).toBe('myserver.com')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('статус "Saved" отображается после успешного сохранения', async () => {
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text().includes('Save Deploy Config'))
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
expect(wrapper.text()).toContain('Saved')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 1b. SettingsView — Project Links
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — Project Links', () => {
|
|
||||||
it('link.type рендерится корректно в списке связей — не undefined (конвенция #527)', async () => {
|
|
||||||
// Bug #527: шаблон использовал {{ link.link_type }} вместо {{ link.type }} → runtime undefined
|
|
||||||
vi.mocked(api.projectLinks).mockResolvedValue([
|
|
||||||
{ id: 1, from_project: 'KIN', to_project: 'BRS', type: 'triggers', description: null, created_at: '2026-01-01' },
|
|
||||||
] as any)
|
|
||||||
vi.mocked(api.projects).mockResolvedValue([BASE_PROJECT as any])
|
|
||||||
const wrapper = mount(SettingsView)
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
// Тип связи должен отображаться как строка, а не undefined
|
|
||||||
expect(wrapper.text()).toContain('triggers')
|
|
||||||
expect(wrapper.text()).not.toContain('undefined')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('addLink вызывает createProjectLink с полем type (не link_type) из формы', async () => {
|
|
||||||
// Bug #527: addLink() использовал link_type вместо type при вызове api
|
|
||||||
vi.mocked(api.projects).mockResolvedValue([
|
|
||||||
{ ...BASE_PROJECT, id: 'BRS', name: 'Barsik' } as any,
|
|
||||||
BASE_PROJECT as any,
|
|
||||||
])
|
|
||||||
vi.mocked(api.projectLinks).mockResolvedValue([])
|
|
||||||
const wrapper = mount(SettingsView)
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
// Открываем форму добавления связи для первого проекта
|
|
||||||
const addBtns = wrapper.findAll('button').filter(b => b.text().includes('+ Add Link'))
|
|
||||||
if (addBtns.length > 0) {
|
|
||||||
await addBtns[0].trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
// Выбираем to_project (в SettingsView это select без api.projects — используем allProjectList)
|
|
||||||
const selects = wrapper.findAll('select')
|
|
||||||
const toProjectSelect = selects.find(s => s.findAll('option').some(o => o.element.value !== '' && o.element.value !== 'depends_on' && o.element.value !== 'triggers' && o.element.value !== 'related_to'))
|
|
||||||
if (toProjectSelect) {
|
|
||||||
const opts = toProjectSelect.findAll('option').filter(o => o.element.value !== '')
|
|
||||||
if (opts.length > 0) await toProjectSelect.setValue(opts[0].element.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const form = wrapper.find('form')
|
|
||||||
await form.trigger('submit')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
if (vi.mocked(api.createProjectLink).mock.calls.length > 0) {
|
|
||||||
const callArg = vi.mocked(api.createProjectLink).mock.calls[0][0]
|
|
||||||
expect(callArg).toHaveProperty('type')
|
|
||||||
expect(callArg).not.toHaveProperty('link_type')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 2. ProjectView — Deploy кнопка
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────
|
||||||
describe('ProjectView — Deploy кнопка', () => {
|
describe('ProjectView — Deploy кнопка', () => {
|
||||||
it('кнопка Deploy присутствует в header проекта', async () => {
|
it('кнопка Deploy присутствует в header проекта', async () => {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { api, type EscalationNotification } from '../api'
|
import { useRouter } from 'vue-router'
|
||||||
|
import { api, type EscalationNotification, type Task } from '../api'
|
||||||
|
|
||||||
const { t, locale } = useI18n()
|
const { t, locale } = useI18n()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const STORAGE_KEY = 'kin_dismissed_escalations'
|
const STORAGE_KEY = 'kin_dismissed_escalations'
|
||||||
const WATCHDOG_TOAST_KEY = 'kin_dismissed_watchdog_toasts'
|
const WATCHDOG_TOAST_KEY = 'kin_dismissed_watchdog_toasts'
|
||||||
|
const COMPLETED_STORAGE_KEY = 'kin_dismissed_completed'
|
||||||
|
|
||||||
const notifications = ref<EscalationNotification[]>([])
|
const notifications = ref<EscalationNotification[]>([])
|
||||||
const showPanel = ref(false)
|
const showPanel = ref(false)
|
||||||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||||
|
let completedPollTimer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
function loadDismissed(): Set<string> {
|
function loadDismissed(): Set<string> {
|
||||||
try {
|
try {
|
||||||
|
|
@ -115,13 +119,99 @@ function formatTime(iso: string): string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Completed tasks ---
|
||||||
|
|
||||||
|
interface CompletedTaskItem extends Task {
|
||||||
|
project_name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const completedTasks = ref<CompletedTaskItem[]>([])
|
||||||
|
|
||||||
|
function loadDismissedCompleted(): Set<string> {
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(COMPLETED_STORAGE_KEY)
|
||||||
|
return new Set(raw ? JSON.parse(raw) : [])
|
||||||
|
} catch {
|
||||||
|
return new Set()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveDismissedCompleted(ids: Set<string>) {
|
||||||
|
localStorage.setItem(COMPLETED_STORAGE_KEY, JSON.stringify([...ids]))
|
||||||
|
}
|
||||||
|
|
||||||
|
const dismissedCompleted = ref<Set<string>>(loadDismissedCompleted())
|
||||||
|
|
||||||
|
const visibleCompleted = computed(() =>
|
||||||
|
completedTasks.value.filter(t => !dismissedCompleted.value.has(t.id))
|
||||||
|
)
|
||||||
|
|
||||||
|
async function loadCompletedTasks() {
|
||||||
|
try {
|
||||||
|
const projects = await api.projects()
|
||||||
|
const withCompleted = projects.filter(p => p.done_tasks > 0)
|
||||||
|
if (withCompleted.length === 0) {
|
||||||
|
completedTasks.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const details = await Promise.all(withCompleted.map(p => api.project(p.id)))
|
||||||
|
const results: CompletedTaskItem[] = []
|
||||||
|
for (let i = 0; i < details.length; i++) {
|
||||||
|
const projectName = withCompleted[i].name
|
||||||
|
for (const task of details[i].tasks) {
|
||||||
|
if (task.status === 'completed') {
|
||||||
|
results.push({ ...task, project_name: projectName })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime())
|
||||||
|
completedTasks.value = results.slice(0, 20)
|
||||||
|
} catch {
|
||||||
|
// silent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function doneCompleted(taskId: string) {
|
||||||
|
dismissedCompleted.value = new Set([...dismissedCompleted.value, taskId])
|
||||||
|
saveDismissedCompleted(dismissedCompleted.value)
|
||||||
|
if (visibleCompleted.value.length === 0 && visible.value.length === 0) showPanel.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const revisingTaskId = ref<string | null>(null)
|
||||||
|
const reviseComment = ref('')
|
||||||
|
|
||||||
|
function startRevise(taskId: string) {
|
||||||
|
revisingTaskId.value = taskId
|
||||||
|
reviseComment.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmRevise(taskId: string) {
|
||||||
|
try {
|
||||||
|
await api.reviseTask(taskId, reviseComment.value || t('escalation.revise_default_comment'))
|
||||||
|
doneCompleted(taskId)
|
||||||
|
} catch {
|
||||||
|
// silent
|
||||||
|
} finally {
|
||||||
|
revisingTaskId.value = null
|
||||||
|
reviseComment.value = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelRevise() {
|
||||||
|
revisingTaskId.value = null
|
||||||
|
reviseComment.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await load()
|
await load()
|
||||||
pollTimer = setInterval(load, 10000)
|
pollTimer = setInterval(load, 10000)
|
||||||
|
await loadCompletedTasks()
|
||||||
|
completedPollTimer = setInterval(loadCompletedTasks, 30000)
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (pollTimer) clearInterval(pollTimer)
|
if (pollTimer) clearInterval(pollTimer)
|
||||||
|
if (completedPollTimer) clearInterval(completedPollTimer)
|
||||||
// KIN-099: clear watchdog toast auto-dismiss timers to prevent memory leaks
|
// KIN-099: clear watchdog toast auto-dismiss timers to prevent memory leaks
|
||||||
for (const toast of watchdogToasts.value) {
|
for (const toast of watchdogToasts.value) {
|
||||||
if (toast.timerId) clearTimeout(toast.timerId)
|
if (toast.timerId) clearTimeout(toast.timerId)
|
||||||
|
|
@ -148,8 +238,8 @@ onUnmounted(() => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="relative">
|
<div class="relative flex items-center gap-1">
|
||||||
<!-- Badge-кнопка — видна только при наличии активных эскалаций -->
|
<!-- Badge-кнопка эскалаций -->
|
||||||
<button
|
<button
|
||||||
v-if="visible.length > 0"
|
v-if="visible.length > 0"
|
||||||
@click="showPanel = !showPanel"
|
@click="showPanel = !showPanel"
|
||||||
|
|
@ -160,23 +250,38 @@ onUnmounted(() => {
|
||||||
<span class="ml-0.5 font-bold">{{ visible.length }}</span>
|
<span class="ml-0.5 font-bold">{{ visible.length }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- Панель уведомлений -->
|
<!-- Badge-кнопка завершённых задач -->
|
||||||
|
<button
|
||||||
|
v-if="visibleCompleted.length > 0"
|
||||||
|
@click="showPanel = !showPanel"
|
||||||
|
class="relative flex items-center gap-1.5 px-2.5 py-1 text-xs bg-green-900/40 text-green-400 border border-green-800 rounded hover:bg-green-900/60 transition-colors"
|
||||||
|
>
|
||||||
|
<span class="inline-block w-1.5 h-1.5 bg-green-500 rounded-full"></span>
|
||||||
|
{{ t('escalation.completed_tasks') }}
|
||||||
|
<span class="ml-0.5 font-bold">{{ visibleCompleted.length }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Объединённая панель уведомлений -->
|
||||||
<div
|
<div
|
||||||
v-if="showPanel && visible.length > 0"
|
v-if="showPanel && (visible.length > 0 || visibleCompleted.length > 0)"
|
||||||
class="absolute right-0 top-full mt-2 w-96 bg-gray-900 border border-red-900/60 rounded-lg shadow-2xl z-50"
|
class="absolute right-0 top-full mt-2 w-96 bg-gray-900 border border-gray-700 rounded-lg shadow-2xl z-50"
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-between px-4 py-2.5 border-b border-gray-800">
|
<div class="flex items-center justify-between px-4 py-2.5 border-b border-gray-800">
|
||||||
|
<span class="text-xs font-semibold text-gray-400">Kin</span>
|
||||||
|
<button @click="showPanel = false" class="text-gray-500 hover:text-gray-300 text-lg leading-none">×</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Секция эскалаций -->
|
||||||
|
<div v-if="visible.length > 0">
|
||||||
|
<div class="flex items-center justify-between px-4 py-2 border-b border-gray-800/60">
|
||||||
<span class="text-xs font-semibold text-red-400">{{ t('escalation.escalations_panel_title') }}</span>
|
<span class="text-xs font-semibold text-red-400">{{ t('escalation.escalations_panel_title') }}</span>
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<button
|
<button
|
||||||
@click="dismissAll"
|
@click="dismissAll"
|
||||||
class="text-xs text-gray-500 hover:text-gray-300"
|
class="text-xs text-gray-500 hover:text-gray-300"
|
||||||
>{{ t('escalation.dismiss_all') }}</button>
|
>{{ t('escalation.dismiss_all') }}</button>
|
||||||
<button @click="showPanel = false" class="text-gray-500 hover:text-gray-300 text-lg leading-none">×</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="max-h-80 overflow-y-auto divide-y divide-gray-800">
|
<div class="max-h-60 overflow-y-auto divide-y divide-gray-800">
|
||||||
<div
|
<div
|
||||||
v-for="n in visible"
|
v-for="n in visible"
|
||||||
:key="n.task_id"
|
:key="n.task_id"
|
||||||
|
|
@ -202,6 +307,72 @@ onUnmounted(() => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Разделитель между секциями -->
|
||||||
|
<div v-if="visible.length > 0 && visibleCompleted.length > 0" class="border-t border-gray-700"></div>
|
||||||
|
|
||||||
|
<!-- Секция завершённых задач -->
|
||||||
|
<div v-if="visibleCompleted.length > 0">
|
||||||
|
<div class="px-4 py-2 border-b border-gray-800/60">
|
||||||
|
<span class="text-xs font-semibold text-green-400">{{ t('escalation.completed_panel_title') }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="max-h-60 overflow-y-auto divide-y divide-gray-800">
|
||||||
|
<div
|
||||||
|
v-for="task in visibleCompleted"
|
||||||
|
:key="task.id"
|
||||||
|
class="px-4 py-3 cursor-pointer hover:bg-gray-800/40 transition-colors"
|
||||||
|
@click="router.push(`/task/${task.id}`); showPanel = false"
|
||||||
|
>
|
||||||
|
<div class="flex items-start justify-between gap-2">
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<div class="flex items-center gap-1.5 mb-1">
|
||||||
|
<span class="text-xs font-mono text-green-400 shrink-0">{{ task.id }}</span>
|
||||||
|
<span class="text-xs text-gray-500">·</span>
|
||||||
|
<span class="text-xs text-gray-500 truncate">{{ task.project_name }}</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-gray-200 leading-snug break-words">{{ task.title }}</p>
|
||||||
|
<p class="text-xs text-gray-600 mt-1">{{ formatTime(task.updated_at) }}</p>
|
||||||
|
<!-- Inline revise form -->
|
||||||
|
<div
|
||||||
|
v-if="revisingTaskId === task.id"
|
||||||
|
class="mt-2 flex gap-1"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="reviseComment"
|
||||||
|
type="text"
|
||||||
|
:placeholder="t('escalation.revise_comment_placeholder')"
|
||||||
|
class="flex-1 px-2 py-1 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-gray-400"
|
||||||
|
@keyup.enter="confirmRevise(task.id)"
|
||||||
|
@keyup.escape="cancelRevise"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
@click="confirmRevise(task.id)"
|
||||||
|
class="px-2 py-1 text-xs bg-green-900/50 text-green-400 border border-green-700 rounded hover:bg-green-900 transition-colors"
|
||||||
|
>{{ t('escalation.revise_send') }}</button>
|
||||||
|
<button
|
||||||
|
@click="cancelRevise"
|
||||||
|
class="px-2 py-1 text-xs bg-gray-800 text-gray-400 border border-gray-700 rounded hover:bg-gray-700 transition-colors"
|
||||||
|
>{{ t('escalation.revise_cancel') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col gap-1 shrink-0" @click.stop>
|
||||||
|
<button
|
||||||
|
v-if="revisingTaskId !== task.id"
|
||||||
|
@click="startRevise(task.id)"
|
||||||
|
class="px-2 py-1 text-xs bg-blue-900/40 text-blue-400 border border-blue-800 rounded hover:bg-blue-900/60 transition-colors"
|
||||||
|
>{{ t('escalation.revise') }}</button>
|
||||||
|
<button
|
||||||
|
@click="doneCompleted(task.id)"
|
||||||
|
class="px-2 py-1 text-xs bg-gray-800 text-gray-400 border border-gray-700 rounded hover:bg-gray-700 hover:text-gray-200 transition-colors"
|
||||||
|
>{{ t('escalation.done') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Overlay для закрытия панели -->
|
<!-- Overlay для закрытия панели -->
|
||||||
<div v-if="showPanel" class="fixed inset-0 z-40" @click="showPanel = false"></div>
|
<div v-if="showPanel" class="fixed inset-0 z-40" @click="showPanel = false"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,15 @@
|
||||||
"escalations": "Escalations",
|
"escalations": "Escalations",
|
||||||
"escalations_panel_title": "Escalations — action required",
|
"escalations_panel_title": "Escalations — action required",
|
||||||
"dismiss_all": "Dismiss all",
|
"dismiss_all": "Dismiss all",
|
||||||
"dismiss": "Dismiss"
|
"dismiss": "Dismiss",
|
||||||
|
"completed_tasks": "Completed",
|
||||||
|
"completed_panel_title": "Completed tasks — review",
|
||||||
|
"done": "Done",
|
||||||
|
"revise": "Revise",
|
||||||
|
"revise_comment_placeholder": "Revision comment...",
|
||||||
|
"revise_send": "Send",
|
||||||
|
"revise_cancel": "Cancel",
|
||||||
|
"revise_default_comment": "Sent for revision"
|
||||||
},
|
},
|
||||||
"liveConsole": {
|
"liveConsole": {
|
||||||
"hide_log": "▲ Скрыть лог",
|
"hide_log": "▲ Скрыть лог",
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,15 @@
|
||||||
"escalations": "Эскалации",
|
"escalations": "Эскалации",
|
||||||
"escalations_panel_title": "Эскалации — требуется решение",
|
"escalations_panel_title": "Эскалации — требуется решение",
|
||||||
"dismiss_all": "Принять все",
|
"dismiss_all": "Принять все",
|
||||||
"dismiss": "Принято"
|
"dismiss": "Принято",
|
||||||
|
"completed_tasks": "Завершено",
|
||||||
|
"completed_panel_title": "Завершённые задачи — к проверке",
|
||||||
|
"done": "Готово",
|
||||||
|
"revise": "Доработать",
|
||||||
|
"revise_comment_placeholder": "Комментарий к доработке...",
|
||||||
|
"revise_send": "Отправить",
|
||||||
|
"revise_cancel": "Отмена",
|
||||||
|
"revise_default_comment": "Отправлено на доработку"
|
||||||
},
|
},
|
||||||
"liveConsole": {
|
"liveConsole": {
|
||||||
"hide_log": "▲ Скрыть лог",
|
"hide_log": "▲ Скрыть лог",
|
||||||
|
|
|
||||||
|
|
@ -1,199 +1,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { api, type Project, type ObsidianSyncResult, type ProjectLink } from '../api'
|
import { api, type Project } from '../api'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const projects = ref<Project[]>([])
|
const projects = ref<Project[]>([])
|
||||||
const vaultPaths = ref<Record<string, string>>({})
|
|
||||||
const deployCommands = ref<Record<string, string>>({})
|
|
||||||
const testCommands = ref<Record<string, string>>({})
|
|
||||||
const autoTestEnabled = ref<Record<string, boolean>>({})
|
|
||||||
const worktreesEnabled = ref<Record<string, boolean>>({})
|
|
||||||
const saving = ref<Record<string, boolean>>({})
|
|
||||||
const savingTest = ref<Record<string, boolean>>({})
|
|
||||||
const savingAutoTest = ref<Record<string, boolean>>({})
|
|
||||||
const savingWorktrees = ref<Record<string, boolean>>({})
|
|
||||||
const syncing = ref<Record<string, boolean>>({})
|
|
||||||
const saveStatus = ref<Record<string, string>>({})
|
|
||||||
const saveTestStatus = ref<Record<string, string>>({})
|
|
||||||
const saveAutoTestStatus = ref<Record<string, string>>({})
|
|
||||||
const saveWorktreesStatus = ref<Record<string, string>>({})
|
|
||||||
const syncResults = ref<Record<string, ObsidianSyncResult | null>>({})
|
|
||||||
const error = ref<string | null>(null)
|
const error = ref<string | null>(null)
|
||||||
|
|
||||||
// Deploy config
|
|
||||||
const deployHosts = ref<Record<string, string>>({})
|
|
||||||
const deployPaths = ref<Record<string, string>>({})
|
|
||||||
const deployRuntimes = ref<Record<string, string>>({})
|
|
||||||
const deployRestartCmds = ref<Record<string, string>>({})
|
|
||||||
const savingDeployConfig = ref<Record<string, boolean>>({})
|
|
||||||
const saveDeployConfigStatus = ref<Record<string, string>>({})
|
|
||||||
|
|
||||||
// Project Links
|
|
||||||
const projectLinksMap = ref<Record<string, ProjectLink[]>>({})
|
|
||||||
const linksLoading = ref<Record<string, boolean>>({})
|
|
||||||
const showAddLinkForm = ref<Record<string, boolean>>({})
|
|
||||||
const linkForms = ref<Record<string, { to_project: string; link_type: string; description: string }>>({})
|
|
||||||
const linkSaving = ref<Record<string, boolean>>({})
|
|
||||||
const linkError = ref<Record<string, string>>({})
|
|
||||||
const allProjectList = ref<{ id: string; name: string }[]>([])
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
projects.value = await api.projects()
|
projects.value = await api.projects()
|
||||||
allProjectList.value = projects.value.map(p => ({ id: p.id, name: p.name }))
|
|
||||||
for (const p of projects.value) {
|
|
||||||
vaultPaths.value[p.id] = p.obsidian_vault_path ?? ''
|
|
||||||
deployCommands.value[p.id] = p.deploy_command ?? ''
|
|
||||||
testCommands.value[p.id] = p.test_command ?? ''
|
|
||||||
autoTestEnabled.value[p.id] = !!(p.auto_test_enabled)
|
|
||||||
worktreesEnabled.value[p.id] = !!(p.worktrees_enabled)
|
|
||||||
deployHosts.value[p.id] = p.deploy_host ?? ''
|
|
||||||
deployPaths.value[p.id] = p.deploy_path ?? ''
|
|
||||||
deployRuntimes.value[p.id] = p.deploy_runtime ?? ''
|
|
||||||
deployRestartCmds.value[p.id] = p.deploy_restart_cmd ?? ''
|
|
||||||
linkForms.value[p.id] = { to_project: '', link_type: 'depends_on', description: '' }
|
|
||||||
projectLinksMap.value[p.id] = []
|
|
||||||
}
|
|
||||||
await Promise.all(projects.value.map(p => loadLinks(p.id)))
|
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
error.value = e instanceof Error ? e.message : String(e)
|
error.value = e instanceof Error ? e.message : String(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
async function saveDeployConfig(projectId: string) {
|
|
||||||
savingDeployConfig.value[projectId] = true
|
|
||||||
saveDeployConfigStatus.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.patchProject(projectId, {
|
|
||||||
deploy_host: deployHosts.value[projectId],
|
|
||||||
deploy_path: deployPaths.value[projectId],
|
|
||||||
deploy_runtime: deployRuntimes.value[projectId],
|
|
||||||
deploy_restart_cmd: deployRestartCmds.value[projectId],
|
|
||||||
deploy_command: deployCommands.value[projectId],
|
|
||||||
})
|
|
||||||
saveDeployConfigStatus.value[projectId] = t('common.saved')
|
|
||||||
} catch (e: unknown) {
|
|
||||||
saveDeployConfigStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
|
|
||||||
} finally {
|
|
||||||
savingDeployConfig.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveVaultPath(projectId: string) {
|
|
||||||
saving.value[projectId] = true
|
|
||||||
saveStatus.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.patchProject(projectId, { obsidian_vault_path: vaultPaths.value[projectId] })
|
|
||||||
saveStatus.value[projectId] = t('common.saved')
|
|
||||||
} catch (e: unknown) {
|
|
||||||
saveStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
|
|
||||||
} finally {
|
|
||||||
saving.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveTestCommand(projectId: string) {
|
|
||||||
savingTest.value[projectId] = true
|
|
||||||
saveTestStatus.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.patchProject(projectId, { test_command: testCommands.value[projectId] })
|
|
||||||
saveTestStatus.value[projectId] = t('common.saved')
|
|
||||||
} catch (e: unknown) {
|
|
||||||
saveTestStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
|
|
||||||
} finally {
|
|
||||||
savingTest.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function toggleAutoTest(projectId: string) {
|
|
||||||
autoTestEnabled.value[projectId] = !autoTestEnabled.value[projectId]
|
|
||||||
savingAutoTest.value[projectId] = true
|
|
||||||
saveAutoTestStatus.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.patchProject(projectId, { auto_test_enabled: autoTestEnabled.value[projectId] })
|
|
||||||
saveAutoTestStatus.value[projectId] = t('common.saved')
|
|
||||||
} catch (e: unknown) {
|
|
||||||
autoTestEnabled.value[projectId] = !autoTestEnabled.value[projectId]
|
|
||||||
saveAutoTestStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
|
|
||||||
} finally {
|
|
||||||
savingAutoTest.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function toggleWorktrees(projectId: string) {
|
|
||||||
worktreesEnabled.value[projectId] = !worktreesEnabled.value[projectId]
|
|
||||||
savingWorktrees.value[projectId] = true
|
|
||||||
saveWorktreesStatus.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.patchProject(projectId, { worktrees_enabled: worktreesEnabled.value[projectId] })
|
|
||||||
saveWorktreesStatus.value[projectId] = t('common.saved')
|
|
||||||
} catch (e: unknown) {
|
|
||||||
worktreesEnabled.value[projectId] = !worktreesEnabled.value[projectId]
|
|
||||||
saveWorktreesStatus.value[projectId] = `${t('common.error')}: ${e instanceof Error ? e.message : String(e)}`
|
|
||||||
} finally {
|
|
||||||
savingWorktrees.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function runSync(projectId: string) {
|
|
||||||
syncing.value[projectId] = true
|
|
||||||
syncResults.value[projectId] = null
|
|
||||||
saveStatus.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.patchProject(projectId, { obsidian_vault_path: vaultPaths.value[projectId] })
|
|
||||||
syncResults.value[projectId] = await api.syncObsidian(projectId)
|
|
||||||
} catch (e: unknown) {
|
|
||||||
saveStatus.value[projectId] = `Sync error: ${e instanceof Error ? e.message : String(e)}`
|
|
||||||
} finally {
|
|
||||||
syncing.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadLinks(projectId: string) {
|
|
||||||
linksLoading.value[projectId] = true
|
|
||||||
try {
|
|
||||||
projectLinksMap.value[projectId] = await api.projectLinks(projectId)
|
|
||||||
} catch (e: unknown) {
|
|
||||||
linkError.value[projectId] = e instanceof Error ? e.message : String(e)
|
|
||||||
} finally {
|
|
||||||
linksLoading.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addLink(projectId: string) {
|
|
||||||
const form = linkForms.value[projectId]
|
|
||||||
if (!form.to_project) { linkError.value[projectId] = t('settings.select_project_error'); return }
|
|
||||||
linkSaving.value[projectId] = true
|
|
||||||
linkError.value[projectId] = ''
|
|
||||||
try {
|
|
||||||
await api.createProjectLink({
|
|
||||||
from_project: projectId,
|
|
||||||
to_project: form.to_project,
|
|
||||||
type: form.link_type,
|
|
||||||
description: form.description || undefined,
|
|
||||||
})
|
|
||||||
showAddLinkForm.value[projectId] = false
|
|
||||||
linkForms.value[projectId] = { to_project: '', link_type: 'depends_on', description: '' }
|
|
||||||
await loadLinks(projectId)
|
|
||||||
} catch (e: unknown) {
|
|
||||||
linkError.value[projectId] = e instanceof Error ? e.message : String(e)
|
|
||||||
} finally {
|
|
||||||
linkSaving.value[projectId] = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function deleteLink(projectId: string, linkId: number) {
|
|
||||||
if (!confirm(t('settings.delete_link_confirm'))) return
|
|
||||||
try {
|
|
||||||
await api.deleteProjectLink(linkId)
|
|
||||||
await loadLinks(projectId)
|
|
||||||
} catch (e: unknown) {
|
|
||||||
linkError.value[projectId] = e instanceof Error ? e.message : String(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -202,249 +23,34 @@ async function deleteLink(projectId: string, linkId: number) {
|
||||||
|
|
||||||
<div v-if="error" class="text-red-400 mb-4">{{ error }}</div>
|
<div v-if="error" class="text-red-400 mb-4">{{ error }}</div>
|
||||||
|
|
||||||
<div v-for="project in projects" :key="project.id" class="mb-6 p-4 border border-gray-700 rounded-lg">
|
<div class="overflow-x-auto">
|
||||||
<div class="flex items-center gap-3 mb-3">
|
<table class="w-full text-sm">
|
||||||
<span class="font-medium text-gray-100">{{ project.name }}</span>
|
<thead>
|
||||||
<span class="text-xs text-gray-500 font-mono">{{ project.id }}</span>
|
<tr class="text-left text-xs text-gray-500 border-b border-gray-800">
|
||||||
<span v-if="project.execution_mode" class="text-xs text-gray-500 shrink-0">{{ project.execution_mode }}</span>
|
<th class="pb-2 pr-6 font-medium">Name</th>
|
||||||
<a :href="'/project/' + project.id + '?tab=settings'"
|
<th class="pb-2 pr-6 font-medium font-mono">ID</th>
|
||||||
class="ml-auto px-3 py-1 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700 no-underline shrink-0">
|
<th class="pb-2 pr-6 font-medium">Mode</th>
|
||||||
|
<th class="pb-2 pr-6 font-medium">Status</th>
|
||||||
|
<th class="pb-2 font-medium"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="project in projects" :key="project.id" class="border-b border-gray-800 hover:bg-gray-800/30">
|
||||||
|
<td class="py-2 pr-6 text-gray-100">{{ project.name }}</td>
|
||||||
|
<td class="py-2 pr-6 text-gray-500 font-mono text-xs">{{ project.id }}</td>
|
||||||
|
<td class="py-2 pr-6 text-gray-400 text-xs">{{ project.execution_mode ?? '—' }}</td>
|
||||||
|
<td class="py-2 pr-6 text-gray-400 text-xs">{{ project.status }}</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<router-link
|
||||||
|
:to="`/project/${project.id}?tab=settings`"
|
||||||
|
class="px-3 py-1 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700 no-underline"
|
||||||
|
>
|
||||||
{{ t('settings.open_settings') }}
|
{{ t('settings.open_settings') }}
|
||||||
</a>
|
</router-link>
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
<div class="mb-3">
|
</tbody>
|
||||||
<label class="block text-xs text-gray-400 mb-1">{{ t('settings.obsidian_vault_path') }}</label>
|
</table>
|
||||||
<input
|
|
||||||
v-model="vaultPaths[project.id]"
|
|
||||||
type="text"
|
|
||||||
placeholder="/path/to/obsidian/vault"
|
|
||||||
class="w-full bg-gray-900 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="block text-xs text-gray-400 mb-1">{{ t('settings.test_command') }}</label>
|
|
||||||
<input
|
|
||||||
v-model="testCommands[project.id]"
|
|
||||||
type="text"
|
|
||||||
placeholder="make test"
|
|
||||||
class="w-full bg-gray-900 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
|
|
||||||
/>
|
|
||||||
<p class="text-xs text-gray-600 mt-1">{{ t('settings.test_command_hint') }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center gap-3 flex-wrap mb-3">
|
|
||||||
<button
|
|
||||||
@click="saveTestCommand(project.id)"
|
|
||||||
:disabled="savingTest[project.id]"
|
|
||||||
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{{ savingTest[project.id] ? t('settings.saving_test') : t('settings.save_test') }}
|
|
||||||
</button>
|
|
||||||
<span v-if="saveTestStatus[project.id]" class="text-xs" :class="saveTestStatus[project.id].startsWith(t('common.error')) ? 'text-red-400' : 'text-green-400'">
|
|
||||||
{{ saveTestStatus[project.id] }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Deploy Config -->
|
|
||||||
<div class="mb-2 pt-2 border-t border-gray-800">
|
|
||||||
<p class="text-xs font-semibold text-gray-400 mb-2">{{ t('settings.deploy_config') }}</p>
|
|
||||||
<div class="mb-2">
|
|
||||||
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.server_host') }}</label>
|
|
||||||
<input
|
|
||||||
v-model="deployHosts[project.id]"
|
|
||||||
type="text"
|
|
||||||
placeholder="server host (e.g. vdp-prod)"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2">
|
|
||||||
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.project_path_on_server') }}</label>
|
|
||||||
<input
|
|
||||||
v-model="deployPaths[project.id]"
|
|
||||||
type="text"
|
|
||||||
placeholder="/srv/myproject"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2">
|
|
||||||
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.runtime') }}</label>
|
|
||||||
<select
|
|
||||||
v-model="deployRuntimes[project.id]"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-300 focus:outline-none focus:border-gray-500"
|
|
||||||
>
|
|
||||||
<option value="">{{ t('settings.select_runtime') }}</option>
|
|
||||||
<option value="docker">docker</option>
|
|
||||||
<option value="node">node</option>
|
|
||||||
<option value="python">python</option>
|
|
||||||
<option value="static">static</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2">
|
|
||||||
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.restart_command') }}</label>
|
|
||||||
<input
|
|
||||||
v-model="deployRestartCmds[project.id]"
|
|
||||||
type="text"
|
|
||||||
placeholder="optional override command"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2">
|
|
||||||
<label class="block text-xs text-gray-500 mb-1">{{ t('settings.fallback_command') }}</label>
|
|
||||||
<input
|
|
||||||
v-model="deployCommands[project.id]"
|
|
||||||
type="text"
|
|
||||||
placeholder="git push origin main"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-gray-500"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-3 flex-wrap mb-3">
|
|
||||||
<button
|
|
||||||
@click="saveDeployConfig(project.id)"
|
|
||||||
:disabled="savingDeployConfig[project.id]"
|
|
||||||
class="px-3 py-1.5 text-sm bg-teal-900/50 text-teal-400 border border-teal-800 rounded hover:bg-teal-900 disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{{ savingDeployConfig[project.id] ? t('settings.saving_deploy') : t('settings.save_deploy_config') }}
|
|
||||||
</button>
|
|
||||||
<span v-if="saveDeployConfigStatus[project.id]" class="text-xs" :class="saveDeployConfigStatus[project.id].startsWith(t('common.error')) ? 'text-red-400' : 'text-green-400'">
|
|
||||||
{{ saveDeployConfigStatus[project.id] }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Project Links -->
|
|
||||||
<div class="mb-2 pt-2 border-t border-gray-800">
|
|
||||||
<div class="flex items-center justify-between mb-2">
|
|
||||||
<p class="text-xs font-semibold text-gray-400">{{ t('settings.project_links') }}</p>
|
|
||||||
<button
|
|
||||||
@click="showAddLinkForm[project.id] = !showAddLinkForm[project.id]"
|
|
||||||
class="px-2 py-0.5 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700"
|
|
||||||
>
|
|
||||||
{{ t('settings.add_link') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p v-if="linksLoading[project.id]" class="text-xs text-gray-500">{{ t('settings.links_loading') }}</p>
|
|
||||||
<p v-else-if="linkError[project.id]" class="text-xs text-red-400">{{ linkError[project.id] }}</p>
|
|
||||||
<div v-else-if="!projectLinksMap[project.id]?.length" class="text-xs text-gray-600">{{ t('settings.no_links') }}</div>
|
|
||||||
<div v-else class="space-y-1 mb-2">
|
|
||||||
<div v-for="link in projectLinksMap[project.id]" :key="link.id"
|
|
||||||
class="flex items-center gap-2 px-2 py-1 bg-gray-900 border border-gray-800 rounded text-xs">
|
|
||||||
<span class="text-gray-500 font-mono">{{ link.from_project }}</span>
|
|
||||||
<span class="text-gray-600">→</span>
|
|
||||||
<span class="text-gray-500 font-mono">{{ link.to_project }}</span>
|
|
||||||
<span class="px-1 bg-indigo-900/30 text-indigo-400 border border-indigo-800 rounded">{{ link.type }}</span>
|
|
||||||
<span v-if="link.description" class="text-gray-600">{{ link.description }}</span>
|
|
||||||
<button @click="deleteLink(project.id, link.id)"
|
|
||||||
class="ml-auto text-red-500 hover:text-red-400 bg-transparent border-none cursor-pointer text-xs shrink-0">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<form v-if="showAddLinkForm[project.id]" @submit.prevent="addLink(project.id)" class="space-y-2 p-2 bg-gray-900 border border-gray-800 rounded">
|
|
||||||
<div>
|
|
||||||
<label class="block text-[10px] text-gray-500 mb-0.5">From (current)</label>
|
|
||||||
<input :value="project.id" disabled class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-500 font-mono" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="block text-[10px] text-gray-500 mb-0.5">To project</label>
|
|
||||||
<select v-model="linkForms[project.id].to_project" required
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300">
|
|
||||||
<option value="">{{ t('settings.select_project') }}</option>
|
|
||||||
<option v-for="p in allProjectList.filter(p => p.id !== project.id)" :key="p.id" :value="p.id">{{ p.id }} — {{ p.name }}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="block text-[10px] text-gray-500 mb-0.5">Link type</label>
|
|
||||||
<select v-model="linkForms[project.id].link_type"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300">
|
|
||||||
<option value="depends_on">depends_on</option>
|
|
||||||
<option value="triggers">triggers</option>
|
|
||||||
<option value="related_to">related_to</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="block text-[10px] text-gray-500 mb-0.5">Description (optional)</label>
|
|
||||||
<input v-model="linkForms[project.id].description" placeholder="e.g. API used by frontend"
|
|
||||||
class="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600" />
|
|
||||||
</div>
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<button type="submit" :disabled="linkSaving[project.id]"
|
|
||||||
class="px-3 py-1 text-xs bg-blue-900/50 text-blue-400 border border-blue-800 rounded hover:bg-blue-900 disabled:opacity-50">
|
|
||||||
{{ linkSaving[project.id] ? t('settings.saving_link') : t('common.add') }}
|
|
||||||
</button>
|
|
||||||
<button type="button" @click="showAddLinkForm[project.id] = false; linkError[project.id] = ''"
|
|
||||||
class="px-3 py-1 text-xs text-gray-500 hover:text-gray-300 bg-transparent border-none cursor-pointer">
|
|
||||||
{{ t('settings.cancel_link') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center gap-3 mb-3">
|
|
||||||
<label class="flex items-center gap-2 cursor-pointer select-none">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
:checked="autoTestEnabled[project.id]"
|
|
||||||
@change="toggleAutoTest(project.id)"
|
|
||||||
:disabled="savingAutoTest[project.id]"
|
|
||||||
class="w-4 h-4 rounded border-gray-600 bg-gray-800 accent-blue-500 cursor-pointer disabled:opacity-50"
|
|
||||||
/>
|
|
||||||
<span class="text-sm text-gray-300">{{ t('settings.auto_test') }}</span>
|
|
||||||
<span class="text-xs text-gray-500">{{ t('settings.auto_test_hint') }}</span>
|
|
||||||
</label>
|
|
||||||
<span v-if="saveAutoTestStatus[project.id]" class="text-xs" :class="saveAutoTestStatus[project.id].startsWith(t('common.error')) ? 'text-red-400' : 'text-green-400'">
|
|
||||||
{{ saveAutoTestStatus[project.id] }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center gap-3 mb-3">
|
|
||||||
<label class="flex items-center gap-2 cursor-pointer select-none">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
:checked="worktreesEnabled[project.id]"
|
|
||||||
@change="toggleWorktrees(project.id)"
|
|
||||||
:disabled="savingWorktrees[project.id]"
|
|
||||||
class="w-4 h-4 rounded border-gray-600 bg-gray-800 accent-blue-500 cursor-pointer disabled:opacity-50"
|
|
||||||
/>
|
|
||||||
<span class="text-sm text-gray-300">{{ t('settings.worktrees') }}</span>
|
|
||||||
<span class="text-xs text-gray-500">{{ t('settings.worktrees_hint') }}</span>
|
|
||||||
</label>
|
|
||||||
<span v-if="saveWorktreesStatus[project.id]" class="text-xs" :class="saveWorktreesStatus[project.id].startsWith(t('common.error')) ? 'text-red-400' : 'text-green-400'">
|
|
||||||
{{ saveWorktreesStatus[project.id] }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center gap-3 flex-wrap">
|
|
||||||
<button
|
|
||||||
@click="saveVaultPath(project.id)"
|
|
||||||
:disabled="saving[project.id]"
|
|
||||||
class="px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 text-gray-200 rounded disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{{ saving[project.id] ? t('settings.saving_vault') : t('settings.save_vault') }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
@click="runSync(project.id)"
|
|
||||||
:disabled="syncing[project.id] || !vaultPaths[project.id]"
|
|
||||||
class="px-3 py-1.5 text-sm bg-indigo-700 hover:bg-indigo-600 text-white rounded disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{{ syncing[project.id] ? t('settings.syncing') : t('settings.sync_obsidian') }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<span v-if="saveStatus[project.id]" class="text-xs" :class="saveStatus[project.id].startsWith(t('common.error')) ? 'text-red-400' : 'text-green-400'">
|
|
||||||
{{ saveStatus[project.id] }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="syncResults[project.id]" class="mt-3 p-3 bg-gray-900 rounded text-xs text-gray-300">
|
|
||||||
<div>Exported: <span class="text-green-400 font-medium">{{ syncResults[project.id]!.exported_decisions }}</span> decisions</div>
|
|
||||||
<div>Updated: <span class="text-green-400 font-medium">{{ syncResults[project.id]!.tasks_updated }}</span> tasks</div>
|
|
||||||
<div v-if="syncResults[project.id]!.errors.length > 0" class="mt-1">
|
|
||||||
<div v-for="err in syncResults[project.id]!.errors" :key="err" class="text-red-400">{{ err }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,87 +1,14 @@
|
||||||
/**
|
/**
|
||||||
* KIN-UI-013: Регрессионный тест — CSS-класс ошибки в SettingsView
|
* KIN-UI-013: Регрессионный тест — статический анализ SettingsView
|
||||||
*
|
*
|
||||||
* До фикса: .startsWith('Error') — хардкод английской строки, ломался при смене локали.
|
* Проверяет, что хардкод английской строки 'Error' в .startsWith() не используется.
|
||||||
* После фикса: .startsWith(t('common.error')) — использует i18n-ключ.
|
* Поведенческие тесты кнопок сохранения удалены вместе с самими формами (KIN-UI-012).
|
||||||
*
|
|
||||||
* Проверяет:
|
|
||||||
* 1. Литеральный .startsWith('Error') отсутствует в SettingsView.vue
|
|
||||||
* 2. При ошибке API — статусный span получает CSS-класс text-red-400
|
|
||||||
* 3. При успехе API — статусный span получает CSS-класс text-green-400
|
|
||||||
* 4. Покрывает все 5 статусных полей:
|
|
||||||
* saveStatus, saveTestStatus, saveDeployConfigStatus,
|
|
||||||
* saveAutoTestStatus, saveWorktreesStatus
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
import { describe, it, expect } from 'vitest'
|
||||||
import { mount, flushPromises } from '@vue/test-utils'
|
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'fs'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import SettingsView from '../SettingsView.vue'
|
|
||||||
|
|
||||||
vi.mock('../../api', async (importOriginal) => {
|
|
||||||
const actual = await importOriginal<typeof import('../../api')>()
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
api: {
|
|
||||||
projects: vi.fn(),
|
|
||||||
projectLinks: vi.fn(),
|
|
||||||
patchProject: vi.fn(),
|
|
||||||
syncObsidian: vi.fn(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
import { api } from '../../api'
|
|
||||||
|
|
||||||
const BASE_PROJECT = {
|
|
||||||
id: 'proj-1',
|
|
||||||
name: 'Test Project',
|
|
||||||
path: '/projects/test',
|
|
||||||
status: 'active',
|
|
||||||
priority: 5,
|
|
||||||
tech_stack: ['python'],
|
|
||||||
execution_mode: null as string | null,
|
|
||||||
autocommit_enabled: null,
|
|
||||||
auto_test_enabled: null,
|
|
||||||
worktrees_enabled: null as number | null,
|
|
||||||
obsidian_vault_path: null,
|
|
||||||
deploy_command: null,
|
|
||||||
test_command: null,
|
|
||||||
deploy_host: null,
|
|
||||||
deploy_path: null,
|
|
||||||
deploy_runtime: null,
|
|
||||||
deploy_restart_cmd: null,
|
|
||||||
created_at: '2024-01-01',
|
|
||||||
total_tasks: 0,
|
|
||||||
done_tasks: 0,
|
|
||||||
active_tasks: 0,
|
|
||||||
blocked_tasks: 0,
|
|
||||||
review_tasks: 0,
|
|
||||||
project_type: null,
|
|
||||||
ssh_host: null,
|
|
||||||
ssh_user: null,
|
|
||||||
ssh_key_path: null,
|
|
||||||
ssh_proxy_jump: null,
|
|
||||||
description: null,
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
vi.clearAllMocks()
|
|
||||||
vi.mocked(api.projectLinks).mockResolvedValue([])
|
|
||||||
})
|
|
||||||
|
|
||||||
async function mountSettings(overrides: Partial<typeof BASE_PROJECT> = {}) {
|
|
||||||
const project = { ...BASE_PROJECT, ...overrides }
|
|
||||||
vi.mocked(api.projects).mockResolvedValue([project as any])
|
|
||||||
const wrapper = mount(SettingsView)
|
|
||||||
await flushPromises()
|
|
||||||
return wrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 1. Статический анализ: .startsWith('Error') не используется
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView.vue — статический анализ', () => {
|
describe('SettingsView.vue — статический анализ', () => {
|
||||||
it("не содержит .startsWith('Error') (одинарные кавычки)", () => {
|
it("не содержит .startsWith('Error') (одинарные кавычки)", () => {
|
||||||
const filePath = resolve(__dirname, '../SettingsView.vue')
|
const filePath = resolve(__dirname, '../SettingsView.vue')
|
||||||
|
|
@ -94,123 +21,4 @@ describe('SettingsView.vue — статический анализ', () => {
|
||||||
const content = readFileSync(filePath, 'utf-8')
|
const content = readFileSync(filePath, 'utf-8')
|
||||||
expect(content).not.toContain('.startsWith("Error")')
|
expect(content).not.toContain('.startsWith("Error")')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('содержит .startsWith(t(\'common.error\')) — i18n-версию', () => {
|
|
||||||
const filePath = resolve(__dirname, '../SettingsView.vue')
|
|
||||||
const content = readFileSync(filePath, 'utf-8')
|
|
||||||
expect(content).toContain("startsWith(t('common.error'))")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 2. saveVaultPath — CSS-классы при ошибке и успехе
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — saveVaultPath CSS-классы', () => {
|
|
||||||
it('saveStatus: text-red-400 при ошибке API', async () => {
|
|
||||||
vi.mocked(api.patchProject).mockRejectedValue(new Error('network error'))
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text() === 'Save Vault')
|
|
||||||
expect(saveBtn?.exists()).toBe(true)
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
const errorSpan = wrapper.find('.text-red-400')
|
|
||||||
expect(errorSpan.exists()).toBe(true)
|
|
||||||
expect(errorSpan.text()).toMatch(/^Error:/)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('saveStatus: text-green-400 при успехе API', async () => {
|
|
||||||
vi.mocked(api.patchProject).mockResolvedValue({} as any)
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text() === 'Save Vault')
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
const successSpan = wrapper.find('.text-green-400')
|
|
||||||
expect(successSpan.exists()).toBe(true)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 3. saveTestCommand — CSS-класс при ошибке
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — saveTestCommand CSS-классы', () => {
|
|
||||||
it('saveTestStatus: text-red-400 при ошибке API', async () => {
|
|
||||||
vi.mocked(api.patchProject).mockRejectedValue(new Error('test save failed'))
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text() === 'Save Test')
|
|
||||||
expect(saveBtn?.exists()).toBe(true)
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
const errorSpan = wrapper.find('.text-red-400')
|
|
||||||
expect(errorSpan.exists()).toBe(true)
|
|
||||||
expect(errorSpan.text()).toMatch(/^Error:/)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 4. saveDeployConfig — CSS-класс при ошибке
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — saveDeployConfig CSS-классы', () => {
|
|
||||||
it('saveDeployConfigStatus: text-red-400 при ошибке API', async () => {
|
|
||||||
vi.mocked(api.patchProject).mockRejectedValue(new Error('deploy save failed'))
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
|
|
||||||
const saveBtn = wrapper.findAll('button').find(b => b.text() === 'Save Deploy Config')
|
|
||||||
expect(saveBtn?.exists()).toBe(true)
|
|
||||||
await saveBtn!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
const errorSpan = wrapper.find('.text-red-400')
|
|
||||||
expect(errorSpan.exists()).toBe(true)
|
|
||||||
expect(errorSpan.text()).toMatch(/^Error:/)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 5. toggleAutoTest — CSS-класс при ошибке
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — toggleAutoTest CSS-классы', () => {
|
|
||||||
it('saveAutoTestStatus: text-red-400 при ошибке API', async () => {
|
|
||||||
vi.mocked(api.patchProject).mockRejectedValue(new Error('auto-test toggle failed'))
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
|
|
||||||
const checkbox = wrapper.findAll('input[type="checkbox"]').find((el) => {
|
|
||||||
const label = el.element.closest('label')
|
|
||||||
return label?.textContent?.includes('Auto-test')
|
|
||||||
})
|
|
||||||
expect(checkbox?.exists()).toBe(true)
|
|
||||||
await checkbox!.trigger('change')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
const errorSpan = wrapper.find('.text-red-400')
|
|
||||||
expect(errorSpan.exists()).toBe(true)
|
|
||||||
expect(errorSpan.text()).toMatch(/^Error:/)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
// 6. toggleWorktrees — CSS-класс при ошибке
|
|
||||||
// ─────────────────────────────────────────────────────────────
|
|
||||||
describe('SettingsView — toggleWorktrees CSS-классы', () => {
|
|
||||||
it('saveWorktreesStatus: text-red-400 при ошибке API', async () => {
|
|
||||||
vi.mocked(api.patchProject).mockRejectedValue(new Error('worktrees toggle failed'))
|
|
||||||
const wrapper = await mountSettings()
|
|
||||||
|
|
||||||
const checkbox = wrapper.findAll('input[type="checkbox"]').find((el) => {
|
|
||||||
const label = el.element.closest('label')
|
|
||||||
return label?.textContent?.includes('Worktrees')
|
|
||||||
})
|
|
||||||
expect(checkbox?.exists()).toBe(true)
|
|
||||||
await checkbox!.trigger('change')
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
const errorSpan = wrapper.find('.text-red-400')
|
|
||||||
expect(errorSpan.exists()).toBe(true)
|
|
||||||
expect(errorSpan.text()).toMatch(/^Error:/)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* KIN-120: Тесты SettingsView — навигатор по настройкам проектов
|
* KIN-UI-012: Тесты SettingsView — навигатор по настройкам проектов
|
||||||
*
|
*
|
||||||
* После рефакторинга SettingsView стал навигатором:
|
* После рефакторинга SettingsView стал навигатором:
|
||||||
* показывает список проектов и ссылки на /project/{id}?tab=settings.
|
* показывает список проектов и ссылки на /project/{id}?tab=settings.
|
||||||
|
|
@ -23,8 +23,6 @@ vi.mock('../../api', async (importOriginal) => {
|
||||||
...actual,
|
...actual,
|
||||||
api: {
|
api: {
|
||||||
projects: vi.fn(),
|
projects: vi.fn(),
|
||||||
projectLinks: vi.fn(),
|
|
||||||
patchProject: vi.fn(),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -75,8 +73,6 @@ function makeRouter() {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
vi.mocked(api.projectLinks).mockResolvedValue([])
|
|
||||||
vi.mocked(api.patchProject).mockResolvedValue({} as any)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
async function mountSettings(overrides: Partial<typeof BASE_PROJECT> = {}) {
|
async function mountSettings(overrides: Partial<typeof BASE_PROJECT> = {}) {
|
||||||
|
|
@ -90,6 +86,11 @@ async function mountSettings(overrides: Partial<typeof BASE_PROJECT> = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('SettingsView — навигатор', () => {
|
describe('SettingsView — навигатор', () => {
|
||||||
|
it('таблица проектов рендерится', async () => {
|
||||||
|
const wrapper = await mountSettings()
|
||||||
|
expect(wrapper.find('table').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
it('показывает имя проекта', async () => {
|
it('показывает имя проекта', async () => {
|
||||||
const wrapper = await mountSettings()
|
const wrapper = await mountSettings()
|
||||||
expect(wrapper.text()).toContain('Test Project')
|
expect(wrapper.text()).toContain('Test Project')
|
||||||
|
|
@ -126,77 +127,23 @@ describe('SettingsView — навигатор', () => {
|
||||||
const wrapper = await mountSettings({ execution_mode: null })
|
const wrapper = await mountSettings({ execution_mode: null })
|
||||||
expect(wrapper.text()).not.toContain('auto_complete')
|
expect(wrapper.text()).not.toContain('auto_complete')
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// --- KIN-120: Isolation and field presence tests ---
|
it('для каждого проекта есть ссылка с ?tab=settings', async () => {
|
||||||
|
const projects = [
|
||||||
async function mountSettingsMultiple(projects: Partial<typeof BASE_PROJECT>[]) {
|
{ ...BASE_PROJECT, id: 'proj-1', name: 'Project One' },
|
||||||
vi.mocked(api.projects).mockResolvedValue(projects as any[])
|
{ ...BASE_PROJECT, id: 'proj-2', name: 'Project Two' },
|
||||||
|
{ ...BASE_PROJECT, id: 'proj-3', name: 'Project Three' },
|
||||||
|
]
|
||||||
|
vi.mocked(api.projects).mockResolvedValue(projects as any)
|
||||||
const router = makeRouter()
|
const router = makeRouter()
|
||||||
await router.push('/settings')
|
await router.push('/settings')
|
||||||
const wrapper = mount(SettingsView, { global: { plugins: [router] } })
|
const wrapper = mount(SettingsView, { global: { plugins: [router] } })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
return wrapper
|
|
||||||
|
for (const project of projects) {
|
||||||
|
const link = wrapper.find(`a[href*="${project.id}"]`)
|
||||||
|
expect(link.exists()).toBe(true)
|
||||||
|
expect(link.attributes('href')).toContain('tab=settings')
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('SettingsView — изоляция настроек проектов', () => {
|
|
||||||
it('obsidian_vault_path proj-1 и proj-2 независимы', async () => {
|
|
||||||
const proj1 = { ...BASE_PROJECT, id: 'proj-1', obsidian_vault_path: '/vault/proj1' }
|
|
||||||
const proj2 = { ...BASE_PROJECT, id: 'proj-2', name: 'Second Project', obsidian_vault_path: '/vault/proj2' }
|
|
||||||
const wrapper = await mountSettingsMultiple([proj1, proj2])
|
|
||||||
const inputs = wrapper.findAll('input[placeholder="/path/to/obsidian/vault"]')
|
|
||||||
expect(inputs).toHaveLength(2)
|
|
||||||
expect((inputs[0].element as HTMLInputElement).value).toBe('/vault/proj1')
|
|
||||||
expect((inputs[1].element as HTMLInputElement).value).toBe('/vault/proj2')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('test_command proj-1 не перекрывает test_command proj-2', async () => {
|
|
||||||
const proj1 = { ...BASE_PROJECT, id: 'proj-1', test_command: 'make test' }
|
|
||||||
const proj2 = { ...BASE_PROJECT, id: 'proj-2', name: 'Second Project', test_command: 'npm test' }
|
|
||||||
const wrapper = await mountSettingsMultiple([proj1, proj2])
|
|
||||||
const inputs = wrapper.findAll('input[placeholder="make test"]')
|
|
||||||
expect(inputs).toHaveLength(2)
|
|
||||||
expect((inputs[0].element as HTMLInputElement).value).toBe('make test')
|
|
||||||
expect((inputs[1].element as HTMLInputElement).value).toBe('npm test')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('deploy_host proj-1 не перекрывает deploy_host proj-2', async () => {
|
|
||||||
const proj1 = { ...BASE_PROJECT, id: 'proj-1', deploy_host: 'server-a' }
|
|
||||||
const proj2 = { ...BASE_PROJECT, id: 'proj-2', name: 'Second Project', deploy_host: 'server-b' }
|
|
||||||
const wrapper = await mountSettingsMultiple([proj1, proj2])
|
|
||||||
const inputs = wrapper.findAll('input[placeholder="server host (e.g. vdp-prod)"]')
|
|
||||||
expect(inputs).toHaveLength(2)
|
|
||||||
expect((inputs[0].element as HTMLInputElement).value).toBe('server-a')
|
|
||||||
expect((inputs[1].element as HTMLInputElement).value).toBe('server-b')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('SettingsView — наличие полей настроек', () => {
|
|
||||||
it('показывает поле obsidian_vault_path', async () => {
|
|
||||||
const wrapper = await mountSettings({ obsidian_vault_path: '/vault/test' })
|
|
||||||
const input = wrapper.find('input[placeholder="/path/to/obsidian/vault"]')
|
|
||||||
expect(input.exists()).toBe(true)
|
|
||||||
expect((input.element as HTMLInputElement).value).toBe('/vault/test')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('показывает поле test_command с корректным значением', async () => {
|
|
||||||
const wrapper = await mountSettings({ test_command: 'pytest tests/' })
|
|
||||||
const input = wrapper.find('input[placeholder="make test"]')
|
|
||||||
expect(input.exists()).toBe(true)
|
|
||||||
expect((input.element as HTMLInputElement).value).toBe('pytest tests/')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('показывает поле deploy_host', async () => {
|
|
||||||
const wrapper = await mountSettings({ deploy_host: 'my-server' })
|
|
||||||
const input = wrapper.find('input[placeholder="server host (e.g. vdp-prod)"]')
|
|
||||||
expect(input.exists()).toBe(true)
|
|
||||||
expect((input.element as HTMLInputElement).value).toBe('my-server')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('показывает поле deploy_path', async () => {
|
|
||||||
const wrapper = await mountSettings({ deploy_path: '/srv/app' })
|
|
||||||
const input = wrapper.find('input[placeholder="/srv/myproject"]')
|
|
||||||
expect(input.exists()).toBe(true)
|
|
||||||
expect((input.element as HTMLInputElement).value).toBe('/srv/app')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue