WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
)
|
||||
|
||||
type stubAgentForEmbed struct {
|
||||
interfaces.CustomAgentService
|
||||
agent *types.CustomAgent
|
||||
err error
|
||||
}
|
||||
|
||||
func (s *stubAgentForEmbed) GetAgentByID(_ context.Context, _ string) (*types.CustomAgent, error) {
|
||||
if s.err != nil {
|
||||
return nil, s.err
|
||||
}
|
||||
return s.agent, nil
|
||||
}
|
||||
|
||||
func TestResolveKnowledgeBaseIDsFromAgent(t *testing.T) {
|
||||
svc := &embedChannelService{
|
||||
agentService: &stubAgentForEmbed{
|
||||
agent: &types.CustomAgent{
|
||||
Config: types.CustomAgentConfig{
|
||||
KBSelectionMode: "selected",
|
||||
KnowledgeBases: []string{"kb-a", "kb-b"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
ids := svc.resolveKnowledgeBaseIDs(context.Background(), &types.EmbedChannel{
|
||||
AgentID: "agent-1",
|
||||
})
|
||||
if len(ids) != 2 || ids[0] != "kb-a" || ids[1] != "kb-b" {
|
||||
t.Fatalf("unexpected kb ids: %#v", ids)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicConfigUsesAgentKBs(t *testing.T) {
|
||||
svc := &embedChannelService{
|
||||
agentService: &stubAgentForEmbed{
|
||||
agent: &types.CustomAgent{
|
||||
Config: types.CustomAgentConfig{
|
||||
KBSelectionMode: "selected",
|
||||
KnowledgeBases: []string{"kb-primary"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg := svc.PublicConfig(context.Background(), &types.EmbedChannel{
|
||||
ID: "ch-1",
|
||||
AgentID: "agent-1",
|
||||
Name: "Support",
|
||||
})
|
||||
if len(cfg.KnowledgeBaseIDs) != 1 || cfg.KnowledgeBaseIDs[0] != "kb-primary" {
|
||||
t.Fatalf("unexpected public config: %#v", cfg)
|
||||
}
|
||||
if cfg.AgentID != "agent-1" || cfg.ChannelID != "ch-1" {
|
||||
t.Fatalf("unexpected ids: %#v", cfg)
|
||||
}
|
||||
if cfg.DisplayTitle != "Support" {
|
||||
t.Fatalf("display_title = %q, want channel name", cfg.DisplayTitle)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicConfigDisplayTitlePrefersPageTitle(t *testing.T) {
|
||||
svc := &embedChannelService{
|
||||
agentService: &stubAgentForEmbed{
|
||||
agent: &types.CustomAgent{
|
||||
Name: "Agent Name",
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg := svc.PublicConfig(context.Background(), &types.EmbedChannel{
|
||||
ID: "ch-3",
|
||||
AgentID: "agent-3",
|
||||
Name: "Internal Channel",
|
||||
PageTitle: "Visitor Chat",
|
||||
})
|
||||
if cfg.DisplayTitle != "Visitor Chat" {
|
||||
t.Fatalf("display_title = %q, want page title", cfg.DisplayTitle)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicConfigIncludesCapabilityFlags(t *testing.T) {
|
||||
svc := &embedChannelService{
|
||||
agentService: &stubAgentForEmbed{
|
||||
agent: &types.CustomAgent{
|
||||
Config: types.CustomAgentConfig{
|
||||
KBSelectionMode: "all",
|
||||
WebSearchEnabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg := svc.PublicConfig(context.Background(), &types.EmbedChannel{
|
||||
ID: "ch-cap",
|
||||
AgentID: "agent-cap",
|
||||
AllowWebSearch: true,
|
||||
WidgetPosition: "top-left",
|
||||
})
|
||||
if !cfg.AllowWebSearch {
|
||||
t.Fatalf("allow_web_search = false, want true")
|
||||
}
|
||||
if !cfg.AgentWebSearchEnabled {
|
||||
t.Fatalf("agent_web_search_enabled = false, want true")
|
||||
}
|
||||
if cfg.WidgetPosition != "top-left" {
|
||||
t.Fatalf("widget_position = %q, want top-left", cfg.WidgetPosition)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicConfigDisplayTitleFallsBackToAgentName(t *testing.T) {
|
||||
svc := &embedChannelService{
|
||||
agentService: &stubAgentForEmbed{
|
||||
agent: &types.CustomAgent{
|
||||
Name: "客服助手",
|
||||
Config: types.CustomAgentConfig{
|
||||
KBSelectionMode: "all",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg := svc.PublicConfig(context.Background(), &types.EmbedChannel{
|
||||
ID: "ch-2",
|
||||
AgentID: "agent-2",
|
||||
})
|
||||
if cfg.DisplayTitle != "客服助手" {
|
||||
t.Fatalf("display_title = %q, want agent name", cfg.DisplayTitle)
|
||||
}
|
||||
if cfg.AgentName != "客服助手" {
|
||||
t.Fatalf("agent_name = %q", cfg.AgentName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user