43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
package workbench
|
|||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestQualityIsBoundToAcceptedManuscript(t *testing.T) {
|
||
|
|
d := TaskData{Segments: []Segment{{ID: "s", AgentID: "author", Status: "accepted", Content: "first"}}}
|
||
|
|
accepted, _ := acceptedManuscript(d)
|
||
|
|
if requireQuality(d, accepted) == nil {
|
||
|
|
t.Fatal("unreviewed draft allowed")
|
||
|
|
}
|
||
|
|
d.Quality = &QualityReport{Passed: true, Summary: "consistent"}
|
||
|
|
if err := validateQuality(d.Quality, accepted); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
if err := requireQuality(d, accepted); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
accepted[0].Content = "changed"
|
||
|
|
if requireQuality(d, accepted) == nil {
|
||
|
|
t.Fatal("stale review allowed")
|
||
|
|
}
|
||
|
|
bad := QualityReport{Passed: true, Summary: "contradictory", Issues: []QualityIssue{{SegmentIDs: []string{"s"}, Severity: "blocking", Problem: "gap", Suggestion: "fix"}}}
|
||
|
|
if validateQuality(&bad, accepted) == nil {
|
||
|
|
t.Fatal("conflicting verdict allowed")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestDecompositionEnforcesCanvasDependencies(t *testing.T) {
|
||
|
|
flow := FlowData{Nodes: []FlowNode{{ID: "a", AgentID: "writer"}, {ID: "b", AgentID: "writer"}}, Edges: []FlowEdge{{Source: "a", Target: "b"}}}
|
||
|
|
for _, segments := range [][]Segment{
|
||
|
|
{{ID: "s", AgentID: "writer"}},
|
||
|
|
{{ID: "s", NodeID: "b", AgentID: "writer"}},
|
||
|
|
{{ID: "s", NodeID: "b", AgentID: "writer"}, {ID: "t", NodeID: "a", AgentID: "writer"}},
|
||
|
|
} {
|
||
|
|
if validateSegmentOrder(segments, flow) == nil {
|
||
|
|
t.Fatal("ambiguous or reversed topology allowed")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if err := validateSegmentOrder([]Segment{{NodeID: "a", AgentID: "writer"}, {NodeID: "b", AgentID: "writer"}}, flow); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
}
|