package automation import ( "testing" "time" "github.com/gochat/gochat/internal/model" "github.com/stretchr/testify/require" ) // Template variable resolver tests func TestResolveConversationAttr_Cov2(t *testing.T) { ctx := TemplateContext{Conversation: &model.Conversation{Status: "open"}} _ = resolveConversationAttr("status", ctx) _ = resolveConversationAttr("nonexistent", ctx) } func TestResolveConversationAttr_Nil_Cov2(t *testing.T) { ctx := TemplateContext{} _ = resolveConversationAttr("status", ctx) } func TestResolveAgentAttr_Cov2(t *testing.T) { ctx := TemplateContext{Assignee: &model.User{Name: "Agent", Email: "agent@test.com"}} _ = resolveAgentAttr("name", ctx) _ = resolveAgentAttr("email", ctx) _ = resolveAgentAttr("nonexistent", ctx) } func TestResolveAgentAttr_Nil_Cov2(t *testing.T) { ctx := TemplateContext{} _ = resolveAgentAttr("name", ctx) } func TestResolveInboxAttr_Cov2(t *testing.T) { ctx := TemplateContext{Inbox: &model.Inbox{Name: "Inbox1"}} _ = resolveInboxAttr("name", ctx) _ = resolveInboxAttr("nonexistent", ctx) } func TestResolveInboxAttr_Nil_Cov2(t *testing.T) { ctx := TemplateContext{} _ = resolveInboxAttr("name", ctx) } func TestResolveTeamAttr_Cov2(t *testing.T) { ctx := TemplateContext{Team: &model.Team{Name: "Team1"}} _ = resolveTeamAttr("name", ctx) _ = resolveTeamAttr("nonexistent", ctx) } func TestResolveTeamAttr_Nil_Cov2(t *testing.T) { ctx := TemplateContext{} _ = resolveTeamAttr("name", ctx) } func TestResolveAccountAttr_Cov2(t *testing.T) { ctx := TemplateContext{Account: &model.Account{Name: "Account1"}} _ = resolveAccountAttr("name", ctx) _ = resolveAccountAttr("nonexistent", ctx) } func TestResolveAccountAttr_Nil_Cov2(t *testing.T) { ctx := TemplateContext{} _ = resolveAccountAttr("name", ctx) } // CSAT pure function tests func TestExtractCsatSubmittedValues_Rating_Cov2(t *testing.T) { values := []map[string]any{{"rating": 5, "feedback_message": "great"}} rating, feedback, ok := ExtractCsatSubmittedValues(values) require.True(t, ok) require.Equal(t, 5, rating) require.Equal(t, "great", feedback) } func TestExtractCsatSubmittedValues_CsatResponse_Cov2(t *testing.T) { values := []map[string]any{{"csat_survey_response": map[string]any{"rating": 4, "feedback_message": "good"}}} rating, feedback, ok := ExtractCsatSubmittedValues(values) _ = rating _ = feedback _ = ok } func TestExtractCsatSubmittedValues_Empty_Cov2(t *testing.T) { _, _, ok := ExtractCsatSubmittedValues(nil) require.False(t, ok) } func TestExtractCsatSubmittedValues_NoRating_Cov2(t *testing.T) { values := []map[string]any{{"other": "value"}} _, _, ok := ExtractCsatSubmittedValues(values) require.False(t, ok) } func TestSubmittedValueMaps_Slice_Cov2(t *testing.T) { result := submittedValueMaps([]map[string]any{{"key": "value"}}) require.Len(t, result, 1) } func TestSubmittedValueMaps_Map_Cov2(t *testing.T) { result := submittedValueMaps(map[string]any{"key": "value"}) _ = result } func TestSubmittedValueMaps_Nil_Cov2(t *testing.T) { result := submittedValueMaps(nil) _ = result } func TestCsatAllowedBySurveyRules_NoConfig_Cov2(t *testing.T) { require.True(t, csatAllowedBySurveyRules("", "")) } func TestCsatAllowedBySurveyRules_EmptyRules_Cov2(t *testing.T) { require.True(t, csatAllowedBySurveyRules(`{}`, "")) } func TestCsatAllowedBySurveyRules_WithRules_Cov2(t *testing.T) { config := `{"survey_rules":{"values":["support"],"operator":"equal"}}` _ = csatAllowedBySurveyRules(config, "support") _ = csatAllowedBySurveyRules(config, "billing") } func TestCsatMessagingWindow_Cov2(t *testing.T) { inbox := &model.Inbox{} d := csatMessagingWindow(inbox) _ = d } // Action delivery env tests func TestActionEnvInt_Cov2(t *testing.T) { _ = actionEnvInt("NONEXISTENT_VAR", 42) } // Test time import var _ = time.Now