feat: harden support, localize knowledge and add operator availability [skip ci]
Source-only publication of reviewed commit 64e96a7f423673dc29ad56485be9fc79bce8af1c.
Passed in isolation: focused frontend/backend tests, race checks, TypeScript typecheck, lint, Go compilation, Flowgram build, and deterministic SDK build/tests.
Not accepted as a production release: Next.js export/native assembly remains blocked by environment memory limits; browser interaction and MySQL staging acceptance remain unverified. No production server, database/schema, runtime configuration, deployment, release tag, or workflow execution was performed.
Expected source tree: 0a4a7528e9.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Modified in the independent AgentDesk fork: localized knowledge workflows and safe display errors.
|
||||
package services
|
||||
|
||||
import (
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"agent-desk/internal/models"
|
||||
"agent-desk/internal/pkg/dto/request"
|
||||
"agent-desk/internal/pkg/enums"
|
||||
"agent-desk/internal/pkg/errorsx"
|
||||
"agent-desk/internal/repositories"
|
||||
|
||||
"github.com/glebarez/sqlite"
|
||||
@@ -203,3 +205,36 @@ func assertKnowledgeBaseServiceTestCount(t *testing.T, model any, query string,
|
||||
t.Fatalf("count %T = %d, want %d", model, count, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteKnowledgeBaseWorkflowErrorsLocalized(t *testing.T) {
|
||||
for _, count := range []int{1, 2} {
|
||||
t.Run(string(rune('0'+count)), func(t *testing.T) {
|
||||
setupKnowledgeBaseServiceTestDB(t)
|
||||
kb := createKnowledgeBaseServiceTestBase(t, "Keep this knowledge base")
|
||||
for i := 0; i < count; i++ {
|
||||
createKnowledgeBaseServiceTestWorkflow(t, "流程 %s / Процесс"+string(rune('A'+i)), knowledgeBaseServiceTestWorkflowDefinition([]int64{kb.ID}))
|
||||
}
|
||||
err := KnowledgeBaseService.DeleteKnowledgeBase(kb.ID)
|
||||
localized, ok := err.(*errorsx.I18nError)
|
||||
if !ok {
|
||||
t.Fatalf("expected localized application error, got %T: %v", err, err)
|
||||
}
|
||||
key := "error.knowledge.workflowReference"
|
||||
if count > 1 {
|
||||
key = "error.knowledge.workflowReferences"
|
||||
}
|
||||
if localized.Key != key {
|
||||
t.Fatalf("error key = %q", localized.Key)
|
||||
}
|
||||
for _, locale := range []string{"en-US", "ru-RU"} {
|
||||
message := localized.Message(locale)
|
||||
if strings.Contains(message, "%!") || strings.Contains(message, "error.knowledge") || strings.Contains(message, "知识库正在") {
|
||||
t.Fatalf("bad localized message %q", message)
|
||||
}
|
||||
if count == 1 && !strings.Contains(message, "流程 %s / Процесс") {
|
||||
t.Fatalf("workflow name changed: %q", message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user