kin: auto-commit after pipeline
This commit is contained in:
parent
12fed3e31f
commit
49ea6542b8
8 changed files with 720 additions and 35 deletions
|
|
@ -2,7 +2,9 @@ import { createI18n } from 'vue-i18n'
|
||||||
import ru from './locales/ru.json'
|
import ru from './locales/ru.json'
|
||||||
import en from './locales/en.json'
|
import en from './locales/en.json'
|
||||||
|
|
||||||
const savedLocale = localStorage.getItem('kin-locale') || 'ru'
|
const savedLocale = (typeof localStorage !== 'undefined' && typeof localStorage.getItem === 'function'
|
||||||
|
? localStorage.getItem('kin-locale')
|
||||||
|
: null) || 'en'
|
||||||
|
|
||||||
export const i18n = createI18n({
|
export const i18n = createI18n({
|
||||||
legacy: false,
|
legacy: false,
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
"back_to_project": "← Project",
|
"back_to_project": "← Project",
|
||||||
"chat_label": "— chat",
|
"chat_label": "— chat",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
"server_unavailable": "Server unavailable. Check your connection.",
|
"server_unavailable": "Сервер недоступен. Проверьте подключение.",
|
||||||
"empty_hint": "Describe a task or ask about the project status",
|
"empty_hint": "Describe a task or ask about the project status",
|
||||||
"input_placeholder": "Describe a task or question... (Enter — send, Shift+Enter — newline)",
|
"input_placeholder": "Describe a task or question... (Enter — send, Shift+Enter — newline)",
|
||||||
"send": "Send",
|
"send": "Send",
|
||||||
|
|
@ -159,10 +159,10 @@
|
||||||
"revise_placeholder": "What to revise or clarify...",
|
"revise_placeholder": "What to revise or clarify...",
|
||||||
"autopilot_active": "Autopilot active",
|
"autopilot_active": "Autopilot active",
|
||||||
"attachments": "Attachments",
|
"attachments": "Attachments",
|
||||||
"more_details": "↓ more details",
|
"more_details": "↓ подробнее",
|
||||||
"terminal_login_hint": "Open a terminal and run:",
|
"terminal_login_hint": "Open a terminal and run:",
|
||||||
"login_after_hint": "After login, retry the pipeline.",
|
"login_after_hint": "After login, retry the pipeline.",
|
||||||
"dependent_projects": "Dependent projects:",
|
"dependent_projects": "Зависимые проекты:",
|
||||||
"decision_title_placeholder": "Decision title (optional)",
|
"decision_title_placeholder": "Decision title (optional)",
|
||||||
"description_placeholder": "Description",
|
"description_placeholder": "Description",
|
||||||
"brief_label": "Brief",
|
"brief_label": "Brief",
|
||||||
|
|
@ -181,7 +181,8 @@
|
||||||
"kanban_tab": "Kanban",
|
"kanban_tab": "Kanban",
|
||||||
"links_tab": "Links",
|
"links_tab": "Links",
|
||||||
"add_task": "+ Task",
|
"add_task": "+ Task",
|
||||||
"audit_backlog": "Audit backlog",
|
"audit_backlog": "Аудит бэклога",
|
||||||
|
"kanban_add_task": "+ Тас",
|
||||||
"back": "← back",
|
"back": "← back",
|
||||||
"deploy": "Deploy",
|
"deploy": "Deploy",
|
||||||
"kanban_pending": "Pending",
|
"kanban_pending": "Pending",
|
||||||
|
|
@ -196,7 +197,8 @@
|
||||||
"worktrees_on": "Worktrees: on",
|
"worktrees_on": "Worktrees: on",
|
||||||
"worktrees_off": "Worktrees: off",
|
"worktrees_off": "Worktrees: off",
|
||||||
"all_statuses": "All",
|
"all_statuses": "All",
|
||||||
"search_placeholder": "Search tasks...",
|
"search_placeholder": "Поиск по задачам...",
|
||||||
|
"kanban_search_placeholder": "Поиск...",
|
||||||
"manual_escalations_warn": "⚠ Require manual resolution",
|
"manual_escalations_warn": "⚠ Require manual resolution",
|
||||||
"comment_required": "Comment required",
|
"comment_required": "Comment required",
|
||||||
"select_project": "Select project",
|
"select_project": "Select project",
|
||||||
|
|
@ -225,10 +227,10 @@
|
||||||
"dismiss": "Dismiss"
|
"dismiss": "Dismiss"
|
||||||
},
|
},
|
||||||
"liveConsole": {
|
"liveConsole": {
|
||||||
"hide_log": "▲ Hide log",
|
"hide_log": "▲ Скрыть лог",
|
||||||
"show_log": "▼ Show log",
|
"show_log": "▼ Показать лог",
|
||||||
"no_records": "No records...",
|
"no_records": "Нет записей...",
|
||||||
"error_prefix": "Error:"
|
"error_prefix": "Ошибка:"
|
||||||
},
|
},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"images_only": "Only images are supported",
|
"images_only": "Only images are supported",
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,7 @@
|
||||||
"links_tab": "Связи",
|
"links_tab": "Связи",
|
||||||
"add_task": "+ Задача",
|
"add_task": "+ Задача",
|
||||||
"audit_backlog": "Аудит бэклога",
|
"audit_backlog": "Аудит бэклога",
|
||||||
|
"kanban_add_task": "+ Тас",
|
||||||
"back": "← назад",
|
"back": "← назад",
|
||||||
"deploy": "Деплой",
|
"deploy": "Деплой",
|
||||||
"kanban_pending": "Ожидает",
|
"kanban_pending": "Ожидает",
|
||||||
|
|
@ -197,6 +198,7 @@
|
||||||
"worktrees_off": "Worktrees: выкл",
|
"worktrees_off": "Worktrees: выкл",
|
||||||
"all_statuses": "Все",
|
"all_statuses": "Все",
|
||||||
"search_placeholder": "Поиск по задачам...",
|
"search_placeholder": "Поиск по задачам...",
|
||||||
|
"kanban_search_placeholder": "Поиск...",
|
||||||
"manual_escalations_warn": "⚠ Требуют ручного решения",
|
"manual_escalations_warn": "⚠ Требуют ручного решения",
|
||||||
"comment_required": "Комментарий обязателен",
|
"comment_required": "Комментарий обязателен",
|
||||||
"select_project": "Выберите проект",
|
"select_project": "Выберите проект",
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ function checkAndPoll() {
|
||||||
if (!hasRunningTasks(updated)) stopPoll()
|
if (!hasRunningTasks(updated)) stopPoll()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
consecutiveErrors.value++
|
consecutiveErrors.value++
|
||||||
console.warn('[polling] error #' + consecutiveErrors.value + ':', e)
|
console.warn(`[polling] ошибка #${consecutiveErrors.value}:`, e)
|
||||||
if (consecutiveErrors.value >= 3) {
|
if (consecutiveErrors.value >= 3) {
|
||||||
error.value = t('chat.server_unavailable')
|
error.value = t('chat.server_unavailable')
|
||||||
stopPoll()
|
stopPoll()
|
||||||
|
|
|
||||||
|
|
@ -1324,7 +1324,7 @@ async function addDecision() {
|
||||||
<div v-if="activeTab === 'kanban'" class="pb-4">
|
<div v-if="activeTab === 'kanban'" class="pb-4">
|
||||||
<div class="flex items-center justify-between gap-2 mb-3">
|
<div class="flex items-center justify-between gap-2 mb-3">
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
<input v-model="taskSearch" :placeholder="t('projectView.search_placeholder')"
|
<input v-model="taskSearch" :placeholder="t('projectView.kanban_search_placeholder')"
|
||||||
class="bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300 placeholder-gray-600 w-48 focus:border-gray-500 outline-none" />
|
class="bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300 placeholder-gray-600 w-48 focus:border-gray-500 outline-none" />
|
||||||
<button v-if="taskSearch" @click="taskSearch = ''"
|
<button v-if="taskSearch" @click="taskSearch = ''"
|
||||||
class="text-gray-600 hover:text-red-400 text-xs px-1">✕</button>
|
class="text-gray-600 hover:text-red-400 text-xs px-1">✕</button>
|
||||||
|
|
@ -1370,7 +1370,7 @@ async function addDecision() {
|
||||||
</button>
|
</button>
|
||||||
<button @click="showAddTask = true"
|
<button @click="showAddTask = true"
|
||||||
class="px-3 py-1 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700">
|
class="px-3 py-1 text-xs bg-gray-800 text-gray-300 border border-gray-700 rounded hover:bg-gray-700">
|
||||||
{{ t('projectView.add_task') }}
|
{{ t('projectView.kanban_add_task') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,450 @@
|
||||||
<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 } from '../api'
|
import { api, type Project, type ObsidianSyncResult, type ProjectLink } from '../api'
|
||||||
import Badge from '../components/Badge.vue'
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const projects = ref<Project[]>([])
|
const projects = ref<Project[]>([])
|
||||||
const loading = ref(true)
|
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)
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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>
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-xl font-semibold text-gray-100 mb-2">{{ t('settings.title') }}</h1>
|
<h1 class="text-xl font-semibold text-gray-100 mb-6">{{ t('settings.title') }}</h1>
|
||||||
<p class="text-xs text-gray-500 mb-6">{{ t('settings.navigate_hint') }}</p>
|
|
||||||
|
|
||||||
<div v-if="loading" class="text-gray-500 text-sm">{{ t('common.loading') }}</div>
|
<div v-if="error" class="text-red-400 mb-4">{{ error }}</div>
|
||||||
<div v-else-if="error" class="text-red-400 mb-4">{{ error }}</div>
|
|
||||||
<div v-else class="space-y-2">
|
<div v-for="project in projects" :key="project.id" class="mb-6 p-4 border border-gray-700 rounded-lg">
|
||||||
<div v-for="project in projects" :key="project.id"
|
<div class="flex items-center gap-3 mb-3">
|
||||||
class="flex items-center justify-between px-4 py-3 border border-gray-700 rounded-lg hover:border-gray-600 transition-colors">
|
|
||||||
<div class="flex items-center gap-3 min-w-0">
|
|
||||||
<span class="font-medium text-gray-100">{{ project.name }}</span>
|
<span class="font-medium text-gray-100">{{ project.name }}</span>
|
||||||
<span class="text-xs text-gray-500 font-mono shrink-0">{{ project.id }}</span>
|
<span class="text-xs text-gray-500 font-mono">{{ project.id }}</span>
|
||||||
<Badge :text="project.status" :color="project.status === 'active' ? 'green' : 'gray'" />
|
|
||||||
<span v-if="project.execution_mode" class="text-xs text-gray-500 shrink-0">{{ project.execution_mode }}</span>
|
<span v-if="project.execution_mode" class="text-xs text-gray-500 shrink-0">{{ project.execution_mode }}</span>
|
||||||
</div>
|
<a :href="'/project/' + project.id + '?tab=settings'"
|
||||||
<router-link
|
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">
|
||||||
:to="{ path: `/project/${project.id}`, query: { 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 shrink-0 ml-4">
|
|
||||||
{{ t('settings.open_settings') }}
|
{{ t('settings.open_settings') }}
|
||||||
</router-link>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="block text-xs text-gray-400 mb-1">{{ t('settings.obsidian_vault_path') }}</label>
|
||||||
|
<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('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('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('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('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('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>
|
||||||
|
|
|
||||||
200
web/frontend/src/views/__tests__/ProjectView.settings.test.ts
Normal file
200
web/frontend/src/views/__tests__/ProjectView.settings.test.ts
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
/**
|
||||||
|
* KIN-120: Тесты ProjectView — вкладка Settings
|
||||||
|
*
|
||||||
|
* Проверяет:
|
||||||
|
* 1. Вкладка Settings активируется при route.query.tab=settings
|
||||||
|
* 2. Вкладка Settings не показывается по умолчанию (tasks активен)
|
||||||
|
* 3. Форма настроек заполняется данными из проекта
|
||||||
|
* 4. Поля deploy_host, ssh_host присутствуют в Settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||||
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
|
import { createRouter, createMemoryHistory } from 'vue-router'
|
||||||
|
import ProjectView from '../ProjectView.vue'
|
||||||
|
|
||||||
|
vi.mock('../../api', async (importOriginal) => {
|
||||||
|
const actual = await importOriginal<typeof import('../../api')>()
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
api: {
|
||||||
|
project: vi.fn(),
|
||||||
|
projects: vi.fn(),
|
||||||
|
getPhases: vi.fn(),
|
||||||
|
environments: vi.fn(),
|
||||||
|
projectLinks: vi.fn(),
|
||||||
|
patchProject: vi.fn(),
|
||||||
|
syncObsidian: vi.fn(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
import { api } from '../../api'
|
||||||
|
|
||||||
|
// localStorage mock (required: ProjectView calls localStorage synchronously in setup)
|
||||||
|
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 BASE_PROJECT_DETAIL = {
|
||||||
|
id: 'proj-1',
|
||||||
|
name: 'Test Project',
|
||||||
|
path: '/projects/test',
|
||||||
|
status: 'active',
|
||||||
|
priority: 5,
|
||||||
|
tech_stack: ['python'],
|
||||||
|
execution_mode: 'review',
|
||||||
|
autocommit_enabled: 0,
|
||||||
|
auto_test_enabled: 0,
|
||||||
|
worktrees_enabled: 0,
|
||||||
|
obsidian_vault_path: '/vault/test',
|
||||||
|
deploy_command: 'git push',
|
||||||
|
test_command: 'make test',
|
||||||
|
deploy_host: 'vdp-prod',
|
||||||
|
deploy_path: '/srv/proj',
|
||||||
|
deploy_runtime: 'python',
|
||||||
|
deploy_restart_cmd: '',
|
||||||
|
created_at: '2024-01-01',
|
||||||
|
total_tasks: 0,
|
||||||
|
done_tasks: 0,
|
||||||
|
active_tasks: 0,
|
||||||
|
blocked_tasks: 0,
|
||||||
|
review_tasks: 0,
|
||||||
|
project_type: 'development',
|
||||||
|
ssh_host: 'my-ssh-server',
|
||||||
|
ssh_user: 'root',
|
||||||
|
ssh_key_path: '~/.ssh/id_rsa',
|
||||||
|
ssh_proxy_jump: 'jumpt',
|
||||||
|
description: null,
|
||||||
|
tasks: [],
|
||||||
|
modules: [],
|
||||||
|
decisions: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeRouter() {
|
||||||
|
return createRouter({
|
||||||
|
history: createMemoryHistory(),
|
||||||
|
routes: [
|
||||||
|
{ path: '/project/:id', component: ProjectView, props: true },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
localStorageMock.clear()
|
||||||
|
vi.clearAllMocks()
|
||||||
|
vi.mocked(api.project).mockResolvedValue(BASE_PROJECT_DETAIL as any)
|
||||||
|
vi.mocked(api.projects).mockResolvedValue([])
|
||||||
|
vi.mocked(api.getPhases).mockResolvedValue([])
|
||||||
|
vi.mocked(api.environments).mockResolvedValue([])
|
||||||
|
vi.mocked(api.projectLinks).mockResolvedValue([])
|
||||||
|
vi.mocked(api.patchProject).mockResolvedValue(BASE_PROJECT_DETAIL as any)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('ProjectView — вкладка Settings', () => {
|
||||||
|
it('вкладка settings активируется при route.query.tab=settings', async () => {
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/project/proj-1?tab=settings')
|
||||||
|
const wrapper = mount(ProjectView, {
|
||||||
|
props: { id: 'proj-1' },
|
||||||
|
global: { plugins: [router] },
|
||||||
|
})
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
// execution_mode select с опциями review/auto_complete — только в settings tab
|
||||||
|
const selects = wrapper.findAll('select')
|
||||||
|
const modeSelect = selects.find(s =>
|
||||||
|
s.findAll('option').some(o => o.attributes('value') === 'auto_complete')
|
||||||
|
)
|
||||||
|
expect(modeSelect?.exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('вкладка settings не открывается без query tab=settings', async () => {
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/project/proj-1')
|
||||||
|
const wrapper = mount(ProjectView, {
|
||||||
|
props: { id: 'proj-1' },
|
||||||
|
global: { plugins: [router] },
|
||||||
|
})
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
// settings form должна быть скрыта (tasks tab по умолчанию)
|
||||||
|
const selects = wrapper.findAll('select')
|
||||||
|
const modeSelect = selects.find(s =>
|
||||||
|
s.findAll('option').some(o => o.attributes('value') === 'auto_complete')
|
||||||
|
)
|
||||||
|
expect(modeSelect).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('форма settings заполняется test_command из проекта', async () => {
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/project/proj-1?tab=settings')
|
||||||
|
const wrapper = mount(ProjectView, {
|
||||||
|
props: { id: 'proj-1' },
|
||||||
|
global: { plugins: [router] },
|
||||||
|
})
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
const testCommandInput = wrapper.find('input[placeholder="make test"]')
|
||||||
|
expect(testCommandInput.exists()).toBe(true)
|
||||||
|
expect((testCommandInput.element as HTMLInputElement).value).toBe('make test')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('форма settings заполняется deploy_host из проекта', async () => {
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/project/proj-1?tab=settings')
|
||||||
|
const wrapper = mount(ProjectView, {
|
||||||
|
props: { id: 'proj-1' },
|
||||||
|
global: { plugins: [router] },
|
||||||
|
})
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
const deployHostInput = wrapper.find('input[placeholder="vdp-prod"]')
|
||||||
|
expect(deployHostInput.exists()).toBe(true)
|
||||||
|
expect((deployHostInput.element as HTMLInputElement).value).toBe('vdp-prod')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('форма settings показывает и заполняет ssh_key_path из проекта', async () => {
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/project/proj-1?tab=settings')
|
||||||
|
const wrapper = mount(ProjectView, {
|
||||||
|
props: { id: 'proj-1' },
|
||||||
|
global: { plugins: [router] },
|
||||||
|
})
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
// ssh_key_path имеет уникальный placeholder, это надёжный способ найти SSH секцию
|
||||||
|
const sshKeyInput = wrapper.find('input[placeholder="~/.ssh/id_rsa"]')
|
||||||
|
expect(sshKeyInput.exists()).toBe(true)
|
||||||
|
expect((sshKeyInput.element as HTMLInputElement).value).toBe('~/.ssh/id_rsa')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('форма settings заполняет execution_mode из проекта', async () => {
|
||||||
|
vi.mocked(api.project).mockResolvedValue({
|
||||||
|
...BASE_PROJECT_DETAIL,
|
||||||
|
execution_mode: 'auto_complete',
|
||||||
|
} as any)
|
||||||
|
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/project/proj-1?tab=settings')
|
||||||
|
const wrapper = mount(ProjectView, {
|
||||||
|
props: { id: 'proj-1' },
|
||||||
|
global: { plugins: [router] },
|
||||||
|
})
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
const selects = wrapper.findAll('select')
|
||||||
|
const modeSelect = selects.find(s =>
|
||||||
|
s.findAll('option').some(o => o.attributes('value') === 'auto_complete')
|
||||||
|
)
|
||||||
|
expect(modeSelect?.exists()).toBe(true)
|
||||||
|
expect((modeSelect!.element as HTMLSelectElement).value).toBe('auto_complete')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -23,6 +23,8 @@ vi.mock('../../api', async (importOriginal) => {
|
||||||
...actual,
|
...actual,
|
||||||
api: {
|
api: {
|
||||||
projects: vi.fn(),
|
projects: vi.fn(),
|
||||||
|
projectLinks: vi.fn(),
|
||||||
|
patchProject: vi.fn(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -73,6 +75,8 @@ 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> = {}) {
|
||||||
|
|
@ -123,3 +127,76 @@ describe('SettingsView — навигатор', () => {
|
||||||
expect(wrapper.text()).not.toContain('auto_complete')
|
expect(wrapper.text()).not.toContain('auto_complete')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// --- KIN-120: Isolation and field presence tests ---
|
||||||
|
|
||||||
|
async function mountSettingsMultiple(projects: Partial<typeof BASE_PROJECT>[]) {
|
||||||
|
vi.mocked(api.projects).mockResolvedValue(projects as any[])
|
||||||
|
const router = makeRouter()
|
||||||
|
await router.push('/settings')
|
||||||
|
const wrapper = mount(SettingsView, { global: { plugins: [router] } })
|
||||||
|
await flushPromises()
|
||||||
|
return wrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
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