@@ -585,3 +585,93 @@ def test_push_status(client, test_job, test_user):
585585 assert resp .status_code == 200
586586 assert isinstance (resp .json (), dict )
587587 assert resp .json () == {"completed" : 0 , "pending" : 0 , "running" : 0 }
588+
589+
590+ def test_push_health_new_failures (client , test_repository , test_push , test_job ):
591+ """
592+ test retrieving the health_new_failures endpoint which filters by failure_classification_id=6
593+ """
594+ # Set the job to have failure_classification_id=6 (new failure not classified)
595+ new_failure_classification = FailureClassification .objects .get (
596+ name = "new failure not classified"
597+ )
598+ test_job .failure_classification = new_failure_classification
599+ test_job .result = "testfailed"
600+ test_job .save ()
601+
602+ resp = client .get (
603+ reverse ("push-health_new_failures" , kwargs = {"project" : test_repository .name }),
604+ {"revision" : test_push .revision },
605+ )
606+ assert resp .status_code == 200
607+ data = resp .json ()
608+
609+ # Verify response structure matches the health endpoint
610+ assert "revision" in data
611+ assert "id" in data
612+ assert "result" in data
613+ assert "jobs" in data
614+ assert "metrics" in data
615+ assert "status" in data
616+
617+ # Verify metrics structure
618+ assert "commitHistory" in data ["metrics" ]
619+ assert "linting" in data ["metrics" ]
620+ assert "tests" in data ["metrics" ]
621+ assert "builds" in data ["metrics" ]
622+
623+ # Verify commit history is returned for hg repos (test_repository is hg by default)
624+ assert data ["metrics" ]["commitHistory" ]["name" ] == "Commit History"
625+ assert data ["metrics" ]["commitHistory" ]["result" ] == "none"
626+ # commit history details should be populated for hg repos
627+ assert "details" in data ["metrics" ]["commitHistory" ]
628+
629+ # Verify the response contains the revision
630+ assert data ["revision" ] == test_push .revision
631+ assert data ["id" ] == test_push .id
632+
633+
634+ def test_push_health_new_failures_excludes_other_classifications (
635+ client , test_repository , test_push , test_job , test_job_2
636+ ):
637+ """
638+ test that health_new_failures only includes jobs with failure_classification_id=6
639+ """
640+ # Set one job to failure_classification_id=6
641+ new_failure_classification = FailureClassification .objects .get (
642+ name = "new failure not classified"
643+ )
644+ test_job .failure_classification = new_failure_classification
645+ test_job .result = "testfailed"
646+ test_job .save ()
647+
648+ # Set another job to a different failure_classification_id (e.g., intermittent = 4)
649+ intermittent_classification = FailureClassification .objects .get (name = "intermittent" )
650+ test_job_2 .failure_classification = intermittent_classification
651+ test_job_2 .result = "testfailed"
652+ test_job_2 .save ()
653+
654+ resp = client .get (
655+ reverse ("push-health_new_failures" , kwargs = {"project" : test_repository .name }),
656+ {"revision" : test_push .revision },
657+ )
658+ assert resp .status_code == 200
659+ data = resp .json ()
660+
661+ # The response should only include the job with failure_classification_id=6
662+ jobs_dict = data ["jobs" ]
663+
664+ # Verify we have job data
665+ assert isinstance (jobs_dict , dict )
666+
667+ # Collect all job IDs from the response
668+ all_job_ids = set ()
669+ for job_type_name , job_list in jobs_dict .items ():
670+ for job in job_list :
671+ all_job_ids .add (job ["id" ])
672+
673+ # Verify that only the job with classification_id=6 is included
674+ assert test_job .id in all_job_ids , "Job with classification_id=6 should be included"
675+ assert test_job_2 .id not in all_job_ids , (
676+ "Job with classification_id=4 (intermittent) should be excluded"
677+ )
0 commit comments