HH-598: hide unavailable AI takeover (#155)
* fix(HH-598): hide unavailable AI takeover * fix: isolate inbox assistant availability --------- Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -533,6 +533,28 @@ func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenUnbound() {
|
||||
assert.Nil(s.T(), resp["assistant"])
|
||||
}
|
||||
|
||||
func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenBoundAssistantInactive() {
|
||||
assistant := &model.CaptainAssistant{AccountID: s.testAccount.ID, Name: "Inactive Helper", Config: json.RawMessage(`{}`), Status: model.AssistantStatusDraft}
|
||||
s.Require().NoError(s.db.Create(assistant).Error)
|
||||
s.Require().NoError(s.db.Create(&model.CaptainInbox{AccountID: s.testAccount.ID, AssistantID: assistant.ID, InboxID: s.testInbox.ID}).Error)
|
||||
|
||||
assertUnavailable := func() {
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("GET", s.convURL(s.testConv.ID)+"/inbox_assistant", nil)
|
||||
s.router.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
var resp map[string]interface{}
|
||||
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
|
||||
assert.Nil(s.T(), resp["assistant"])
|
||||
}
|
||||
|
||||
assertUnavailable()
|
||||
assistant.Status = model.AssistantStatusArchived
|
||||
s.Require().NoError(s.db.Save(assistant).Error)
|
||||
assertUnavailable()
|
||||
}
|
||||
|
||||
func (s *ConversationCrudTestSuite) TestInboxAssistant_UsesDisplayIDRoute() {
|
||||
displayID := uint(77)
|
||||
s.testConv.DisplayID = &displayID
|
||||
|
||||
Reference in New Issue
Block a user