@@ -2575,6 +2575,113 @@ def test_kick_off_seer_automation_without_scanner_on(
2575
2575
2576
2576
mock_start_seer_automation .assert_not_called ()
2577
2577
2578
+ @patch (
2579
+ "sentry.seer.seer_setup.get_seer_org_acknowledgement" ,
2580
+ return_value = True ,
2581
+ )
2582
+ @patch ("sentry.tasks.autofix.start_seer_automation.delay" )
2583
+ @with_feature ("organizations:gen-ai-features" )
2584
+ @with_feature ("organizations:trigger-autofix-on-issue-summary" )
2585
+ def test_kick_off_seer_automation_skips_existing_summary_and_score (
2586
+ self , mock_start_seer_automation , mock_get_seer_org_acknowledgement
2587
+ ):
2588
+ from sentry .seer .issue_summary import get_issue_summary_cache_key
2589
+
2590
+ self .project .update_option ("sentry:seer_scanner_automation" , True )
2591
+ event = self .create_event (
2592
+ data = {"message" : "testing" },
2593
+ project_id = self .project .id ,
2594
+ )
2595
+
2596
+ # Set seer_fixability_score on the group
2597
+ group = event .group
2598
+ group .seer_fixability_score = 0.75
2599
+ group .save ()
2600
+
2601
+ # Set cached issue summary
2602
+ cache_key = get_issue_summary_cache_key (group .id )
2603
+ cache .set (cache_key , {"summary" : "test summary" }, 3600 )
2604
+
2605
+ self .call_post_process_group (
2606
+ is_new = False , # Not a new group
2607
+ is_regression = False ,
2608
+ is_new_group_environment = False ,
2609
+ event = event ,
2610
+ )
2611
+
2612
+ mock_start_seer_automation .assert_not_called ()
2613
+
2614
+ @patch (
2615
+ "sentry.seer.seer_setup.get_seer_org_acknowledgement" ,
2616
+ return_value = True ,
2617
+ )
2618
+ @patch ("sentry.tasks.autofix.start_seer_automation.delay" )
2619
+ @with_feature ("organizations:gen-ai-features" )
2620
+ @with_feature ("organizations:trigger-autofix-on-issue-summary" )
2621
+ def test_kick_off_seer_automation_runs_with_missing_fixability_score (
2622
+ self , mock_start_seer_automation , mock_get_seer_org_acknowledgement
2623
+ ):
2624
+ from sentry .seer .issue_summary import get_issue_summary_cache_key
2625
+
2626
+ self .project .update_option ("sentry:seer_scanner_automation" , True )
2627
+ event = self .create_event (
2628
+ data = {"message" : "testing" },
2629
+ project_id = self .project .id ,
2630
+ )
2631
+
2632
+ # Group has no seer_fixability_score (None by default)
2633
+ group = event .group
2634
+ assert group .seer_fixability_score is None
2635
+
2636
+ # Set cached issue summary
2637
+ cache_key = get_issue_summary_cache_key (group .id )
2638
+ cache .set (cache_key , {"summary" : "test summary" }, 3600 )
2639
+
2640
+ self .call_post_process_group (
2641
+ is_new = False , # Not a new group
2642
+ is_regression = False ,
2643
+ is_new_group_environment = False ,
2644
+ event = event ,
2645
+ )
2646
+
2647
+ mock_start_seer_automation .assert_called_once_with (group .id )
2648
+
2649
+ @patch (
2650
+ "sentry.seer.seer_setup.get_seer_org_acknowledgement" ,
2651
+ return_value = True ,
2652
+ )
2653
+ @patch ("sentry.tasks.autofix.start_seer_automation.delay" )
2654
+ @with_feature ("organizations:gen-ai-features" )
2655
+ @with_feature ("organizations:trigger-autofix-on-issue-summary" )
2656
+ def test_kick_off_seer_automation_runs_with_missing_summary_cache (
2657
+ self , mock_start_seer_automation , mock_get_seer_org_acknowledgement
2658
+ ):
2659
+ from sentry .seer .issue_summary import get_issue_summary_cache_key
2660
+
2661
+ self .project .update_option ("sentry:seer_scanner_automation" , True )
2662
+ event = self .create_event (
2663
+ data = {"message" : "testing" },
2664
+ project_id = self .project .id ,
2665
+ )
2666
+
2667
+ # Set seer_fixability_score on the group
2668
+ group = event .group
2669
+ group .seer_fixability_score = 0.75
2670
+ group .save ()
2671
+
2672
+ # No cached issue summary (cache.get will return None)
2673
+ cache_key = get_issue_summary_cache_key (group .id )
2674
+ assert cache .get (cache_key ) is None
2675
+
2676
+ self .call_post_process_group (
2677
+ is_new = False , # Not a new group
2678
+ is_regression = False ,
2679
+ is_new_group_environment = False ,
2680
+ event = event ,
2681
+ )
2682
+
2683
+ mock_start_seer_automation .assert_called_once_with (group .id )
2684
+
2578
2685
2579
2686
class PostProcessGroupErrorTest (
2580
2687
TestCase ,
0 commit comments