Identify the protected alias affected by a proposed edit
This commit is contained in:
@@ -3,6 +3,7 @@ package validators
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
domain "gitea.maximumdirect.net/eric/audita/v3/internal/core/glossary"
|
||||
@@ -107,3 +108,28 @@ func TestProtectedNameRepetitionRequiresSurvivingIdentityAndSpokenWordScope(t *t
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProtectedNameFindingIdentifiesRemovedAlias(t *testing.T) {
|
||||
req := Request{
|
||||
ModuleKey: "glossary",
|
||||
IndependentEvidence: true,
|
||||
ReplacementPolicy: proposals.ReplacementPolicyReplaceAll,
|
||||
WorkingTranscript: &schema.Transcript{Segments: []schema.Segment{
|
||||
{ID: 1, Text: "Mira spoke to Captain Mira"},
|
||||
}},
|
||||
ProtectedTerms: domain.Vocabulary([]domain.Entry{{ID: "mira", Name: "Mira", Aliases: []string{"Captain Mira"}}}, nil),
|
||||
CandidateProposal: []proposals.EnrichedCorrectionProposal{{
|
||||
CorrectionProposal: proposals.CorrectionProposal{
|
||||
TargetSegmentID: 1, OriginalText: "Captain Mira", CorrectedText: "the captain", Confidence: 0.9,
|
||||
},
|
||||
}},
|
||||
}
|
||||
result, err := ValidateProtectedTerms(req)
|
||||
if err != nil || len(result.Decisions) != 1 {
|
||||
t.Fatalf("result=%+v err=%v", result, err)
|
||||
}
|
||||
decision := result.Decisions[0]
|
||||
if decision.Approved || decision.ReasonCode != ReasonProtectedGlossaryTerm || !strings.Contains(decision.Message, `"Captain Mira"`) {
|
||||
t.Fatalf("finding did not identify the removed alias: %+v", decision)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user