🐛 Defer slice name validation during disposition edits
This commit is contained in:
parent
b947af4fd0
commit
93a08777f7
@ -14,7 +14,7 @@
|
||||
|
||||
已有自由文本原样保留,无词条 ID 的原因显示“手动填写”。普通保存不能篡改原因快照;字典改名/停用不追写历史。舍弃/恢复记录保留前后快照。新生成和复用媒体的审核 JSON 均保留词条快照。舍弃仍保留完整审核媒体,不改变切片边界,也不进入最终交付。
|
||||
|
||||
已舍弃片段免除切片名称字典校验,包括默认名称;确认舍弃时按变更后的用途校验,避免尚未设置舍弃状态就被命名规则拦截。舍弃原因、边界和审核证据仍正常校验。保留片段继续校验名称;恢复后的片段在重新确认切片时也需符合命名字典。未修改的历史名称仍沿用兼容规则;其他保留片段的新非法名称明确指出编号和名称,关闭重开保留舍弃原因草稿。
|
||||
已舍弃片段免除切片名称字典校验,包括默认名称。舍弃/恢复属于逐片编辑操作,不校验整组切片名称,因此其他尚未命名的保留片段不会阻止当前操作;舍弃原因、边界、归属、版本和审核证据仍正常校验。最终确认整组切片时,保留片段(包括恢复后的片段)必须符合命名字典规则,已舍弃片段免检;历史名称沿用已有兼容规则。
|
||||
|
||||
验证入口:
|
||||
- Go `TestDiscardReason*`:字典隔离、独立项目配置、旧版本/停用/跨组织校验、快照、历史名称与恢复。
|
||||
|
||||
@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDiscardSkipsTargetNameButValidatesKeptSlices(t *testing.T) {
|
||||
func TestDiscardAllowsUnfinishedKeptNamesUntilConfirmation(t *testing.T) {
|
||||
for _, invalidKept := range []bool{false, true} {
|
||||
t.Run(map[bool]string{false: "discard default name", true: "reject invalid kept name"}[invalidKept], func(t *testing.T) {
|
||||
t.Run(map[bool]string{false: "discard default name", true: "save with unfinished kept name"}[invalidKept], func(t *testing.T) {
|
||||
f := newCombinedDraftFixture(t)
|
||||
seedSliceDictionary(t, f, "测试切片")
|
||||
body := dispositionFixturePayload(t, f)
|
||||
@ -20,12 +20,6 @@ func TestDiscardSkipsTargetNameButValidatesKeptSlices(t *testing.T) {
|
||||
body.SliceSegments[0].Name = "切片 002"
|
||||
}
|
||||
r := f.request("POST", "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/slice-dispositions", f.annotator, body)
|
||||
if invalidKept {
|
||||
if r.Code != 400 {
|
||||
t.Fatalf("expected validation failure: %d %s", r.Code, r.Body.String())
|
||||
}
|
||||
return
|
||||
}
|
||||
if r.Code != 200 {
|
||||
t.Fatalf("discard default name: %d %s", r.Code, r.Body.String())
|
||||
}
|
||||
@ -54,8 +48,20 @@ func TestDiscardSkipsTargetNameButValidatesKeptSlices(t *testing.T) {
|
||||
t.Fatal("discard not retained on readback")
|
||||
}
|
||||
server := &server{store: f.store}
|
||||
if issues := server.validateProjectSliceNames(f.ctx, &got.Item, got.Workspace.SliceSegments, "confirm"); len(issues) != 0 {
|
||||
t.Fatal(issues)
|
||||
if issues := server.validateProjectSliceNames(f.ctx, &got.Item, got.Workspace.SliceSegments, "confirm"); (len(issues) > 0) != invalidKept {
|
||||
t.Fatalf("confirmation must reject unfinished kept names only: %v", issues)
|
||||
}
|
||||
if invalidKept && saved[0].Name != "切片 002" {
|
||||
t.Fatal("discard changed another slice's draft name")
|
||||
}
|
||||
restore := body
|
||||
restore.Version = got.Item.Version
|
||||
restore.SliceSegments = got.Workspace.SliceSegments
|
||||
restore.Segments = got.Workspace.Segments
|
||||
restore.Disposition = "keep"
|
||||
r = f.request("POST", "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/slice-dispositions", f.annotator, restore)
|
||||
if r.Code != 200 {
|
||||
t.Fatalf("restore unfinished names: %d %s", r.Code, r.Body.String())
|
||||
}
|
||||
kept := append([]domain.SliceSegment(nil), got.Workspace.SliceSegments...)
|
||||
kept[1].DeliveryDisposition = "keep"
|
||||
|
||||
@ -239,8 +239,9 @@ func (s *server) handleSliceDisposition(w http.ResponseWriter, r *http.Request)
|
||||
next.AnnotationStatus = domain.SliceAnnotationPending
|
||||
}
|
||||
slices[idx] = next
|
||||
issues = s.validateProjectSliceNames(r.Context(), item, slices, "draft")
|
||||
issues = append(issues, validateDraftCombinedAnnotationEvents(segments, *task)...)
|
||||
// Disposition is an incremental edit, not confirmation of the whole slicing
|
||||
// plan. Other slices may still have draft names; confirmation validates them.
|
||||
issues = validateDraftCombinedAnnotationEvents(segments, *task)
|
||||
if len(issues) > 0 {
|
||||
renderValidationError(w, describeSliceNameIssues(issues, slices)...)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user