feat(版本详情): 完善任务流程与风险预警
This commit is contained in:
@@ -27,20 +27,30 @@ function BugRowImpl({ bug, testCaseNo, onClick }: Props) {
|
|||||||
const members = useMemberStore((s) => s.members);
|
const members = useMemberStore((s) => s.members);
|
||||||
const assigneeName = resolveMemberDisplayName(bug.assigneeId, members);
|
const assigneeName = resolveMemberDisplayName(bug.assigneeId, members);
|
||||||
return (
|
return (
|
||||||
<div onClick={onClick} className="flex items-center gap-3 px-4 py-2.5 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0">
|
<div onClick={onClick} className="px-4 py-2 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0">
|
||||||
<span className={`h-2 w-2 rounded-full shrink-0 ${PRIORITY_DOT[bug.priority] || 'bg-zinc-300'}`} />
|
<div className="flex min-w-0 items-start gap-2">
|
||||||
<span className="text-[11px] font-mono text-[var(--ink-muted)] w-16 shrink-0">{bug.bugNo}</span>
|
<span className={`mt-1.5 h-2 w-2 shrink-0 rounded-full ${PRIORITY_DOT[bug.priority] || 'bg-zinc-300'}`} />
|
||||||
<span className="text-[13px] text-[var(--ink)] flex-1 truncate">{bug.title}</span>
|
<span className="mt-0.5 w-16 shrink-0 text-[11px] font-mono text-[var(--ink-muted)]">{bug.bugNo}</span>
|
||||||
<span className={`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${BUG_SEVERITY_COLOR[bug.severity]}`}>{BUG_SEVERITY_LABEL[bug.severity]}</span>
|
<div className="min-w-0 flex-1">
|
||||||
<BugStatusBadge status={bug.status} />
|
<div className="flex min-w-0 items-center gap-1.5">
|
||||||
<span className="text-[11px] text-[var(--ink-muted)] tabular-nums w-24 text-right shrink-0 whitespace-nowrap" title="计划修复时间">
|
<span className="truncate text-[13px] font-medium leading-5 text-[var(--ink)]">{bug.title}</span>
|
||||||
{bug.plannedFixAt ? formatDateTimeShort(bug.plannedFixAt) : '待排期'}
|
<span className="ml-auto inline-flex min-w-0 shrink-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 text-[11px]">
|
||||||
</span>
|
<span className="tabular-nums whitespace-nowrap text-[var(--ink-muted)]" title="计划修复时间">
|
||||||
{actualHours > 0 && (
|
{bug.plannedFixAt ? formatDateTimeShort(bug.plannedFixAt) : '待排期'}
|
||||||
<span className="text-[11px] text-[var(--ink-muted)] tabular-nums w-28 text-right shrink-0 whitespace-nowrap">{formatWorkHours(actualHours)}</span>
|
</span>
|
||||||
)}
|
{actualHours > 0 && (
|
||||||
{testCaseNo && <span className="text-[10px] font-mono text-[var(--ink-muted)] w-14 text-right shrink-0">{testCaseNo}</span>}
|
<span className="tabular-nums whitespace-nowrap text-[var(--ink-muted)]">实际 {formatWorkHours(actualHours)}</span>
|
||||||
<span className="text-[11px] text-[var(--ink-soft)] w-14 text-right truncate shrink-0">{assigneeName}</span>
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 flex min-w-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 text-[11px]">
|
||||||
|
<span className={`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${BUG_SEVERITY_COLOR[bug.severity]}`}>{BUG_SEVERITY_LABEL[bug.severity]}</span>
|
||||||
|
<BugStatusBadge status={bug.status} />
|
||||||
|
<span className="max-w-[120px] truncate whitespace-nowrap text-[var(--ink-soft)]">{assigneeName}</span>
|
||||||
|
{testCaseNo && <span className="font-mono text-[10px] text-[var(--ink-muted)]">{testCaseNo}</span>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { BugStatus } from '@/lib/bug';
|
|||||||
|
|
||||||
export function BugStatusBadge({ status }: { status: BugStatus }) {
|
export function BugStatusBadge({ status }: { status: BugStatus }) {
|
||||||
return (
|
return (
|
||||||
<span className={`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${BUG_STATUS_COLOR[status]}`}>
|
<span className={`inline-flex h-5 shrink-0 items-center whitespace-nowrap rounded px-1.5 text-[10px] font-medium ${BUG_STATUS_COLOR[status]}`}>
|
||||||
{BUG_STATUS_LABEL[status]}
|
{BUG_STATUS_LABEL[status]}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import type { CSSProperties } from 'react';
|
||||||
import type { TaskCategory } from '@/lib/task-category';
|
import type { TaskCategory } from '@/lib/task-category';
|
||||||
|
|
||||||
export function CategoryChip({ category }: { category?: TaskCategory }) {
|
export function CategoryChip({ category, widthEm }: { category?: TaskCategory; widthEm?: number }) {
|
||||||
if (!category) return <span className="text-[11px] text-[var(--ink-muted)]">未分类</span>;
|
const widthStyle: CSSProperties = widthEm ? { width: `${widthEm}em` } : {};
|
||||||
|
if (!category) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded px-1.5 text-[10px] font-medium text-[var(--ink-muted)]"
|
||||||
|
style={widthStyle}
|
||||||
|
>
|
||||||
|
未分类
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className="inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium"
|
className="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded px-1.5 text-[10px] font-medium"
|
||||||
style={{
|
style={{
|
||||||
|
...widthStyle,
|
||||||
backgroundColor: category.color ? `${category.color}15` : 'var(--bg-subtle)',
|
backgroundColor: category.color ? `${category.color}15` : 'var(--bg-subtle)',
|
||||||
color: category.color || 'var(--ink-soft)',
|
color: category.color || 'var(--ink-soft)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -9,16 +9,20 @@ import { useWorkActivityStore } from '@/stores/useWorkActivityStore';
|
|||||||
import { useTaskCategoryStore } from '@/stores/useTaskCategoryStore';
|
import { useTaskCategoryStore } from '@/stores/useTaskCategoryStore';
|
||||||
import { useRequirementStore } from '@/stores/useRequirementStore';
|
import { useRequirementStore } from '@/stores/useRequirementStore';
|
||||||
import { useMemberStore } from '@/stores/useMemberStore';
|
import { useMemberStore } from '@/stores/useMemberStore';
|
||||||
|
import { useAuthStore } from '@/stores/useAuthStore';
|
||||||
|
import { WorkDateTimePicker } from '@/components/WorkDateTimePicker';
|
||||||
import {
|
import {
|
||||||
ALLOWED_TRANSITIONS,
|
ALLOWED_TRANSITIONS,
|
||||||
DEV_TASK_STATUS_LABEL,
|
DEV_TASK_STATUS_LABEL,
|
||||||
DEV_TASK_STATUS_COLOR,
|
DEV_TASK_STATUS_COLOR,
|
||||||
|
canStartDevTask,
|
||||||
formatHours,
|
formatHours,
|
||||||
getEstimateHours,
|
getEstimateHours,
|
||||||
getActualHours,
|
getActualHours,
|
||||||
|
needsDevTaskClaim,
|
||||||
} from '@/lib/dev-task';
|
} from '@/lib/dev-task';
|
||||||
import { needsDelayReason } from '@/lib/dev-task-transitions';
|
import { needsDelayReason } from '@/lib/dev-task-transitions';
|
||||||
import { formatShortTime } from '@/lib/work-hours';
|
import { calcWorkHours, formatShortTime, isoToLocal, localToISO } from '@/lib/work-hours';
|
||||||
import type { DevTaskStatus } from '@/lib/dev-task';
|
import type { DevTaskStatus } from '@/lib/dev-task';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -28,16 +32,32 @@ interface Props {
|
|||||||
contextLabel?: string;
|
contextLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultPlanStartLocal(): string {
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(9, 0, 0, 0);
|
||||||
|
return isoToLocal(d.toISOString());
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultPlanEndLocal(): string {
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(18, 0, 0, 0);
|
||||||
|
return isoToLocal(d.toISOString());
|
||||||
|
}
|
||||||
|
|
||||||
export function DevTaskDetailDrawer({ taskId, allTaskIds, onClose, contextLabel }: Props) {
|
export function DevTaskDetailDrawer({ taskId, allTaskIds, onClose, contextLabel }: Props) {
|
||||||
const { tasks, changeStatus, setBlocked, deleteTask, updateTask } = useDevTaskStore();
|
const { tasks, changeStatus, setBlocked, deleteTask, updateTask } = useDevTaskStore();
|
||||||
const addProgressNote = useWorkActivityStore((s) => s.addProgressNote);
|
const addProgressNote = useWorkActivityStore((s) => s.addProgressNote);
|
||||||
const { categories } = useTaskCategoryStore();
|
const { categories } = useTaskCategoryStore();
|
||||||
const { requirements } = useRequirementStore();
|
const { requirements } = useRequirementStore();
|
||||||
const { members } = useMemberStore();
|
const { members } = useMemberStore();
|
||||||
|
const user = useAuthStore((s) => s.user);
|
||||||
const [showTransfer, setShowTransfer] = useState(false);
|
const [showTransfer, setShowTransfer] = useState(false);
|
||||||
const [transferTo, setTransferTo] = useState('');
|
const [transferTo, setTransferTo] = useState('');
|
||||||
const [showDelayInput, setShowDelayInput] = useState(false);
|
const [showDelayInput, setShowDelayInput] = useState(false);
|
||||||
const [delayReason, setDelayReason] = useState('');
|
const [delayReason, setDelayReason] = useState('');
|
||||||
|
const [showPlanInput, setShowPlanInput] = useState(false);
|
||||||
|
const [planStartLocal, setPlanStartLocal] = useState('');
|
||||||
|
const [planEndLocal, setPlanEndLocal] = useState('');
|
||||||
const [progressNote, setProgressNote] = useState('');
|
const [progressNote, setProgressNote] = useState('');
|
||||||
const [progressBlocker, setProgressBlocker] = useState('');
|
const [progressBlocker, setProgressBlocker] = useState('');
|
||||||
const [progressHelperId, setProgressHelperId] = useState('');
|
const [progressHelperId, setProgressHelperId] = useState('');
|
||||||
@@ -61,8 +81,42 @@ export function DevTaskDetailDrawer({ taskId, allTaskIds, onClose, contextLabel
|
|||||||
const actual = useMemo(() => getActualHours(task), [task]);
|
const actual = useMemo(() => getActualHours(task), [task]);
|
||||||
const overrun = actual > estimate && estimate > 0;
|
const overrun = actual > estimate && estimate > 0;
|
||||||
const requireDelay = task.status === 'todo' && needsDelayReason(task);
|
const requireDelay = task.status === 'todo' && needsDelayReason(task);
|
||||||
|
const currentUserName = user?.name || '';
|
||||||
|
const needsClaim = needsDevTaskClaim(task);
|
||||||
|
const startReady = canStartDevTask(task);
|
||||||
|
const visibleNextStatuses = nextStatuses.filter((status) => status !== 'in_progress' || startReady);
|
||||||
|
const planStartISO = localToISO(planStartLocal);
|
||||||
|
const planEndISO = localToISO(planEndLocal);
|
||||||
|
const planStartBeforeEnd = Boolean(planStartISO && planEndISO && planStartISO < planEndISO);
|
||||||
|
const planEstimateHours = planStartBeforeEnd ? calcWorkHours(planStartISO, planEndISO) : 0;
|
||||||
|
|
||||||
|
const openPlanInput = () => {
|
||||||
|
setPlanStartLocal(task.expectedStartAt ? isoToLocal(task.expectedStartAt) : defaultPlanStartLocal());
|
||||||
|
setPlanEndLocal(task.expectedEndAt ? isoToLocal(task.expectedEndAt) : defaultPlanEndLocal());
|
||||||
|
setShowPlanInput(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSavePlan = () => {
|
||||||
|
const assigneeId = task.assigneeId || currentUserName;
|
||||||
|
if (!assigneeId) {
|
||||||
|
alert('领取前需要先登录或选择负责人');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!planStartBeforeEnd || planEstimateHours <= 0 || !planStartISO || !planEndISO) return;
|
||||||
|
updateTask(task.id, {
|
||||||
|
assigneeId,
|
||||||
|
expectedStartAt: planStartISO,
|
||||||
|
expectedEndAt: planEndISO,
|
||||||
|
estimateHours: planEstimateHours,
|
||||||
|
});
|
||||||
|
setShowPlanInput(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleTransition = (to: DevTaskStatus) => {
|
const handleTransition = (to: DevTaskStatus) => {
|
||||||
|
if (to === 'in_progress' && !startReady) {
|
||||||
|
openPlanInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (to === 'in_progress' && requireDelay && !showDelayInput) {
|
if (to === 'in_progress' && requireDelay && !showDelayInput) {
|
||||||
setShowDelayInput(true);
|
setShowDelayInput(true);
|
||||||
return;
|
return;
|
||||||
@@ -179,10 +233,10 @@ export function DevTaskDetailDrawer({ taskId, allTaskIds, onClose, contextLabel
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{nextStatuses.length > 0 && !showDelayInput && (
|
{visibleNextStatuses.length > 0 && !showDelayInput && (
|
||||||
<div className="flex items-center gap-2 pt-1 flex-wrap">
|
<div className="flex items-center gap-2 pt-1 flex-wrap">
|
||||||
<ChevronRight className="h-3.5 w-3.5 text-[var(--ink-muted)]" />
|
<ChevronRight className="h-3.5 w-3.5 text-[var(--ink-muted)]" />
|
||||||
{nextStatuses.map((s) => (
|
{visibleNextStatuses.map((s) => (
|
||||||
<button key={s} onClick={() => handleTransition(s)} className="h-8 px-4 rounded-lg text-[12px] font-medium bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)] transition-colors">
|
<button key={s} onClick={() => handleTransition(s)} className="h-8 px-4 rounded-lg text-[12px] font-medium bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)] transition-colors">
|
||||||
{DEV_TASK_STATUS_LABEL[s]}
|
{DEV_TASK_STATUS_LABEL[s]}
|
||||||
</button>
|
</button>
|
||||||
@@ -190,6 +244,61 @@ export function DevTaskDetailDrawer({ taskId, allTaskIds, onClose, contextLabel
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{task.status === 'todo' && !startReady && !showPlanInput && (
|
||||||
|
<div className="flex items-center gap-2 pt-1">
|
||||||
|
<button
|
||||||
|
onClick={openPlanInput}
|
||||||
|
disabled={needsClaim && !currentUserName}
|
||||||
|
className="h-8 px-4 rounded-lg text-[12px] font-medium bg-orange-500 text-white hover:bg-orange-600 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
{needsClaim ? '领取并填写计划' : '填写计划'}
|
||||||
|
</button>
|
||||||
|
<span className="text-[11px] text-[var(--ink-muted)]">
|
||||||
|
{needsClaim ? '领取时必须填写预计开始和预计截止' : '开始开发前需要补齐预计开始和预计截止'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showPlanInput && (
|
||||||
|
<div className="rounded-lg border border-orange-200 bg-orange-50 p-3 space-y-3">
|
||||||
|
<div className="text-[11px] font-medium text-orange-700">
|
||||||
|
{needsClaim ? '领取并填写计划' : '填写计划'}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<div>
|
||||||
|
<label className="mb-1 block text-[11px] text-orange-700">预计开始</label>
|
||||||
|
<WorkDateTimePicker
|
||||||
|
value={planStartLocal}
|
||||||
|
onChange={setPlanStartLocal}
|
||||||
|
placeholder="选择预计开始"
|
||||||
|
defaultHour={9}
|
||||||
|
className="bg-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="mb-1 block text-[11px] text-orange-700">预计截止</label>
|
||||||
|
<WorkDateTimePicker
|
||||||
|
value={planEndLocal}
|
||||||
|
onChange={setPlanEndLocal}
|
||||||
|
placeholder="选择预计截止"
|
||||||
|
defaultHour={18}
|
||||||
|
popoverAlign="right"
|
||||||
|
className="bg-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
<span className="text-[11px] text-orange-700">
|
||||||
|
执行预估:{planEstimateHours > 0 ? formatHours(planEstimateHours) : '请选择有效起止时间'}
|
||||||
|
</span>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button onClick={handleSavePlan} disabled={!planStartBeforeEnd || planEstimateHours <= 0} className="h-7 px-3 rounded text-[11px] font-medium bg-[var(--accent)] text-white disabled:opacity-50">保存</button>
|
||||||
|
<button onClick={() => setShowPlanInput(false)} className="h-7 px-2 text-[11px] text-orange-700">取消</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{showDelayInput && (
|
{showDelayInput && (
|
||||||
<div className="rounded-lg border border-orange-200 bg-orange-50 p-3 space-y-2">
|
<div className="rounded-lg border border-orange-200 bg-orange-50 p-3 space-y-2">
|
||||||
<div className="flex items-center gap-1.5 text-[11px] text-orange-700">
|
<div className="flex items-center gap-1.5 text-[11px] text-orange-700">
|
||||||
@@ -332,7 +441,7 @@ export function DevTaskDetailDrawer({ taskId, allTaskIds, onClose, contextLabel
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<User className="h-3 w-3 text-[var(--ink-muted)]" />
|
<User className="h-3 w-3 text-[var(--ink-muted)]" />
|
||||||
<span className="text-[var(--ink-muted)]">负责人</span>
|
<span className="text-[var(--ink-muted)]">负责人</span>
|
||||||
<span className="text-[var(--ink)] font-medium">{task.assigneeId}</span>
|
<span className={`font-medium ${needsClaim ? 'text-orange-600' : 'text-[var(--ink)]'}`}>{needsClaim ? '待领取' : task.assigneeId}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-[var(--ink-muted)]">优先级</span>
|
<span className="text-[var(--ink-muted)]">优先级</span>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { AlertTriangle } from 'lucide-react';
|
import { AlertTriangle } from 'lucide-react';
|
||||||
import { StatusBadge } from './StatusBadge';
|
import { StatusBadge } from './StatusBadge';
|
||||||
import { CategoryChip } from './CategoryChip';
|
import { CategoryChip } from './CategoryChip';
|
||||||
import { getEstimateHours, getActualHours } from '@/lib/dev-task';
|
import { getEstimateHours, getActualHours, needsDevTaskClaim } from '@/lib/dev-task';
|
||||||
import { formatShortTime, formatWorkHours } from '@/lib/work-hours';
|
import { formatShortTime, formatWorkHours } from '@/lib/work-hours';
|
||||||
import type { DevTask } from '@/lib/dev-task';
|
import type { DevTask } from '@/lib/dev-task';
|
||||||
import type { TaskCategory } from '@/lib/task-category';
|
import type { TaskCategory } from '@/lib/task-category';
|
||||||
@@ -11,6 +11,7 @@ import type { TaskCategory } from '@/lib/task-category';
|
|||||||
interface Props {
|
interface Props {
|
||||||
task: DevTask;
|
task: DevTask;
|
||||||
category?: TaskCategory;
|
category?: TaskCategory;
|
||||||
|
categoryLabelWidthEm?: number;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,37 +46,64 @@ function hoursText(task: DevTask, estimate: number, actual: number): { text: str
|
|||||||
return { text: `${formatWorkHours(actual)} / ${formatWorkHours(estimate)}`, tone };
|
return { text: `${formatWorkHours(actual)} / ${formatWorkHours(estimate)}`, tone };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DevTaskRow({ task, category, onClick }: Props) {
|
export function DevTaskRow({ task, category, categoryLabelWidthEm, onClick }: Props) {
|
||||||
const estimate = getEstimateHours(task);
|
const estimate = getEstimateHours(task);
|
||||||
const actual = getActualHours(task);
|
const actual = getActualHours(task);
|
||||||
const range = timeRangeText(task);
|
const range = timeRangeText(task);
|
||||||
const hours = hoursText(task, estimate, actual);
|
const hours = hoursText(task, estimate, actual);
|
||||||
|
const needsClaim = needsDevTaskClaim(task);
|
||||||
|
const labelWidthStyle = categoryLabelWidthEm ? { width: `${categoryLabelWidthEm}em` } : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={`flex items-center gap-3 px-4 py-2.5 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0 ${task.aiDraft ? 'border-l-2 border-l-purple-400 bg-purple-50/30' : ''}`}
|
className={`px-4 py-2 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0 ${task.aiDraft ? 'border-l-2 border-l-purple-400 bg-purple-50/30' : ''}`}
|
||||||
>
|
>
|
||||||
<span className={`h-2 w-2 rounded-full shrink-0 ${PRIORITY_DOT[task.priority] || 'bg-zinc-300'}`} title={task.priority} />
|
<div className="flex min-w-0 items-start gap-2">
|
||||||
<span className="text-[11px] font-mono text-[var(--ink-muted)] w-16 shrink-0">{task.taskNo}</span>
|
<span className={`mt-1.5 h-2 w-2 shrink-0 rounded-full ${PRIORITY_DOT[task.priority] || 'bg-zinc-300'}`} title={task.priority} />
|
||||||
<div className="flex-1 min-w-0 flex items-center gap-1.5">
|
<span className="mt-0.5 w-16 shrink-0 text-[11px] font-mono text-[var(--ink-muted)]">{task.taskNo}</span>
|
||||||
<span className="text-[13px] text-[var(--ink)] truncate">{task.title}</span>
|
<div className="min-w-0 flex-1">
|
||||||
{task.aiDraft && (
|
<div className="flex min-w-0 items-center gap-1.5">
|
||||||
<span className="flex items-center gap-0.5 text-[10px] text-purple-600 bg-purple-100 px-1.5 py-0.5 rounded shrink-0" title="AI 拆解草案,编辑后会移除标记">
|
<span className="truncate text-[13px] font-medium leading-5 text-[var(--ink)]">{task.title}</span>
|
||||||
AI 草案
|
<span className="ml-auto inline-flex min-w-0 shrink-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 text-[11px]">
|
||||||
</span>
|
{range.text && (
|
||||||
)}
|
<span className={`tabular-nums whitespace-nowrap ${range.tone}`} title={range.text}>{range.text}</span>
|
||||||
{task.isBlocked && (
|
)}
|
||||||
<span className="flex items-center gap-0.5 text-[10px] text-red-500 bg-red-50 px-1.5 py-0.5 rounded shrink-0" title={task.blockReason}>
|
<span className={`tabular-nums whitespace-nowrap ${hours.tone}`}>{hours.text}</span>
|
||||||
<AlertTriangle className="h-2.5 w-2.5" />阻塞
|
</span>
|
||||||
</span>
|
</div>
|
||||||
)}
|
<div className="mt-1 flex min-w-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 text-[11px]">
|
||||||
|
{task.isBlocked && (
|
||||||
|
<span className="inline-flex h-5 shrink-0 items-center gap-0.5 whitespace-nowrap rounded bg-red-50 px-1.5 text-[10px] font-medium text-red-500" title={task.blockReason}>
|
||||||
|
<AlertTriangle className="h-2.5 w-2.5" />阻塞
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{task.aiDraft && (
|
||||||
|
<span
|
||||||
|
className="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded bg-purple-100 px-1.5 text-[10px] font-medium text-purple-600"
|
||||||
|
style={labelWidthStyle}
|
||||||
|
title="AI 拆解草案,编辑后会移除标记"
|
||||||
|
>
|
||||||
|
AI 草案
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{!needsClaim && (
|
||||||
|
<span className="max-w-[140px] truncate whitespace-nowrap text-[var(--ink-soft)]">负责人:{task.assigneeId}</span>
|
||||||
|
)}
|
||||||
|
{needsClaim ? (
|
||||||
|
<span
|
||||||
|
className="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded bg-orange-50 px-1.5 text-[10px] font-medium text-orange-600"
|
||||||
|
style={labelWidthStyle}
|
||||||
|
>
|
||||||
|
待领取
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<StatusBadge status={task.status} widthEm={categoryLabelWidthEm} />
|
||||||
|
)}
|
||||||
|
<CategoryChip category={category} widthEm={categoryLabelWidthEm} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<CategoryChip category={category} />
|
|
||||||
<StatusBadge status={task.status} />
|
|
||||||
<span className={`text-[11px] tabular-nums shrink-0 ${range.tone}`} title={range.text}>{range.text}</span>
|
|
||||||
<span className={`text-[11px] tabular-nums w-40 text-right shrink-0 whitespace-nowrap ${hours.tone}`}>{hours.text}</span>
|
|
||||||
<span className="text-[11px] text-[var(--ink-soft)] w-14 text-right truncate shrink-0">{task.assigneeId}</span>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ export function DevTaskTab({ versionId, requirementIds, versionDeadline }: Props
|
|||||||
}, [paged]);
|
}, [paged]);
|
||||||
|
|
||||||
const categoryMap = useMemo(() => new Map(categories.map((c) => [c.id, c])), [categories]);
|
const categoryMap = useMemo(() => new Map(categories.map((c) => [c.id, c])), [categories]);
|
||||||
|
const categoryLabelWidthEm = useMemo(
|
||||||
|
() => Math.max(4, ...categories.map((category) => category.name.length)) + 1,
|
||||||
|
[categories],
|
||||||
|
);
|
||||||
const requirementMap = useMemo(() => new Map(requirements.map((r) => [r.id, r])), [requirements]);
|
const requirementMap = useMemo(() => new Map(requirements.map((r) => [r.id, r])), [requirements]);
|
||||||
const allTaskIds = useMemo(() => versionTasks.map((t) => t.id), [versionTasks]);
|
const allTaskIds = useMemo(() => versionTasks.map((t) => t.id), [versionTasks]);
|
||||||
|
|
||||||
@@ -179,11 +183,16 @@ export function DevTaskTab({ versionId, requirementIds, versionDeadline }: Props
|
|||||||
const reqProgress = calcGroupProgress(reqTasks);
|
const reqProgress = calcGroupProgress(reqTasks);
|
||||||
return (
|
return (
|
||||||
<div key={reqId} className="rounded-lg border border-[var(--line)] bg-[var(--bg-card)] overflow-hidden">
|
<div key={reqId} className="rounded-lg border border-[var(--line)] bg-[var(--bg-card)] overflow-hidden">
|
||||||
<div className="flex items-center gap-2 px-4 py-2 bg-[var(--bg-subtle)] border-b border-[var(--line)]">
|
<div className="flex items-center bg-[var(--bg-subtle)] border-b border-[var(--line)]">
|
||||||
<input type="checkbox" checked={reqTasks.every((t) => selectedIds.has(t.id))} onChange={() => { const ids = reqTasks.map((t) => t.id); const allSelected = ids.every((id) => selectedIds.has(id)); const next = new Set(selectedIds); if (allSelected) ids.forEach((id) => next.delete(id)); else ids.forEach((id) => next.add(id)); setSelectedIds(next); }} className="h-3.5 w-3.5 rounded border-[var(--line)]" />
|
<div className="pl-4 flex items-center">
|
||||||
<span className="text-[11px] font-mono text-[var(--ink-muted)]">{req?.code}</span>
|
<input type="checkbox" checked={reqTasks.every((t) => selectedIds.has(t.id))} onChange={() => { const ids = reqTasks.map((t) => t.id); const allSelected = ids.every((id) => selectedIds.has(id)); const next = new Set(selectedIds); if (allSelected) ids.forEach((id) => next.delete(id)); else ids.forEach((id) => next.add(id)); setSelectedIds(next); }} className="h-3.5 w-3.5 rounded border-[var(--line)]" />
|
||||||
<span className="text-[12px] font-medium text-[var(--ink)] flex-1 truncate">{req?.title}</span>
|
</div>
|
||||||
<span className="text-[11px] text-[var(--ink-muted)]">{reqProgress}%</span>
|
<div className="flex flex-1 min-w-0 items-center gap-2 px-4 py-2">
|
||||||
|
<span className="h-2 w-2 shrink-0" />
|
||||||
|
<span className="w-16 shrink-0 truncate text-[11px] font-mono text-[var(--ink-muted)]" title={req?.code}>{req?.code}</span>
|
||||||
|
<span className="min-w-0 flex-1 truncate text-[12px] font-medium text-[var(--ink)]">{req?.title}</span>
|
||||||
|
<span className="shrink-0 text-[11px] text-[var(--ink-muted)]">{reqProgress}%</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{reqTasks.map((t) => (
|
{reqTasks.map((t) => (
|
||||||
<div key={t.id} className="flex items-center">
|
<div key={t.id} className="flex items-center">
|
||||||
@@ -191,7 +200,7 @@ export function DevTaskTab({ versionId, requirementIds, versionDeadline }: Props
|
|||||||
<input type="checkbox" checked={selectedIds.has(t.id)} onChange={() => toggleSelect(t.id)} className="h-3.5 w-3.5 rounded border-[var(--line)]" onClick={(e) => e.stopPropagation()} />
|
<input type="checkbox" checked={selectedIds.has(t.id)} onChange={() => toggleSelect(t.id)} className="h-3.5 w-3.5 rounded border-[var(--line)]" onClick={(e) => e.stopPropagation()} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<DevTaskRow task={t} category={categoryMap.get(t.categoryId)} onClick={() => setSelectedTaskId(t.id)} />
|
<DevTaskRow task={t} category={categoryMap.get(t.categoryId)} categoryLabelWidthEm={categoryLabelWidthEm} onClick={() => setSelectedTaskId(t.id)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@
|
|||||||
import { DEV_TASK_STATUS_LABEL, DEV_TASK_STATUS_COLOR } from '@/lib/dev-task';
|
import { DEV_TASK_STATUS_LABEL, DEV_TASK_STATUS_COLOR } from '@/lib/dev-task';
|
||||||
import type { DevTaskStatus } from '@/lib/dev-task';
|
import type { DevTaskStatus } from '@/lib/dev-task';
|
||||||
|
|
||||||
export function StatusBadge({ status }: { status: DevTaskStatus }) {
|
export function StatusBadge({ status, widthEm }: { status: DevTaskStatus; widthEm?: number }) {
|
||||||
return (
|
return (
|
||||||
<span className={`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${DEV_TASK_STATUS_COLOR[status]}`}>
|
<span
|
||||||
|
className={`inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded px-1.5 text-[10px] font-medium ${DEV_TASK_STATUS_COLOR[status]}`}
|
||||||
|
style={widthEm ? { width: `${widthEm}em` } : undefined}
|
||||||
|
>
|
||||||
{DEV_TASK_STATUS_LABEL[status]}
|
{DEV_TASK_STATUS_LABEL[status]}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ function defaultPlannedTestLocal(): string {
|
|||||||
return isoToLocal(d.toISOString());
|
return isoToLocal(d.toISOString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultPlannedEndLocal(): string {
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(10, 0, 0, 0);
|
||||||
|
return isoToLocal(d.toISOString());
|
||||||
|
}
|
||||||
|
|
||||||
export function TestCaseCreateModal({ versionId, requirementIds, roundNo, onClose }: Props) {
|
export function TestCaseCreateModal({ versionId, requirementIds, roundNo, onClose }: Props) {
|
||||||
const { createTestCase } = useTestCaseStore();
|
const { createTestCase } = useTestCaseStore();
|
||||||
const { requirements } = useRequirementStore();
|
const { requirements } = useRequirementStore();
|
||||||
@@ -49,6 +55,7 @@ export function TestCaseCreateModal({ versionId, requirementIds, roundNo, onClos
|
|||||||
);
|
);
|
||||||
const [estimateHours, setEstimateHours] = useState(0.5);
|
const [estimateHours, setEstimateHours] = useState(0.5);
|
||||||
const [plannedTestLocal, setPlannedTestLocal] = useState(defaultPlannedTestLocal);
|
const [plannedTestLocal, setPlannedTestLocal] = useState(defaultPlannedTestLocal);
|
||||||
|
const [plannedEndLocal, setPlannedEndLocal] = useState(defaultPlannedEndLocal);
|
||||||
const [assigneeId, setAssigneeId] = useState(user?.name || '');
|
const [assigneeId, setAssigneeId] = useState(user?.name || '');
|
||||||
const [description, setDescription] = useState('');
|
const [description, setDescription] = useState('');
|
||||||
const [prototypeNotes, setPrototypeNotes] = useState('');
|
const [prototypeNotes, setPrototypeNotes] = useState('');
|
||||||
@@ -69,7 +76,9 @@ export function TestCaseCreateModal({ versionId, requirementIds, roundNo, onClos
|
|||||||
|
|
||||||
const normalizedEstimateHours = clampTestCaseEstimateHours(selectedCategory?.code, estimateHours);
|
const normalizedEstimateHours = clampTestCaseEstimateHours(selectedCategory?.code, estimateHours);
|
||||||
const plannedTestAt = localToISO(plannedTestLocal);
|
const plannedTestAt = localToISO(plannedTestLocal);
|
||||||
const canSubmit = title.trim() && categoryId && normalizedEstimateHours > 0 && Boolean(plannedTestAt);
|
const plannedEndAt = localToISO(plannedEndLocal);
|
||||||
|
const hasValidPlan = Boolean(plannedTestAt && plannedEndAt && plannedEndAt > plannedTestAt);
|
||||||
|
const canSubmit = title.trim() && categoryId && normalizedEstimateHours > 0 && hasValidPlan;
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (!canSubmit) return;
|
if (!canSubmit) return;
|
||||||
@@ -92,6 +101,7 @@ export function TestCaseCreateModal({ versionId, requirementIds, roundNo, onClos
|
|||||||
priority,
|
priority,
|
||||||
estimateHours: normalizedEstimateHours,
|
estimateHours: normalizedEstimateHours,
|
||||||
plannedTestAt,
|
plannedTestAt,
|
||||||
|
plannedEndAt,
|
||||||
assigneeId: assigneeId || undefined,
|
assigneeId: assigneeId || undefined,
|
||||||
references: references.length > 0 ? references : undefined,
|
references: references.length > 0 ? references : undefined,
|
||||||
createdBy: user?.name || '系统',
|
createdBy: user?.name || '系统',
|
||||||
@@ -154,15 +164,32 @@ export function TestCaseCreateModal({ versionId, requirementIds, roundNo, onClos
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<label className="block text-[12px] text-[var(--ink-soft)] mb-1">计划测试时间 *</label>
|
<div>
|
||||||
<WorkDateTimePicker
|
<label className="block text-[12px] text-[var(--ink-soft)] mb-1">计划开始 *</label>
|
||||||
value={plannedTestLocal}
|
<WorkDateTimePicker
|
||||||
onChange={setPlannedTestLocal}
|
value={plannedTestLocal}
|
||||||
placeholder="选择计划测试时间"
|
onChange={setPlannedTestLocal}
|
||||||
defaultHour={9}
|
placeholder="选择计划开始时间"
|
||||||
/>
|
defaultHour={9}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-[12px] text-[var(--ink-soft)] mb-1">计划结束 *</label>
|
||||||
|
<WorkDateTimePicker
|
||||||
|
value={plannedEndLocal}
|
||||||
|
onChange={setPlannedEndLocal}
|
||||||
|
placeholder="选择计划结束时间"
|
||||||
|
defaultHour={10}
|
||||||
|
popoverAlign="right"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{!hasValidPlan && plannedTestLocal && plannedEndLocal && (
|
||||||
|
<div className="rounded-lg border border-amber-200 bg-amber-50 p-2 text-[11px] text-amber-700">
|
||||||
|
计划开始必须早于计划结束
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-[12px] text-[var(--ink-soft)] mb-1">测试步骤 & 预期结果</label>
|
<label className="block text-[12px] text-[var(--ink-soft)] mb-1">测试步骤 & 预期结果</label>
|
||||||
<textarea rows={4} value={description} onChange={(e) => setDescription(e.target.value)} className="w-full rounded-lg border border-[var(--line)] bg-[var(--bg)] px-3 py-2 text-[13px] focus:border-[var(--accent)] focus:outline-none resize-none" placeholder="1. 操作步骤... 2. 预期结果..." />
|
<textarea rows={4} value={description} onChange={(e) => setDescription(e.target.value)} className="w-full rounded-lg border border-[var(--line)] bg-[var(--bg)] px-3 py-2 text-[13px] focus:border-[var(--accent)] focus:outline-none resize-none" placeholder="1. 操作步骤... 2. 预期结果..." />
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ import { useBugStore } from '@/stores/useBugStore';
|
|||||||
import { useRequirementStore } from '@/stores/useRequirementStore';
|
import { useRequirementStore } from '@/stores/useRequirementStore';
|
||||||
import { useMemberStore } from '@/stores/useMemberStore';
|
import { useMemberStore } from '@/stores/useMemberStore';
|
||||||
import { useTaskCategoryStore } from '@/stores/useTaskCategoryStore';
|
import { useTaskCategoryStore } from '@/stores/useTaskCategoryStore';
|
||||||
|
import { useAuthStore } from '@/stores/useAuthStore';
|
||||||
|
import { WorkDateTimePicker } from '@/components/WorkDateTimePicker';
|
||||||
import { CategoryChip } from '@/components/dev-task/CategoryChip';
|
import { CategoryChip } from '@/components/dev-task/CategoryChip';
|
||||||
import { TC_ALLOWED_TRANSITIONS, TEST_CASE_STATUS_LABEL, getTestCaseActualHours } from '@/lib/test-case';
|
import { TC_ALLOWED_TRANSITIONS, TEST_CASE_STATUS_LABEL, canStartTestCase, getTestCaseActualHours, needsTestCaseClaim } from '@/lib/test-case';
|
||||||
import { formatWorkHours } from '@/lib/work-hours';
|
import { calcWorkHours, formatWorkHours, isoToLocal, localToISO } from '@/lib/work-hours';
|
||||||
import { formatDateTime } from '@/lib/format';
|
import { formatDateTime } from '@/lib/format';
|
||||||
import { BUG_SEVERITY_LABEL, BUG_SEVERITY_COLOR } from '@/lib/bug';
|
import { BUG_SEVERITY_LABEL, BUG_SEVERITY_COLOR } from '@/lib/bug';
|
||||||
import type { TestCaseStatus } from '@/lib/test-case';
|
import type { TestCaseStatus } from '@/lib/test-case';
|
||||||
@@ -23,14 +25,30 @@ interface Props {
|
|||||||
contextLabel?: string;
|
contextLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultPlanStartLocal(): string {
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(9, 0, 0, 0);
|
||||||
|
return isoToLocal(d.toISOString());
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultPlanEndLocal(): string {
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(10, 0, 0, 0);
|
||||||
|
return isoToLocal(d.toISOString());
|
||||||
|
}
|
||||||
|
|
||||||
export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, contextLabel }: Props) {
|
export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, contextLabel }: Props) {
|
||||||
const { testCases, changeStatus, deleteTestCase, updateTestCase } = useTestCaseStore();
|
const { testCases, changeStatus, deleteTestCase, updateTestCase } = useTestCaseStore();
|
||||||
const { bugs } = useBugStore();
|
const { bugs } = useBugStore();
|
||||||
const { requirements } = useRequirementStore();
|
const { requirements } = useRequirementStore();
|
||||||
const { members } = useMemberStore();
|
const { members } = useMemberStore();
|
||||||
const { categories } = useTaskCategoryStore();
|
const { categories } = useTaskCategoryStore();
|
||||||
|
const user = useAuthStore((s) => s.user);
|
||||||
const [showTransfer, setShowTransfer] = useState(false);
|
const [showTransfer, setShowTransfer] = useState(false);
|
||||||
const [transferTo, setTransferTo] = useState('');
|
const [transferTo, setTransferTo] = useState('');
|
||||||
|
const [showPlanInput, setShowPlanInput] = useState(false);
|
||||||
|
const [planStartLocal, setPlanStartLocal] = useState('');
|
||||||
|
const [planEndLocal, setPlanEndLocal] = useState('');
|
||||||
|
|
||||||
const tc = testCases.find((c) => c.id === testCaseId);
|
const tc = testCases.find((c) => c.id === testCaseId);
|
||||||
if (!tc) return null;
|
if (!tc) return null;
|
||||||
@@ -42,6 +60,39 @@ export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, context
|
|||||||
const executorEstimateHours = typeof tc.estimateHours === 'number' && tc.estimateHours > 0 ? tc.estimateHours : undefined;
|
const executorEstimateHours = typeof tc.estimateHours === 'number' && tc.estimateHours > 0 ? tc.estimateHours : undefined;
|
||||||
const aiEstimateHours = typeof tc.aiEstimateHours === 'number' && tc.aiEstimateHours > 0 ? tc.aiEstimateHours : undefined;
|
const aiEstimateHours = typeof tc.aiEstimateHours === 'number' && tc.aiEstimateHours > 0 ? tc.aiEstimateHours : undefined;
|
||||||
const actualHours = getTestCaseActualHours(tc);
|
const actualHours = getTestCaseActualHours(tc);
|
||||||
|
const planDisplay = tc.plannedTestAt && tc.plannedEndAt
|
||||||
|
? `${formatDateTime(tc.plannedTestAt)} → ${formatDateTime(tc.plannedEndAt)}`
|
||||||
|
: tc.plannedTestAt ? formatDateTime(tc.plannedTestAt) : '-';
|
||||||
|
const currentUserName = user?.name || '';
|
||||||
|
const needsClaim = needsTestCaseClaim(tc);
|
||||||
|
const startReady = canStartTestCase(tc);
|
||||||
|
const visibleNextStatuses = nextStatuses.filter((status) => status !== 'running' || startReady);
|
||||||
|
const planStartISO = localToISO(planStartLocal);
|
||||||
|
const planEndISO = localToISO(planEndLocal);
|
||||||
|
const planStartBeforeEnd = Boolean(planStartISO && planEndISO && planEndISO > planStartISO);
|
||||||
|
const planEstimateHours = planStartBeforeEnd ? calcWorkHours(planStartISO, planEndISO) : 0;
|
||||||
|
|
||||||
|
const openPlanInput = () => {
|
||||||
|
setPlanStartLocal(tc.plannedTestAt ? isoToLocal(tc.plannedTestAt) : defaultPlanStartLocal());
|
||||||
|
setPlanEndLocal(tc.plannedEndAt ? isoToLocal(tc.plannedEndAt) : defaultPlanEndLocal());
|
||||||
|
setShowPlanInput(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSavePlan = () => {
|
||||||
|
const assigneeId = tc.assigneeId || currentUserName;
|
||||||
|
if (!assigneeId) {
|
||||||
|
alert('领取前需要先登录或选择负责人');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!planStartBeforeEnd || planEstimateHours <= 0 || !planStartISO || !planEndISO) return;
|
||||||
|
updateTestCase(tc.id, {
|
||||||
|
assigneeId,
|
||||||
|
plannedTestAt: planStartISO,
|
||||||
|
plannedEndAt: planEndISO,
|
||||||
|
estimateHours: planEstimateHours,
|
||||||
|
});
|
||||||
|
setShowPlanInput(false);
|
||||||
|
};
|
||||||
|
|
||||||
const [failReason, setFailReason] = useState('');
|
const [failReason, setFailReason] = useState('');
|
||||||
const [blockReason, setBlockReason] = useState('');
|
const [blockReason, setBlockReason] = useState('');
|
||||||
@@ -49,6 +100,10 @@ export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, context
|
|||||||
const [showBlockInput, setShowBlockInput] = useState(false);
|
const [showBlockInput, setShowBlockInput] = useState(false);
|
||||||
|
|
||||||
const handleTransition = (to: TestCaseStatus) => {
|
const handleTransition = (to: TestCaseStatus) => {
|
||||||
|
if (to === 'running' && !startReady) {
|
||||||
|
openPlanInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (to === 'failed') { setShowFailInput(true); return; }
|
if (to === 'failed') { setShowFailInput(true); return; }
|
||||||
if (to === 'blocked') { setShowBlockInput(true); return; }
|
if (to === 'blocked') { setShowBlockInput(true); return; }
|
||||||
changeStatus(tc.id, to);
|
changeStatus(tc.id, to);
|
||||||
@@ -122,10 +177,10 @@ export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, context
|
|||||||
{tc.executedAt && <span className="text-[11px] text-[var(--ink-muted)]">执行于 {tc.executedAt}</span>}
|
{tc.executedAt && <span className="text-[11px] text-[var(--ink-muted)]">执行于 {tc.executedAt}</span>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{nextStatuses.length > 0 && !showFailInput && !showBlockInput && (
|
{visibleNextStatuses.length > 0 && !showFailInput && !showBlockInput && (
|
||||||
<div className="flex items-center gap-2 pt-1">
|
<div className="flex items-center gap-2 pt-1">
|
||||||
<ChevronRight className="h-3.5 w-3.5 text-[var(--ink-muted)]" />
|
<ChevronRight className="h-3.5 w-3.5 text-[var(--ink-muted)]" />
|
||||||
{nextStatuses.map((s) => (
|
{visibleNextStatuses.map((s) => (
|
||||||
<button key={s} onClick={() => handleTransition(s)} className={`h-8 px-4 rounded-lg text-[12px] font-medium transition-colors ${s === 'passed' ? 'bg-emerald-500 text-white hover:bg-emerald-600' : s === 'failed' ? 'bg-red-500 text-white hover:bg-red-600' : 'bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]'}`}>
|
<button key={s} onClick={() => handleTransition(s)} className={`h-8 px-4 rounded-lg text-[12px] font-medium transition-colors ${s === 'passed' ? 'bg-emerald-500 text-white hover:bg-emerald-600' : s === 'failed' ? 'bg-red-500 text-white hover:bg-red-600' : 'bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]'}`}>
|
||||||
{TEST_CASE_STATUS_LABEL[s]}
|
{TEST_CASE_STATUS_LABEL[s]}
|
||||||
</button>
|
</button>
|
||||||
@@ -133,6 +188,61 @@ export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, context
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{tc.status === 'pending' && !startReady && !showPlanInput && (
|
||||||
|
<div className="flex items-center gap-2 pt-1">
|
||||||
|
<button
|
||||||
|
onClick={openPlanInput}
|
||||||
|
disabled={needsClaim && !currentUserName}
|
||||||
|
className="h-8 px-4 rounded-lg text-[12px] font-medium bg-orange-500 text-white hover:bg-orange-600 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
{needsClaim ? '领取并填写计划' : '填写计划'}
|
||||||
|
</button>
|
||||||
|
<span className="text-[11px] text-[var(--ink-muted)]">
|
||||||
|
{needsClaim ? '领取时必须填写计划开始和计划结束' : '开始测试前需要补齐计划开始和计划结束'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showPlanInput && (
|
||||||
|
<div className="rounded-lg border border-orange-200 bg-orange-50 p-3 space-y-3">
|
||||||
|
<div className="text-[11px] font-medium text-orange-700">
|
||||||
|
{needsClaim ? '领取并填写计划' : '填写计划'}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<div>
|
||||||
|
<label className="mb-1 block text-[11px] text-orange-700">计划开始</label>
|
||||||
|
<WorkDateTimePicker
|
||||||
|
value={planStartLocal}
|
||||||
|
onChange={setPlanStartLocal}
|
||||||
|
placeholder="选择计划开始"
|
||||||
|
defaultHour={9}
|
||||||
|
className="bg-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="mb-1 block text-[11px] text-orange-700">计划结束</label>
|
||||||
|
<WorkDateTimePicker
|
||||||
|
value={planEndLocal}
|
||||||
|
onChange={setPlanEndLocal}
|
||||||
|
placeholder="选择计划结束"
|
||||||
|
defaultHour={10}
|
||||||
|
popoverAlign="right"
|
||||||
|
className="bg-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
<span className="text-[11px] text-orange-700">
|
||||||
|
执行预估:{planEstimateHours > 0 ? formatWorkHours(planEstimateHours) : '请选择有效起止时间'}
|
||||||
|
</span>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button onClick={handleSavePlan} disabled={!planStartBeforeEnd || planEstimateHours <= 0} className="h-7 px-3 rounded text-[11px] font-medium bg-[var(--accent)] text-white disabled:opacity-50">保存</button>
|
||||||
|
<button onClick={() => setShowPlanInput(false)} className="h-7 px-2 text-[11px] text-orange-700">取消</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{showFailInput && (
|
{showFailInput && (
|
||||||
<div className="flex gap-2 pt-1">
|
<div className="flex gap-2 pt-1">
|
||||||
<input value={failReason} onChange={(e) => setFailReason(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') confirmFail(); }} placeholder="不通过原因(可选)" className="flex-1 h-8 rounded-lg border border-[var(--line)] px-3 text-[12px] focus:border-red-400 focus:outline-none" autoFocus />
|
<input value={failReason} onChange={(e) => setFailReason(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') confirmFail(); }} placeholder="不通过原因(可选)" className="flex-1 h-8 rounded-lg border border-[var(--line)] px-3 text-[12px] focus:border-red-400 focus:outline-none" autoFocus />
|
||||||
@@ -157,10 +267,10 @@ export function TestCaseDetailDrawer({ testCaseId, onClose, onCreateBug, context
|
|||||||
<div className="rounded-xl border border-[var(--line)] bg-[var(--bg-card)] p-4">
|
<div className="rounded-xl border border-[var(--line)] bg-[var(--bg-card)] p-4">
|
||||||
<div className="text-[10px] text-[var(--ink-muted)] uppercase tracking-wide mb-3">基本信息</div>
|
<div className="text-[10px] text-[var(--ink-muted)] uppercase tracking-wide mb-3">基本信息</div>
|
||||||
<div className="grid grid-cols-2 gap-y-3 gap-x-4 text-[12px]">
|
<div className="grid grid-cols-2 gap-y-3 gap-x-4 text-[12px]">
|
||||||
<div><span className="text-[var(--ink-muted)]">计划测试:</span><span className="text-[var(--ink)] font-medium">{tc.plannedTestAt ? formatDateTime(tc.plannedTestAt) : '待排期'}</span></div>
|
<div><span className="text-[var(--ink-muted)]">计划测试:</span><span className="text-[var(--ink)] font-medium">{planDisplay}</span></div>
|
||||||
<div><span className="text-[var(--ink-muted)]">优先级:</span><span className="text-[var(--ink)] font-medium">{tc.priority}</span></div>
|
<div><span className="text-[var(--ink-muted)]">优先级:</span><span className="text-[var(--ink)] font-medium">{tc.priority}</span></div>
|
||||||
<div className="flex items-center gap-1.5"><span className="text-[var(--ink-muted)]">任务类型:</span><CategoryChip category={category} /></div>
|
<div className="flex items-center gap-1.5"><span className="text-[var(--ink-muted)]">任务类型:</span><CategoryChip category={category} /></div>
|
||||||
<div><span className="text-[var(--ink-muted)]">负责人:</span><span className="text-[var(--ink)] font-medium">{tc.assigneeId || '-'}</span></div>
|
<div><span className="text-[var(--ink-muted)]">负责人:</span><span className={`font-medium ${needsClaim ? 'text-orange-600' : 'text-[var(--ink)]'}`}>{needsClaim ? '待领取' : tc.assigneeId}</span></div>
|
||||||
<div><span className="text-[var(--ink-muted)]">AI 预估:</span><span className="text-[var(--ink)] font-medium">{aiEstimateHours ? formatWorkHours(aiEstimateHours) : '—'}</span></div>
|
<div><span className="text-[var(--ink-muted)]">AI 预估:</span><span className="text-[var(--ink)] font-medium">{aiEstimateHours ? formatWorkHours(aiEstimateHours) : '—'}</span></div>
|
||||||
<div><span className="text-[var(--ink-muted)]">执行预估:</span><span className="text-[var(--ink)] font-medium">{executorEstimateHours ? formatWorkHours(executorEstimateHours) : '待负责人填写'}</span></div>
|
<div><span className="text-[var(--ink-muted)]">执行预估:</span><span className="text-[var(--ink)] font-medium">{executorEstimateHours ? formatWorkHours(executorEstimateHours) : '待负责人填写'}</span></div>
|
||||||
<div><span className="text-[var(--ink-muted)]">创建人:</span><span className="text-[var(--ink)]">{tc.createdBy}</span></div>
|
<div><span className="text-[var(--ink-muted)]">创建人:</span><span className="text-[var(--ink)]">{tc.createdBy}</span></div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { TestCaseStatusBadge } from './TestCaseStatusBadge';
|
import { TestCaseStatusBadge } from './TestCaseStatusBadge';
|
||||||
import { getTestCaseActualHours, getTestCaseEstimateHours } from '@/lib/test-case';
|
import { getTestCaseActualHours, getTestCaseEstimateHours, needsTestCaseClaim } from '@/lib/test-case';
|
||||||
import { formatWorkHours } from '@/lib/work-hours';
|
import { formatWorkHours } from '@/lib/work-hours';
|
||||||
import { formatDateTimeShort } from '@/lib/format';
|
import { formatDateTimeShort } from '@/lib/format';
|
||||||
import type { TestCase } from '@/lib/test-case';
|
import type { TestCase } from '@/lib/test-case';
|
||||||
@@ -11,6 +11,7 @@ import type { TaskCategory } from '@/lib/task-category';
|
|||||||
interface Props {
|
interface Props {
|
||||||
testCase: TestCase;
|
testCase: TestCase;
|
||||||
category?: TaskCategory;
|
category?: TaskCategory;
|
||||||
|
categoryLabelWidthEm?: number;
|
||||||
bugCount: number;
|
bugCount: number;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
@@ -22,45 +23,74 @@ const PRIORITY_DOT: Record<string, string> = {
|
|||||||
P3: 'bg-zinc-300',
|
P3: 'bg-zinc-300',
|
||||||
};
|
};
|
||||||
|
|
||||||
function TestCaseRowImpl({ testCase, category, bugCount, onClick }: Props) {
|
function TestCaseRowImpl({ testCase, category, categoryLabelWidthEm, bugCount, onClick }: Props) {
|
||||||
const estimateHours = getTestCaseEstimateHours(testCase);
|
const estimateHours = getTestCaseEstimateHours(testCase);
|
||||||
const actualHours = getTestCaseActualHours(testCase);
|
const actualHours = getTestCaseActualHours(testCase);
|
||||||
|
const needsClaim = needsTestCaseClaim(testCase);
|
||||||
|
const labelWidthStyle = categoryLabelWidthEm ? { width: `${categoryLabelWidthEm}em` } : undefined;
|
||||||
const hasExecutorEstimate = typeof testCase.estimateHours === 'number' && testCase.estimateHours > 0;
|
const hasExecutorEstimate = typeof testCase.estimateHours === 'number' && testCase.estimateHours > 0;
|
||||||
const hasAiEstimate = typeof testCase.aiEstimateHours === 'number' && testCase.aiEstimateHours > 0;
|
const hasAiEstimate = typeof testCase.aiEstimateHours === 'number' && testCase.aiEstimateHours > 0;
|
||||||
const estimatePrefix = hasExecutorEstimate ? '执行预' : hasAiEstimate ? 'AI预' : '预';
|
const estimatePrefix = hasExecutorEstimate ? '执行预' : hasAiEstimate ? 'AI预' : '预';
|
||||||
|
const planText = testCase.plannedTestAt && testCase.plannedEndAt
|
||||||
|
? `${formatDateTimeShort(testCase.plannedTestAt)} → ${formatDateTimeShort(testCase.plannedEndAt)}`
|
||||||
|
: testCase.plannedTestAt ? formatDateTimeShort(testCase.plannedTestAt) : '';
|
||||||
return (
|
return (
|
||||||
<div onClick={onClick} className={`flex items-center gap-3 px-4 py-2.5 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0 ${testCase.aiDraft ? 'border-l-2 border-l-purple-400 bg-purple-50/30' : ''}`}>
|
<div onClick={onClick} className={`px-4 py-2 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0 ${testCase.aiDraft ? 'border-l-2 border-l-purple-400 bg-purple-50/30' : ''}`}>
|
||||||
<span className={`h-2 w-2 rounded-full shrink-0 ${PRIORITY_DOT[testCase.priority] || 'bg-zinc-300'}`} />
|
<div className="flex min-w-0 items-start gap-2">
|
||||||
<span className="text-[11px] font-mono text-[var(--ink-muted)] w-14 shrink-0">{testCase.caseNo}</span>
|
<span className={`mt-1.5 h-2 w-2 shrink-0 rounded-full ${PRIORITY_DOT[testCase.priority] || 'bg-zinc-300'}`} />
|
||||||
<span
|
<span className="mt-0.5 w-14 shrink-0 text-[11px] font-mono text-[var(--ink-muted)]">{testCase.caseNo}</span>
|
||||||
className="inline-flex h-5 w-24 shrink-0 items-center justify-center rounded px-1.5 text-[10px] font-medium whitespace-nowrap"
|
<div className="min-w-0 flex-1">
|
||||||
style={{
|
<div className="flex min-w-0 items-center gap-1.5">
|
||||||
backgroundColor: category?.color ? `${category.color}15` : 'var(--bg-subtle)',
|
<span className="truncate text-[13px] font-medium leading-5 text-[var(--ink)]">{testCase.title}</span>
|
||||||
color: category?.color || 'var(--ink-soft)',
|
<span className="ml-auto inline-flex min-w-0 shrink-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 text-[11px]">
|
||||||
}}
|
{planText && (
|
||||||
title={category?.name || '未分类'}
|
<span className="tabular-nums whitespace-nowrap text-[var(--ink-muted)]" title="计划测试时间">{planText}</span>
|
||||||
>
|
)}
|
||||||
{category?.name || '未分类'}
|
<span className="tabular-nums whitespace-nowrap text-[var(--ink-muted)]">
|
||||||
</span>
|
{actualHours > 0 ? `${formatWorkHours(actualHours)} / ${formatWorkHours(estimateHours)}` : `${estimatePrefix} ${formatWorkHours(estimateHours)}`}
|
||||||
<div className="flex-1 min-w-0 flex items-center gap-1.5">
|
</span>
|
||||||
<span className="text-[13px] text-[var(--ink)] truncate">{testCase.title}</span>
|
</span>
|
||||||
{testCase.aiDraft && (
|
</div>
|
||||||
<span className="text-[10px] text-purple-600 bg-purple-100 px-1.5 py-0.5 rounded shrink-0" title="AI 拆解草案,编辑后会移除标记">
|
<div className="mt-1 flex min-w-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 text-[11px]">
|
||||||
AI 草案
|
{bugCount > 0 && (
|
||||||
</span>
|
<span className="inline-flex h-5 shrink-0 items-center whitespace-nowrap rounded bg-red-50 px-1.5 text-[10px] font-medium text-red-500">{bugCount} Bug</span>
|
||||||
)}
|
)}
|
||||||
|
{testCase.aiDraft && (
|
||||||
|
<span
|
||||||
|
className="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded bg-purple-100 px-1.5 text-[10px] font-medium text-purple-600"
|
||||||
|
style={labelWidthStyle}
|
||||||
|
title="AI 拆解草案,编辑后会移除标记"
|
||||||
|
>
|
||||||
|
AI 草案
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{!needsClaim && (
|
||||||
|
<span className="max-w-[140px] truncate whitespace-nowrap text-[var(--ink-soft)]">负责人:{testCase.assigneeId}</span>
|
||||||
|
)}
|
||||||
|
{needsClaim ? (
|
||||||
|
<span
|
||||||
|
className="inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded bg-orange-50 px-1.5 text-[10px] font-medium text-orange-600"
|
||||||
|
style={labelWidthStyle}
|
||||||
|
>
|
||||||
|
待领取
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<TestCaseStatusBadge status={testCase.status} widthEm={categoryLabelWidthEm} />
|
||||||
|
)}
|
||||||
|
<span
|
||||||
|
className="inline-flex h-5 shrink-0 items-center justify-center rounded px-1.5 text-[10px] font-medium whitespace-nowrap"
|
||||||
|
style={{
|
||||||
|
...(categoryLabelWidthEm ? { width: `${categoryLabelWidthEm}em` } : {}),
|
||||||
|
backgroundColor: category?.color ? `${category.color}15` : 'var(--bg-subtle)',
|
||||||
|
color: category?.color || 'var(--ink-soft)',
|
||||||
|
}}
|
||||||
|
title={category?.name || '未分类'}
|
||||||
|
>
|
||||||
|
{category?.name || '未分类'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{bugCount > 0 && (
|
|
||||||
<span className="text-[10px] text-red-500 bg-red-50 px-1.5 py-0.5 rounded shrink-0">{bugCount} Bug</span>
|
|
||||||
)}
|
|
||||||
<TestCaseStatusBadge status={testCase.status} />
|
|
||||||
<span className="text-[11px] text-[var(--ink-muted)] tabular-nums w-24 text-right shrink-0 whitespace-nowrap" title="计划测试时间">
|
|
||||||
{testCase.plannedTestAt ? formatDateTimeShort(testCase.plannedTestAt) : '待排期'}
|
|
||||||
</span>
|
|
||||||
<span className="text-[11px] text-[var(--ink-muted)] tabular-nums w-32 text-right shrink-0 whitespace-nowrap">
|
|
||||||
{actualHours > 0 ? `${formatWorkHours(actualHours)} / ${formatWorkHours(estimateHours)}` : `${estimatePrefix} ${formatWorkHours(estimateHours)}`}
|
|
||||||
</span>
|
|
||||||
<span className="text-[11px] text-[var(--ink-soft)] w-14 text-right truncate shrink-0">{testCase.assigneeId || '-'}</span>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@
|
|||||||
import { TEST_CASE_STATUS_LABEL, TEST_CASE_STATUS_COLOR } from '@/lib/test-case';
|
import { TEST_CASE_STATUS_LABEL, TEST_CASE_STATUS_COLOR } from '@/lib/test-case';
|
||||||
import type { TestCaseStatus } from '@/lib/test-case';
|
import type { TestCaseStatus } from '@/lib/test-case';
|
||||||
|
|
||||||
export function TestCaseStatusBadge({ status }: { status: TestCaseStatus }) {
|
export function TestCaseStatusBadge({ status, widthEm }: { status: TestCaseStatus; widthEm?: number }) {
|
||||||
return (
|
return (
|
||||||
<span className={`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${TEST_CASE_STATUS_COLOR[status]}`}>
|
<span
|
||||||
|
className={`inline-flex h-5 shrink-0 items-center justify-center whitespace-nowrap rounded px-1.5 text-[10px] font-medium ${TEST_CASE_STATUS_COLOR[status]}`}
|
||||||
|
style={widthEm ? { width: `${widthEm}em` } : undefined}
|
||||||
|
>
|
||||||
{TEST_CASE_STATUS_LABEL[status]}
|
{TEST_CASE_STATUS_LABEL[status]}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -152,6 +152,10 @@ export function TestCaseTab({ versionId, requirementIds }: Props) {
|
|||||||
|
|
||||||
const requirementMap = useMemo(() => new Map(requirements.map((r) => [r.id, r])), [requirements]);
|
const requirementMap = useMemo(() => new Map(requirements.map((r) => [r.id, r])), [requirements]);
|
||||||
const categoryMap = useMemo(() => new Map(categories.map((c) => [c.id, c])), [categories]);
|
const categoryMap = useMemo(() => new Map(categories.map((c) => [c.id, c])), [categories]);
|
||||||
|
const categoryLabelWidthEm = useMemo(
|
||||||
|
() => Math.max(4, ...categories.map((category) => category.name.length)) + 1,
|
||||||
|
[categories],
|
||||||
|
);
|
||||||
const bugCountByCase = useMemo(() => {
|
const bugCountByCase = useMemo(() => {
|
||||||
const map = new Map<string, number>();
|
const map = new Map<string, number>();
|
||||||
for (const b of versionBugs) map.set(b.testCaseId, (map.get(b.testCaseId) ?? 0) + 1);
|
for (const b of versionBugs) map.set(b.testCaseId, (map.get(b.testCaseId) ?? 0) + 1);
|
||||||
@@ -230,21 +234,19 @@ export function TestCaseTab({ versionId, requirementIds }: Props) {
|
|||||||
<div className="pl-4 flex items-center">
|
<div className="pl-4 flex items-center">
|
||||||
<input type="checkbox" checked={cases.every((c) => selectedIds.has(c.id))} onChange={() => { const ids = cases.map((c) => c.id); const allSel = ids.every((id) => selectedIds.has(id)); const next = new Set(selectedIds); if (allSel) ids.forEach((id) => next.delete(id)); else ids.forEach((id) => next.add(id)); setSelectedIds(next); }} className="h-3.5 w-3.5 rounded border-[var(--line)]" />
|
<input type="checkbox" checked={cases.every((c) => selectedIds.has(c.id))} onChange={() => { const ids = cases.map((c) => c.id); const allSel = ids.every((id) => selectedIds.has(id)); const next = new Set(selectedIds); if (allSel) ids.forEach((id) => next.delete(id)); else ids.forEach((id) => next.add(id)); setSelectedIds(next); }} className="h-3.5 w-3.5 rounded border-[var(--line)]" />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-1 min-w-0 items-center gap-3 px-4 py-2">
|
<div className="flex flex-1 min-w-0 items-center gap-2 px-4 py-2">
|
||||||
<span className="h-2 w-2 shrink-0" />
|
<span className="h-2 w-2 shrink-0" />
|
||||||
<span className="w-14 min-w-0 shrink-0 truncate text-[11px] font-mono text-[var(--ink-muted)]" title={req?.code || '通用'}>{req?.code || '通用'}</span>
|
<span className="w-14 min-w-0 shrink-0 truncate text-[11px] font-mono text-[var(--ink-muted)]" title={req?.code || '通用'}>{req?.code || '通用'}</span>
|
||||||
{deliveryStatus ? (
|
<span className="text-[12px] font-medium text-[var(--ink)] flex-1 truncate">{req?.title || '未关联需求'}</span>
|
||||||
<span className={`inline-flex h-5 w-24 shrink-0 items-center justify-center rounded px-1.5 text-[10px] font-medium whitespace-nowrap ${
|
{deliveryStatus && (
|
||||||
|
<span className={`inline-flex h-5 w-14 shrink-0 items-center justify-center rounded px-1.5 text-[10px] font-medium whitespace-nowrap ${
|
||||||
deliveryStatus === 'submitted'
|
deliveryStatus === 'submitted'
|
||||||
? 'bg-emerald-50 text-emerald-600 border border-emerald-100'
|
? 'bg-emerald-50 text-emerald-600 border border-emerald-100'
|
||||||
: 'bg-orange-50 text-orange-600 border border-orange-100'
|
: 'bg-orange-50 text-orange-600 border border-orange-100'
|
||||||
}`}>
|
}`}>
|
||||||
{deliveryStatus === 'submitted' ? '已提测' : '待提测'}
|
{deliveryStatus === 'submitted' ? '已提测' : '待提测'}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
|
||||||
<span className="h-5 w-24 shrink-0" />
|
|
||||||
)}
|
)}
|
||||||
<span className="text-[12px] font-medium text-[var(--ink)] flex-1 truncate">{req?.title || '未关联需求'}</span>
|
|
||||||
<span className="text-[11px] text-[var(--ink-muted)]">{reqPassed}/{cases.length} 通过</span>
|
<span className="text-[11px] text-[var(--ink-muted)]">{reqPassed}/{cases.length} 通过</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -254,7 +256,7 @@ export function TestCaseTab({ versionId, requirementIds }: Props) {
|
|||||||
<input type="checkbox" checked={selectedIds.has(c.id)} onChange={() => toggleSelect(c.id)} className="h-3.5 w-3.5 rounded border-[var(--line)]" onClick={(e) => e.stopPropagation()} />
|
<input type="checkbox" checked={selectedIds.has(c.id)} onChange={() => toggleSelect(c.id)} className="h-3.5 w-3.5 rounded border-[var(--line)]" onClick={(e) => e.stopPropagation()} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<TestCaseRow testCase={c} category={categoryMap.get(c.categoryId)} bugCount={bugCountByCase.get(c.id) ?? 0} onClick={() => setSelectedCaseId(c.id)} />
|
<TestCaseRow testCase={c} category={categoryMap.get(c.categoryId)} categoryLabelWidthEm={categoryLabelWidthEm} bugCount={bugCountByCase.get(c.id) ?? 0} onClick={() => setSelectedCaseId(c.id)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
|
||||||
import type { DevTask } from './dev-task';
|
import { canStartDevTask, hasDevTaskPlan, needsDevTaskClaim, type DevTask } from './dev-task';
|
||||||
import { applyDevTaskTransition, normalizeDevTaskOnCreate } from './dev-task-workflow';
|
import { applyDevTaskTransition, normalizeDevTaskOnCreate } from './dev-task-workflow';
|
||||||
|
|
||||||
function task(patch: Partial<DevTask> = {}): DevTask {
|
function task(patch: Partial<DevTask> = {}): DevTask {
|
||||||
@@ -47,6 +47,44 @@ test('todo to in_progress writes actualStartAt from manual click time', () => {
|
|||||||
assert.equal(result.patch?.actualStartAt, '2026-06-25T03:30:00.000Z');
|
assert.equal(result.patch?.actualStartAt, '2026-06-25T03:30:00.000Z');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('AI dev task without an assignee must be claimed with a plan before starting', () => {
|
||||||
|
const draft = task({
|
||||||
|
assigneeId: '',
|
||||||
|
expectedStartAt: '',
|
||||||
|
expectedEndAt: '',
|
||||||
|
aiDraft: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(needsDevTaskClaim(draft), true);
|
||||||
|
assert.equal(hasDevTaskPlan(draft), false);
|
||||||
|
assert.equal(canStartDevTask(draft), false);
|
||||||
|
|
||||||
|
const result = applyDevTaskTransition(draft, 'in_progress', {
|
||||||
|
now: new Date('2026-06-25T03:30:00.000Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(result.ok, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('recommended assignee dev task still needs a plan before starting', () => {
|
||||||
|
const draft = task({
|
||||||
|
assigneeId: 'Alice',
|
||||||
|
expectedStartAt: '',
|
||||||
|
expectedEndAt: '',
|
||||||
|
aiDraft: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(needsDevTaskClaim(draft), false);
|
||||||
|
assert.equal(hasDevTaskPlan(draft), false);
|
||||||
|
assert.equal(canStartDevTask(draft), false);
|
||||||
|
|
||||||
|
const result = applyDevTaskTransition(draft, 'in_progress', {
|
||||||
|
now: new Date('2026-06-25T03:30:00.000Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(result.ok, false);
|
||||||
|
});
|
||||||
|
|
||||||
test('in_progress to testing does not write actualEndAt', () => {
|
test('in_progress to testing does not write actualEndAt', () => {
|
||||||
const result = applyDevTaskTransition(task({
|
const result = applyDevTaskTransition(task({
|
||||||
status: 'in_progress',
|
status: 'in_progress',
|
||||||
@@ -71,6 +109,21 @@ test('testing to submitted writes actualEndAt', () => {
|
|||||||
assert.equal(result.patch?.actualEndAt, '2026-06-25T05:00:00.000Z');
|
assert.equal(result.patch?.actualEndAt, '2026-06-25T05:00:00.000Z');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('blocked task cannot be submitted to test until unblocked', () => {
|
||||||
|
const result = applyDevTaskTransition(task({
|
||||||
|
status: 'testing',
|
||||||
|
actualStartAt: '2026-06-25T03:30:00.000Z',
|
||||||
|
isBlocked: true,
|
||||||
|
blockReason: '等待接口联调',
|
||||||
|
}), 'submitted', {
|
||||||
|
now: new Date('2026-06-25T05:00:00.000Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(result.ok, false);
|
||||||
|
assert.equal(result.patch, undefined);
|
||||||
|
assert.match(result.message || '', /\u963b\u585e/);
|
||||||
|
});
|
||||||
|
|
||||||
test('invalid transition is rejected', () => {
|
test('invalid transition is rejected', () => {
|
||||||
const result = applyDevTaskTransition(task(), 'submitted', {
|
const result = applyDevTaskTransition(task(), 'submitted', {
|
||||||
now: new Date('2026-06-25T05:00:00.000Z'),
|
now: new Date('2026-06-25T05:00:00.000Z'),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { DevTask, DevTaskStatus } from './dev-task';
|
import type { DevTask, DevTaskStatus } from './dev-task';
|
||||||
import { canTransition } from './dev-task';
|
import { canStartDevTask, canTransition } from './dev-task';
|
||||||
|
|
||||||
export interface DevTaskWorkflowResult {
|
export interface DevTaskWorkflowResult {
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
@@ -30,7 +30,15 @@ export function applyDevTaskTransition(
|
|||||||
return { ok: false, message: `不允许从「${task.status}」流转到「${to}」` };
|
return { ok: false, message: `不允许从「${task.status}」流转到「${to}」` };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (to === 'submitted' && task.isBlocked) {
|
||||||
|
return { ok: false, message: '任务仍处于阻塞中,请先解除阻塞后再提测' };
|
||||||
|
}
|
||||||
|
|
||||||
const nowIso = (options.now ?? new Date()).toISOString();
|
const nowIso = (options.now ?? new Date()).toISOString();
|
||||||
|
if (to === 'in_progress' && !canStartDevTask(task)) {
|
||||||
|
return { ok: false, message: '开始开发前需要先领取并填写预计开始和预计截止时间' };
|
||||||
|
}
|
||||||
|
|
||||||
const patch: Partial<DevTask> = {
|
const patch: Partial<DevTask> = {
|
||||||
status: to,
|
status: to,
|
||||||
aiDraft: false,
|
aiDraft: false,
|
||||||
|
|||||||
@@ -112,6 +112,21 @@ function roundEffortHours(hours: number): number {
|
|||||||
return Number(hours.toFixed(2));
|
return Number(hours.toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function needsDevTaskClaim(task: Pick<DevTask, 'assigneeId'>): boolean {
|
||||||
|
return !task.assigneeId?.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hasDevTaskPlan(task: Pick<DevTask, 'expectedStartAt' | 'expectedEndAt'>): boolean {
|
||||||
|
if (!task.expectedStartAt || !task.expectedEndAt) return false;
|
||||||
|
const start = new Date(task.expectedStartAt).getTime();
|
||||||
|
const end = new Date(task.expectedEndAt).getTime();
|
||||||
|
return Number.isFinite(start) && Number.isFinite(end) && end > start;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canStartDevTask(task: Pick<DevTask, 'assigneeId' | 'expectedStartAt' | 'expectedEndAt'>): boolean {
|
||||||
|
return !needsDevTaskClaim(task) && hasDevTaskPlan(task);
|
||||||
|
}
|
||||||
|
|
||||||
export function getActualHours(task: DevTask, now: Date = new Date()): number {
|
export function getActualHours(task: DevTask, now: Date = new Date()): number {
|
||||||
if (!task.actualStartAt) return 0;
|
if (!task.actualStartAt) return 0;
|
||||||
const end = task.actualEndAt ?? (task.status === 'submitted' ? task.updatedAt : now.toISOString());
|
const end = task.actualEndAt ?? (task.status === 'submitted' ? task.updatedAt : now.toISOString());
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import test from 'node:test';
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
|
||||||
import type { TestCase } from './test-case';
|
import type { TestCase } from './test-case';
|
||||||
|
import { canStartTestCase, hasTestCasePlan, needsTestCaseClaim } from './test-case';
|
||||||
import { applyTestCaseTransition, normalizeTestCaseOnCreate } from './test-case-workflow';
|
import { applyTestCaseTransition, normalizeTestCaseOnCreate } from './test-case-workflow';
|
||||||
|
|
||||||
function tc(patch: Partial<TestCase> = {}): TestCase {
|
function tc(patch: Partial<TestCase> = {}): TestCase {
|
||||||
@@ -14,6 +15,9 @@ function tc(patch: Partial<TestCase> = {}): TestCase {
|
|||||||
categoryId: 'cat-test-functional',
|
categoryId: 'cat-test-functional',
|
||||||
priority: 'P2',
|
priority: 'P2',
|
||||||
status: 'pending',
|
status: 'pending',
|
||||||
|
assigneeId: 'QA',
|
||||||
|
plannedTestAt: '2026-06-25T01:00:00.000Z',
|
||||||
|
plannedEndAt: '2026-06-25T02:00:00.000Z',
|
||||||
createdBy: 'QA',
|
createdBy: 'QA',
|
||||||
createdAt: '2026-06-25T00:00:00.000Z',
|
createdAt: '2026-06-25T00:00:00.000Z',
|
||||||
updatedAt: '2026-06-25T00:00:00.000Z',
|
updatedAt: '2026-06-25T00:00:00.000Z',
|
||||||
@@ -48,6 +52,44 @@ test('pending to running writes startedAt', () => {
|
|||||||
assert.equal(result.patch?.startedAt, '2026-06-25T01:00:00.000Z');
|
assert.equal(result.patch?.startedAt, '2026-06-25T01:00:00.000Z');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('AI test case without an assignee must be claimed with a plan before running', () => {
|
||||||
|
const draft = tc({
|
||||||
|
assigneeId: undefined,
|
||||||
|
plannedTestAt: undefined,
|
||||||
|
plannedEndAt: undefined,
|
||||||
|
aiDraft: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(needsTestCaseClaim(draft), true);
|
||||||
|
assert.equal(hasTestCasePlan(draft), false);
|
||||||
|
assert.equal(canStartTestCase(draft), false);
|
||||||
|
|
||||||
|
const result = applyTestCaseTransition(draft, 'running', {
|
||||||
|
now: new Date('2026-06-25T01:00:00.000Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(result.ok, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('recommended assignee test case still needs a plan before running', () => {
|
||||||
|
const draft = tc({
|
||||||
|
assigneeId: 'QA',
|
||||||
|
plannedTestAt: undefined,
|
||||||
|
plannedEndAt: undefined,
|
||||||
|
aiDraft: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(needsTestCaseClaim(draft), false);
|
||||||
|
assert.equal(hasTestCasePlan(draft), false);
|
||||||
|
assert.equal(canStartTestCase(draft), false);
|
||||||
|
|
||||||
|
const result = applyTestCaseTransition(draft, 'running', {
|
||||||
|
now: new Date('2026-06-25T01:00:00.000Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(result.ok, false);
|
||||||
|
});
|
||||||
|
|
||||||
test('running to passed writes completedAt', () => {
|
test('running to passed writes completedAt', () => {
|
||||||
const result = applyTestCaseTransition(tc({
|
const result = applyTestCaseTransition(tc({
|
||||||
status: 'running',
|
status: 'running',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { TestCase, TestCaseStatus } from './test-case';
|
import type { TestCase, TestCaseStatus } from './test-case';
|
||||||
import { canTcTransition, getTestCaseRoundNo } from './test-case';
|
import { canStartTestCase, canTcTransition, getTestCaseRoundNo } from './test-case';
|
||||||
|
|
||||||
export interface TestCaseWorkflowResult {
|
export interface TestCaseWorkflowResult {
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
@@ -36,6 +36,10 @@ export function applyTestCaseTransition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nowIso = (options.now ?? new Date()).toISOString();
|
const nowIso = (options.now ?? new Date()).toISOString();
|
||||||
|
if (to === 'running' && !canStartTestCase(testCase)) {
|
||||||
|
return { ok: false, message: '开始测试前需要先领取并填写计划开始和计划结束时间' };
|
||||||
|
}
|
||||||
|
|
||||||
const patch: Partial<TestCase> = {
|
const patch: Partial<TestCase> = {
|
||||||
status: to,
|
status: to,
|
||||||
aiDraft: false,
|
aiDraft: false,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export interface TestCase {
|
|||||||
estimateHours?: number;
|
estimateHours?: number;
|
||||||
aiEstimateHours?: number;
|
aiEstimateHours?: number;
|
||||||
plannedTestAt?: string;
|
plannedTestAt?: string;
|
||||||
|
plannedEndAt?: string;
|
||||||
startedAt?: string;
|
startedAt?: string;
|
||||||
completedAt?: string;
|
completedAt?: string;
|
||||||
executedAt?: string;
|
executedAt?: string;
|
||||||
@@ -98,6 +99,7 @@ export function normalizeTestCase(testCase: Partial<TestCase>, index = 0): TestC
|
|||||||
estimateHours: typeof testCase.estimateHours === 'number' && testCase.estimateHours > 0 ? testCase.estimateHours : undefined,
|
estimateHours: typeof testCase.estimateHours === 'number' && testCase.estimateHours > 0 ? testCase.estimateHours : undefined,
|
||||||
aiEstimateHours: typeof testCase.aiEstimateHours === 'number' && testCase.aiEstimateHours > 0 ? testCase.aiEstimateHours : undefined,
|
aiEstimateHours: typeof testCase.aiEstimateHours === 'number' && testCase.aiEstimateHours > 0 ? testCase.aiEstimateHours : undefined,
|
||||||
plannedTestAt: testCase.plannedTestAt,
|
plannedTestAt: testCase.plannedTestAt,
|
||||||
|
plannedEndAt: testCase.plannedEndAt,
|
||||||
startedAt: testCase.startedAt,
|
startedAt: testCase.startedAt,
|
||||||
completedAt: testCase.completedAt,
|
completedAt: testCase.completedAt,
|
||||||
executedAt: testCase.executedAt,
|
executedAt: testCase.executedAt,
|
||||||
@@ -172,6 +174,7 @@ export function copyTestCaseToRound(source: TestCase, roundNo: number, createdBy
|
|||||||
estimateHours: source.estimateHours,
|
estimateHours: source.estimateHours,
|
||||||
aiEstimateHours: source.aiEstimateHours,
|
aiEstimateHours: source.aiEstimateHours,
|
||||||
plannedTestAt: source.plannedTestAt,
|
plannedTestAt: source.plannedTestAt,
|
||||||
|
plannedEndAt: source.plannedEndAt,
|
||||||
assigneeId: source.assigneeId,
|
assigneeId: source.assigneeId,
|
||||||
startedAt: undefined,
|
startedAt: undefined,
|
||||||
completedAt: undefined,
|
completedAt: undefined,
|
||||||
@@ -224,6 +227,23 @@ export function getTestCaseEstimateHours(tc: TestCase): number {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function needsTestCaseClaim(testCase: Pick<TestCase, 'assigneeId'>): boolean {
|
||||||
|
return !testCase.assigneeId?.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hasTestCasePlan(testCase: Pick<TestCase, 'plannedTestAt' | 'plannedEndAt'>): boolean {
|
||||||
|
if (!testCase.plannedTestAt || !testCase.plannedEndAt) return false;
|
||||||
|
const start = new Date(testCase.plannedTestAt).getTime();
|
||||||
|
const end = new Date(testCase.plannedEndAt).getTime();
|
||||||
|
return Number.isFinite(start) && Number.isFinite(end) && end > start;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canStartTestCase(
|
||||||
|
testCase: Pick<TestCase, 'assigneeId' | 'plannedTestAt' | 'plannedEndAt'>,
|
||||||
|
): boolean {
|
||||||
|
return !needsTestCaseClaim(testCase) && hasTestCasePlan(testCase);
|
||||||
|
}
|
||||||
|
|
||||||
export function getTestCaseActualHours(tc: TestCase, now: Date = new Date()): number {
|
export function getTestCaseActualHours(tc: TestCase, now: Date = new Date()): number {
|
||||||
if (!tc.startedAt) return 0;
|
if (!tc.startedAt) return 0;
|
||||||
const isTerminal = tc.status === 'passed' || tc.status === 'failed' || tc.status === 'blocked';
|
const isTerminal = tc.status === 'passed' || tc.status === 'failed' || tc.status === 'blocked';
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
|
||||||
|
import type { Bug } from './bug';
|
||||||
|
import { calcXiaobaoVersionRisk } from './xiaobao-risk';
|
||||||
import { buildRiskSignature, summarizeRiskTrend } from './xiaobao-risk-trend';
|
import { buildRiskSignature, summarizeRiskTrend } from './xiaobao-risk-trend';
|
||||||
import type { XiaobaoRiskSnapshot } from './xiaobao-risk-trend';
|
import type { XiaobaoRiskSnapshot } from './xiaobao-risk-trend';
|
||||||
|
|
||||||
@@ -38,3 +40,55 @@ test('buildRiskSignature changes when score and bug counts change', () => {
|
|||||||
|
|
||||||
assert.notEqual(base, changed);
|
assert.notEqual(base, changed);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('calcXiaobaoVersionRisk uses all open bugs in the current trend snapshot signature', () => {
|
||||||
|
const now = new Date('2026-07-02T01:00:00.000Z');
|
||||||
|
const risk = calcXiaobaoVersionRisk({
|
||||||
|
version: {
|
||||||
|
id: 'ver-1',
|
||||||
|
name: 'V1.0',
|
||||||
|
expectedReleaseDate: '2026-07-03T10:00:00.000Z',
|
||||||
|
members: [{ name: 'Alice' }],
|
||||||
|
},
|
||||||
|
devTasks: [],
|
||||||
|
testCases: [],
|
||||||
|
bugs: [bug({ severity: 'major', priority: 'P2' })],
|
||||||
|
now,
|
||||||
|
});
|
||||||
|
const currentSignature = (risk.trend as { currentSignature?: string }).currentSignature;
|
||||||
|
|
||||||
|
assert.equal(risk.signals.openBugCount, 1);
|
||||||
|
assert.equal(risk.signals.criticalBugCount, 0);
|
||||||
|
assert.equal(currentSignature, buildRiskSignature({
|
||||||
|
versionId: risk.versionId,
|
||||||
|
date: now.toISOString().slice(0, 10),
|
||||||
|
riskScore: risk.riskScore,
|
||||||
|
riskLevel: risk.riskLevel,
|
||||||
|
forecastReleaseDate: risk.forecastReleaseDate,
|
||||||
|
openBugCount: 1,
|
||||||
|
failedTestCount: 0,
|
||||||
|
blockedCount: 0,
|
||||||
|
silentRiskCount: 0,
|
||||||
|
confidence: risk.confidence,
|
||||||
|
createdAt: now.toISOString(),
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
function bug(patch: Partial<Bug> = {}): Bug {
|
||||||
|
return {
|
||||||
|
id: 'bug-1',
|
||||||
|
bugNo: 'BUG-001',
|
||||||
|
versionId: 'ver-1',
|
||||||
|
testCaseId: 'tc-1',
|
||||||
|
title: 'Non-critical open bug',
|
||||||
|
description: 'Open but not critical.',
|
||||||
|
severity: 'major',
|
||||||
|
priority: 'P2',
|
||||||
|
reportedBy: 'qa-1',
|
||||||
|
assigneeId: 'dev-1',
|
||||||
|
status: 'open',
|
||||||
|
createdAt: '2026-07-01T09:00:00.000Z',
|
||||||
|
updatedAt: '2026-07-01T09:00:00.000Z',
|
||||||
|
...patch,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface RiskTrendSummary {
|
|||||||
delta: number;
|
delta: number;
|
||||||
summary: string;
|
summary: string;
|
||||||
pattern: 'continuous_rising' | 'continuous_falling' | 'score_delta' | 'stable' | 'unknown';
|
pattern: 'continuous_rising' | 'continuous_falling' | 'score_delta' | 'stable' | 'unknown';
|
||||||
|
currentSignature?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function summarizeRiskTrend(snapshots: XiaobaoRiskSnapshot[]): RiskTrendSummary {
|
export function summarizeRiskTrend(snapshots: XiaobaoRiskSnapshot[]): RiskTrendSummary {
|
||||||
@@ -65,7 +66,10 @@ export function summarizeRiskTrendWithCurrent(
|
|||||||
snapshots: XiaobaoRiskSnapshot[] = [],
|
snapshots: XiaobaoRiskSnapshot[] = [],
|
||||||
current: XiaobaoRiskSnapshot,
|
current: XiaobaoRiskSnapshot,
|
||||||
): RiskTrendSummary {
|
): RiskTrendSummary {
|
||||||
return summarizeRiskTrend([...snapshots, current]);
|
return {
|
||||||
|
...summarizeRiskTrend([...snapshots, current]),
|
||||||
|
currentSignature: buildRiskSignature(current),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildRiskSignature(snapshot: XiaobaoRiskSnapshot): string {
|
export function buildRiskSignature(snapshot: XiaobaoRiskSnapshot): string {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ export function calcXiaobaoVersionRisk(input: CalcXiaobaoVersionRiskInput): Xiao
|
|||||||
riskScore,
|
riskScore,
|
||||||
riskLevel,
|
riskLevel,
|
||||||
forecastReleaseDate,
|
forecastReleaseDate,
|
||||||
openBugCount: signals.criticalBugCount,
|
openBugCount: signals.openBugCount,
|
||||||
failedTestCount: signals.failedTestCount,
|
failedTestCount: signals.failedTestCount,
|
||||||
blockedCount: signals.blockedCount,
|
blockedCount: signals.blockedCount,
|
||||||
silentRiskCount: signals.silentRiskCount,
|
silentRiskCount: signals.silentRiskCount,
|
||||||
|
|||||||
@@ -96,8 +96,9 @@
|
|||||||
**决策**:
|
**决策**:
|
||||||
- `status: todo|in_progress|testing|submitted`
|
- `status: todo|in_progress|testing|submitted`
|
||||||
- `isBlocked: boolean` + `blockReason: string` + `blockedById: string`
|
- `isBlocked: boolean` + `blockReason: string` + `blockedById: string`
|
||||||
|
- DevTask 存在阻塞时不能转为 `submitted`,必须先解除阻塞再提测。
|
||||||
|
|
||||||
**理由**:阻塞和状态正交。工作台筛选 `isBlocked=true` 一键拉出所有阻塞项,跨状态。
|
**理由**:阻塞和状态正交。工作台筛选 `isBlocked=true` 一键拉出所有阻塞项,跨状态;但 `submitted` 代表开发交付完成,仍必须满足“当前无阻塞”的完成条件。
|
||||||
|
|
||||||
## 11. 加班原因可选,且去掉"其他"
|
## 11. 加班原因可选,且去掉"其他"
|
||||||
|
|
||||||
@@ -352,7 +353,7 @@
|
|||||||
- 新建统一的工作日日期时间选择组件,创建任务时复用同一套交互。
|
- 新建统一的工作日日期时间选择组件,创建任务时复用同一套交互。
|
||||||
- 内置国务院办公厅发布的 2026 年中国法定节假日和调休工作日;未知年份按周末/工作日兜底。
|
- 内置国务院办公厅发布的 2026 年中国法定节假日和调休工作日;未知年份按周末/工作日兜底。
|
||||||
- 选择节假日或周末时只提示,不阻止保存;选择调休工作日时按工作日提示。
|
- 选择节假日或周末时只提示,不阻止保存;选择调休工作日时按工作日提示。
|
||||||
- TestCase 增加 `plannedTestAt`,Bug 增加 `plannedFixAt`,保存为 ISO 时间戳。
|
- TestCase 增加 `plannedTestAt` / `plannedEndAt`,Bug 增加 `plannedFixAt`,保存为 ISO 时间戳。
|
||||||
|
|
||||||
**理由**:项目排期需要贴近中国工作日,但研发和线上 Bug 可能确实安排在非工作日处理,所以系统负责提醒,最终是否保存交给用户判断。
|
**理由**:项目排期需要贴近中国工作日,但研发和线上 Bug 可能确实安排在非工作日处理,所以系统负责提醒,最终是否保存交给用户判断。
|
||||||
|
|
||||||
@@ -404,3 +405,16 @@
|
|||||||
- 没有明确角色匹配或成员匹配时,AI 不输出推荐字段,任务保持未分配,供成员后续领取或手动分配。
|
- 没有明确角色匹配或成员匹配时,AI 不输出推荐字段,任务保持未分配,供成员后续领取或手动分配。
|
||||||
|
|
||||||
**理由**:负责人推荐能减少项目经理初次分配成本,但分配本身是团队执行承诺,必须由人确认。把推荐和写入分开,可以复用版本成员上下文,又避免模型幻觉姓名或越权自动派单。
|
**理由**:负责人推荐能减少项目经理初次分配成本,但分配本身是团队执行承诺,必须由人确认。把推荐和写入分开,可以复用版本成员上下文,又避免模型幻觉姓名或越权自动派单。
|
||||||
|
|
||||||
|
## 34. AI 草案领取和计划必须绑定
|
||||||
|
|
||||||
|
**问题**:AI 生成的 DevTask / TestCase 如果没有负责人,团队需要先领取;如果把“待领取”和“待排期”拆成两个可见状态,会让版本详情列表出现更多标签,且无法体现“领取时就应该承诺计划”的业务动作。
|
||||||
|
|
||||||
|
**决策**:
|
||||||
|
- 版本详情开发任务和测试用例不显示“待排期”标签。
|
||||||
|
- 无负责人时显示“待领取”,领取入口必须同时填写计划起止时间。
|
||||||
|
- 用户采纳 AI 推荐负责人后,草案已经有负责人,不再需要领取;但开始开发/测试前仍必须补齐计划起止时间。
|
||||||
|
- DevTask 进入 `in_progress` 前必须具备 `assigneeId`、`expectedStartAt`、`expectedEndAt`。
|
||||||
|
- TestCase 进入 `running` 前必须具备 `assigneeId`、`plannedTestAt`、`plannedEndAt`。
|
||||||
|
|
||||||
|
**理由**:领取代表成员承诺执行,计划时间代表承诺边界,二者应该在同一个动作里完成。列表层只表达“谁还没接手”,状态机层负责阻止未计划任务进入执行,页面不会被额外标签干扰。
|
||||||
|
|||||||
2394
docs/superpowers/plans/2026-06-29-xiaobao-warning.md
Normal file
2394
docs/superpowers/plans/2026-06-29-xiaobao-warning.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,22 @@
|
|||||||
|
|
||||||
开发任务从“待开发”切换到“开发中”时,只有当前时间已经超过 `expectedEndAt`(预计截止)才要求填写延后原因。超过预计开始时间但仍未超过预计截止时间,不视为延后。
|
开发任务从“待开发”切换到“开发中”时,只有当前时间已经超过 `expectedEndAt`(预计截止)才要求填写延后原因。超过预计开始时间但仍未超过预计截止时间,不视为延后。
|
||||||
|
|
||||||
|
## AI 草案领取与计划流程
|
||||||
|
|
||||||
|
开发任务和测试用例由 AI 生成后,版本详情里不再显示独立的“待排期”状态:
|
||||||
|
|
||||||
|
1. DevTask / TestCase 没有负责人时显示“待领取”。
|
||||||
|
2. 点击“领取并填写计划”时同时写入当前用户为负责人,并填写计划起止时间。
|
||||||
|
3. 已采纳推荐负责人的 AI 草案已经有负责人,不需要领取,但开始开发/测试前仍必须点击“填写计划”补齐计划起止时间。
|
||||||
|
4. DevTask 开始开发前必须同时具备 `assigneeId`、`expectedStartAt`、`expectedEndAt`;TestCase 开始测试前必须同时具备 `assigneeId`、`plannedTestAt`、`plannedEndAt`。
|
||||||
|
5. 计划起止时间自动按工作日历计算 `estimateHours`。AI 预估仍保留在 `aiEstimateHours`,不代表负责人已确认排期。
|
||||||
|
|
||||||
|
## 开发任务提测流程
|
||||||
|
|
||||||
|
1. DevTask 从“自测”转为“已提测”前,任务不能处于阻塞中。
|
||||||
|
2. 如果 `isBlocked=true`,必须先解除阻塞并清空阻塞原因,再允许提测。
|
||||||
|
3. “已提测”仍然是 DevTask 终态;后续测试通过或失败不回写 DevTask 状态。
|
||||||
|
|
||||||
## 测试轮次流程
|
## 测试轮次流程
|
||||||
|
|
||||||
测试用例支持按版本开启多轮测试:
|
测试用例支持按版本开启多轮测试:
|
||||||
@@ -231,8 +247,8 @@ Implementation convention:
|
|||||||
- 调研、产品方案、UI 设计、开发任务、测试用例、Bug 创建时使用统一工作日日期时间选择器。
|
- 调研、产品方案、UI 设计、开发任务、测试用例、Bug 创建时使用统一工作日日期时间选择器。
|
||||||
- 日期选择器接入中国节假日日历。当前内置 2026 年国务院办公厅放假调休安排;其他年份先按周末/工作日兜底。
|
- 日期选择器接入中国节假日日历。当前内置 2026 年国务院办公厅放假调休安排;其他年份先按周末/工作日兜底。
|
||||||
- 非工作日只提示,不阻止保存;调休工作日按工作日提示。
|
- 非工作日只提示,不阻止保存;调休工作日按工作日提示。
|
||||||
- 测试用例计划测试时间字段为 `plannedTestAt`;Bug 计划修复时间字段为 `plannedFixAt`。
|
- 测试用例计划测试时间字段为 `plannedTestAt` / `plannedEndAt`;Bug 计划修复时间字段为 `plannedFixAt`。
|
||||||
- 测试轮次复制用例时保留计划测试时间、AI 预估和执行预估,清空实际执行记录。
|
- 测试轮次复制用例时保留计划测试起止时间、AI 预估和执行预估,清空实际执行记录。
|
||||||
|
|
||||||
## 工时统计口径
|
## 工时统计口径
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user