kin: KIN-UI-015-frontend_dev

This commit is contained in:
Gros Frumos 2026-03-18 15:50:08 +02:00
parent abd58e00f0
commit 62a483b62a
3 changed files with 12 additions and 71 deletions

View file

@ -19,8 +19,7 @@ vi.mock('vue-router', () => ({
vi.mock('../api', () => ({
api: {
notifications: vi.fn(),
projects: vi.fn(),
project: vi.fn(),
listTasks: vi.fn(),
reviseTask: vi.fn(),
},
}))
@ -38,40 +37,6 @@ const localStorageMock = (() => {
})()
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,
@ -93,21 +58,13 @@ function makeCompletedTask(id = 'TSK-1', title = 'Test task') {
}
}
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.listTasks).mockResolvedValue([])
vi.mocked(api.reviseTask).mockResolvedValue({ status: 'ok', comment: '' })
})
@ -116,13 +73,8 @@ afterEach(() => {
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))
async function mountWithCompleted(tasks = [makeCompletedTask()]) {
vi.mocked(api.listTasks).mockResolvedValue(tasks)
const wrapper = mount(EscalationBanner)
await flushPromises()
return wrapper
@ -158,7 +110,7 @@ describe('KIN-125 AC1: завершённые задачи отображают
})
it('Бейдж не отображается когда нет завершённых задач', async () => {
vi.mocked(api.projects).mockResolvedValue([makeProject('proj-1', 'P', 0)])
vi.mocked(api.listTasks).mockResolvedValue([])
const wrapper = mount(EscalationBanner)
await flushPromises()
const badge = wrapper.findAll('button').find(b => b.text().includes('Completed'))