test(studio): create connector bindings with a kind

A binding needs a kind now, so the route specs name the platform, and
the spec for an offline binding checks that nothing is kept while no
add-on serves the kind.

Assisted-by: Claude:claude-sonnet-5-5 go test
This commit is contained in:
Ettore Di Giacinto committed 2026-11-03 17:05:24 +00:00
1 parent afb06fd42f
commit f60e464fb3
3 files changed
+7 -11

No files matched your search

@@ -119,7 +119,7 @@ var _ = Describe("connector owner routing", func() {
Expect(kinds).To(BeEmpty())
})
It("persists an offline Telegram connector with the real transport when add-ons are disabled", func() {
It("refuses a connector with the real transport when add-ons are disabled, and keeps nothing", func() {
ctx := context.Background()
app := &Application{applicationConfig: &config.ApplicationConfig{}}
Expect(app.startAddons()).To(Succeed())
@@ -139,17 +139,13 @@ var _ = Describe("connector owner routing", func() {
DeferCleanup(client.Close)
ag, err := svc.SaveAgent(ctx, studio.AnonymousPrincipal, agents.Agent{Name: "Offline", Model: "fake"})
Expect(err).NotTo(HaveOccurred())
created, err := client.CreateConnector(ctx, studio.AnonymousPrincipal, studio.ConnectorInput{Kind: "telegram", Name: "Telegram", AgentID: ag.ID, Token: "offline-secret", AcceptAny: true})
Expect(err).NotTo(HaveOccurred())
Expect(created.Active).To(BeFalse())
_, err = client.CreateConnector(ctx, studio.AnonymousPrincipal, studio.ConnectorInput{Kind: "telegram", Name: "Telegram", AgentID: ag.ID, Token: "offline-secret", AcceptAny: true})
Expect(err).To(MatchError(connectors.ErrInvalid))
reopened, err := connectors.NewJSON(dir)
Expect(err).NotTo(HaveOccurred())
persisted, err := reopened.GetBinding(ctx, created.ID)
left, err := reopened.ListBindings(ctx, studio.AnonymousPrincipal)
Expect(err).NotTo(HaveOccurred())
Expect(persisted.Kind).To(Equal("telegram"))
Expect(persisted.AddonID).To(Equal("telegram"))
Expect(persisted.AgentID).To(Equal(ag.ID))
Expect(persisted.Token).NotTo(BeEmpty())
Expect(left).To(BeEmpty())
})
It("keeps configured missing gateways and unreachable nonowners unavailable", func() {
+1 -1
View File
@@ -27,7 +27,7 @@ var _ = Describe("Chats administrator view", func() {
"schedule": "daily 07:30", "time_zone": "UTC", "enabled": true, "model": "test-model"})
Expect(rec.Code).To(Equal(http.StatusCreated), rec.Body.String())
trigID = decodeJSON(rec)["id"].(string)
rec = s.do("alice", http.MethodPost, "/api/chats/connectors", map[string]any{"name": "Bot", "token": specToken, "agent_id": agentID, "enabled": false})
rec = s.do("alice", http.MethodPost, "/api/chats/connectors", map[string]any{"kind": "telegram", "name": "Bot", "token": specToken, "agent_id": agentID, "enabled": false})
Expect(rec.Code).To(Equal(http.StatusCreated), rec.Body.String())
conID = decodeJSON(rec)["id"].(string)
})
+1 -1
View File
@@ -33,7 +33,7 @@ var _ = Describe("Chats connectors: accepting any sender needs a server-checked
Expect(rec.Code).To(Equal(http.StatusCreated))
ag := decodeJSON(rec)["id"].(string)
body := func(extra map[string]any) map[string]any {
m := map[string]any{"name": "Bot", "token": specToken, "agent_id": ag, "enabled": true, "accept_any": true}
m := map[string]any{"kind": "telegram", "name": "Bot", "token": specToken, "agent_id": ag, "enabled": true, "accept_any": true}
for k, v := range extra {
m[k] = v
}