kin: KIN-049 Кнопка Deploy на странице задачи после approve. Для каждого проекта настраивается deploy-команда (git push, scp, ssh restart). В Settings проекта.

This commit is contained in:
Gros Frumos 2026-03-16 08:21:13 +02:00
parent 860ef3f6c9
commit d50bd703ae
11 changed files with 517 additions and 61 deletions

View file

@ -28,6 +28,7 @@ vi.mock('../api', () => ({
createTask: vi.fn(),
patchTask: vi.fn(),
patchProject: vi.fn(),
deployProject: vi.fn(),
},
}))
@ -785,3 +786,126 @@ describe('KIN-015: TaskDetail — Edit button и форма редактиров
expect(wrapper.find('input:not([type])').exists(), 'Форма должна закрыться после сохранения').toBe(false)
})
})
// ─────────────────────────────────────────────────────────────
// KIN-049: TaskDetail — кнопка Deploy
// ─────────────────────────────────────────────────────────────
describe('KIN-049: TaskDetail — кнопка Deploy', () => {
function makeDeployTask(status: string, deployCommand: string | null) {
return {
id: 'KIN-049',
project_id: 'KIN',
title: 'Deploy Task',
status,
priority: 3,
assigned_role: null,
parent_task_id: null,
brief: null,
spec: null,
execution_mode: null,
project_deploy_command: deployCommand,
created_at: '2024-01-01',
updated_at: '2024-01-01',
pipeline_steps: [],
related_decisions: [],
}
}
it('Кнопка Deploy видна при status=done и project_deploy_command задан', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('done', 'git push origin main') as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const deployBtn = wrapper.findAll('button').find(b => b.text().includes('Deploy'))
expect(deployBtn?.exists(), 'Кнопка Deploy должна быть видна при done + deploy_command').toBe(true)
})
it('Кнопка Deploy скрыта при status=done но без project_deploy_command', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('done', null) as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const hasDeployBtn = wrapper.findAll('button').some(b => b.text().includes('Deploy'))
expect(hasDeployBtn, 'Deploy не должна быть видна без deploy_command').toBe(false)
})
it('Кнопка Deploy скрыта при status=pending (даже с deploy_command)', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('pending', 'git push') as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const hasDeployBtn = wrapper.findAll('button').some(b => b.text().includes('Deploy'))
expect(hasDeployBtn, 'Deploy не должна быть видна при статусе pending').toBe(false)
})
it('Кнопка Deploy скрыта при status=in_progress', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('in_progress', 'git push') as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const hasDeployBtn = wrapper.findAll('button').some(b => b.text().includes('Deploy'))
expect(hasDeployBtn, 'Deploy не должна быть видна при статусе in_progress').toBe(false)
})
it('Кнопка Deploy скрыта при status=review', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('review', 'git push') as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const hasDeployBtn = wrapper.findAll('button').some(b => b.text().includes('Deploy'))
expect(hasDeployBtn, 'Deploy не должна быть видна при статусе review').toBe(false)
})
it('Клик по Deploy вызывает api.deployProject с project_id задачи', async () => {
vi.mocked(api.taskFull).mockResolvedValue(makeDeployTask('done', 'echo ok') as any)
vi.mocked(api.deployProject).mockResolvedValue({
success: true, exit_code: 0, stdout: 'ok\n', stderr: '', duration_seconds: 0.1,
} as any)
const router = makeRouter()
await router.push('/task/KIN-049')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-049' },
global: { plugins: [router] },
})
await flushPromises()
const deployBtn = wrapper.findAll('button').find(b => b.text().includes('Deploy'))
await deployBtn!.trigger('click')
await flushPromises()
expect(api.deployProject).toHaveBeenCalledWith('KIN')
})
})