dsh-uitest 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -10
- package/bin/studio.mjs +117 -17
- package/bin/uitest.mjs +3 -3
- package/client.js +1030 -192
- package/index.js +90 -5
- package/lib/backfill.mjs +37 -22
- package/lib/cases-import.mjs +67 -43
- package/lib/cases-md.mjs +5 -0
- package/lib/csv.mjs +207 -0
- package/lib/knowledge-central.mjs +29 -5
- package/lib/xlsx.mjs +2 -1
- package/package.json +1 -1
- package/skills/uitest/SKILL.md +9 -4
- package/studio/documents.mjs +86 -16
- package/studio/host.mjs +126 -17
- package/studio/import.mjs +115 -21
- package/studio/knowledge.mjs +93 -6
- package/studio/runner.mjs +55 -0
- package/studio/snapshot.mjs +23 -12
- package/studio/store.mjs +25 -1
- package/studio/writeback.mjs +85 -23
package/client.js
CHANGED
|
@@ -18,6 +18,7 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
const RECENT_PROJECTS_KEY = 'uitest.studio.recentProjects';
|
|
19
19
|
const POLL_RUNNING = 1600;
|
|
20
20
|
const POLL_IDLE = 9000;
|
|
21
|
+
const POLL_DISTILL = 1200;
|
|
21
22
|
|
|
22
23
|
/* ------------------------------------------------------------------ */
|
|
23
24
|
/* 纯工具 */
|
|
@@ -170,7 +171,8 @@ window.__ModuleLoader__.load({
|
|
|
170
171
|
untested,
|
|
171
172
|
pending: (queuedRuns.length || Number(s.queued) || 0) + untested,
|
|
172
173
|
running: runningRuns.length,
|
|
173
|
-
|
|
174
|
+
// 还有未判定用例时最多 99%,避免 241/242 四舍五入成 100%。
|
|
175
|
+
percent: total ? (done >= total ? 100 : Math.min(99, Math.floor((done / total) * 100))) : 0,
|
|
174
176
|
current,
|
|
175
177
|
queuedRuns,
|
|
176
178
|
stage: runningStage,
|
|
@@ -215,7 +217,7 @@ window.__ModuleLoader__.load({
|
|
|
215
217
|
return String(value || '')
|
|
216
218
|
.normalize('NFKC')
|
|
217
219
|
.trim()
|
|
218
|
-
.replace(/\.(md|markdown|txt|xlsx|json)$/i, '')
|
|
220
|
+
.replace(/\.(md|markdown|txt|xlsx|csv|json)$/i, '')
|
|
219
221
|
.replace(/\s+/g, '')
|
|
220
222
|
.toLowerCase();
|
|
221
223
|
}
|
|
@@ -529,7 +531,7 @@ window.__ModuleLoader__.load({
|
|
|
529
531
|
const elapsed = useElapsed(props.startedAt, props.active !== false);
|
|
530
532
|
return h('div', { className: 'studio-op', role: 'status', 'aria-live': 'polite' },
|
|
531
533
|
h('div', { className: 'studio-op-head' },
|
|
532
|
-
h(Spinner),
|
|
534
|
+
props.active === false ? h(Icon, { name: 'clock', size: 14 }) : h(Spinner),
|
|
533
535
|
h('span', { className: 'studio-op-title' }, props.label || '正在处理'),
|
|
534
536
|
h('span', { className: 'studio-op-time' }, formatDuration(elapsed))
|
|
535
537
|
),
|
|
@@ -542,10 +544,62 @@ window.__ModuleLoader__.load({
|
|
|
542
544
|
}, h('span', { className: 'studio-op-step-dot' }), step.label))
|
|
543
545
|
)
|
|
544
546
|
: null,
|
|
545
|
-
h('div', { className: 'studio-op-bar' }, h(Progress, {
|
|
547
|
+
h('div', { className: 'studio-op-bar' }, h(Progress, {
|
|
548
|
+
percent: props.percent,
|
|
549
|
+
indeterminate: props.indeterminate !== false,
|
|
550
|
+
tone: 'business',
|
|
551
|
+
}))
|
|
546
552
|
);
|
|
547
553
|
}
|
|
548
554
|
|
|
555
|
+
const DISTILL_PHASES = [
|
|
556
|
+
{ id: 'learn', label: '页面学习' },
|
|
557
|
+
{ id: 'process', label: '流程知识合并' },
|
|
558
|
+
{ id: 'episodes', label: '整理中心知识' },
|
|
559
|
+
{ id: 'central', label: '写入中心知识库' },
|
|
560
|
+
{ id: 'finalize', label: '写入批次知识' },
|
|
561
|
+
];
|
|
562
|
+
const DISTILL_PHASE_LABELS = {
|
|
563
|
+
starting: '正在启动沉淀',
|
|
564
|
+
learn: '页面学习',
|
|
565
|
+
process: '流程知识合并',
|
|
566
|
+
episodes: '整理中心知识',
|
|
567
|
+
central: '写入中心知识库',
|
|
568
|
+
finalize: '写入批次知识',
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
function distillSteps(stage) {
|
|
572
|
+
const phase = String(stage?.phase || '');
|
|
573
|
+
const activeIndex = phase === 'done'
|
|
574
|
+
? DISTILL_PHASES.length
|
|
575
|
+
: phase === 'starting'
|
|
576
|
+
? 0
|
|
577
|
+
: DISTILL_PHASES.findIndex((item) => item.id === phase);
|
|
578
|
+
return DISTILL_PHASES.map((item, index) => ({
|
|
579
|
+
label: item.label,
|
|
580
|
+
status: phase === 'done' || index < activeIndex ? 'done' : index === activeIndex ? 'active' : '',
|
|
581
|
+
}));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function distillPhaseText(stage) {
|
|
585
|
+
if (!stage) return '';
|
|
586
|
+
if (stage.status === 'failed') return '沉淀失败,可重新沉淀。';
|
|
587
|
+
if (stage.status === 'done') return '沉淀完成。';
|
|
588
|
+
const phase = String(stage.phase || 'starting');
|
|
589
|
+
const label = DISTILL_PHASE_LABELS[phase] || '正在沉淀';
|
|
590
|
+
const total = Number(stage.total) || 0;
|
|
591
|
+
const done = Number(stage.done) || 0;
|
|
592
|
+
const count = total > 0 ? ' · ' + done + ' / ' + total : '';
|
|
593
|
+
const mode = phase === 'central'
|
|
594
|
+
? stage.mode === 'fast'
|
|
595
|
+
? ' · 只写原始 Episode,实体抽取由中心服务后台继续'
|
|
596
|
+
: stage.mode === 'classic'
|
|
597
|
+
? ' · 正在同步写入并等待中心服务抽取'
|
|
598
|
+
: ''
|
|
599
|
+
: '';
|
|
600
|
+
return label + count + mode;
|
|
601
|
+
}
|
|
602
|
+
|
|
549
603
|
function Field(props) {
|
|
550
604
|
return h('label', { className: 'studio-field' },
|
|
551
605
|
h('span', { className: 'studio-field-label' }, props.label),
|
|
@@ -569,13 +623,18 @@ window.__ModuleLoader__.load({
|
|
|
569
623
|
return () => window.removeEventListener('keydown', onKey);
|
|
570
624
|
}, [props.onClose]);
|
|
571
625
|
return h('div', { className: 'studio-modal-overlay', onMouseDown: (e) => { if (e.target === e.currentTarget) props.onClose(); } },
|
|
572
|
-
h('div', {
|
|
626
|
+
h('div', {
|
|
627
|
+
className: cx('studio-modal', props.wide ? 'studio-modal-wide' : ''),
|
|
628
|
+
role: 'dialog',
|
|
629
|
+
'aria-modal': 'true',
|
|
630
|
+
'aria-label': props.title || '对话框',
|
|
631
|
+
},
|
|
573
632
|
h('div', { className: 'studio-modal-head' },
|
|
574
633
|
h('div', null,
|
|
575
634
|
h('h3', { className: 'studio-modal-title' }, props.title),
|
|
576
635
|
props.desc ? h('p', { className: 'studio-modal-desc' }, props.desc) : null
|
|
577
636
|
),
|
|
578
|
-
h('button', { className: 'studio-icon-btn', onClick: props.onClose, title: '关闭' }, h(Icon, { name: 'x', size: 16 }))
|
|
637
|
+
h('button', { className: 'studio-icon-btn', onClick: props.onClose, title: '关闭', 'aria-label': '关闭对话框' }, h(Icon, { name: 'x', size: 16 }))
|
|
579
638
|
),
|
|
580
639
|
h('div', { className: 'studio-modal-body' }, props.children),
|
|
581
640
|
props.footer ? h('div', { className: 'studio-modal-foot' }, props.footer) : null
|
|
@@ -900,6 +959,10 @@ window.__ModuleLoader__.load({
|
|
|
900
959
|
'.studio-case.is-active{border-color:var(--ui-accent);background:var(--ui-accent-soft);box-shadow:0 0 0 1px color-mix(in srgb,var(--ui-accent) 22%,transparent)}',
|
|
901
960
|
'.studio-case.is-active:before{content:"";position:absolute;left:-1px;top:9px;bottom:9px;width:3px;border-radius:0 3px 3px 0;background:var(--ui-accent)}',
|
|
902
961
|
'.studio-case.is-live{border-color:color-mix(in srgb,var(--ui-business) 32%,var(--ui-border))}',
|
|
962
|
+
'.studio-case.is-child{margin-left:24px;border-left:3px solid color-mix(in srgb,var(--ui-accent) 24%,var(--ui-border))}',
|
|
963
|
+
'.studio-case.is-child.is-active{border-left-color:var(--ui-accent)}',
|
|
964
|
+
'.studio-case-seq{flex:none;min-width:30px;height:22px;padding:0 5px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px;background:var(--ui-surface-2);color:var(--ui-text-3);font-family:var(--ui-mono);font-size:10.5px;font-variant-numeric:tabular-nums}',
|
|
965
|
+
'.studio-case.is-active .studio-case-seq{background:color-mix(in srgb,var(--ui-accent) 14%,var(--ui-surface));color:var(--ui-accent)}',
|
|
903
966
|
'.studio-case-check{margin-top:2px;flex:none;display:flex;align-items:center}',
|
|
904
967
|
'.studio-case-main{flex:1;min-width:0;display:flex;flex-direction:column;justify-content:center}',
|
|
905
968
|
'.studio-case-top{display:flex;align-items:center;gap:7px;min-width:0}',
|
|
@@ -909,7 +972,11 @@ window.__ModuleLoader__.load({
|
|
|
909
972
|
'.studio-case-meta>span{flex:none}',
|
|
910
973
|
'.studio-case-meta>span:last-child{overflow:hidden;text-overflow:ellipsis;flex:0 1 auto}',
|
|
911
974
|
'.studio-case-side{display:flex;flex-direction:column;align-items:flex-end;justify-content:center;gap:3px;flex:none}',
|
|
975
|
+
'.studio-case-status-mobile{display:none}',
|
|
912
976
|
'.studio-case-scroll{max-height:clamp(320px,calc(100vh - 330px),760px);border-radius:10px}',
|
|
977
|
+
'.studio-picker-group{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}',
|
|
978
|
+
'.studio-picker-doc{height:auto;cursor:default;padding:8px 10px}',
|
|
979
|
+
'.studio-picker-doc .studio-doc-hint{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
913
980
|
|
|
914
981
|
/* ---------- 文档行 ---------- */
|
|
915
982
|
'.studio-doc-row{display:flex;align-items:center;gap:9px;padding:9px 12px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface-2);cursor:pointer;height:100%;min-width:0;overflow:hidden;transition:background .12s ease,border-color .12s ease}',
|
|
@@ -928,7 +995,18 @@ window.__ModuleLoader__.load({
|
|
|
928
995
|
'.studio-doc-sub>span{flex:none}',
|
|
929
996
|
'.studio-doc-hint{overflow:hidden;text-overflow:ellipsis;flex:0 1 auto!important}',
|
|
930
997
|
'.studio-doc-rollup{display:inline-flex;gap:7px;min-width:0;overflow:hidden}',
|
|
931
|
-
'.studio-doc-writeback,.studio-doc-mode,.studio-doc-action{flex:none}',
|
|
998
|
+
'.studio-doc-writeback,.studio-doc-mode,.studio-doc-action,.studio-doc-more{flex:none}',
|
|
999
|
+
'.studio-doc-row.is-archived{opacity:.78}',
|
|
1000
|
+
'.studio-doc-archived{flex:none}',
|
|
1001
|
+
'.studio-doc-more{width:24px;height:24px}',
|
|
1002
|
+
'.studio-archived-toggle{flex:none;margin-left:auto;white-space:nowrap}',
|
|
1003
|
+
'.studio-doc-action-list{display:grid;gap:6px}',
|
|
1004
|
+
'.studio-doc-action-row{width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer}',
|
|
1005
|
+
'.studio-doc-action-row.is-danger .studio-row-title{color:var(--ui-danger)}',
|
|
1006
|
+
'.studio-doc-action-desc{font-size:11px;color:var(--ui-text-3);line-height:1.55;white-space:normal}',
|
|
1007
|
+
'.studio-doc-action-icon{flex:none;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;border:1px solid var(--ui-border);background:var(--ui-surface);color:var(--ui-text-2)}',
|
|
1008
|
+
'.studio-doc-action-row.is-danger .studio-doc-action-icon{color:var(--ui-danger);border-color:color-mix(in srgb,var(--ui-danger) 35%,var(--ui-border))}',
|
|
1009
|
+
'.studio-doc-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:6px}',
|
|
932
1010
|
|
|
933
1011
|
/* ---------- 用例所属文档 ---------- */
|
|
934
1012
|
'.studio-doc-link{display:flex;align-items:center;gap:5px;margin-top:8px;font-size:11px;color:var(--ui-text-3);min-width:0;flex-wrap:wrap}',
|
|
@@ -950,6 +1028,8 @@ window.__ModuleLoader__.load({
|
|
|
950
1028
|
'.studio-nl-label{font-size:10.5px;font-weight:650;color:var(--ui-text-3);margin-bottom:5px;letter-spacing:.1px}',
|
|
951
1029
|
'.studio-nl-list{margin:0;padding-left:18px;color:var(--ui-text-2);font-size:12px;line-height:1.75}',
|
|
952
1030
|
'.studio-nl-list li{margin:2px 0}',
|
|
1031
|
+
'.studio-definition{display:flex;flex-direction:column;gap:14px}',
|
|
1032
|
+
'.studio-definition.is-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;align-items:start}',
|
|
953
1033
|
'.studio-note{white-space:pre-wrap;word-break:break-word;color:var(--ui-text-2);font-size:11.5px;line-height:1.65}',
|
|
954
1034
|
'.studio-evidence{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}',
|
|
955
1035
|
'.studio-evidence-item{display:flex;flex-direction:column;gap:4px;min-width:0}',
|
|
@@ -959,6 +1039,8 @@ window.__ModuleLoader__.load({
|
|
|
959
1039
|
'.studio-lifecycle{display:flex;gap:6px;flex-wrap:wrap;margin-top:12px}',
|
|
960
1040
|
'.studio-lifecycle-item{flex:1 1 118px;min-width:0;display:flex;align-items:flex-start;gap:6px;padding:7px 9px;border:1px solid transparent;border-radius:8px;background:var(--ui-surface-2);color:inherit;font:inherit;text-align:left;cursor:pointer;transition:background .12s ease,border-color .12s ease}',
|
|
961
1041
|
'.studio-lifecycle-item:hover{background:var(--ui-hover);border-color:var(--ui-border)}',
|
|
1042
|
+
'.studio-lifecycle-item.is-active{background:var(--ui-active);border-color:color-mix(in srgb,var(--ui-accent) 38%,var(--ui-border))}',
|
|
1043
|
+
'.studio-lifecycle-item.is-active .studio-lifecycle-label{color:var(--ui-accent)}',
|
|
962
1044
|
'.studio-lifecycle-dot{flex:none;width:7px;height:7px;margin-top:5px;border-radius:50%;background:var(--ui-text-3)}',
|
|
963
1045
|
'.studio-lifecycle-label{font-size:11px;font-weight:650;color:var(--ui-text)}',
|
|
964
1046
|
'.studio-lifecycle-detail{font-size:10.5px;line-height:1.45;color:var(--ui-text-2);word-break:break-word}',
|
|
@@ -971,6 +1053,10 @@ window.__ModuleLoader__.load({
|
|
|
971
1053
|
'.studio-result-row{display:flex;align-items:flex-start;gap:12px;width:100%;padding:11px 13px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface);color:inherit;font:inherit;text-align:left;cursor:pointer;min-width:0;height:100%;transition:background .12s ease,border-color .12s ease}',
|
|
972
1054
|
'.studio-result-row:hover{background:var(--ui-hover)}',
|
|
973
1055
|
'.studio-result-row.is-live{border-color:color-mix(in srgb,var(--ui-business) 32%,var(--ui-border));background:color-mix(in srgb,var(--ui-business) 4%,var(--ui-surface))}',
|
|
1056
|
+
'.studio-result-row.is-selected{border-color:var(--ui-accent);background:var(--ui-accent-soft)}',
|
|
1057
|
+
'.studio-bulk-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;border:1px solid color-mix(in srgb,var(--ui-accent) 30%,var(--ui-border));border-radius:9px;background:var(--ui-accent-soft);font-size:11.5px}',
|
|
1058
|
+
'.studio-bulk-bar .studio-row-sub{margin:0}',
|
|
1059
|
+
'.studio-run-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
|
|
974
1060
|
'.studio-result-main{flex:1;min-width:0;display:grid;gap:4px}',
|
|
975
1061
|
'.studio-result-title{font-size:12px;font-weight:620;line-height:1.45;word-break:break-word;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}',
|
|
976
1062
|
'.studio-result-summary{font-size:11px;line-height:1.5;color:var(--ui-text-2);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
|
|
@@ -1045,7 +1131,7 @@ window.__ModuleLoader__.load({
|
|
|
1045
1131
|
'.studio-modal-body{padding:16px 18px;overflow-y:auto;min-height:0}',
|
|
1046
1132
|
'.studio-modal-foot{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:12px 18px;border-top:1px solid var(--ui-border);background:var(--ui-surface-2);flex:none}',
|
|
1047
1133
|
'.studio-drawer-overlay{position:absolute;inset:0;z-index:80;display:flex;justify-content:flex-end;background:color-mix(in srgb,var(--ui-bg) 55%,transparent);backdrop-filter:blur(2px)}',
|
|
1048
|
-
'.studio-drawer{width:min(
|
|
1134
|
+
'.studio-drawer{width:min(1120px,100%);height:100%;display:flex;flex-direction:column;background:var(--ui-surface);border-left:1px solid var(--ui-border);box-shadow:var(--ui-shadow-lg)}',
|
|
1049
1135
|
'.studio-drawer-body{flex:1;overflow-y:auto;padding:14px 18px 24px;min-height:0}',
|
|
1050
1136
|
'.studio-form{display:flex;flex-direction:column;gap:13px}',
|
|
1051
1137
|
'.studio-field{display:flex;flex-direction:column;gap:5px}',
|
|
@@ -1105,7 +1191,7 @@ window.__ModuleLoader__.load({
|
|
|
1105
1191
|
'@media (max-width:1240px){.studio-brand-sub{display:none}.studio-env{max-width:180px}.studio-content{padding:22px 24px 56px}.studio-hero{padding:22px 22px 20px}.studio-hero-grid{grid-template-columns:minmax(0,1.3fr) minmax(260px,.9fr);gap:20px}.studio-hero-title{font-size:24px}.studio-grid-2{grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:14px}.studio-case-scroll{max-height:clamp(300px,calc(100vh - 320px),720px)}.studio-doc-mode{display:none}}',
|
|
1106
1192
|
'@media (max-width:1080px){.studio-env{display:none}.studio-topbar{gap:8px}.studio-select{max-width:180px}.studio-hero-grid{grid-template-columns:1fr}.studio-pipeline{grid-template-columns:repeat(3,minmax(0,1fr))}.studio-pipe:nth-child(4){border-left:0;border-top:1px solid var(--ui-border)}.studio-pipe:nth-child(n+4){border-top:1px solid var(--ui-border)}.studio-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-stat:nth-child(3){border-left:0;border-top:1px solid var(--ui-border)}.studio-stat:nth-child(4){border-top:1px solid var(--ui-border)}.studio-grid-2{grid-template-columns:1fr}.studio-detail{position:static;max-height:none}.studio-case-scroll{max-height:520px}.studio-result-scroll{max-height:480px}.studio-stage-strip{grid-template-columns:repeat(3,minmax(0,1fr))}}',
|
|
1107
1193
|
'@media (max-width:900px){.studio-account-grid{grid-template-columns:1fr}.studio-monitor-grid{grid-template-columns:1fr}.studio-live-grid{grid-template-columns:1fr}.studio-result-side{max-width:52%}.studio-doc-writeback{display:none}}',
|
|
1108
|
-
'@media (max-width:720px){.studio-topbar{flex-wrap:wrap;padding:9px 12px;min-height:auto;gap:8px}.studio-brand-sub{display:none}.studio-topbar-spacer{display:none}.studio-topbar .studio-btn{padding:0 9px}.studio-rail{position:fixed;left:0;right:0;bottom:0;z-index:30;width:auto;flex-direction:row;gap:2px;padding:6px 8px;border-right:0;border-top:1px solid var(--ui-border);overflow-x:auto}.studio-rail-group,.studio-rail-foot{display:none}.studio-nav{flex-direction:column;gap:2px;height:48px;justify-content:center;padding:0 6px;font-size:9.5px;min-width:56px}.studio-nav.is-active:before{display:none}.studio-nav-icon{display:flex}.studio-nav-badge{display:none}.studio-body{padding-bottom:58px}.studio-content{padding:16px 14px 44px}.studio-hero{padding:18px 16px}.studio-hero-title{font-size:21px}.studio-pipeline{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-page-head{flex-direction:column;justify-content:flex-start;gap:12px}.studio-page-head>div:first-child{flex:0 1 auto;width:100%}.studio-page-actions{justify-content:flex-start}.studio-evidence{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-case-side{display:none}.studio-kv{grid-template-columns:90px minmax(0,1fr)}.studio-step-thumb{width:72px;height:44px}.studio-row-actions{opacity:1}.studio-stat-grid{grid-template-columns:1fr 1fr}.studio-execution-metrics{gap:8px 0}.studio-metric{min-width:64px;padding-right:10px;margin-right:10px}.studio-result-side{display:none}.studio-filter-bar{width:100%;overflow-x:auto;flex-wrap:nowrap}.studio-doc-row{padding:8px 9px;gap:6px}.studio-doc-sub{gap:6px}.studio-doc-kind,.studio-doc-version,.studio-doc-writeback,.studio-doc-mode,.studio-doc-action-label{display:none}.studio-doc-action{padding:0 6px}}',
|
|
1194
|
+
'@media (max-width:720px){.studio-topbar{flex-wrap:wrap;padding:9px 12px;min-height:auto;gap:8px}.studio-brand-sub{display:none}.studio-topbar-spacer{display:none}.studio-topbar .studio-btn{padding:0 9px}.studio-rail{position:fixed;left:0;right:0;bottom:0;z-index:30;width:auto;flex-direction:row;gap:2px;padding:6px 8px;border-right:0;border-top:1px solid var(--ui-border);overflow-x:auto}.studio-rail-group,.studio-rail-foot{display:none}.studio-nav{flex-direction:column;gap:2px;height:48px;justify-content:center;padding:0 6px;font-size:9.5px;min-width:56px}.studio-nav.is-active:before{display:none}.studio-nav-icon{display:flex}.studio-nav-badge{display:none}.studio-body{padding-bottom:58px}.studio-content{padding:16px 14px 44px}.studio-hero{padding:18px 16px}.studio-hero-title{font-size:21px}.studio-pipeline{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-page-head{flex-direction:column;justify-content:flex-start;gap:12px}.studio-page-head>div:first-child{flex:0 1 auto;width:100%}.studio-page-actions{justify-content:flex-start}.studio-evidence{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-case-side{display:none}.studio-case-status-mobile{display:inline-flex}.studio-kv{grid-template-columns:90px minmax(0,1fr)}.studio-step-thumb{width:72px;height:44px}.studio-row-actions{opacity:1}.studio-stat-grid{grid-template-columns:1fr 1fr}.studio-execution-metrics{gap:8px 0}.studio-metric{min-width:64px;padding-right:10px;margin-right:10px}.studio-result-side{display:none}.studio-filter-bar{width:100%;overflow-x:auto;flex-wrap:nowrap}.studio-doc-row{padding:8px 9px;gap:6px}.studio-doc-sub{gap:6px}.studio-doc-kind,.studio-doc-version,.studio-doc-writeback,.studio-doc-mode,.studio-doc-action-label{display:none}.studio-doc-action{padding:0 6px}}',
|
|
1109
1195
|
'@media (prefers-reduced-motion:reduce){.studio-root *{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}}',
|
|
1110
1196
|
].join('\n');
|
|
1111
1197
|
|
|
@@ -1276,6 +1362,32 @@ window.__ModuleLoader__.load({
|
|
|
1276
1362
|
.map((item) => item.run);
|
|
1277
1363
|
}
|
|
1278
1364
|
|
|
1365
|
+
function runIsActive(run) {
|
|
1366
|
+
return ['running', 'preparing', 'queued', 'pending'].includes(run?.status)
|
|
1367
|
+
|| ['running', 'queued'].includes(run?.queue?.state);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
function runMatchesQuery(run, query) {
|
|
1371
|
+
if (!query) return true;
|
|
1372
|
+
const text = [
|
|
1373
|
+
run.title,
|
|
1374
|
+
run.caseId,
|
|
1375
|
+
run.note,
|
|
1376
|
+
run.review?.summary,
|
|
1377
|
+
asArray(run.review?.issues).join(' '),
|
|
1378
|
+
run.queue?.hint,
|
|
1379
|
+
run.mode,
|
|
1380
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
1381
|
+
return text.includes(query);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
const RUN_SORTS = [
|
|
1385
|
+
{ id: 'active', label: '执行优先' },
|
|
1386
|
+
{ id: 'seq', label: '序号' },
|
|
1387
|
+
{ id: 'started', label: '开始时间' },
|
|
1388
|
+
{ id: 'duration', label: '执行时长' },
|
|
1389
|
+
];
|
|
1390
|
+
|
|
1279
1391
|
function QueueBadge(props) {
|
|
1280
1392
|
const info = queueDisplay(props.run);
|
|
1281
1393
|
if (!info) return null;
|
|
@@ -1803,10 +1915,11 @@ window.__ModuleLoader__.load({
|
|
|
1803
1915
|
const latest = batches[0];
|
|
1804
1916
|
const activeProgress = active ? batchProgress(active) : null;
|
|
1805
1917
|
const latestProgress = latest ? batchProgress(latest) : null;
|
|
1806
|
-
const
|
|
1807
|
-
const
|
|
1918
|
+
const judged = (counts.passed || 0) + (counts.partial || 0) + (counts.failed || 0) + (counts.blocked || 0);
|
|
1919
|
+
const ran = judged + (counts.stopped || 0);
|
|
1920
|
+
const passRate = judged ? Math.round((((counts.passed || 0) + (counts.partial || 0)) / judged) * 100) : 0;
|
|
1808
1921
|
const nextActions = [];
|
|
1809
|
-
if (!counts.total) nextActions.push({ icon: 'import', title: '导入第一份用例文档', desc: '支持 Markdown、文本、xlsx
|
|
1922
|
+
if (!counts.total) nextActions.push({ icon: 'import', title: '导入第一份用例文档', desc: '支持 Markdown、文本、xlsx、CSV;导入后自动生成自然语言用例', onClick: props.onImport });
|
|
1810
1923
|
if (counts.total && !batches.length) nextActions.push({ icon: 'play', title: '创建第一个执行批次', desc: 'flow 与 Agent 两条泳道并发,前置造数自动执行', onClick: props.onNewBatch });
|
|
1811
1924
|
if (active) nextActions.push({ icon: 'clock', title: '继续查看执行中的批次', desc: active.name + ' · ' + activeProgress.percent + '% 完成' + (activeProgress.current ? ' · ' + (activeProgress.current.title || activeProgress.current.caseId) : ''), onClick: () => props.onOpenBatch(active.id) });
|
|
1812
1925
|
if (latest && latest.status === 'done' && !latest.writeback) nextActions.push({ icon: 'file', title: '回写用例文档', desc: '批次已结束;按批次一次写回,避免并发覆盖', onClick: () => props.onOpenBatch(latest.id) });
|
|
@@ -1870,7 +1983,7 @@ window.__ModuleLoader__.load({
|
|
|
1870
1983
|
|
|
1871
1984
|
h('div', { className: 'studio-stat-grid' },
|
|
1872
1985
|
h(Stat, { label: '用例总数', value: counts.total || 0, hint: (counts.flow || 0) + ' 条有 flow · ' + (counts.agent || 0) + ' 条走 Agent' }),
|
|
1873
|
-
h(Stat, { label: '已执行', value: ran, tone: counts.failed ? 'danger' : 'success', hint: '通过 ' + (counts.passed || 0) + ' · 失败 ' + (counts.failed || 0) }),
|
|
1986
|
+
h(Stat, { label: '已执行', value: ran, tone: counts.failed ? 'danger' : 'success', hint: '通过 ' + (counts.passed || 0) + ' · 部分 ' + (counts.partial || 0) + ' · 失败 ' + (counts.failed || 0) }),
|
|
1874
1987
|
h(Stat, { label: '通过率', value: passRate + '%', tone: passRate >= 80 ? 'success' : passRate >= 50 ? 'warn' : 'danger', hint: '仅统计已判定用例' }),
|
|
1875
1988
|
h(Stat, { label: '知识资产', value: knowledge.pages || 0, hint: (knowledge.processes || 0) + ' 个流程 · ' + (knowledge.learnings || 0) + ' 条学习' })
|
|
1876
1989
|
),
|
|
@@ -1943,11 +2056,15 @@ window.__ModuleLoader__.load({
|
|
|
1943
2056
|
}
|
|
1944
2057
|
|
|
1945
2058
|
function docKindLabel(kind) {
|
|
1946
|
-
return ({ xlsx: 'Excel', markdown: 'Markdown', json: 'JSON', text: '文本' })[kind] || kind || '文档';
|
|
2059
|
+
return ({ xlsx: 'Excel', csv: 'CSV', markdown: 'Markdown', json: 'JSON', text: '文本' })[kind] || kind || '文档';
|
|
1947
2060
|
}
|
|
1948
2061
|
|
|
1949
2062
|
function docKindTone(kind) {
|
|
1950
|
-
return kind === 'xlsx' ? 'success' : kind === 'markdown' ? 'link' : kind === 'json' ? 'warn' : 'muted';
|
|
2063
|
+
return kind === 'xlsx' || kind === 'csv' ? 'success' : kind === 'markdown' ? 'link' : kind === 'json' ? 'warn' : 'muted';
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
function docCaseFileLabel(state) {
|
|
2067
|
+
return ({ ready: '可用', missing: '缺失', pending: '待生成' })[state] || state || '未知';
|
|
1951
2068
|
}
|
|
1952
2069
|
|
|
1953
2070
|
function docModeLabel(mode) {
|
|
@@ -1960,6 +2077,8 @@ window.__ModuleLoader__.load({
|
|
|
1960
2077
|
['failed', '失败', 'danger'],
|
|
1961
2078
|
['blocked', '阻塞', 'warn'],
|
|
1962
2079
|
['running', '执行中', 'business'],
|
|
2080
|
+
['queued', '排队', 'muted'],
|
|
2081
|
+
['stopped', '已停', 'warn'],
|
|
1963
2082
|
['untested', '未执行', 'muted'],
|
|
1964
2083
|
];
|
|
1965
2084
|
|
|
@@ -2017,7 +2136,7 @@ window.__ModuleLoader__.load({
|
|
|
2017
2136
|
const total = doc ? Number(doc.visibleCount) || 0 : Number(props.total) || 0;
|
|
2018
2137
|
const toggle = () => props.onToggleCollapse(collapseKey);
|
|
2019
2138
|
return h('div', {
|
|
2020
|
-
className: cx('studio-doc-row', isUnassigned ? 'is-unassigned' : '', expanded ? 'is-expanded' : ''),
|
|
2139
|
+
className: cx('studio-doc-row', isUnassigned ? 'is-unassigned' : '', expanded ? 'is-expanded' : '', doc?.archived ? 'is-archived' : ''),
|
|
2021
2140
|
role: 'button',
|
|
2022
2141
|
tabIndex: 0,
|
|
2023
2142
|
onClick: toggle,
|
|
@@ -2046,9 +2165,14 @@ window.__ModuleLoader__.load({
|
|
|
2046
2165
|
h('div', { className: 'studio-doc-top' },
|
|
2047
2166
|
h('span', { className: 'studio-doc-name', title: doc?.name || '未归属文档' }, doc?.name || '未归属文档'),
|
|
2048
2167
|
doc ? h(Badge, { tone: docKindTone(doc.kind), className: 'studio-doc-kind' }, docKindLabel(doc.kind)) : null,
|
|
2168
|
+
doc?.archived ? h(Badge, { tone: 'muted', className: 'studio-doc-archived' }, '已归档') : null,
|
|
2049
2169
|
h('span', { className: 'studio-doc-count' },
|
|
2050
2170
|
total + ' 条',
|
|
2051
|
-
props.filtering && cases.length !== total
|
|
2171
|
+
props.filtering && cases.length !== total
|
|
2172
|
+
? ' · 命中 ' + cases.length
|
|
2173
|
+
: !props.filtering && props.truncated && doc && cases.length < total
|
|
2174
|
+
? ' · 已载入 ' + cases.length
|
|
2175
|
+
: ''
|
|
2052
2176
|
),
|
|
2053
2177
|
doc ? h('span', { className: 'studio-doc-version' }, 'v' + (doc.version || 1)) : null,
|
|
2054
2178
|
doc
|
|
@@ -2064,7 +2188,9 @@ window.__ModuleLoader__.load({
|
|
|
2064
2188
|
h('span', { className: 'studio-doc-rollup' },
|
|
2065
2189
|
rollup.length
|
|
2066
2190
|
? rollup.map((part) => h('span', { key: part.key, className: cx('tone-' + part.tone) }, part.label))
|
|
2067
|
-
:
|
|
2191
|
+
: total
|
|
2192
|
+
? '暂无执行结果'
|
|
2193
|
+
: '暂无用例,可重新导读或重新关联源文件'
|
|
2068
2194
|
),
|
|
2069
2195
|
h('span', { className: 'studio-doc-writeback' },
|
|
2070
2196
|
doc.writeback?.at ? '回写 ' + relativeTime(doc.writeback.at) : '未回写'),
|
|
@@ -2077,7 +2203,14 @@ window.__ModuleLoader__.load({
|
|
|
2077
2203
|
className: 'studio-btn studio-btn-sm studio-doc-action',
|
|
2078
2204
|
title: '重新读取源文档并更新该文档下的用例',
|
|
2079
2205
|
onClick: (event) => { event.stopPropagation(); props.onReRead(doc); },
|
|
2080
|
-
}, h(Icon, { name: 'refresh', size: 12 }), h('span', { className: 'studio-doc-action-label' }, '重新导读')) : null
|
|
2206
|
+
}, h(Icon, { name: 'refresh', size: 12 }), h('span', { className: 'studio-doc-action-label' }, '重新导读')) : null,
|
|
2207
|
+
doc ? h('button', {
|
|
2208
|
+
type: 'button',
|
|
2209
|
+
className: 'studio-icon-btn studio-doc-more',
|
|
2210
|
+
title: '更多文档操作',
|
|
2211
|
+
'aria-label': '更多文档操作:' + (doc.name || doc.id),
|
|
2212
|
+
onClick: (event) => { event.stopPropagation(); props.onActions(doc); },
|
|
2213
|
+
}, h(Icon, { name: 'more', size: 15 })) : null
|
|
2081
2214
|
);
|
|
2082
2215
|
});
|
|
2083
2216
|
|
|
@@ -2085,7 +2218,7 @@ window.__ModuleLoader__.load({
|
|
|
2085
2218
|
const item = props.item;
|
|
2086
2219
|
const live = props.live || null;
|
|
2087
2220
|
return h('div', {
|
|
2088
|
-
className: cx('studio-case', props.active ? 'is-active' : '', live ? 'is-live' : ''),
|
|
2221
|
+
className: cx('studio-case', props.indent ? 'is-child' : '', props.active ? 'is-active' : '', live ? 'is-live' : ''),
|
|
2089
2222
|
onClick: () => props.onSelect(item.tcId),
|
|
2090
2223
|
role: 'button',
|
|
2091
2224
|
tabIndex: 0,
|
|
@@ -2101,6 +2234,7 @@ window.__ModuleLoader__.load({
|
|
|
2101
2234
|
),
|
|
2102
2235
|
h('div', { className: 'studio-case-main' },
|
|
2103
2236
|
h('div', { className: 'studio-case-top' },
|
|
2237
|
+
props.seq ? h('span', { className: 'studio-case-seq', title: '文档内序号' }, '#' + props.seq) : null,
|
|
2104
2238
|
h('span', { className: 'studio-case-title' }, item.title || item.tcId),
|
|
2105
2239
|
h('span', { className: 'studio-case-id' }, item.tcId)
|
|
2106
2240
|
),
|
|
@@ -2118,9 +2252,10 @@ window.__ModuleLoader__.load({
|
|
|
2118
2252
|
item.module ? h('span', { key: 'module' }, item.module) : null,
|
|
2119
2253
|
item.priority ? h('span', { key: 'priority' }, item.priority) : null,
|
|
2120
2254
|
item.mode === 'flow' && asArray(item.dataNeeds).length ? h('span', { key: 'data' }, '数据提示:' + item.dataNeeds.join('、')) : null,
|
|
2121
|
-
)
|
|
2122
|
-
|
|
2123
|
-
|
|
2255
|
+
),
|
|
2256
|
+
h('span', { className: 'studio-case-status-mobile' }, h(StatusBadge, { status: live ? live.status : item.status }))
|
|
2257
|
+
)
|
|
2258
|
+
),
|
|
2124
2259
|
h('div', { className: 'studio-case-side' },
|
|
2125
2260
|
h(StatusBadge, { status: live ? live.status : item.status }),
|
|
2126
2261
|
item.lastRun ? h('span', { className: 'studio-case-id' }, relativeTime(item.lastRun.at)) : null
|
|
@@ -2128,6 +2263,8 @@ window.__ModuleLoader__.load({
|
|
|
2128
2263
|
);
|
|
2129
2264
|
}, (prev, next) => prev.active === next.active
|
|
2130
2265
|
&& prev.selected === next.selected
|
|
2266
|
+
&& prev.seq === next.seq
|
|
2267
|
+
&& prev.indent === next.indent
|
|
2131
2268
|
&& sameLiveState(prev.live, next.live)
|
|
2132
2269
|
&& caseSignature(prev.item) === caseSignature(next.item));
|
|
2133
2270
|
|
|
@@ -2142,13 +2279,29 @@ window.__ModuleLoader__.load({
|
|
|
2142
2279
|
});
|
|
2143
2280
|
}
|
|
2144
2281
|
|
|
2282
|
+
/** 用例定义的三段自然语言内容;详情与执行抽屉共用同一数据形状。 */
|
|
2283
|
+
function CaseDefinition(props) {
|
|
2284
|
+
const nl = props.nl || {};
|
|
2285
|
+
const blocks = [
|
|
2286
|
+
{ key: 'preconditions', label: '前置条件', items: asArray(nl.preconditions), empty: '无特殊前置,按用例步骤直接执行。' },
|
|
2287
|
+
{ key: 'steps', label: '测试过程', items: asArray(nl.steps), empty: '未提供步骤;执行时由 Agent 按用例描述完成并记录页面状态。' },
|
|
2288
|
+
{ key: 'expected', label: '预期结果', items: asArray(nl.expected), empty: '未提供明确预期;执行时记录实际结果与判定依据。' },
|
|
2289
|
+
];
|
|
2290
|
+
return h('div', { className: cx('studio-definition', props.grid ? 'is-grid' : '') },
|
|
2291
|
+
blocks.map((block) => h('div', { key: block.key, className: 'studio-nl-block' },
|
|
2292
|
+
h('div', { className: 'studio-nl-label' }, block.label),
|
|
2293
|
+
block.items.length
|
|
2294
|
+
? h('ol', { className: 'studio-nl-list' }, block.items.map((line, index) => h('li', { key: index }, line)))
|
|
2295
|
+
: h('div', { className: 'studio-note' }, block.empty)
|
|
2296
|
+
))
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2145
2300
|
function CaseDetail(props) {
|
|
2146
2301
|
const item = props.item;
|
|
2147
2302
|
const [tab, setTab] = useState(item?.lastRun ? 'run' : 'nl');
|
|
2148
|
-
const [feedbackRequest, setFeedbackRequest] = useState(0);
|
|
2149
2303
|
useEffect(() => {
|
|
2150
2304
|
setTab(item?.lastRun ? 'run' : 'nl');
|
|
2151
|
-
setFeedbackRequest(0);
|
|
2152
2305
|
}, [item?.tcId, item?.lastRun?.batchId]);
|
|
2153
2306
|
if (!item) return h(Empty, { icon: 'cases', title: '选择一条用例', desc: '查看自然语言用例、关联流程和执行历史。' });
|
|
2154
2307
|
const nl = item.nl || { preconditions: [], steps: [], expected: [] };
|
|
@@ -2165,6 +2318,30 @@ window.__ModuleLoader__.load({
|
|
|
2165
2318
|
const caseDocId = item.docId || item.source?.docId || '';
|
|
2166
2319
|
const caseDocName = caseDoc?.name || item.docName || '';
|
|
2167
2320
|
const caseDocKind = caseDoc?.kind || item.docKind || '';
|
|
2321
|
+
const flowCount = (item.flow ? 1 : 0) + asArray(item.preconditionFlows).length;
|
|
2322
|
+
const tabs = [
|
|
2323
|
+
{ id: 'nl', label: '用例定义', detail: '前置 / 步骤 / 预期' + (flowCount ? ' · ' + flowCount + ' 个流程' : ''), tone: 'success' },
|
|
2324
|
+
{ id: 'run', label: '最近执行', detail: item.lastRun ? statusLabel(item.lastRun.status) + ' · ' + relativeTime(item.lastRun.at) : '尚未执行', tone: runTone },
|
|
2325
|
+
{ id: 'feedback', label: '执行反馈', detail: item.lastFeedback ? '已记录 · 下一轮可带入' : '执行后可填写', tone: item.lastFeedback ? 'success' : 'muted' },
|
|
2326
|
+
{ id: 'knowledge', label: '知识沉淀', detail: knowledge ? knowledgePages + ' 页 · ' + knowledgeCorrections + ' 条纠错' : '执行后生成', tone: knowledge ? 'business' : 'muted' },
|
|
2327
|
+
];
|
|
2328
|
+
const feedbackBox = (defaultOpen) => h(RunFeedbackBox, {
|
|
2329
|
+
caseId: item.tcId,
|
|
2330
|
+
batchId: item.lastRun.batchId,
|
|
2331
|
+
runStatus: item.lastRun.status,
|
|
2332
|
+
project: props.project,
|
|
2333
|
+
latestFeedback: item.lastFeedback || null,
|
|
2334
|
+
usedFeedback: item.lastFeedback && item.lastRun.batchId && item.lastFeedback.batchId === item.lastRun.batchId ? item.lastFeedback : null,
|
|
2335
|
+
defaultOpen,
|
|
2336
|
+
rerunDisabled: !props.hasBaseUrl,
|
|
2337
|
+
onToast: props.onToast,
|
|
2338
|
+
onOpenBatch: (batchId) => props.onCaseRunBatch ? props.onCaseRunBatch(batchId, item.tcId) : props.onOpenBatch(batchId),
|
|
2339
|
+
onRequeued: (payload) => {
|
|
2340
|
+
const batchId = payload?.batch?.id || item.lastRun.batchId;
|
|
2341
|
+
if (props.onCaseRunBatch) props.onCaseRunBatch(batchId, item.tcId);
|
|
2342
|
+
else if (batchId) props.onOpenBatch(batchId);
|
|
2343
|
+
},
|
|
2344
|
+
});
|
|
2168
2345
|
return h('div', { className: 'studio-detail' },
|
|
2169
2346
|
h('div', { className: 'studio-detail-head' },
|
|
2170
2347
|
h('div', { style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 8 } },
|
|
@@ -2195,7 +2372,7 @@ window.__ModuleLoader__.load({
|
|
|
2195
2372
|
item.lastRun && ['failed', 'partial', 'blocked'].includes(item.lastRun.status)
|
|
2196
2373
|
? h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', disabled: !props.hasBaseUrl || Boolean(liveRun), title: liveRun ? '该用例正在批次中执行' : props.hasBaseUrl ? '不填写反馈,直接用 Agent 重跑' : '请先配置被测地址', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'play', size: 12 }), '直接重跑')
|
|
2197
2374
|
: h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', disabled: !props.hasBaseUrl || Boolean(liveRun), title: liveRun ? '该用例正在批次中执行' : props.hasBaseUrl ? '' : '请先配置被测地址', onClick: () => props.onRun(item) }, h(Icon, { name: 'play', size: 12 }), liveRun ? '执行中' : item.lastRun ? '再执行一次' : '执行用例'),
|
|
2198
|
-
item.lastRun ? h('button', { className: 'studio-btn studio-btn-sm', onClick: () =>
|
|
2375
|
+
item.lastRun ? h('button', { className: 'studio-btn studio-btn-sm', onClick: () => setTab('feedback') }, h(Icon, { name: 'file', size: 12 }), '填写反馈') : null,
|
|
2199
2376
|
(!item.lastRun || !['failed', 'partial', 'blocked'].includes(item.lastRun.status)) && (item.flow || asArray(item.preconditionFlows).length) ? h('button', { className: 'studio-btn studio-btn-sm', disabled: !props.hasBaseUrl || Boolean(liveRun), title: liveRun ? '该用例正在批次中执行' : props.hasBaseUrl ? '' : '请先配置被测地址', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑') : null,
|
|
2200
2377
|
item.lastRun?.batchId ? h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onOpenBatch(item.lastRun.batchId) }, h(Icon, { name: 'batch', size: 12 }), '打开批次') : null,
|
|
2201
2378
|
h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onAdd(item.tcId) }, h(Icon, { name: 'plus', size: 12 }), '加入批次'),
|
|
@@ -2220,13 +2397,15 @@ window.__ModuleLoader__.load({
|
|
|
2220
2397
|
),
|
|
2221
2398
|
liveRun.note ? h('div', { style: { marginTop: 5, color: 'var(--ui-text-2)' } }, liveRun.note) : null
|
|
2222
2399
|
) : null,
|
|
2223
|
-
h('div', { className: 'studio-lifecycle' },
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2400
|
+
h('div', { className: 'studio-lifecycle', role: 'tablist', 'aria-label': '用例详情' },
|
|
2401
|
+
tabs.map((step) => h('button', {
|
|
2402
|
+
key: step.id,
|
|
2403
|
+
type: 'button',
|
|
2404
|
+
role: 'tab',
|
|
2405
|
+
'aria-selected': tab === step.id,
|
|
2406
|
+
className: cx('studio-lifecycle-item', tab === step.id ? 'is-active' : ''),
|
|
2407
|
+
onClick: () => setTab(step.id),
|
|
2408
|
+
},
|
|
2230
2409
|
h('span', { className: cx('studio-lifecycle-dot', 'tone-' + step.tone) }),
|
|
2231
2410
|
h('div', { style: { minWidth: 0 } },
|
|
2232
2411
|
h('div', { className: 'studio-lifecycle-label' }, step.label),
|
|
@@ -2235,45 +2414,58 @@ window.__ModuleLoader__.load({
|
|
|
2235
2414
|
))
|
|
2236
2415
|
),
|
|
2237
2416
|
h('div', { className: 'studio-detail-body' },
|
|
2238
|
-
h(TabBar, {
|
|
2239
|
-
tabs: [
|
|
2240
|
-
{ id: 'run', label: '执行与反馈', count: item.lastRun ? 1 : 0 },
|
|
2241
|
-
{ id: 'nl', label: '用例定义' },
|
|
2242
|
-
{ id: 'flow', label: '关联流程', count: (item.flow ? 1 : 0) + asArray(item.preconditionFlows).length },
|
|
2243
|
-
],
|
|
2244
|
-
active: tab,
|
|
2245
|
-
onChange: setTab,
|
|
2246
|
-
}),
|
|
2247
2417
|
tab === 'nl' ? h('div', { className: 'studio-nl' },
|
|
2248
|
-
item.source ? h('div', { className: 'studio-note'
|
|
2418
|
+
item.source ? h('div', { className: 'studio-note' },
|
|
2249
2419
|
'来源:' + (item.source.docName || item.source.doc || item.source.file || '—')
|
|
2250
2420
|
+ (item.source.sheet ? ' · ' + item.source.sheet : '')
|
|
2251
2421
|
+ (item.source.rowNumber ? ' · 第 ' + item.source.rowNumber + ' 行' : '')
|
|
2252
2422
|
+ (item.source.kind ? '(' + item.source.kind + ')' : '')
|
|
2253
2423
|
) : null,
|
|
2254
|
-
h(
|
|
2255
|
-
|
|
2256
|
-
nl.preconditions.length
|
|
2257
|
-
? h('ol', { className: 'studio-nl-list' }, nl.preconditions.map((line, index) => h('li', { key: index }, line)))
|
|
2258
|
-
: h('div', { className: 'studio-note' }, '无特殊前置,按用例步骤直接执行。')
|
|
2259
|
-
),
|
|
2260
|
-
h('div', { className: 'studio-nl-block' },
|
|
2261
|
-
h('div', { className: 'studio-nl-label' }, '测试过程'),
|
|
2262
|
-
nl.steps.length
|
|
2263
|
-
? h('ol', { className: 'studio-nl-list' }, nl.steps.map((line, index) => h('li', { key: index }, line)))
|
|
2264
|
-
: h('div', { className: 'studio-note' }, '未提供步骤;执行时由 Agent 按用例描述完成并记录页面状态。')
|
|
2265
|
-
),
|
|
2266
|
-
h('div', { className: 'studio-nl-block' },
|
|
2267
|
-
h('div', { className: 'studio-nl-label' }, '预期结果'),
|
|
2268
|
-
nl.expected.length
|
|
2269
|
-
? h('ol', { className: 'studio-nl-list' }, nl.expected.map((line, index) => h('li', { key: index }, line)))
|
|
2270
|
-
: h('div', { className: 'studio-note' }, '未提供明确预期;执行时记录实际结果与判定依据。')
|
|
2271
|
-
),
|
|
2272
|
-
item.mode === 'flow' && asArray(item.dataNeeds).length ? h('div', { className: 'studio-note', style: { marginTop: 4 } }, '数据提示(从用例文本推断,不是文档参数字段):' + item.dataNeeds.join('、') + '。') : null,
|
|
2424
|
+
h(CaseDefinition, { nl }),
|
|
2425
|
+
item.mode === 'flow' && asArray(item.dataNeeds).length ? h('div', { className: 'studio-note' }, '数据提示(从用例文本推断,不是文档参数字段):' + item.dataNeeds.join('、') + '。') : null,
|
|
2273
2426
|
item.remark ? h('div', { className: 'studio-nl-block' },
|
|
2274
2427
|
h('div', { className: 'studio-nl-label' }, '备注'),
|
|
2275
2428
|
h('div', { className: 'studio-note' }, item.remark)
|
|
2276
|
-
) : null
|
|
2429
|
+
) : null,
|
|
2430
|
+
h('div', { className: 'studio-nl-block' },
|
|
2431
|
+
h('div', { className: 'studio-nl-label' }, '关联流程(' + flowCount + ')'),
|
|
2432
|
+
item.flow ? h('div', null,
|
|
2433
|
+
h('div', { className: 'studio-kv' },
|
|
2434
|
+
h('span', { className: 'studio-kv-key' }, '流程名'),
|
|
2435
|
+
h('span', { className: 'studio-kv-val' }, h('span', { className: 'studio-code' }, item.flow.name)),
|
|
2436
|
+
h('span', { className: 'studio-kv-key' }, '标题'),
|
|
2437
|
+
h('span', { className: 'studio-kv-val' }, item.flow.title || '—'),
|
|
2438
|
+
h('span', { className: 'studio-kv-key' }, '标签'),
|
|
2439
|
+
h('span', { className: 'studio-kv-val' }, asArray(item.flow.tags).join('、') || '—'),
|
|
2440
|
+
h('span', { className: 'studio-kv-key' }, '文件'),
|
|
2441
|
+
h('span', { className: 'studio-kv-val' }, item.flow.file || '—')
|
|
2442
|
+
),
|
|
2443
|
+
h('div', { className: 'studio-note', style: { marginTop: 10 } }, '有 flow 的用例优先走 flow 泳道;需要重新探索时可用 Agent 重跑,或删除关联 flow 后回到 Agent 泳道。'),
|
|
2444
|
+
h('div', { className: 'studio-detail-actions' },
|
|
2445
|
+
h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑'),
|
|
2446
|
+
h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(item.flow, item) }, '删除关联流程')
|
|
2447
|
+
)
|
|
2448
|
+
) : null,
|
|
2449
|
+
asArray(item.preconditionFlows).length ? h('div', null,
|
|
2450
|
+
h('div', { className: 'studio-nl-label', style: { marginTop: item.flow ? 16 : 0 } }, '前置条件流程'),
|
|
2451
|
+
asArray(item.preconditionFlows).map((flow) => h('div', { key: flow.name, className: 'studio-card', style: { padding: '11px 12px', marginTop: 8, background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
2452
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 7, flexWrap: 'wrap' } },
|
|
2453
|
+
h('span', { className: 'studio-row-title' }, flow.title || flow.name),
|
|
2454
|
+
h(Badge, { tone: 'muted' }, '前置'),
|
|
2455
|
+
h('span', { className: 'studio-code' }, flow.name)
|
|
2456
|
+
),
|
|
2457
|
+
h('div', { className: 'studio-row-sub', style: { marginTop: 5 } }, '提供:' + (asArray(flow.provides).join('、') || '—')),
|
|
2458
|
+
h('div', { className: 'studio-detail-actions' },
|
|
2459
|
+
h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 执行(含前置造数)'),
|
|
2460
|
+
h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(flow, item) }, '删除前置流程')
|
|
2461
|
+
)
|
|
2462
|
+
)),
|
|
2463
|
+
h('div', { className: 'studio-note', style: { marginTop: 8 } }, 'Agent 执行会从头准备前置数据,并在 Agent 视图显示造数思考与操作过程。')
|
|
2464
|
+
) : null,
|
|
2465
|
+
!item.flow && !asArray(item.preconditionFlows).length
|
|
2466
|
+
? h('div', { className: 'studio-note' }, '还没有关联流程。Agent 执行通过后会自动把轨迹沉淀成 flows/agent-<caseId>.json。')
|
|
2467
|
+
: null
|
|
2468
|
+
)
|
|
2277
2469
|
) : null,
|
|
2278
2470
|
tab === 'run' ? (item.lastRun
|
|
2279
2471
|
? h('div', { className: 'studio-nl' },
|
|
@@ -2295,70 +2487,26 @@ window.__ModuleLoader__.load({
|
|
|
2295
2487
|
issues: item.lastRun.review?.issues,
|
|
2296
2488
|
technicalError: item.lastRun.technicalError,
|
|
2297
2489
|
}),
|
|
2298
|
-
evidence.length ? h('div', { className: 'studio-evidence'
|
|
2490
|
+
evidence.length ? h('div', { className: 'studio-evidence' },
|
|
2299
2491
|
evidence.slice(0, 6).map((entry, index) => h('div', { key: index, className: 'studio-evidence-item' },
|
|
2300
2492
|
/\.(png|jpe?g|webp)$/i.test(entry.file || '') ? h(EvidenceImage, { src: entry.url, alt: entry.caption || '证据', onClick: () => props.onShot({ src: entry.url, alt: entry.caption }) }) : h('div', { className: 'studio-note' }, entry.caption || entry.file),
|
|
2301
2493
|
h('span', { className: 'studio-evidence-cap' }, entry.caption || '')
|
|
2302
2494
|
))
|
|
2303
2495
|
) : null,
|
|
2304
|
-
h(
|
|
2305
|
-
h('div', { className: 'studio-note', style: { marginTop: 8 } }, '反馈可选:填写后会保存并带入下一轮;留空可以直接再次 Agent 运行。'),
|
|
2306
|
-
h(RunFeedbackBox, {
|
|
2307
|
-
caseId: item.tcId,
|
|
2308
|
-
batchId: item.lastRun.batchId,
|
|
2309
|
-
runStatus: item.lastRun.status,
|
|
2310
|
-
project: props.project,
|
|
2311
|
-
latestFeedback: item.lastFeedback || null,
|
|
2312
|
-
usedFeedback: item.lastFeedback && item.lastRun.batchId && item.lastFeedback.batchId === item.lastRun.batchId ? item.lastFeedback : null,
|
|
2313
|
-
defaultOpen: feedbackRequest > 0,
|
|
2314
|
-
focusToken: feedbackRequest,
|
|
2315
|
-
rerunDisabled: !props.hasBaseUrl,
|
|
2316
|
-
onToast: props.onToast,
|
|
2317
|
-
onOpenBatch: (batchId) => props.onCaseRunBatch ? props.onCaseRunBatch(batchId, item.tcId) : props.onOpenBatch(batchId),
|
|
2318
|
-
onRequeued: (payload) => {
|
|
2319
|
-
const batchId = payload?.batch?.id || item.lastRun.batchId;
|
|
2320
|
-
if (props.onCaseRunBatch) props.onCaseRunBatch(batchId, item.tcId);
|
|
2321
|
-
else if (batchId) props.onOpenBatch(batchId);
|
|
2322
|
-
},
|
|
2323
|
-
})
|
|
2496
|
+
h('div', { className: 'studio-note' }, '执行反馈与知识沉淀分别在对应页签中维护;填写反馈后可带入下一轮。')
|
|
2324
2497
|
)
|
|
2325
2498
|
: h(Empty, { icon: 'clock', title: '还没有执行记录', desc: props.hasBaseUrl ? '执行后,结果、证据、知识沉淀和反馈会集中显示在这里。' : '请先在设置页配置被测地址,再执行这条用例。', action: h('button', { className: 'studio-btn studio-btn-primary', style: { marginTop: 12 }, disabled: !props.hasBaseUrl, onClick: () => props.onRun(item) }, h(Icon, { name: 'play', size: 13 }), props.hasBaseUrl ? '执行这条用例' : '先配置被测地址') })
|
|
2326
2499
|
) : null,
|
|
2327
|
-
tab === '
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
h('span', { className: 'studio-kv-val' }, h('span', { className: 'studio-code' }, item.flow.name)),
|
|
2332
|
-
h('span', { className: 'studio-kv-key' }, '标题'),
|
|
2333
|
-
h('span', { className: 'studio-kv-val' }, item.flow.title || '—'),
|
|
2334
|
-
h('span', { className: 'studio-kv-key' }, '标签'),
|
|
2335
|
-
h('span', { className: 'studio-kv-val' }, asArray(item.flow.tags).join('、') || '—'),
|
|
2336
|
-
h('span', { className: 'studio-kv-key' }, '文件'),
|
|
2337
|
-
h('span', { className: 'studio-kv-val' }, item.flow.file || '—')
|
|
2338
|
-
),
|
|
2339
|
-
h('div', { className: 'studio-note', style: { marginTop: 10 } }, '有 flow 的用例优先走 flow 泳道;需要重新探索时可用 Agent 重跑,或删除关联 flow 后回到 Agent 泳道。'),
|
|
2340
|
-
h('div', { className: 'studio-detail-actions' },
|
|
2341
|
-
h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑'),
|
|
2342
|
-
h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(item.flow, item) }, '删除关联流程')
|
|
2500
|
+
tab === 'feedback' ? (item.lastRun
|
|
2501
|
+
? h('div', { className: 'studio-nl' },
|
|
2502
|
+
h('div', { className: 'studio-note' }, '反馈可选:填写后会保存并带入下一轮;留空可以直接再次 Agent 运行。'),
|
|
2503
|
+
feedbackBox(true)
|
|
2343
2504
|
)
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
h('span', { className: 'studio-row-title' }, flow.title || flow.name),
|
|
2350
|
-
h(Badge, { tone: 'muted' }, '前置'),
|
|
2351
|
-
h('span', { className: 'studio-code' }, flow.name)
|
|
2352
|
-
),
|
|
2353
|
-
h('div', { className: 'studio-row-sub', style: { marginTop: 5 } }, '提供:' + (asArray(flow.provides).join('、') || '—')),
|
|
2354
|
-
h('div', { className: 'studio-detail-actions' },
|
|
2355
|
-
h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 执行(含前置造数)'),
|
|
2356
|
-
h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(flow, item) }, '删除前置流程')
|
|
2357
|
-
)
|
|
2358
|
-
)),
|
|
2359
|
-
h('div', { className: 'studio-note', style: { marginTop: 8 } }, 'Agent 执行会从头准备前置数据,并在 Agent 视图显示造数思考与操作过程。')
|
|
2360
|
-
) : null,
|
|
2361
|
-
!item.flow && !asArray(item.preconditionFlows).length ? h(Empty, { icon: 'flow', title: '还没有关联流程', desc: 'Agent 执行通过后会自动把轨迹沉淀成 flows/agent-<caseId>.json。' }) : null
|
|
2505
|
+
: h(Empty, { icon: 'file', title: '执行后可以填写反馈', desc: '最近一次执行结束并给出判定后,反馈会保存在这里。' })
|
|
2506
|
+
) : null,
|
|
2507
|
+
tab === 'knowledge' ? (knowledge
|
|
2508
|
+
? h('div', { className: 'studio-nl' }, h(KnowledgeDeposit, { knowledge, open: true }))
|
|
2509
|
+
: h(Empty, { icon: 'knowledge', title: '还没有知识沉淀', desc: '执行结束后,页面、动作、流程与纠错经验会汇总在这里。' })
|
|
2362
2510
|
) : null
|
|
2363
2511
|
)
|
|
2364
2512
|
);
|
|
@@ -2741,6 +2889,218 @@ window.__ModuleLoader__.load({
|
|
|
2741
2889
|
);
|
|
2742
2890
|
}
|
|
2743
2891
|
|
|
2892
|
+
function DocActionsDialog(props) {
|
|
2893
|
+
const doc = props.doc;
|
|
2894
|
+
const archived = doc.archived === true;
|
|
2895
|
+
const caseFile = doc.caseFile || doc.generatedPath || doc.writeback?.targetPath || '';
|
|
2896
|
+
const caseFileState = doc.caseFileState || 'missing';
|
|
2897
|
+
const actions = [
|
|
2898
|
+
{ key: 'reread', icon: 'refresh', title: '重新导读', desc: '重新读取源文件,新增或更新该文档下的用例;源文件只读。', run: () => props.onReRead(doc) },
|
|
2899
|
+
{ key: 'writeback', icon: 'check', title: '回写执行结果', desc: '把该文档下用例的最近执行结果写回用例文件;xlsx 生成执行副本,CSV 写入生成的 Markdown 镜像。', run: () => props.onWriteback(doc) },
|
|
2900
|
+
{ key: 'reassociate', icon: 'import', title: '重新关联源文件', desc: '选择新的本地文件或服务器路径;文档 id、名称和已有用例归属保留。', run: () => props.onReassociate(doc) },
|
|
2901
|
+
{ key: 'archive', icon: archived ? 'refresh' : 'folder', title: archived ? '恢复文档' : '归档文档', desc: archived ? '恢复后该文档和用例回到默认列表。' : '从默认用例列表隐藏该文档;用例与文件都保留,可随时恢复。', run: () => props.onArchive(doc, !archived) },
|
|
2902
|
+
{ key: 'delete', icon: 'trash', title: '删除文档记录', desc: '只删除文档记录。用例保留并转为未归属;源文件和用例文件不会被删除。', danger: true, run: () => props.onDelete(doc) },
|
|
2903
|
+
];
|
|
2904
|
+
return h(Modal, {
|
|
2905
|
+
title: '文档操作',
|
|
2906
|
+
desc: doc.name || doc.id,
|
|
2907
|
+
onClose: props.onClose,
|
|
2908
|
+
footer: h('button', { className: 'studio-btn', onClick: props.onClose }, '关闭'),
|
|
2909
|
+
},
|
|
2910
|
+
h('div', { className: 'studio-form' },
|
|
2911
|
+
h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
2912
|
+
h('div', { className: 'studio-doc-meta' },
|
|
2913
|
+
h(Badge, { tone: docKindTone(doc.kind) }, docKindLabel(doc.kind)),
|
|
2914
|
+
h(Badge, { tone: archived ? 'muted' : 'success' }, archived ? '已归档' : '使用中'),
|
|
2915
|
+
h(Badge, { tone: doc.sourceState === 'missing' ? 'danger' : 'success' }, doc.sourceState === 'missing' ? '源缺失' : '源就绪'),
|
|
2916
|
+
h(Badge, { tone: caseFileState === 'ready' ? 'success' : caseFileState === 'pending' ? 'muted' : 'danger' }, '用例文件' + docCaseFileLabel(caseFileState)),
|
|
2917
|
+
h('span', { className: 'studio-row-sub' },
|
|
2918
|
+
'v' + (doc.version || 1) + ' · ' + (Number(doc.visibleCount) || 0) + ' 条用例'
|
|
2919
|
+
+ (Number(doc.ownedCount) > Number(doc.visibleCount) ? ' / 账本 ' + doc.ownedCount : '')
|
|
2920
|
+
)
|
|
2921
|
+
),
|
|
2922
|
+
h('div', { className: 'studio-kv', style: { marginTop: 8 } },
|
|
2923
|
+
h('span', { className: 'studio-kv-key' }, '源文件'),
|
|
2924
|
+
h('span', { className: 'studio-kv-val studio-mono-break' }, doc.sourcePath || '—'),
|
|
2925
|
+
h('span', { className: 'studio-kv-key' }, '用例文件'),
|
|
2926
|
+
h('span', { className: 'studio-kv-val studio-mono-break' }, caseFile || '—'),
|
|
2927
|
+
h('span', { className: 'studio-kv-key' }, '最近执行'),
|
|
2928
|
+
h('span', { className: 'studio-kv-val' }, doc.lastRun?.at ? relativeTime(doc.lastRun.at) : '暂无执行结果'),
|
|
2929
|
+
h('span', { className: 'studio-kv-key' }, '上次回写'),
|
|
2930
|
+
h('span', { className: 'studio-kv-val' }, doc.writeback?.at ? relativeTime(doc.writeback.at) : '尚未回写')
|
|
2931
|
+
),
|
|
2932
|
+
Number(doc.tombstonedCount) || Number(doc.staleCount)
|
|
2933
|
+
? h('div', { className: 'studio-note', style: { marginTop: 6 } },
|
|
2934
|
+
'登记用例中已删除 ' + (Number(doc.tombstonedCount) || 0) + ' 条,来源中缺失 ' + (Number(doc.staleCount) || 0) + ' 条。')
|
|
2935
|
+
: null
|
|
2936
|
+
),
|
|
2937
|
+
h('div', { className: 'studio-doc-action-list' },
|
|
2938
|
+
actions.map((action) => h('button', {
|
|
2939
|
+
key: action.key,
|
|
2940
|
+
type: 'button',
|
|
2941
|
+
className: cx('studio-row', 'studio-doc-action-row', action.danger ? 'is-danger' : ''),
|
|
2942
|
+
onClick: () => { props.onClose(); action.run(); },
|
|
2943
|
+
},
|
|
2944
|
+
h('span', { className: 'studio-doc-action-icon' }, h(Icon, { name: action.icon, size: 15 })),
|
|
2945
|
+
h('div', { className: 'studio-row-main' },
|
|
2946
|
+
h('div', { className: 'studio-row-title' }, action.title),
|
|
2947
|
+
h('div', { className: 'studio-doc-action-desc' }, action.desc)
|
|
2948
|
+
),
|
|
2949
|
+
h(Icon, { name: 'chevron', size: 13 })
|
|
2950
|
+
))
|
|
2951
|
+
)
|
|
2952
|
+
)
|
|
2953
|
+
);
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
function DocWritebackDialog(props) {
|
|
2957
|
+
const [preview, setPreview] = useState(null);
|
|
2958
|
+
const [loadingPreview, setLoadingPreview] = useState(true);
|
|
2959
|
+
const [applying, setApplying] = useState(false);
|
|
2960
|
+
const [error, setError] = useState('');
|
|
2961
|
+
const [done, setDone] = useState(null);
|
|
2962
|
+
useEffect(() => {
|
|
2963
|
+
let cancelled = false;
|
|
2964
|
+
setLoadingPreview(true);
|
|
2965
|
+
props.onWriteback({ docId: props.doc.id, dryRun: true })
|
|
2966
|
+
.then((payload) => { if (!cancelled) setPreview(payload); })
|
|
2967
|
+
.catch((err) => { if (!cancelled) setError(err.message); })
|
|
2968
|
+
.finally(() => { if (!cancelled) setLoadingPreview(false); });
|
|
2969
|
+
return () => { cancelled = true; };
|
|
2970
|
+
}, [props.doc.id]);
|
|
2971
|
+
const data = done || preview;
|
|
2972
|
+
const summary = data?.writeback || null;
|
|
2973
|
+
const results = Number(data?.results) || 0;
|
|
2974
|
+
// xlsx 的未写入清单在 writeback.skippedCaseIds 里,markdown 另有 skipped 计数。
|
|
2975
|
+
const skippedCount = (payload) => {
|
|
2976
|
+
const writeback = payload?.writeback || null;
|
|
2977
|
+
return Number(writeback?.markdown?.skipped) || asArray(writeback?.skippedCaseIds).length || 0;
|
|
2978
|
+
};
|
|
2979
|
+
const skipped = skippedCount(data);
|
|
2980
|
+
const caseRows = asArray(data?.cases).filter((item) => item.status);
|
|
2981
|
+
const target = summary?.targetPath || '';
|
|
2982
|
+
const apply = async () => {
|
|
2983
|
+
setApplying(true);
|
|
2984
|
+
setError('');
|
|
2985
|
+
try {
|
|
2986
|
+
const payload = await props.onWriteback({ docId: props.doc.id });
|
|
2987
|
+
setDone(payload);
|
|
2988
|
+
if (props.onToast) {
|
|
2989
|
+
const missed = skippedCount(payload);
|
|
2990
|
+
props.onToast({
|
|
2991
|
+
kind: 'success',
|
|
2992
|
+
text: '已回写 ' + (payload?.results || 0) + ' 条结果'
|
|
2993
|
+
+ (missed ? ';' + missed + ' 条在目标文件中未找到对应行,未写入' : '')
|
|
2994
|
+
+ (payload?.writeback?.targetPath ? ':' + payload.writeback.targetPath : ''),
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
} catch (err) {
|
|
2998
|
+
setError(err.message);
|
|
2999
|
+
} finally {
|
|
3000
|
+
setApplying(false);
|
|
3001
|
+
}
|
|
3002
|
+
};
|
|
3003
|
+
return h(Modal, {
|
|
3004
|
+
title: '回写文档执行结果',
|
|
3005
|
+
desc: '使用该文档下用例的最近一次执行结果;没有结果的用例会跳过。',
|
|
3006
|
+
onClose: props.onClose,
|
|
3007
|
+
footer: h(React.Fragment, null,
|
|
3008
|
+
h('button', { className: 'studio-btn', onClick: props.onClose }, done ? '完成' : '取消'),
|
|
3009
|
+
done ? null : h('button', {
|
|
3010
|
+
className: 'studio-btn studio-btn-primary',
|
|
3011
|
+
disabled: loadingPreview || applying || !preview || !results,
|
|
3012
|
+
onClick: apply,
|
|
3013
|
+
}, applying ? h(Spinner) : h(Icon, { name: 'check', size: 14 }), applying ? '回写中…' : '确认回写')
|
|
3014
|
+
),
|
|
3015
|
+
},
|
|
3016
|
+
h('div', { className: 'studio-form' },
|
|
3017
|
+
h('div', { className: 'studio-kv' },
|
|
3018
|
+
h('span', { className: 'studio-kv-key' }, '文档'),
|
|
3019
|
+
h('span', { className: 'studio-kv-val' }, props.doc.name || props.doc.id),
|
|
3020
|
+
h('span', { className: 'studio-kv-key' }, '类型'),
|
|
3021
|
+
h('span', { className: 'studio-kv-val' }, docKindLabel(props.doc.kind)),
|
|
3022
|
+
h('span', { className: 'studio-kv-key' }, '结果条数'),
|
|
3023
|
+
h('span', { className: 'studio-kv-val', style: { fontWeight: 600 } }, loadingPreview && !data ? '…' : results),
|
|
3024
|
+
h('span', { className: 'studio-kv-key' }, '回写目标'),
|
|
3025
|
+
h('span', { className: 'studio-kv-val studio-mono-break' }, target || (loadingPreview ? '…' : '—')),
|
|
3026
|
+
h('span', { className: 'studio-kv-key' }, '回写方式'),
|
|
3027
|
+
h('span', { className: 'studio-kv-val' }, props.doc.kind === 'xlsx'
|
|
3028
|
+
? '生成执行结果副本,不修改源工作簿'
|
|
3029
|
+
: '在生成的用例文件中插入或替换结果块'),
|
|
3030
|
+
h('span', { className: 'studio-kv-key' }, '结果来源'),
|
|
3031
|
+
h('span', { className: 'studio-kv-val' }, summary?.mode === 'batch' || summary?.batchId
|
|
3032
|
+
? '批次 ' + (summary.batchId || summary.sourceBatchIds?.[0] || '')
|
|
3033
|
+
: '最近结果(跨批次)')
|
|
3034
|
+
),
|
|
3035
|
+
loadingPreview && !data ? h('div', { className: 'studio-note' }, h(Spinner), ' 正在计算结果范围…') : null,
|
|
3036
|
+
!loadingPreview && !error && preview && !results
|
|
3037
|
+
? h('div', { className: 'studio-note tone-warn' }, '该文档下还没有可回写的执行结果。先在「批次」中执行用例,再回来回写。')
|
|
3038
|
+
: null,
|
|
3039
|
+
caseRows.length ? h('div', { className: 'studio-list' },
|
|
3040
|
+
h('div', { className: 'studio-nl-label' }, '本次回写用例(' + caseRows.length + ' 条)'),
|
|
3041
|
+
caseRows.slice(0, 10).map((item) => h('div', { key: item.caseId, className: 'studio-row', style: { cursor: 'default' } },
|
|
3042
|
+
h('div', { className: 'studio-row-main' },
|
|
3043
|
+
h('div', { className: 'studio-row-title' }, item.title || item.caseId),
|
|
3044
|
+
h('div', { className: 'studio-row-sub' }, item.caseId)
|
|
3045
|
+
),
|
|
3046
|
+
h(StatusBadge, { status: item.status })
|
|
3047
|
+
)),
|
|
3048
|
+
caseRows.length > 10 ? h('div', { className: 'studio-note' }, '还有 ' + (caseRows.length - 10) + ' 条未展示') : null
|
|
3049
|
+
) : null,
|
|
3050
|
+
error ? h('div', { className: 'studio-note tone-danger' }, error) : null,
|
|
3051
|
+
done ? h('div', { className: 'studio-note tone-success' },
|
|
3052
|
+
'已回写 ' + results + ' 条结果' + (skipped ? ';' + skipped + ' 条在目标文件中未找到对应行,未写入' : '')
|
|
3053
|
+
+ (target ? ':' + target : '') + '。重复回写会覆盖同一结果块。'
|
|
3054
|
+
) : null
|
|
3055
|
+
)
|
|
3056
|
+
);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
function DocDeleteDialog(props) {
|
|
3060
|
+
const doc = props.doc;
|
|
3061
|
+
const [busy, setBusy] = useState(false);
|
|
3062
|
+
const [error, setError] = useState('');
|
|
3063
|
+
const count = Number(doc.visibleCount) || 0;
|
|
3064
|
+
const submit = async () => {
|
|
3065
|
+
setBusy(true);
|
|
3066
|
+
setError('');
|
|
3067
|
+
try {
|
|
3068
|
+
await props.onDelete(doc);
|
|
3069
|
+
props.onClose();
|
|
3070
|
+
} catch (err) {
|
|
3071
|
+
setError(err.message);
|
|
3072
|
+
} finally {
|
|
3073
|
+
setBusy(false);
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
return h(Modal, {
|
|
3077
|
+
title: '删除文档记录',
|
|
3078
|
+
desc: '删除后该文档不再出现在用例库中。',
|
|
3079
|
+
onClose: props.onClose,
|
|
3080
|
+
footer: h(React.Fragment, null,
|
|
3081
|
+
h('button', { className: 'studio-btn', onClick: props.onClose }, '取消'),
|
|
3082
|
+
h('button', { className: 'studio-btn studio-btn-danger', onClick: submit, disabled: busy },
|
|
3083
|
+
busy ? h(Spinner) : h(Icon, { name: 'trash', size: 14 }), busy ? '删除中…' : '删除文档记录')
|
|
3084
|
+
),
|
|
3085
|
+
},
|
|
3086
|
+
h('div', { className: 'studio-form' },
|
|
3087
|
+
h('div', { className: 'studio-kv' },
|
|
3088
|
+
h('span', { className: 'studio-kv-key' }, '文档'),
|
|
3089
|
+
h('span', { className: 'studio-kv-val' }, doc.name || doc.id),
|
|
3090
|
+
h('span', { className: 'studio-kv-key' }, '类型'),
|
|
3091
|
+
h('span', { className: 'studio-kv-val' }, docKindLabel(doc.kind)),
|
|
3092
|
+
h('span', { className: 'studio-kv-key' }, '用例'),
|
|
3093
|
+
h('span', { className: 'studio-kv-val' }, count + ' 条')
|
|
3094
|
+
),
|
|
3095
|
+
h('div', { className: 'studio-note' },
|
|
3096
|
+
'只删除文档记录。该文档下的 ' + count + ' 条用例会保留,并转为「未归属文档」;源文件和用例文件都不会被删除。'
|
|
3097
|
+
+ ' 重新导入同名文档后,这些用例可以重新关联回来。'
|
|
3098
|
+
),
|
|
3099
|
+
error ? h('div', { className: 'studio-note tone-danger' }, error) : null
|
|
3100
|
+
)
|
|
3101
|
+
);
|
|
3102
|
+
}
|
|
3103
|
+
|
|
2744
3104
|
function CasesView(props) {
|
|
2745
3105
|
const snapshot = props.snapshot;
|
|
2746
3106
|
const [query, setQuery] = useState('');
|
|
@@ -2752,7 +3112,40 @@ window.__ModuleLoader__.load({
|
|
|
2752
3112
|
const [exportKind, setExportKind] = useState('cases');
|
|
2753
3113
|
const [collapsedDocs, setCollapsedDocs] = useState(() => new Set());
|
|
2754
3114
|
const [reReadDoc, setReReadDoc] = useState(null);
|
|
3115
|
+
const [docActions, setDocActions] = useState(null);
|
|
3116
|
+
const [docWriteback, setDocWriteback] = useState(null);
|
|
3117
|
+
const [docDelete, setDocDelete] = useState(null);
|
|
3118
|
+
const [showArchived, setShowArchived] = useState(false);
|
|
2755
3119
|
const allCases = asArray(snapshot.cases);
|
|
3120
|
+
const truncated = Number(snapshot.counts?.total) > allCases.length;
|
|
3121
|
+
const allDocs = useMemo(() => asArray(snapshot.docs), [snapshot.docs]);
|
|
3122
|
+
const archivedDocs = useMemo(() => allDocs.filter((doc) => doc.archived === true), [allDocs]);
|
|
3123
|
+
const docs = useMemo(() => (showArchived ? allDocs : allDocs.filter((doc) => doc.archived !== true)), [allDocs, showArchived]);
|
|
3124
|
+
const docIds = useMemo(() => new Set(docs.map((doc) => doc.id)), [docs]);
|
|
3125
|
+
const allDocIds = useMemo(() => new Set(allDocs.map((doc) => doc.id)), [allDocs]);
|
|
3126
|
+
const visibleCases = useMemo(() => allCases.filter((item) => {
|
|
3127
|
+
const id = String(item.docId || item.source?.docId || '');
|
|
3128
|
+
return !id || !allDocIds.has(id) || docIds.has(id);
|
|
3129
|
+
}), [allCases, allDocIds, docIds]);
|
|
3130
|
+
// 序号按文档内稳定顺序计算,过滤或折叠后仍然指向同一条用例。
|
|
3131
|
+
const caseSeq = useMemo(() => {
|
|
3132
|
+
const groups = new Map();
|
|
3133
|
+
for (const item of visibleCases) {
|
|
3134
|
+
const key = String(item.docId || item.source?.docId || '__unassigned__');
|
|
3135
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
3136
|
+
groups.get(key).push(item);
|
|
3137
|
+
}
|
|
3138
|
+
const map = new Map();
|
|
3139
|
+
for (const list of groups.values()) list.forEach((item, index) => map.set(item.tcId, index + 1));
|
|
3140
|
+
return map;
|
|
3141
|
+
}, [visibleCases]);
|
|
3142
|
+
// 归档文档被视图隐藏后,其中的用例不能再留在选择和详情里,否则会“看不见却被执行”。
|
|
3143
|
+
useEffect(() => {
|
|
3144
|
+
const visible = new Set(visibleCases.map((item) => item.tcId));
|
|
3145
|
+
const kept = props.selectedIds.filter((id) => visible.has(id));
|
|
3146
|
+
if (kept.length !== props.selectedIds.length) props.onSelectAll(kept);
|
|
3147
|
+
if (props.selectedCaseId && !visible.has(props.selectedCaseId)) props.onSelectCase('');
|
|
3148
|
+
}, [visibleCases, props.selectedIds, props.selectedCaseId]);
|
|
2756
3149
|
const activeRuns = useMemo(() => {
|
|
2757
3150
|
const map = new Map();
|
|
2758
3151
|
for (const run of asArray(snapshot.activeBatch?.cases)) map.set(String(run.caseId), run);
|
|
@@ -2768,24 +3161,23 @@ window.__ModuleLoader__.load({
|
|
|
2768
3161
|
ahead: run.queue?.ahead,
|
|
2769
3162
|
};
|
|
2770
3163
|
};
|
|
2771
|
-
const cases = useMemo(() =>
|
|
3164
|
+
const cases = useMemo(() => visibleCases.filter((item) => caseMatches(item, query, filter, liveFor(item))), [visibleCases, query, filter, activeRuns]);
|
|
2772
3165
|
const filterCounts = useMemo(() => {
|
|
2773
|
-
const counts = { all:
|
|
3166
|
+
const counts = { all: visibleCases.length };
|
|
2774
3167
|
for (const entry of CASE_FILTERS) {
|
|
2775
|
-
if (entry.id !== 'all') counts[entry.id] =
|
|
3168
|
+
if (entry.id !== 'all') counts[entry.id] = visibleCases.filter((item) => caseMatches(item, '', entry.id, liveFor(item))).length;
|
|
2776
3169
|
}
|
|
2777
3170
|
return counts;
|
|
2778
|
-
}, [
|
|
2779
|
-
const docs = useMemo(() => asArray(snapshot.docs), [snapshot.docs]);
|
|
2780
|
-
const docIds = useMemo(() => new Set(docs.map((doc) => doc.id)), [docs]);
|
|
3171
|
+
}, [visibleCases, activeRuns]);
|
|
2781
3172
|
const filtering = filter !== 'all' || Boolean(query.trim());
|
|
2782
|
-
const unassignedAll = useMemo(() => allCases.filter((item) => !item.docId
|
|
3173
|
+
const unassignedAll = useMemo(() => allCases.filter((item) => !allDocIds.has(String(item.docId || item.source?.docId || ''))), [allCases, allDocIds]);
|
|
2783
3174
|
const rows = useMemo(() => {
|
|
2784
3175
|
const byDoc = new Map();
|
|
2785
3176
|
const unassigned = [];
|
|
2786
3177
|
for (const item of cases) {
|
|
2787
3178
|
const id = item.docId || item.source?.docId || '';
|
|
2788
|
-
if (id &&
|
|
3179
|
+
if (id && allDocIds.has(id)) {
|
|
3180
|
+
if (!docIds.has(id)) continue;
|
|
2789
3181
|
if (!byDoc.has(id)) byDoc.set(id, []);
|
|
2790
3182
|
byDoc.get(id).push(item);
|
|
2791
3183
|
} else {
|
|
@@ -2808,7 +3200,7 @@ window.__ModuleLoader__.load({
|
|
|
2808
3200
|
}
|
|
2809
3201
|
}
|
|
2810
3202
|
return next;
|
|
2811
|
-
}, [cases, docs, docIds, filtering, unassignedAll, collapsedDocs]);
|
|
3203
|
+
}, [cases, docs, docIds, allDocIds, filtering, unassignedAll, collapsedDocs]);
|
|
2812
3204
|
const toggleDocCollapse = useCallback((id) => {
|
|
2813
3205
|
setCollapsedDocs((current) => {
|
|
2814
3206
|
const next = new Set(current);
|
|
@@ -2827,7 +3219,7 @@ window.__ModuleLoader__.load({
|
|
|
2827
3219
|
}, [props.selectedIds, props.onSelectAll]);
|
|
2828
3220
|
const selectedCase = allCases.find((item) => item.tcId === props.selectedCaseId) || null;
|
|
2829
3221
|
const selectedDoc = selectedCase
|
|
2830
|
-
?
|
|
3222
|
+
? allDocs.find((doc) => doc.id === (selectedCase.docId || selectedCase.source?.docId)) || null
|
|
2831
3223
|
: null;
|
|
2832
3224
|
const selectedLive = selectedCase ? liveFor(selectedCase) : null;
|
|
2833
3225
|
const selectedCount = props.selectedIds.length;
|
|
@@ -2873,11 +3265,16 @@ window.__ModuleLoader__.load({
|
|
|
2873
3265
|
h('button', { key: 'run', className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch(props.selectedIds), disabled: !cases.length }, h(Icon, { name: 'play', size: 14 }), '执行所选用例'),
|
|
2874
3266
|
],
|
|
2875
3267
|
}),
|
|
3268
|
+
snapshot.docsError ? h('div', { className: 'studio-note tone-danger', style: { marginBottom: 8 } },
|
|
3269
|
+
snapshot.docsError.message + ';请修复或移走该文件后重新加载。'
|
|
3270
|
+
) : null,
|
|
2876
3271
|
h('div', { className: 'studio-note', style: { marginBottom: 8 } },
|
|
2877
3272
|
'用例按导入文档分组展示;执行结果会回写到各自文档的用例文件。'
|
|
2878
|
-
+ ' 共 ' +
|
|
3273
|
+
+ ' 共 ' + allDocs.length + ' 个文档、' + allCases.length + ' 条用例'
|
|
3274
|
+
+ (archivedDocs.length ? '(已归档 ' + archivedDocs.length + ' 个)' : '')
|
|
2879
3275
|
+ (unassignedAll.length ? ',其中 ' + unassignedAll.length + ' 条未归属文档' : '')
|
|
2880
3276
|
+ '。'
|
|
3277
|
+
+ (Number(snapshot.counts?.total) > allCases.length ? ' 列表只加载了 ' + allCases.length + ' 条用例,统计按完整用例库。' : '')
|
|
2881
3278
|
),
|
|
2882
3279
|
h('div', { className: 'studio-toolbar' },
|
|
2883
3280
|
h('div', { className: 'studio-search' },
|
|
@@ -2890,7 +3287,11 @@ window.__ModuleLoader__.load({
|
|
|
2890
3287
|
className: cx('studio-chip', filter === item.id ? 'is-active' : ''),
|
|
2891
3288
|
onClick: () => setFilter(item.id),
|
|
2892
3289
|
}, item.label, h('span', { className: 'studio-chip-count' }, filterCounts[item.id] ?? 0)))
|
|
2893
|
-
)
|
|
3290
|
+
),
|
|
3291
|
+
archivedDocs.length ? h('label', { className: 'studio-check studio-archived-toggle' },
|
|
3292
|
+
h('input', { type: 'checkbox', checked: showArchived, onChange: (event) => setShowArchived(event.target.checked) }),
|
|
3293
|
+
'显示已归档(' + archivedDocs.length + ')'
|
|
3294
|
+
) : null
|
|
2894
3295
|
),
|
|
2895
3296
|
h('div', { className: 'studio-grid-2' },
|
|
2896
3297
|
h('div', { className: 'studio-card studio-card-flush' },
|
|
@@ -2898,6 +3299,7 @@ window.__ModuleLoader__.load({
|
|
|
2898
3299
|
h('span', { className: 'studio-row-sub' },
|
|
2899
3300
|
cases.length + ' 条用例'
|
|
2900
3301
|
+ (filtering ? ' · 已按文档展开' : ' · ' + docs.length + ' 个文档')
|
|
3302
|
+
+ (!showArchived && archivedDocs.length ? ' · 已归档 ' + archivedDocs.length : '')
|
|
2901
3303
|
+ (!filtering && unassignedAll.length ? ' · 未归属 ' + unassignedAll.length : '')
|
|
2902
3304
|
),
|
|
2903
3305
|
h('label', { className: 'studio-check' },
|
|
@@ -2924,6 +3326,8 @@ window.__ModuleLoader__.load({
|
|
|
2924
3326
|
active: row.item.tcId === props.selectedCaseId,
|
|
2925
3327
|
selected: props.selectedIds.includes(row.item.tcId),
|
|
2926
3328
|
live: liveFor(row.item),
|
|
3329
|
+
seq: caseSeq.get(row.item.tcId),
|
|
3330
|
+
indent: true,
|
|
2927
3331
|
onSelect: props.onSelectCase,
|
|
2928
3332
|
onToggle: props.onToggleCase,
|
|
2929
3333
|
});
|
|
@@ -2934,14 +3338,32 @@ window.__ModuleLoader__.load({
|
|
|
2934
3338
|
total: row.total,
|
|
2935
3339
|
expanded: filtering || !collapsedDocs.has(row.doc ? row.doc.id : '__unassigned__'),
|
|
2936
3340
|
filtering,
|
|
3341
|
+
truncated,
|
|
2937
3342
|
selectedIds: props.selectedIds,
|
|
2938
3343
|
onToggleCollapse: toggleDocCollapse,
|
|
2939
3344
|
onToggleCases: toggleDocCases,
|
|
2940
3345
|
onReRead: setReReadDoc,
|
|
3346
|
+
onActions: setDocActions,
|
|
2941
3347
|
});
|
|
2942
3348
|
},
|
|
2943
3349
|
})
|
|
2944
|
-
: h('div', { className: 'studio-empty-wrap' },
|
|
3350
|
+
: h('div', { className: 'studio-empty-wrap' },
|
|
3351
|
+
!filtering && !allCases.length
|
|
3352
|
+
? h(Empty, {
|
|
3353
|
+
icon: 'cases',
|
|
3354
|
+
title: '还没有用例',
|
|
3355
|
+
desc: '导入用例文档后,用例会按文档分组显示。',
|
|
3356
|
+
action: h('button', { className: 'studio-btn studio-btn-primary', style: { marginTop: 12 }, onClick: props.onImport }, h(Icon, { name: 'import', size: 14 }), '导入用例文档'),
|
|
3357
|
+
})
|
|
3358
|
+
: !filtering && !docs.length && archivedDocs.length && !unassignedAll.length
|
|
3359
|
+
? h(Empty, {
|
|
3360
|
+
icon: 'folder',
|
|
3361
|
+
title: '当前文档都已归档',
|
|
3362
|
+
desc: '归档不会删除用例;显示已归档后可以恢复文档。',
|
|
3363
|
+
action: h('button', { className: 'studio-btn', style: { marginTop: 12 }, onClick: () => setShowArchived(true) }, '显示已归档(' + archivedDocs.length + ')'),
|
|
3364
|
+
})
|
|
3365
|
+
: h(Empty, { icon: 'search', title: '没有匹配的用例', desc: '换一个关键词,或先导入新的用例文档。' })
|
|
3366
|
+
)
|
|
2945
3367
|
),
|
|
2946
3368
|
selectedCase ? h(CaseDetail, {
|
|
2947
3369
|
item: selectedCase,
|
|
@@ -2997,6 +3419,26 @@ window.__ModuleLoader__.load({
|
|
|
2997
3419
|
}
|
|
2998
3420
|
},
|
|
2999
3421
|
}) : null,
|
|
3422
|
+
docActions ? h(DocActionsDialog, {
|
|
3423
|
+
doc: docActions,
|
|
3424
|
+
onClose: () => setDocActions(null),
|
|
3425
|
+
onReRead: setReReadDoc,
|
|
3426
|
+
onWriteback: setDocWriteback,
|
|
3427
|
+
onReassociate: (doc) => { setDocActions(null); props.onReassociateDocument(doc); },
|
|
3428
|
+
onArchive: (doc, archived) => { setDocActions(null); props.onArchiveDocument(doc, archived); },
|
|
3429
|
+
onDelete: (doc) => { setDocActions(null); setDocDelete(doc); },
|
|
3430
|
+
}) : null,
|
|
3431
|
+
docWriteback ? h(DocWritebackDialog, {
|
|
3432
|
+
doc: docWriteback,
|
|
3433
|
+
onWriteback: props.onDocsWriteback,
|
|
3434
|
+
onClose: () => setDocWriteback(null),
|
|
3435
|
+
onToast: props.onToast,
|
|
3436
|
+
}) : null,
|
|
3437
|
+
docDelete ? h(DocDeleteDialog, {
|
|
3438
|
+
doc: docDelete,
|
|
3439
|
+
onDelete: props.onDeleteDocument,
|
|
3440
|
+
onClose: () => setDocDelete(null),
|
|
3441
|
+
}) : null,
|
|
3000
3442
|
props.caseRunBatchId ? h(CaseRunDrawer, {
|
|
3001
3443
|
batchId: props.caseRunBatchId,
|
|
3002
3444
|
caseId: props.caseRunCaseId || props.selectedCaseId,
|
|
@@ -3263,7 +3705,7 @@ window.__ModuleLoader__.load({
|
|
|
3263
3705
|
: [];
|
|
3264
3706
|
return h(Modal, {
|
|
3265
3707
|
title: '回写用例文档',
|
|
3266
|
-
desc: '整个批次结束后只写一次。Markdown 用例插入结果块与截图;xlsx
|
|
3708
|
+
desc: '整个批次结束后只写一次。Markdown 用例插入结果块与截图;xlsx 生成执行结果副本;CSV 写入生成的 Markdown 镜像。',
|
|
3267
3709
|
onClose: props.onClose,
|
|
3268
3710
|
wide: false,
|
|
3269
3711
|
footer: h(React.Fragment, null,
|
|
@@ -3333,7 +3775,7 @@ window.__ModuleLoader__.load({
|
|
|
3333
3775
|
const open = () => props.onClick();
|
|
3334
3776
|
const live = run.status === 'running' || run.queue?.state === 'running' || run.status === 'preparing';
|
|
3335
3777
|
return h('div', {
|
|
3336
|
-
className: cx('studio-result-row', live ? 'is-live' : ''),
|
|
3778
|
+
className: cx('studio-result-row', live ? 'is-live' : '', props.selected ? 'is-selected' : ''),
|
|
3337
3779
|
role: 'button',
|
|
3338
3780
|
tabIndex: 0,
|
|
3339
3781
|
onClick: open,
|
|
@@ -3344,9 +3786,15 @@ window.__ModuleLoader__.load({
|
|
|
3344
3786
|
open();
|
|
3345
3787
|
},
|
|
3346
3788
|
},
|
|
3789
|
+
h(SelectCheckbox, {
|
|
3790
|
+
checked: props.selected,
|
|
3791
|
+
label: '选择执行实例',
|
|
3792
|
+
onChange: () => props.onToggleSelection(run.caseId),
|
|
3793
|
+
}),
|
|
3347
3794
|
h('div', { className: 'studio-result-main' },
|
|
3348
3795
|
h('div', { className: 'studio-result-title' }, run.title || run.caseId),
|
|
3349
3796
|
h('div', { className: 'studio-run-meta' },
|
|
3797
|
+
props.seq ? h('span', { className: 'studio-case-seq', title: '批次内序号' }, '#' + props.seq) : null,
|
|
3350
3798
|
h('span', null, run.caseId),
|
|
3351
3799
|
h(ModeBadge, { mode: run.mode }),
|
|
3352
3800
|
run.durationMs ? h('span', null, formatDuration(run.durationMs)) : null,
|
|
@@ -3379,6 +3827,21 @@ window.__ModuleLoader__.load({
|
|
|
3379
3827
|
const startupFailure = Boolean(run.technicalError || agentLive?.error)
|
|
3380
3828
|
&& !steps.length && !agentLive?.active && !agentSteps.length;
|
|
3381
3829
|
const technicalError = run.technicalError || agentLive?.error || '';
|
|
3830
|
+
const [fetchedDefinition, setFetchedDefinition] = useState(null);
|
|
3831
|
+
useEffect(() => {
|
|
3832
|
+
if (props.definition || !props.project) return undefined;
|
|
3833
|
+
let cancelled = false;
|
|
3834
|
+
setFetchedDefinition(null);
|
|
3835
|
+
api('/case', { project: props.project, query: { id: run.caseId } })
|
|
3836
|
+
.then((payload) => {
|
|
3837
|
+
if (!cancelled) setFetchedDefinition(payload?.studio || payload?.case || null);
|
|
3838
|
+
})
|
|
3839
|
+
.catch(() => {
|
|
3840
|
+
if (!cancelled) setFetchedDefinition(null);
|
|
3841
|
+
});
|
|
3842
|
+
return () => { cancelled = true; };
|
|
3843
|
+
}, [run.caseId, props.definition, props.project]);
|
|
3844
|
+
const definition = props.definition || fetchedDefinition;
|
|
3382
3845
|
return h(Drawer, {
|
|
3383
3846
|
title: run.title || run.caseId,
|
|
3384
3847
|
desc: [run.caseId, statusLabel(run.status), queue ? queue.label + (queue.hint ? ' · ' + queue.hint : '') : '', run.durationMs ? formatDuration(run.durationMs) : ''].filter(Boolean).join(' · '),
|
|
@@ -3390,6 +3853,13 @@ window.__ModuleLoader__.load({
|
|
|
3390
3853
|
),
|
|
3391
3854
|
},
|
|
3392
3855
|
h('div', { className: 'studio-nl' },
|
|
3856
|
+
definition
|
|
3857
|
+
? h('div', { className: 'studio-nl-block' },
|
|
3858
|
+
h('div', { className: 'studio-nl-label' }, '用例定义'),
|
|
3859
|
+
definition.remark ? h('div', { className: 'studio-note', style: { marginBottom: 8 } }, definition.remark) : null,
|
|
3860
|
+
h(CaseDefinition, { nl: definition.nl, grid: true })
|
|
3861
|
+
)
|
|
3862
|
+
: null,
|
|
3393
3863
|
run.live?.wsUrl && run.live?.active !== false ? h('div', { className: 'studio-card', style: { padding: 10 } },
|
|
3394
3864
|
h('div', { className: 'studio-row-title', style: { marginBottom: 8 } }, '实时镜像'),
|
|
3395
3865
|
h(LiveStream, { stream: run.live, title: '实时镜像' })
|
|
@@ -3485,17 +3955,72 @@ window.__ModuleLoader__.load({
|
|
|
3485
3955
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
3486
3956
|
const [deleting, setDeleting] = useState(false);
|
|
3487
3957
|
const [deleteError, setDeleteError] = useState('');
|
|
3488
|
-
const [
|
|
3958
|
+
const [startingDistill, setStartingDistill] = useState(false);
|
|
3489
3959
|
const [distillError, setDistillError] = useState('');
|
|
3960
|
+
const [liveDistill, setLiveDistill] = useState(null);
|
|
3961
|
+
const [distillPolling, setDistillPolling] = useState(false);
|
|
3962
|
+
const [distillInterrupted, setDistillInterrupted] = useState(false);
|
|
3490
3963
|
const [writebackOpen, setWritebackOpen] = useState(false);
|
|
3491
3964
|
const [exportOpen, setExportOpen] = useState(false);
|
|
3492
3965
|
const [liveFocus, setLiveFocus] = useState(null);
|
|
3493
3966
|
const [runFilter, setRunFilter] = useState('all');
|
|
3967
|
+
const [runQuery, setRunQuery] = useState('');
|
|
3968
|
+
const [runSort, setRunSort] = useState('active');
|
|
3969
|
+
const [runSortDir, setRunSortDir] = useState('asc');
|
|
3970
|
+
const [selectedRunIds, setSelectedRunIds] = useState([]);
|
|
3971
|
+
const [bulkBusy, setBulkBusy] = useState('');
|
|
3972
|
+
const [resuming, setResuming] = useState(false);
|
|
3973
|
+
useEffect(() => {
|
|
3974
|
+
if (!distillPolling) return undefined;
|
|
3975
|
+
let cancelled = false;
|
|
3976
|
+
let timer = null;
|
|
3977
|
+
const tick = async () => {
|
|
3978
|
+
try {
|
|
3979
|
+
const payload = await api('/batch/distill/status', {
|
|
3980
|
+
project: props.project,
|
|
3981
|
+
query: { id: batch.id },
|
|
3982
|
+
});
|
|
3983
|
+
const next = payload?.distill;
|
|
3984
|
+
if (cancelled) return;
|
|
3985
|
+
if (!next) {
|
|
3986
|
+
timer = setTimeout(tick, POLL_DISTILL);
|
|
3987
|
+
return;
|
|
3988
|
+
}
|
|
3989
|
+
setLiveDistill(next);
|
|
3990
|
+
if (String(next.status) === 'done') {
|
|
3991
|
+
const fresh = await refreshNow();
|
|
3992
|
+
if (cancelled) return;
|
|
3993
|
+
setLiveDistill(fresh ? null : next);
|
|
3994
|
+
setDistillPolling(false);
|
|
3995
|
+
setDistillInterrupted(false);
|
|
3996
|
+
if (props.onDistilled) props.onDistilled();
|
|
3997
|
+
return;
|
|
3998
|
+
}
|
|
3999
|
+
if (String(next.status) === 'failed') {
|
|
4000
|
+
setDistillPolling(false);
|
|
4001
|
+
setDistillInterrupted(false);
|
|
4002
|
+
return;
|
|
4003
|
+
}
|
|
4004
|
+
if (next.active !== true) {
|
|
4005
|
+
setDistillPolling(false);
|
|
4006
|
+
if (String(next.status) === 'running') setDistillInterrupted(true);
|
|
4007
|
+
return;
|
|
4008
|
+
}
|
|
4009
|
+
} catch {
|
|
4010
|
+
/* 轮询失败时保留当前进度,下一轮重试 */
|
|
4011
|
+
}
|
|
4012
|
+
if (!cancelled) timer = setTimeout(tick, POLL_DISTILL);
|
|
4013
|
+
};
|
|
4014
|
+
timer = setTimeout(tick, POLL_DISTILL);
|
|
4015
|
+
return () => { cancelled = true; if (timer) clearTimeout(timer); };
|
|
4016
|
+
}, [distillPolling, batch.id, props.project, refreshNow]);
|
|
3494
4017
|
const progress = batchProgress(batch);
|
|
3495
|
-
const
|
|
4018
|
+
const rawCases = asArray(batch.cases);
|
|
4019
|
+
const cases = useMemo(() => sortRunsForDisplay(rawCases), [rawCases]);
|
|
4020
|
+
const seqByCase = useMemo(() => new Map(rawCases.map((run, index) => [String(run.caseId), index + 1])), [rawCases]);
|
|
3496
4021
|
const runFilterDefs = [
|
|
3497
4022
|
{ id: 'all', label: '全部', match: () => true },
|
|
3498
|
-
{ id: 'live', label: '进行中', match:
|
|
4023
|
+
{ id: 'live', label: '进行中', match: runIsActive },
|
|
3499
4024
|
{ id: 'passed', label: '通过', match: (run) => run.status === 'passed' || run.status === 'partial' },
|
|
3500
4025
|
{ id: 'failed', label: '失败', match: (run) => run.status === 'failed' },
|
|
3501
4026
|
{ id: 'blocked', label: '阻塞', match: (run) => run.status === 'blocked' },
|
|
@@ -3504,12 +4029,50 @@ window.__ModuleLoader__.load({
|
|
|
3504
4029
|
const runCounts = {};
|
|
3505
4030
|
for (const def of runFilterDefs) runCounts[def.id] = def.id === 'all' ? cases.length : cases.filter(def.match).length;
|
|
3506
4031
|
const activeFilter = runFilterDefs.find((def) => def.id === runFilter) || runFilterDefs[0];
|
|
3507
|
-
const
|
|
4032
|
+
const query = runQuery.trim().toLowerCase();
|
|
4033
|
+
const filteredCases = cases.filter((run) => activeFilter.match(run) && runMatchesQuery(run, query));
|
|
4034
|
+
const sequenceOf = (run) => seqByCase.get(String(run.caseId)) || 0;
|
|
4035
|
+
const sortValue = (run) => {
|
|
4036
|
+
if (runSort === 'seq') return sequenceOf(run);
|
|
4037
|
+
if (runSort === 'started') return run.startedAt ? new Date(run.startedAt).getTime() : 0;
|
|
4038
|
+
return Number(run.durationMs) || 0;
|
|
4039
|
+
};
|
|
4040
|
+
const visibleCases = runSort === 'active'
|
|
4041
|
+
? filteredCases
|
|
4042
|
+
: filteredCases.slice().sort((a, b) => {
|
|
4043
|
+
const direction = runSortDir === 'asc' ? 1 : -1;
|
|
4044
|
+
return (sortValue(a) - sortValue(b)) * direction || sequenceOf(a) - sequenceOf(b);
|
|
4045
|
+
});
|
|
4046
|
+
const selectedSet = new Set(selectedRunIds.map(String));
|
|
4047
|
+
const selectedRuns = cases.filter((run) => selectedSet.has(String(run.caseId)));
|
|
4048
|
+
const allVisibleSelected = visibleCases.length > 0 && visibleCases.every((run) => selectedSet.has(String(run.caseId)));
|
|
4049
|
+
const someVisibleSelected = visibleCases.some((run) => selectedSet.has(String(run.caseId)));
|
|
4050
|
+
const toggleRunSelection = (id) => setSelectedRunIds((current) => (
|
|
4051
|
+
current.map(String).includes(String(id))
|
|
4052
|
+
? current.filter((item) => String(item) !== String(id))
|
|
4053
|
+
: [...current.map(String), String(id)]
|
|
4054
|
+
));
|
|
4055
|
+
const toggleAllVisible = (checked) => {
|
|
4056
|
+
if (!checked) {
|
|
4057
|
+
setSelectedRunIds([]);
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
setSelectedRunIds(visibleCases.map((run) => String(run.caseId)));
|
|
4061
|
+
};
|
|
3508
4062
|
const stoppable = ['running', 'preparing', 'queued'].includes(String(batch.status || ''));
|
|
3509
4063
|
const deletable = !['running', 'queued', 'preparing'].includes(String(batch.status || ''));
|
|
3510
|
-
const distillStage =
|
|
4064
|
+
const distillStage = liveDistill || batch.stages?.distill || null;
|
|
4065
|
+
const distillStageStatus = String(distillStage?.status || '');
|
|
4066
|
+
const distillBusy = startingDistill || distillPolling;
|
|
4067
|
+
const showDistillProgress = distillBusy || distillStageStatus === 'running';
|
|
4068
|
+
const stageDistillError = distillStageStatus === 'failed' ? String(distillStage?.error || '') : '';
|
|
4069
|
+
const distillTotal = Number(distillStage?.total) || 0;
|
|
4070
|
+
const distillPercent = distillTotal > 0
|
|
4071
|
+
? Math.round(((Number(distillStage?.done) || 0) / distillTotal) * 100)
|
|
4072
|
+
: 0;
|
|
4073
|
+
const distillIndeterminate = distillTotal <= 0;
|
|
3511
4074
|
const needsDistill = !['running', 'queued', 'preparing'].includes(String(batch.status || ''))
|
|
3512
|
-
&& (!batch.knowledge ||
|
|
4075
|
+
&& (distillBusy || !batch.knowledge || distillStageStatus === 'running' || distillStageStatus === 'failed');
|
|
3513
4076
|
const caseRun = cases.find((run) => String(run.caseId) === String(caseId)) || null;
|
|
3514
4077
|
const runAction = async (kind, run) => {
|
|
3515
4078
|
const handler = kind === 'stop' ? props.onStopCase : kind === 'prioritize' ? props.onPrioritizeCase : props.onRequeueCase;
|
|
@@ -3518,26 +4081,79 @@ window.__ModuleLoader__.load({
|
|
|
3518
4081
|
if (payload?.batch) applyBatch(payload.batch);
|
|
3519
4082
|
else await refreshNow();
|
|
3520
4083
|
};
|
|
4084
|
+
const bulkAction = async (kind) => {
|
|
4085
|
+
if (!selectedRuns.length || bulkBusy) return;
|
|
4086
|
+
const targets = selectedRuns.filter((run) => (kind === 'stop' ? runIsActive(run) : !runIsActive(run)));
|
|
4087
|
+
if (!targets.length) {
|
|
4088
|
+
props.onToast?.({
|
|
4089
|
+
kind: 'warn',
|
|
4090
|
+
text: kind === 'stop' ? '所选执行实例都不在排队或执行中' : '所选执行实例都在排队或执行中,暂时不能重新执行',
|
|
4091
|
+
});
|
|
4092
|
+
return;
|
|
4093
|
+
}
|
|
4094
|
+
const handler = kind === 'stop' ? props.onStopCase : props.onRequeueCase;
|
|
4095
|
+
if (!handler) return;
|
|
4096
|
+
setBulkBusy(kind);
|
|
4097
|
+
let done = 0;
|
|
4098
|
+
for (const run of targets) {
|
|
4099
|
+
const payload = await handler(batch, run.caseId, run, { silent: true });
|
|
4100
|
+
if (payload) done += 1;
|
|
4101
|
+
}
|
|
4102
|
+
setBulkBusy('');
|
|
4103
|
+
setSelectedRunIds([]);
|
|
4104
|
+
await refreshNow();
|
|
4105
|
+
props.onToast?.({
|
|
4106
|
+
kind: done === targets.length ? 'success' : done ? 'warn' : 'error',
|
|
4107
|
+
text: (kind === 'stop' ? '已请求停止 ' : '已重新排队 ') + done + ' / ' + targets.length + ' 条',
|
|
4108
|
+
});
|
|
4109
|
+
};
|
|
4110
|
+
const resumeBatchNow = async () => {
|
|
4111
|
+
if (resuming || !props.onResumeBatch) return;
|
|
4112
|
+
setResuming(true);
|
|
4113
|
+
try {
|
|
4114
|
+
const payload = await props.onResumeBatch(batch.id);
|
|
4115
|
+
if (payload?.batch) applyBatch(payload.batch);
|
|
4116
|
+
} finally {
|
|
4117
|
+
setResuming(false);
|
|
4118
|
+
}
|
|
4119
|
+
};
|
|
3521
4120
|
useEffect(() => {
|
|
3522
4121
|
setCaseId('');
|
|
3523
4122
|
setDeleteOpen(false);
|
|
3524
4123
|
setDeleteError('');
|
|
3525
4124
|
setDistillError('');
|
|
4125
|
+
setStartingDistill(false);
|
|
4126
|
+
setLiveDistill(null);
|
|
4127
|
+
setDistillInterrupted(false);
|
|
4128
|
+
setDistillPolling(batch.distillActive === true || String(batch.stages?.distill?.status) === 'running');
|
|
3526
4129
|
setLogOpen(false);
|
|
3527
4130
|
setArchiveOpen(false);
|
|
3528
4131
|
setRunFilter('all');
|
|
4132
|
+
setRunQuery('');
|
|
4133
|
+
setRunSort('active');
|
|
4134
|
+
setRunSortDir('asc');
|
|
4135
|
+
setSelectedRunIds([]);
|
|
4136
|
+
setBulkBusy('');
|
|
3529
4137
|
}, [batch.id]);
|
|
3530
4138
|
const distillBatchNow = async () => {
|
|
3531
|
-
|
|
4139
|
+
setStartingDistill(true);
|
|
3532
4140
|
setDistillError('');
|
|
4141
|
+
setDistillInterrupted(false);
|
|
4142
|
+
setLiveDistill({ status: 'running', phase: 'starting', startedAt: new Date().toISOString() });
|
|
4143
|
+
setDistillPolling(true);
|
|
3533
4144
|
try {
|
|
3534
|
-
const payload = await api('/batch/distill', { method: 'POST', project: props.project, body: { id: batch.id }
|
|
4145
|
+
const payload = await api('/batch/distill', { method: 'POST', project: props.project, body: { id: batch.id } });
|
|
3535
4146
|
if (payload?.batch) applyBatch(payload.batch);
|
|
3536
|
-
if (
|
|
4147
|
+
if (payload?.started !== true && payload?.alreadyRunning !== true) {
|
|
4148
|
+
setLiveDistill(null);
|
|
4149
|
+
setDistillPolling(false);
|
|
4150
|
+
}
|
|
3537
4151
|
} catch (err) {
|
|
3538
4152
|
setDistillError(err.message);
|
|
4153
|
+
setLiveDistill(null);
|
|
4154
|
+
setDistillPolling(false);
|
|
3539
4155
|
} finally {
|
|
3540
|
-
|
|
4156
|
+
setStartingDistill(false);
|
|
3541
4157
|
}
|
|
3542
4158
|
};
|
|
3543
4159
|
const deleteBatchNow = async () => {
|
|
@@ -3563,14 +4179,21 @@ window.__ModuleLoader__.load({
|
|
|
3563
4179
|
progress,
|
|
3564
4180
|
actions: [
|
|
3565
4181
|
stoppable ? h('button', { key: 'stop', className: 'studio-btn studio-btn-danger', onClick: async () => { await props.onStop(batch.id); refreshNow(); } }, h(Icon, { name: 'stop', size: 13 }), '停止批次') : null,
|
|
4182
|
+
!stoppable && batch.status === 'stopped' ? h('button', {
|
|
4183
|
+
key: 'resume',
|
|
4184
|
+
className: 'studio-btn studio-btn-primary',
|
|
4185
|
+
disabled: resuming,
|
|
4186
|
+
title: '把未完成的用例重新排入本批次,已判定的结果保留',
|
|
4187
|
+
onClick: resumeBatchNow,
|
|
4188
|
+
}, resuming ? h(Spinner) : h(Icon, { name: 'play', size: 13 }), resuming ? '继续中…' : '继续执行') : null,
|
|
3566
4189
|
!stoppable && (batch.status === 'done' || batch.status === 'stopped') ? h('button', { key: 'writeback', className: 'studio-btn studio-btn-primary', onClick: () => setWritebackOpen(true) }, h(Icon, { name: 'file', size: 13 }), batch.writeback ? '再次回写' : '回写用例文档') : null,
|
|
3567
4190
|
needsDistill ? h('button', {
|
|
3568
4191
|
key: 'distill',
|
|
3569
4192
|
className: 'studio-btn studio-btn-primary',
|
|
3570
|
-
disabled:
|
|
4193
|
+
disabled: distillBusy,
|
|
3571
4194
|
title: '重新学习本批页面与流程并写入中心知识库',
|
|
3572
4195
|
onClick: distillBatchNow,
|
|
3573
|
-
},
|
|
4196
|
+
}, distillBusy ? h(Spinner) : h(Icon, { name: 'knowledge', size: 13 }), distillBusy ? '沉淀中…' : '重新沉淀') : null,
|
|
3574
4197
|
h(MenuButton, { key: 'more', label: '更多', icon: 'more' }, [
|
|
3575
4198
|
h('button', { key: 'export', className: 'studio-btn', disabled: !cases.length, title: cases.length ? '导出本批次测试结果 xlsx' : '批次还没有用例结果', onClick: () => setExportOpen(true) }, h(Icon, { name: 'file', size: 13 }), '导出结果'),
|
|
3576
4199
|
h('button', { key: 'log', className: 'studio-btn', onClick: () => setLogOpen(true) }, h(Icon, { name: 'terminal', size: 13 }), '执行日志'),
|
|
@@ -3580,11 +4203,17 @@ window.__ModuleLoader__.load({
|
|
|
3580
4203
|
],
|
|
3581
4204
|
}),
|
|
3582
4205
|
|
|
3583
|
-
|
|
3584
|
-
label: '正在重新沉淀本批知识',
|
|
3585
|
-
detail:
|
|
3586
|
-
steps:
|
|
4206
|
+
showDistillProgress ? h('div', { style: { marginTop: 12 } }, h(OperationProgress, {
|
|
4207
|
+
label: distillInterrupted ? '上一次沉淀未完成' : '正在重新沉淀本批知识',
|
|
4208
|
+
detail: distillPhaseText(distillStage),
|
|
4209
|
+
steps: distillSteps(distillStage),
|
|
4210
|
+
startedAt: distillStage?.startedAt,
|
|
4211
|
+
percent: distillPercent,
|
|
4212
|
+
indeterminate: distillIndeterminate,
|
|
4213
|
+
active: !distillInterrupted,
|
|
3587
4214
|
})) : null,
|
|
4215
|
+
distillInterrupted ? h('div', { className: 'studio-note tone-warn', style: { marginTop: 10 } }, '上一次沉淀可能已中断,或在另一个进程中运行;可以直接重新沉淀。') : null,
|
|
4216
|
+
stageDistillError ? h('div', { className: 'studio-note tone-danger', style: { marginTop: 10 } }, '重新沉淀失败:' + stageDistillError) : null,
|
|
3588
4217
|
distillError ? h('div', { className: 'studio-note tone-danger', style: { marginTop: 10 } }, '重新沉淀失败:' + distillError) : null,
|
|
3589
4218
|
|
|
3590
4219
|
h('div', { className: 'studio-meta-strip' },
|
|
@@ -3608,34 +4237,90 @@ window.__ModuleLoader__.load({
|
|
|
3608
4237
|
)
|
|
3609
4238
|
),
|
|
3610
4239
|
h('div', { className: 'studio-toolbar' },
|
|
4240
|
+
h('div', { className: 'studio-search' },
|
|
4241
|
+
h('span', { className: 'studio-search-icon' }, h(Icon, { name: 'search', size: 14 })),
|
|
4242
|
+
h('input', {
|
|
4243
|
+
className: 'studio-input',
|
|
4244
|
+
placeholder: '搜索用例编号、标题、执行结果…',
|
|
4245
|
+
value: runQuery,
|
|
4246
|
+
onChange: (event) => setRunQuery(event.target.value),
|
|
4247
|
+
})
|
|
4248
|
+
),
|
|
3611
4249
|
h('div', { className: 'studio-filter-bar' },
|
|
3612
4250
|
runFilterDefs.map((def) => h('button', {
|
|
3613
4251
|
key: def.id,
|
|
3614
4252
|
className: cx('studio-chip', runFilter === def.id ? 'is-active' : ''),
|
|
3615
4253
|
onClick: () => setRunFilter(def.id),
|
|
3616
4254
|
}, def.label, h('span', { className: 'studio-chip-count' }, runCounts[def.id])))
|
|
4255
|
+
),
|
|
4256
|
+
h('div', { className: 'studio-run-tools' },
|
|
4257
|
+
h('span', { className: 'studio-row-sub' }, '排序'),
|
|
4258
|
+
h('select', {
|
|
4259
|
+
className: 'studio-select',
|
|
4260
|
+
value: runSort,
|
|
4261
|
+
onChange: (event) => {
|
|
4262
|
+
const key = event.target.value;
|
|
4263
|
+
setRunSort(key);
|
|
4264
|
+
setRunSortDir(key === 'started' || key === 'duration' ? 'desc' : 'asc');
|
|
4265
|
+
},
|
|
4266
|
+
}, RUN_SORTS.map((item) => h('option', { key: item.id, value: item.id }, item.label))),
|
|
4267
|
+
h('button', {
|
|
4268
|
+
className: 'studio-btn studio-btn-sm',
|
|
4269
|
+
disabled: runSort === 'active',
|
|
4270
|
+
title: runSortDir === 'asc' ? '当前升序,点击切换为降序' : '当前降序,点击切换为升序',
|
|
4271
|
+
onClick: () => setRunSortDir((value) => (value === 'asc' ? 'desc' : 'asc')),
|
|
4272
|
+
}, runSortDir === 'asc' ? '↑ 升序' : '↓ 降序')
|
|
3617
4273
|
)
|
|
3618
4274
|
),
|
|
4275
|
+
h('div', { className: 'studio-list-head' },
|
|
4276
|
+
h('label', { className: 'studio-check' },
|
|
4277
|
+
h('input', {
|
|
4278
|
+
type: 'checkbox',
|
|
4279
|
+
checked: allVisibleSelected,
|
|
4280
|
+
disabled: !visibleCases.length,
|
|
4281
|
+
onChange: (event) => toggleAllVisible(event.target.checked),
|
|
4282
|
+
}),
|
|
4283
|
+
'全选当前结果',
|
|
4284
|
+
someVisibleSelected && !allVisibleSelected ? h('span', { className: 'studio-row-sub' }, '部分已选') : null
|
|
4285
|
+
),
|
|
4286
|
+
h('span', { className: 'studio-row-sub' },
|
|
4287
|
+
(filteredCases.length === cases.length ? '' : filteredCases.length + ' / ') + cases.length + ' 条'
|
|
4288
|
+
+ (selectedRuns.length ? ' · 已选 ' + selectedRuns.length : '')
|
|
4289
|
+
)
|
|
4290
|
+
),
|
|
4291
|
+
selectedRuns.length ? h('div', { className: 'studio-bulk-bar' },
|
|
4292
|
+
h('span', null, '已选 ' + selectedRuns.length + ' 条执行实例'),
|
|
4293
|
+
h('button', { className: 'studio-btn studio-btn-sm', disabled: Boolean(bulkBusy), onClick: () => bulkAction('stop') },
|
|
4294
|
+
bulkBusy === 'stop' ? h(Spinner) : h(Icon, { name: 'stop', size: 12 }), '停止所选'),
|
|
4295
|
+
h('button', { className: 'studio-btn studio-btn-sm', disabled: Boolean(bulkBusy), onClick: () => bulkAction('requeue') },
|
|
4296
|
+
bulkBusy === 'requeue' ? h(Spinner) : h(Icon, { name: 'play', size: 12 }), '重新执行所选'),
|
|
4297
|
+
h('button', { className: 'studio-btn studio-btn-sm', disabled: Boolean(bulkBusy), onClick: () => setSelectedRunIds([]) }, '清除选择')
|
|
4298
|
+
) : null,
|
|
3619
4299
|
cases.length
|
|
3620
4300
|
? h(VirtualList, {
|
|
3621
4301
|
items: visibleCases,
|
|
3622
4302
|
rowHeight: 82,
|
|
3623
4303
|
className: 'studio-result-scroll',
|
|
3624
4304
|
keyFor: (run) => String(run.caseId),
|
|
3625
|
-
resetKey: runFilter,
|
|
4305
|
+
resetKey: runFilter + '|' + runQuery + '|' + runSort + '|' + runSortDir,
|
|
3626
4306
|
ariaLabel: '用例结果',
|
|
3627
|
-
empty: h('div', { className: 'studio-empty-wrap' }, h(Empty, { icon: 'search', title: '当前筛选没有结果', desc: '
|
|
4307
|
+
empty: h('div', { className: 'studio-empty-wrap' }, h(Empty, { icon: 'search', title: '当前筛选没有结果', desc: '切换到其他状态或清空搜索查看该批次的用例。' })),
|
|
3628
4308
|
renderRow: (run) => h(RunListRow, {
|
|
3629
4309
|
run,
|
|
4310
|
+
seq: seqByCase.get(String(run.caseId)),
|
|
4311
|
+
selected: selectedSet.has(String(run.caseId)),
|
|
4312
|
+
onToggleSelection: toggleRunSelection,
|
|
3630
4313
|
onClick: () => setCaseId(String(run.caseId)),
|
|
3631
4314
|
onAction: runAction,
|
|
3632
4315
|
}),
|
|
3633
4316
|
})
|
|
3634
4317
|
: h(Empty, { icon: 'batch', title: '批次还没有用例结果', desc: '执行开始后,这里会按用例实时出现状态、说明与截图。' }),
|
|
3635
4318
|
caseRun ? h(BatchCaseDrawer, {
|
|
4319
|
+
key: caseRun.caseId,
|
|
3636
4320
|
run: caseRun,
|
|
3637
4321
|
batch,
|
|
3638
4322
|
batchId: batch.id,
|
|
4323
|
+
definition: props.caseById?.get(String(caseRun.caseId)) || null,
|
|
3639
4324
|
project: props.project,
|
|
3640
4325
|
hasBaseUrl: props.hasBaseUrl,
|
|
3641
4326
|
onShot: props.onShot,
|
|
@@ -3748,6 +4433,8 @@ window.__ModuleLoader__.load({
|
|
|
3748
4433
|
const [loading, setLoading] = useState(false);
|
|
3749
4434
|
const [error, setError] = useState('');
|
|
3750
4435
|
const selected = props.selectedBatchId;
|
|
4436
|
+
// 批次抽屉的用例定义直接取首页快照;超过快照上限时抽屉再按 id 补取。
|
|
4437
|
+
const caseById = useMemo(() => new Map(asArray(snapshot.cases).map((item) => [String(item.tcId), item])), [snapshot.cases]);
|
|
3751
4438
|
useEffect(() => {
|
|
3752
4439
|
if (!selected) { setDetail(null); setError(''); return undefined; }
|
|
3753
4440
|
let cancelled = false;
|
|
@@ -3766,8 +4453,10 @@ window.__ModuleLoader__.load({
|
|
|
3766
4453
|
batch: detail,
|
|
3767
4454
|
project: snapshot.project,
|
|
3768
4455
|
hasBaseUrl: Boolean(snapshot.config?.baseUrl),
|
|
4456
|
+
caseById,
|
|
3769
4457
|
onBack: () => props.onSelectBatch(''),
|
|
3770
4458
|
onStop: props.onStopBatch,
|
|
4459
|
+
onResumeBatch: props.onResumeBatch,
|
|
3771
4460
|
onWritebackDone: props.onWritebackDone,
|
|
3772
4461
|
onShot: props.onShot,
|
|
3773
4462
|
onOpenBatch: props.onOpenBatch,
|
|
@@ -5510,9 +6199,10 @@ window.__ModuleLoader__.load({
|
|
|
5510
6199
|
/* ------------------------------------------------------------------ */
|
|
5511
6200
|
|
|
5512
6201
|
function ImportDialog(props) {
|
|
5513
|
-
const
|
|
5514
|
-
const [
|
|
5515
|
-
const [
|
|
6202
|
+
const targetDoc = props.targetDoc || null;
|
|
6203
|
+
const [file, setFile] = useState(targetDoc?.sourcePath || '');
|
|
6204
|
+
const [name, setName] = useState(targetDoc?.name || '');
|
|
6205
|
+
const [mode, setMode] = useState(targetDoc?.mode === 'overwrite' ? 'overwrite' : 'merge');
|
|
5516
6206
|
const [busy, setBusy] = useState(false);
|
|
5517
6207
|
const [error, setError] = useState('');
|
|
5518
6208
|
const [result, setResult] = useState(null);
|
|
@@ -5521,7 +6211,7 @@ window.__ModuleLoader__.load({
|
|
|
5521
6211
|
const docs = asArray(props.snapshot?.docs);
|
|
5522
6212
|
const identity = normalizeDocKey(name || baseName(file));
|
|
5523
6213
|
const docKeyOf = (doc) => normalizeDocKey(doc?.docKey) || normalizeDocKey(doc?.name);
|
|
5524
|
-
const matchedDoc = identity ? docs.find((doc) => normalizeDocKey(doc?.name) === identity || docKeyOf(doc) === identity) : null;
|
|
6214
|
+
const matchedDoc = targetDoc || (identity ? docs.find((doc) => normalizeDocKey(doc?.name) === identity || docKeyOf(doc) === identity) : null);
|
|
5525
6215
|
const applyResult = (payload) => {
|
|
5526
6216
|
const count = Math.max(
|
|
5527
6217
|
Number(payload && payload.caseCount) || 0,
|
|
@@ -5543,7 +6233,12 @@ window.__ModuleLoader__.load({
|
|
|
5543
6233
|
setResult(null);
|
|
5544
6234
|
setStatus('正在从服务器路径导入…');
|
|
5545
6235
|
try {
|
|
5546
|
-
const payload = await props.onImport({
|
|
6236
|
+
const payload = await props.onImport({
|
|
6237
|
+
file: file.trim(),
|
|
6238
|
+
name: targetDoc ? '' : name.trim(),
|
|
6239
|
+
mode,
|
|
6240
|
+
...(targetDoc ? { docId: targetDoc.id } : {}),
|
|
6241
|
+
});
|
|
5547
6242
|
applyResult(payload);
|
|
5548
6243
|
} catch (err) {
|
|
5549
6244
|
setError(err.message);
|
|
@@ -5566,10 +6261,12 @@ window.__ModuleLoader__.load({
|
|
|
5566
6261
|
const payload = await props.onUpload({
|
|
5567
6262
|
name: input.name,
|
|
5568
6263
|
dataBase64,
|
|
5569
|
-
docName: name.trim() || input.name.replace(/\.[^.]+$/, ''),
|
|
5570
6264
|
mode,
|
|
6265
|
+
...(targetDoc
|
|
6266
|
+
? { docId: targetDoc.id }
|
|
6267
|
+
: { docName: name.trim() || input.name.replace(/\.[^.]+$/, '') }),
|
|
5571
6268
|
});
|
|
5572
|
-
if (!name.trim()) setName(input.name.replace(/\.[^.]+$/, ''));
|
|
6269
|
+
if (!targetDoc && !name.trim()) setName(input.name.replace(/\.[^.]+$/, ''));
|
|
5573
6270
|
setFile(payload.uploadedFile || input.name);
|
|
5574
6271
|
applyResult(payload);
|
|
5575
6272
|
} catch (err) {
|
|
@@ -5588,8 +6285,10 @@ window.__ModuleLoader__.load({
|
|
|
5588
6285
|
: 0;
|
|
5589
6286
|
const diff = result && result.diffSummary ? result.diffSummary : null;
|
|
5590
6287
|
return h(Modal, {
|
|
5591
|
-
title: '导入用例文档',
|
|
5592
|
-
desc:
|
|
6288
|
+
title: targetDoc ? '重新关联源文件' : '导入用例文档',
|
|
6289
|
+
desc: targetDoc
|
|
6290
|
+
? '选择新的源文件并导入到该文档;文档 id、名称和用例归属保持不变。'
|
|
6291
|
+
: '支持 .md / .markdown / .txt / .xlsx / .csv / .json。可以点击选择本地文件上传,也可以填写服务器上的文件或目录路径。',
|
|
5593
6292
|
onClose: props.onClose,
|
|
5594
6293
|
footer: h(React.Fragment, null,
|
|
5595
6294
|
h('button', { className: 'studio-btn', onClick: props.onClose }, result ? '完成' : '取消'),
|
|
@@ -5597,6 +6296,18 @@ window.__ModuleLoader__.load({
|
|
|
5597
6296
|
),
|
|
5598
6297
|
},
|
|
5599
6298
|
h('div', { className: 'studio-form' },
|
|
6299
|
+
targetDoc ? h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
6300
|
+
h('div', { className: 'studio-doc-meta' },
|
|
6301
|
+
h(Badge, { tone: docKindTone(targetDoc.kind) }, docKindLabel(targetDoc.kind)),
|
|
6302
|
+
h(Badge, { tone: 'link' }, '目标文档'),
|
|
6303
|
+
h('span', { className: 'studio-row-sub' },
|
|
6304
|
+
'v' + (targetDoc.version || 1) + ' · ' + (Number(targetDoc.visibleCount) || 0) + ' 条用例'
|
|
6305
|
+
+ (targetDoc.archived ? ' · 已归档' : '')
|
|
6306
|
+
)
|
|
6307
|
+
),
|
|
6308
|
+
h('div', { className: 'studio-note studio-mono-break', style: { marginTop: 6 } },
|
|
6309
|
+
'当前源文件:' + (targetDoc.sourcePath || '—'))
|
|
6310
|
+
) : null,
|
|
5600
6311
|
h('div', { className: 'studio-card', style: { padding: '13px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
5601
6312
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
|
|
5602
6313
|
h('label', {
|
|
@@ -5607,7 +6318,7 @@ window.__ModuleLoader__.load({
|
|
|
5607
6318
|
'选择本地文件',
|
|
5608
6319
|
h('input', {
|
|
5609
6320
|
type: 'file',
|
|
5610
|
-
accept: '.md,.markdown,.txt,.xlsx,.json',
|
|
6321
|
+
accept: '.md,.markdown,.txt,.xlsx,.csv,.json',
|
|
5611
6322
|
style: { display: 'none' },
|
|
5612
6323
|
disabled: !uploadSupported || busy,
|
|
5613
6324
|
onChange: onLocalFile,
|
|
@@ -5617,10 +6328,10 @@ window.__ModuleLoader__.load({
|
|
|
5617
6328
|
),
|
|
5618
6329
|
!uploadSupported ? h('div', { className: 'studio-note tone-warn', style: { marginTop: 8 } }, '当前 Host 没有加载上传接口。请重启 DSH 后再试;也可以先用下面的服务器路径导入。') : null
|
|
5619
6330
|
),
|
|
5620
|
-
docs.length ? h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
6331
|
+
!targetDoc && docs.length ? h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
5621
6332
|
h('div', { className: 'studio-nl-label' }, '已导入文档(点击可带入路径和导入方式)'),
|
|
5622
|
-
h('div', { className: 'studio-list' },
|
|
5623
|
-
docs.
|
|
6333
|
+
h('div', { className: 'studio-list', style: { maxHeight: 232, overflowY: 'auto' } },
|
|
6334
|
+
docs.map((doc) => {
|
|
5624
6335
|
const visible = Number(doc.visibleCount ?? doc.count) || 0;
|
|
5625
6336
|
const owned = Number(doc.ownedCount) || 0;
|
|
5626
6337
|
const missing = doc.sourceState === 'missing';
|
|
@@ -5638,6 +6349,11 @@ window.__ModuleLoader__.load({
|
|
|
5638
6349
|
setResult(null);
|
|
5639
6350
|
setError('');
|
|
5640
6351
|
},
|
|
6352
|
+
onKeyDown: (event) => {
|
|
6353
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
6354
|
+
event.preventDefault();
|
|
6355
|
+
event.currentTarget.click();
|
|
6356
|
+
},
|
|
5641
6357
|
},
|
|
5642
6358
|
h('div', { className: 'studio-row-main' },
|
|
5643
6359
|
h('div', { className: 'studio-row-title' }, doc.name || doc.docKey),
|
|
@@ -5656,16 +6372,15 @@ window.__ModuleLoader__.load({
|
|
|
5656
6372
|
)
|
|
5657
6373
|
);
|
|
5658
6374
|
})
|
|
5659
|
-
)
|
|
5660
|
-
docs.length > 8 ? h('div', { className: 'studio-note', style: { marginTop: 4 } }, '还有 ' + (docs.length - 8) + ' 个文档未展示') : null
|
|
6375
|
+
)
|
|
5661
6376
|
) : null,
|
|
5662
6377
|
h('div', { className: 'studio-note', style: { textAlign: 'center', color: 'var(--dsw-alias-label-tertiary)' } }, '或使用服务器路径'),
|
|
5663
6378
|
h(Field, { label: '服务器文件 / 目录路径', hint: '绝对路径,或相对测试工程的路径;目录会递归扫描 .md/.markdown/.txt' },
|
|
5664
6379
|
h('input', { className: 'studio-input', placeholder: '例如 /home/ocean/Projects/oms-v2/test/cases/M006/M006履约管理模块-测试用例.xlsx', value: file, onChange: (e) => setFile(e.target.value) })
|
|
5665
6380
|
),
|
|
5666
|
-
h(Field, { label: '文档名称(可选)', hint: '同名的重复导入会更新同一个文档对象;用于生成用例编号前缀和 cases/studio 文件名' },
|
|
6381
|
+
!targetDoc ? h(Field, { label: '文档名称(可选)', hint: '同名的重复导入会更新同一个文档对象;用于生成用例编号前缀和 cases/studio 文件名' },
|
|
5667
6382
|
h('input', { className: 'studio-input', placeholder: '例如 M006 履约回归', value: name, onChange: (e) => setName(e.target.value) })
|
|
5668
|
-
),
|
|
6383
|
+
) : null,
|
|
5669
6384
|
h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
|
|
5670
6385
|
h('div', { className: 'studio-nl-label' }, '导入方式'),
|
|
5671
6386
|
h('label', { className: 'studio-check', style: { padding: '4px 0' } },
|
|
@@ -5675,13 +6390,12 @@ window.__ModuleLoader__.load({
|
|
|
5675
6390
|
h('div', { className: 'studio-note', style: { marginLeft: 22 } }, '新增用例,并更新同编号用例;文档里已删除的旧用例保留。'),
|
|
5676
6391
|
h('label', { className: 'studio-check', style: { padding: '4px 0', marginTop: 6 } },
|
|
5677
6392
|
h('input', { type: 'radio', name: 'studio-import-mode', checked: mode === 'overwrite', onChange: () => setMode('overwrite') }),
|
|
5678
|
-
'覆盖同名文档'
|
|
6393
|
+
targetDoc ? '覆盖该文档' : '覆盖同名文档'
|
|
5679
6394
|
),
|
|
5680
6395
|
h('div', { className: 'studio-note', style: { marginLeft: 22 } }, '以当前文档为准:删除该文档上次导入、本次已不存在的用例;同编号用例以文档内容更新。'),
|
|
5681
6396
|
matchedDoc
|
|
5682
6397
|
? h('div', { className: 'studio-note tone-warn', style: { marginTop: 6 } }, '将更新已导入文档:' + matchedDoc.name + '(v' + (matchedDoc.version || 1) + ' · ' + (matchedDoc.visibleCount ?? matchedDoc.count ?? 0) + ' 条)')
|
|
5683
|
-
: h('div', { className: 'studio-note', style: { marginTop: 6 } }, '没有匹配到同名文档;本次会作为新文档导入。')
|
|
5684
|
-
),
|
|
6398
|
+
: h('div', { className: 'studio-note', style: { marginTop: 6 } }, '没有匹配到同名文档;本次会作为新文档导入。') ),
|
|
5685
6399
|
status ? h('div', { className: 'studio-note' }, h(Spinner), ' ' + status) : null,
|
|
5686
6400
|
error ? h('div', { className: 'studio-note tone-danger' }, error) : null,
|
|
5687
6401
|
result ? h('div', { className: 'studio-nl' },
|
|
@@ -5713,7 +6427,7 @@ window.__ModuleLoader__.load({
|
|
|
5713
6427
|
) : null,
|
|
5714
6428
|
h('div', { className: 'studio-note' }, '导入完成后可在「用例」中检查自然语言内容;如有偏差,直接编辑用例即可。')
|
|
5715
6429
|
) : h('div', { className: 'studio-note', style: { background: 'var(--dsw-alias-bg-layer-2)', padding: '10px 12px', borderRadius: 8 } },
|
|
5716
|
-
'文档没有固定模板:带编号的用例标题、前置条件/操作步骤/预期结果字段表、或编号列表都能识别。xlsx
|
|
6430
|
+
'文档没有固定模板:带编号的用例标题、前置条件/操作步骤/预期结果字段表、或编号列表都能识别。xlsx 会解析所有包含表头的工作表;CSV 按同一套表头识别用例。'
|
|
5717
6431
|
)
|
|
5718
6432
|
)
|
|
5719
6433
|
);
|
|
@@ -5767,7 +6481,45 @@ window.__ModuleLoader__.load({
|
|
|
5767
6481
|
const [startBusy, setStartBusy] = useState(false);
|
|
5768
6482
|
const [error, setError] = useState('');
|
|
5769
6483
|
const cases = asArray(snapshot.cases);
|
|
5770
|
-
const
|
|
6484
|
+
const activeDocs = useMemo(() => asArray(snapshot.docs).filter((doc) => doc.archived !== true), [snapshot.docs]);
|
|
6485
|
+
const docById = useMemo(() => new Map(activeDocs.map((doc) => [doc.id, doc])), [activeDocs]);
|
|
6486
|
+
const archivedDocIds = useMemo(() => new Set(asArray(snapshot.docs).filter((doc) => doc.archived === true).map((doc) => doc.id)), [snapshot.docs]);
|
|
6487
|
+
const pickable = useMemo(() => cases.filter((item) => {
|
|
6488
|
+
const id = String(item.docId || item.source?.docId || '');
|
|
6489
|
+
return !id || !archivedDocIds.has(id);
|
|
6490
|
+
}), [cases, archivedDocIds]);
|
|
6491
|
+
const visible = pickable.filter((item) => caseMatches(item, query, filter));
|
|
6492
|
+
// 批次选择沿用用例库的两层结构:文档分组,用例缩进并带文档内序号。
|
|
6493
|
+
const groups = useMemo(() => {
|
|
6494
|
+
const byDoc = new Map();
|
|
6495
|
+
const unassigned = [];
|
|
6496
|
+
for (const item of visible) {
|
|
6497
|
+
const id = String(item.docId || item.source?.docId || '');
|
|
6498
|
+
if (id && docById.has(id)) {
|
|
6499
|
+
if (!byDoc.has(id)) byDoc.set(id, []);
|
|
6500
|
+
byDoc.get(id).push(item);
|
|
6501
|
+
} else {
|
|
6502
|
+
unassigned.push(item);
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
const out = activeDocs
|
|
6506
|
+
.map((doc) => ({ doc, cases: byDoc.get(doc.id) || [] }))
|
|
6507
|
+
.filter((group) => group.cases.length > 0);
|
|
6508
|
+
if (unassigned.length) out.push({ doc: null, cases: unassigned });
|
|
6509
|
+
return out;
|
|
6510
|
+
}, [visible, activeDocs, docById]);
|
|
6511
|
+
// 序号按文档内稳定顺序计算,搜索或筛选后仍与用例库一致。
|
|
6512
|
+
const seqByCase = useMemo(() => {
|
|
6513
|
+
const groups = new Map();
|
|
6514
|
+
for (const item of pickable) {
|
|
6515
|
+
const key = String(item.docId || item.source?.docId || '__unassigned__');
|
|
6516
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
6517
|
+
groups.get(key).push(item);
|
|
6518
|
+
}
|
|
6519
|
+
const map = new Map();
|
|
6520
|
+
for (const list of groups.values()) list.forEach((item, index) => map.set(item.tcId, index + 1));
|
|
6521
|
+
return map;
|
|
6522
|
+
}, [pickable]);
|
|
5771
6523
|
const toggle = (id) => setSelected((current) => current.includes(id) ? current.filter((item) => item !== id) : [...current, id]);
|
|
5772
6524
|
const selectAll = (ids) => setSelected((current) => Array.from(new Set([...current, ...ids])));
|
|
5773
6525
|
const removeAll = (ids) => { const set = new Set(ids); setSelected((current) => current.filter((item) => !set.has(item))); };
|
|
@@ -5847,14 +6599,41 @@ window.__ModuleLoader__.load({
|
|
|
5847
6599
|
h('button', { className: 'studio-btn studio-btn-sm', onClick: () => removeAll(visible.map((item) => item.tcId)) }, '取消当前结果')
|
|
5848
6600
|
)
|
|
5849
6601
|
),
|
|
5850
|
-
h('div', { className: 'studio-case-list', style: { maxHeight:
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
h('
|
|
5856
|
-
|
|
5857
|
-
|
|
6602
|
+
h('div', { className: 'studio-case-list', style: { maxHeight: 420, overflow: 'auto' } },
|
|
6603
|
+
groups.map((group) => {
|
|
6604
|
+
const ids = group.cases.map((item) => item.tcId);
|
|
6605
|
+
const selectedCount = ids.filter((id) => selected.includes(id)).length;
|
|
6606
|
+
return h('div', { key: group.doc ? group.doc.id : '__unassigned__', className: 'studio-picker-group' },
|
|
6607
|
+
h('div', { className: 'studio-doc-row studio-picker-doc' },
|
|
6608
|
+
group.doc ? h(SelectCheckbox, {
|
|
6609
|
+
checked: ids.length > 0 && selectedCount === ids.length,
|
|
6610
|
+
mixed: selectedCount > 0 && selectedCount < ids.length,
|
|
6611
|
+
label: '选择该文档下的用例',
|
|
6612
|
+
onChange: (next) => next ? selectAll(ids) : removeAll(ids),
|
|
6613
|
+
}) : null,
|
|
6614
|
+
h(Icon, { name: 'folder', size: 14, className: 'studio-folder-icon' }),
|
|
6615
|
+
h('div', { className: 'studio-doc-main' },
|
|
6616
|
+
h('div', { className: 'studio-doc-top' },
|
|
6617
|
+
h('span', { className: 'studio-doc-name' }, group.doc?.name || '未归属文档'),
|
|
6618
|
+
group.doc ? h(Badge, { tone: docKindTone(group.doc.kind), className: 'studio-doc-kind' }, docKindLabel(group.doc.kind)) : h(Badge, { tone: 'warn' }, '未关联文档'),
|
|
6619
|
+
h('span', { className: 'studio-doc-count' }, group.cases.length + ' 条' + (selectedCount ? ' · 已选 ' + selectedCount : ''))
|
|
6620
|
+
),
|
|
6621
|
+
h('div', { className: 'studio-doc-sub' },
|
|
6622
|
+
h('span', { className: 'studio-doc-hint' }, group.doc?.sourcePath || '这些用例没有关联到导入文档')
|
|
6623
|
+
)
|
|
6624
|
+
)
|
|
6625
|
+
),
|
|
6626
|
+
group.cases.map((item) => h(CaseListItem, {
|
|
6627
|
+
key: item.tcId,
|
|
6628
|
+
item,
|
|
6629
|
+
selected: selected.includes(item.tcId),
|
|
6630
|
+
seq: seqByCase.get(item.tcId),
|
|
6631
|
+
indent: true,
|
|
6632
|
+
onSelect: () => toggle(item.tcId),
|
|
6633
|
+
onToggle: () => toggle(item.tcId),
|
|
6634
|
+
}))
|
|
6635
|
+
);
|
|
6636
|
+
})
|
|
5858
6637
|
)
|
|
5859
6638
|
) : null,
|
|
5860
6639
|
step === 2 ? h('div', { className: 'studio-form' },
|
|
@@ -5984,6 +6763,7 @@ window.__ModuleLoader__.load({
|
|
|
5984
6763
|
const [caseRunCaseId, setCaseRunCaseId] = useState('');
|
|
5985
6764
|
const [selectedIds, setSelectedIds] = useState([]);
|
|
5986
6765
|
const [importOpen, setImportOpen] = useState(false);
|
|
6766
|
+
const [importTargetDoc, setImportTargetDoc] = useState(null);
|
|
5987
6767
|
const [batchOpen, setBatchOpen] = useState(false);
|
|
5988
6768
|
const [batchInitial, setBatchInitial] = useState([]);
|
|
5989
6769
|
const [editCase, setEditCase] = useState(null);
|
|
@@ -6083,6 +6863,14 @@ window.__ModuleLoader__.load({
|
|
|
6083
6863
|
setBatchInitial(initial.length ? initial : selectedIds);
|
|
6084
6864
|
setBatchOpen(true);
|
|
6085
6865
|
};
|
|
6866
|
+
const openImport = (target) => {
|
|
6867
|
+
setImportTargetDoc(target || null);
|
|
6868
|
+
setImportOpen(true);
|
|
6869
|
+
};
|
|
6870
|
+
const closeImport = () => {
|
|
6871
|
+
setImportOpen(false);
|
|
6872
|
+
setImportTargetDoc(null);
|
|
6873
|
+
};
|
|
6086
6874
|
const onCreated = (batch) => {
|
|
6087
6875
|
setBatchOpen(false);
|
|
6088
6876
|
setSelectedBatchId(batch.id);
|
|
@@ -6093,6 +6881,37 @@ window.__ModuleLoader__.load({
|
|
|
6093
6881
|
const onImportDone = () => {
|
|
6094
6882
|
studio.reload();
|
|
6095
6883
|
};
|
|
6884
|
+
const onArchiveDocument = async (doc, archived) => {
|
|
6885
|
+
try {
|
|
6886
|
+
const owned = new Set(asArray(studio.snapshot.cases)
|
|
6887
|
+
.filter((item) => String(item.docId || item.source?.docId || '') === doc.id)
|
|
6888
|
+
.map((item) => item.tcId));
|
|
6889
|
+
const payload = await api('/docs/archive', { method: 'POST', project: studio.snapshot.project, body: { docId: doc.id, archived } });
|
|
6890
|
+
if (archived) {
|
|
6891
|
+
setSelectedIds((ids) => ids.filter((id) => !owned.has(id)));
|
|
6892
|
+
if (owned.has(selectedCaseId)) setSelectedCaseId('');
|
|
6893
|
+
}
|
|
6894
|
+
studio.reload();
|
|
6895
|
+
showToast({ kind: 'success', text: (archived ? '已归档文档:' : '已恢复文档:') + (doc.name || doc.id) });
|
|
6896
|
+
return payload;
|
|
6897
|
+
} catch (error) {
|
|
6898
|
+
showToast({ kind: 'error', text: error.message });
|
|
6899
|
+
return null;
|
|
6900
|
+
}
|
|
6901
|
+
};
|
|
6902
|
+
const onDeleteDocument = async (doc) => {
|
|
6903
|
+
const payload = await api('/docs/delete', { method: 'POST', project: studio.snapshot.project, body: { docId: doc.id } });
|
|
6904
|
+
studio.reload();
|
|
6905
|
+
setSelectedCaseId('');
|
|
6906
|
+
setSelectedIds([]);
|
|
6907
|
+
showToast({ kind: 'success', text: '已删除文档记录:' + (doc.name || doc.id) + ';用例保留为未归属' });
|
|
6908
|
+
return payload;
|
|
6909
|
+
};
|
|
6910
|
+
const onDocsWriteback = async (body) => {
|
|
6911
|
+
const payload = await api('/docs/writeback', { method: 'POST', project: studio.snapshot.project, body, timeoutMs: 120000 });
|
|
6912
|
+
if (body.dryRun !== true) studio.reload();
|
|
6913
|
+
return payload;
|
|
6914
|
+
};
|
|
6096
6915
|
const onRunCase = async (item) => {
|
|
6097
6916
|
const batchId = item.lastRun?.batchId || '';
|
|
6098
6917
|
try {
|
|
@@ -6135,14 +6954,14 @@ window.__ModuleLoader__.load({
|
|
|
6135
6954
|
showToast({ kind: 'error', text: error.message });
|
|
6136
6955
|
}
|
|
6137
6956
|
};
|
|
6138
|
-
const onStopCase = async (batch, caseId) => {
|
|
6957
|
+
const onStopCase = async (batch, caseId, run, options = {}) => {
|
|
6139
6958
|
try {
|
|
6140
6959
|
const payload = await api('/batch/case/stop', { method: 'POST', project: studio.snapshot.project, body: { id: batch.id, caseId } });
|
|
6141
6960
|
studio.reload();
|
|
6142
|
-
showToast({ kind: 'success', text: '已请求停止该用例' });
|
|
6961
|
+
if (!options.silent) showToast({ kind: 'success', text: '已请求停止该用例' });
|
|
6143
6962
|
return payload;
|
|
6144
6963
|
} catch (error) {
|
|
6145
|
-
showToast({ kind: 'error', text: error.message });
|
|
6964
|
+
if (!options.silent) showToast({ kind: 'error', text: error.message });
|
|
6146
6965
|
return null;
|
|
6147
6966
|
}
|
|
6148
6967
|
};
|
|
@@ -6157,16 +6976,18 @@ window.__ModuleLoader__.load({
|
|
|
6157
6976
|
return null;
|
|
6158
6977
|
}
|
|
6159
6978
|
};
|
|
6160
|
-
const onRequeueCase = async (batch, caseId, run) => {
|
|
6979
|
+
const onRequeueCase = async (batch, caseId, run, options = {}) => {
|
|
6161
6980
|
try {
|
|
6162
6981
|
const forceAgent = ['manual', 'blocked'].includes(run?.mode) || run?.status === 'blocked';
|
|
6163
6982
|
const payload = await api('/case/run', { method: 'POST', project: studio.snapshot.project, body: { id: caseId, batchId: batch.id, ...(forceAgent ? { forceAgent: true } : {}) } });
|
|
6164
6983
|
studio.reload();
|
|
6165
|
-
if (
|
|
6166
|
-
|
|
6984
|
+
if (!options.silent) {
|
|
6985
|
+
if (payload.alreadyActive) showToast({ kind: 'warn', text: '该用例已经在队列或执行中' });
|
|
6986
|
+
else showToast({ kind: 'success', text: '已重新排队到原批次' });
|
|
6987
|
+
}
|
|
6167
6988
|
return payload;
|
|
6168
6989
|
} catch (error) {
|
|
6169
|
-
showToast({ kind: 'error', text: error.message });
|
|
6990
|
+
if (!options.silent) showToast({ kind: 'error', text: error.message });
|
|
6170
6991
|
return null;
|
|
6171
6992
|
}
|
|
6172
6993
|
};
|
|
@@ -6201,6 +7022,17 @@ window.__ModuleLoader__.load({
|
|
|
6201
7022
|
showToast({ kind: 'error', text: error.message });
|
|
6202
7023
|
}
|
|
6203
7024
|
};
|
|
7025
|
+
const onResumeBatch = async (id) => {
|
|
7026
|
+
try {
|
|
7027
|
+
const payload = await api('/batch/resume', { method: 'POST', project: studio.snapshot.project, body: { id } });
|
|
7028
|
+
studio.reload();
|
|
7029
|
+
showToast({ kind: 'success', text: '已继续执行 ' + (payload?.resumed || 0) + ' 条未完成用例' });
|
|
7030
|
+
return payload;
|
|
7031
|
+
} catch (error) {
|
|
7032
|
+
showToast({ kind: 'error', text: error.message });
|
|
7033
|
+
return null;
|
|
7034
|
+
}
|
|
7035
|
+
};
|
|
6204
7036
|
const onWritebackDone = () => {
|
|
6205
7037
|
studio.reload();
|
|
6206
7038
|
showToast({ kind: 'success', text: '用例文档已回写' });
|
|
@@ -6288,7 +7120,11 @@ window.__ModuleLoader__.load({
|
|
|
6288
7120
|
onDeleteFlow,
|
|
6289
7121
|
onEditCase: setEditCase,
|
|
6290
7122
|
onShot: setLightbox,
|
|
6291
|
-
onImport: () =>
|
|
7123
|
+
onImport: () => openImport(),
|
|
7124
|
+
onReassociateDocument: openImport,
|
|
7125
|
+
onArchiveDocument,
|
|
7126
|
+
onDeleteDocument,
|
|
7127
|
+
onDocsWriteback,
|
|
6292
7128
|
onReReadDocument: async (body) => {
|
|
6293
7129
|
const payload = await api('/docs/re-read', { method: 'POST', project: studio.snapshot.project, body, timeoutMs: 120000 });
|
|
6294
7130
|
studio.reload();
|
|
@@ -6308,6 +7144,7 @@ window.__ModuleLoader__.load({
|
|
|
6308
7144
|
onSelectBatch: setSelectedBatchId,
|
|
6309
7145
|
onNewBatch: openNewBatch,
|
|
6310
7146
|
onStopBatch,
|
|
7147
|
+
onResumeBatch,
|
|
6311
7148
|
onWritebackDone,
|
|
6312
7149
|
onShot: setLightbox,
|
|
6313
7150
|
onOpenBatch: (id) => { setSelectedBatchId(id); setView('batches'); studio.reload(); },
|
|
@@ -6333,7 +7170,7 @@ window.__ModuleLoader__.load({
|
|
|
6333
7170
|
snapshot,
|
|
6334
7171
|
onNavigate: navigate,
|
|
6335
7172
|
onNewBatch: () => openNewBatch([]),
|
|
6336
|
-
onImport: () =>
|
|
7173
|
+
onImport: () => openImport(),
|
|
6337
7174
|
onOpenBatch: (id) => { setSelectedBatchId(id); setView('batches'); },
|
|
6338
7175
|
});
|
|
6339
7176
|
};
|
|
@@ -6347,7 +7184,7 @@ window.__ModuleLoader__.load({
|
|
|
6347
7184
|
onNavigate: navigate,
|
|
6348
7185
|
onPickWorkspace: () => { setWorkspaceInitial(studio.snapshot?.project || ''); setWorkspaceInitialInfo(null); setWorkspaceOpen(true); },
|
|
6349
7186
|
onRefresh: studio.reload,
|
|
6350
|
-
onImport: () =>
|
|
7187
|
+
onImport: () => openImport(),
|
|
6351
7188
|
onNewBatch: () => openNewBatch(selectedIds),
|
|
6352
7189
|
}),
|
|
6353
7190
|
h('div', { className: 'studio-body' },
|
|
@@ -6356,7 +7193,8 @@ window.__ModuleLoader__.load({
|
|
|
6356
7193
|
),
|
|
6357
7194
|
importOpen ? h(ImportDialog, {
|
|
6358
7195
|
snapshot: studio.snapshot,
|
|
6359
|
-
|
|
7196
|
+
targetDoc: importTargetDoc,
|
|
7197
|
+
onClose: closeImport,
|
|
6360
7198
|
onDone: onImportDone,
|
|
6361
7199
|
onToast: showToast,
|
|
6362
7200
|
onImport: (body) => api('/import', { method: 'POST', project: studio.snapshot.project, body, timeoutMs: 120000 }),
|