HH-606: cover soft-deleted inbox assistants (#162)

* test(HH-606): cover soft-deleted inbox assistants

* test(HH-606): bind soft-deleted inbox to persisted assistant

---------

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-24 14:00:17 +08:00
committed by GitHub
co-authored by rogee
parent 26eae1a0d7
commit 49559d6ce1
2 changed files with 966 additions and 957 deletions
@@ -555,6 +555,35 @@ func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenBoundAssist
assertUnavailable()
}
func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenCaptainInboxSoftDeleted() {
assistant := &model.CaptainAssistant{AccountID: s.testAccount.ID, Name: "Deleted Binding Helper", Config: json.RawMessage(`{}`), Status: model.AssistantStatusActive}
s.Require().NoError(s.db.Create(assistant).Error)
binding := &model.CaptainInbox{AccountID: s.testAccount.ID, AssistantID: assistant.ID, InboxID: s.testInbox.ID}
s.Require().NoError(s.db.Create(binding).Error)
s.Require().NoError(s.db.Delete(binding).Error)
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)
assert.JSONEq(s.T(), `{"assistant":null}`, w.Body.String())
}
func (s *ConversationCrudTestSuite) TestInboxAssistant_ReturnsNilWhenCaptainAssistantSoftDeleted() {
assistant := &model.CaptainAssistant{AccountID: s.testAccount.ID, Name: "Deleted Assistant", Config: json.RawMessage(`{}`), Status: model.AssistantStatusActive}
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)
s.Require().NoError(s.db.Delete(assistant).Error)
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)
assert.JSONEq(s.T(), `{"assistant":null}`, w.Body.String())
}
func (s *ConversationCrudTestSuite) TestInboxAssistant_UsesDisplayIDRoute() {
displayID := uint(77)
s.testConv.DisplayID = &displayID
File diff suppressed because it is too large Load Diff