kin: auto-commit after pipeline

This commit is contained in:
Gros Frumos 2026-03-18 21:56:43 +02:00
parent 992dab962a
commit 38aebb7323
2 changed files with 280 additions and 0 deletions

View file

@ -0,0 +1,118 @@
/**
* KIN-UI-017: statusColor() в TaskDetail.vue возвращает 'orange' для статуса 'revising'
*
* Проверяет через DOM: Badge с color="orange" применяет класс text-orange-400
* (decision #837: badge-тест только через text-color класс как CSS-селектор)
*/
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { mount, flushPromises } from '@vue/test-utils'
import { createRouter, createMemoryHistory } from 'vue-router'
import TaskDetail from '../views/TaskDetail.vue'
vi.mock('../api', () => ({
api: {
taskFull: vi.fn(),
patchTask: vi.fn(),
runTask: vi.fn(),
approveTask: vi.fn(),
rejectTask: vi.fn(),
reviseTask: vi.fn(),
followupTask: vi.fn(),
deployProject: vi.fn(),
getAttachments: vi.fn(),
resolveAction: 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 })
const Stub = { template: '<div />' }
function makeRouter() {
return createRouter({
history: createMemoryHistory(),
routes: [
{ path: '/', component: Stub },
{ path: '/task/:id', component: TaskDetail, props: true },
],
})
}
const REVISING_TASK_FULL = {
id: 'KIN-001',
project_id: 'KIN',
title: 'Задача на доработку',
status: 'revising',
priority: 5,
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-01',
updated_at: '2024-01-01',
pipeline_steps: [],
related_decisions: [],
pending_actions: [],
pipeline_id: null,
project_deploy_command: null,
project_deploy_runtime: null,
}
beforeEach(() => {
localStorageMock.clear()
vi.clearAllMocks()
vi.mocked(api.taskFull).mockResolvedValue(REVISING_TASK_FULL as any)
vi.mocked(api.getAttachments).mockResolvedValue([])
})
describe('KIN-UI-017: TaskDetail — statusColor() для статуса revising', () => {
it('statusColor("revising") возвращает "orange" — Badge рендерится с классом text-orange-400', async () => {
const router = makeRouter()
await router.push('/task/KIN-001')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-001' },
global: { plugins: [router] },
})
await flushPromises()
// decision #837: badge-тест через text-color класс как селектор
const orangeBadge = wrapper.find('.text-orange-400')
expect(orangeBadge.exists(), 'Badge с color=orange должен рендерить класс text-orange-400').toBe(true)
})
it('statusColor("revising") — Badge НЕ применяет классы других статусов (не gray, не blue)', async () => {
const router = makeRouter()
await router.push('/task/KIN-001')
const wrapper = mount(TaskDetail, {
props: { id: 'KIN-001' },
global: { plugins: [router] },
})
await flushPromises()
// status-badge не должен быть серым (pending) или синим (in_progress)
const header = wrapper.find('h1')
expect(header.exists()).toBe(true)
// Ищем Badge рядом с заголовком задачи — он должен быть orange, не gray/blue
const grayBadgeInHeader = wrapper.find('.text-gray-400.text-xs.rounded')
// text-gray-400 может встречаться в других элементах, но мы проверяем наличие orange
const orangeBadge = wrapper.find('.text-orange-400')
expect(orangeBadge.exists()).toBe(true)
})
})