forked from longtao.wu/droboticflow
42 lines
2.1 KiB
Go
42 lines
2.1 KiB
Go
package api
|
|
|
|
import (
|
|
"droboticflow/internal/domain"
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestRawHumanAcceptanceWithoutPoseDoesNotRelaxLegacy(t *testing.T) {
|
|
for _, profile := range []string{"", domain.ProcessingProfileRawHuman} {
|
|
t.Run(profile, func(t *testing.T) {
|
|
f := newCombinedDraftFixture(t)
|
|
source, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID)
|
|
source.ProcessingProfile = profile
|
|
if e := f.store.UpsertHumanBatch(f.ctx, *source); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
sourceItem := f.item
|
|
sourceItem.Status = domain.HumanItemAccepted
|
|
if e := f.store.UpsertHumanItem(f.ctx, sourceItem); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
batch := domain.HumanBatchRecord{ID: "raw-acceptance", OrganizationID: source.OrganizationID, ProjectID: source.ProjectID, WorkflowID: source.WorkflowID, RunID: source.RunID, PluginID: source.PluginID, SourceBatchID: source.ID, ProcessingProfile: profile, Status: domain.HumanBatchActive, Stages: []domain.HumanStageDefinition{{ID: fanyuV5PrePackageAcceptanceStageID, Kind: domain.HumanStageAcceptance, RequiredRole: "acceptance_reviewer"}}}
|
|
if e := f.store.UpsertHumanBatch(f.ctx, batch); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
item := domain.HumanItemRecord{ID: "raw-acceptance-item", OrganizationID: source.OrganizationID, ProjectID: source.ProjectID, WorkflowID: source.WorkflowID, RunID: source.RunID, PluginID: source.PluginID, BatchID: batch.ID, ProcessingProfile: profile, CurrentStageID: fanyuV5PrePackageAcceptanceStageID, Status: domain.HumanItemClaimed, AssignedUserID: f.admin.ID, Version: 1, CurrentRevision: 1, Subject: domain.HumanSubjectRef{Payload: map[string]any{"sourceBatchId": source.ID}}}
|
|
if e := f.store.UpsertHumanItem(f.ctx, item); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
r := f.request(http.MethodPost, "/api/human-items/"+item.ID+"/decisions", f.admin, map[string]any{"version": 1, "decision": "approved", "reviewedRevision": 1})
|
|
expected := http.StatusBadRequest
|
|
if profile == domain.ProcessingProfileRawHuman {
|
|
expected = http.StatusOK
|
|
}
|
|
if r.Code != expected {
|
|
t.Fatalf("profile=%s status=%d body=%s", profile, r.Code, r.Body.String())
|
|
}
|
|
})
|
|
}
|
|
}
|