@@ -119,6 +119,28 @@ def test_branch_filter_on_test_results(self) -> None:
119119 )
120120 assert res ["testResults" ] == {"edges" : [{"node" : {"name" : test .name }}]}
121121
122+ def test_interval_filter_on_test_results (self ) -> None :
123+ repo = RepositoryFactory (author = self .owner , active = True , private = True )
124+ test = TestFactory (repository = repo )
125+ test2 = TestFactory (repository = repo )
126+ _ = DailyTestRollupFactory (
127+ test = test ,
128+ date = datetime .datetime .now () - datetime .timedelta (days = 7 ),
129+ repoid = repo .repoid ,
130+ branch = "main" ,
131+ )
132+ _ = DailyTestRollupFactory (
133+ test = test2 ,
134+ date = datetime .datetime .now (),
135+ repoid = repo .repoid ,
136+ branch = "feature" ,
137+ )
138+ res = self .fetch_test_analytics (
139+ repo .name ,
140+ """testResults(filters: { interval: INTERVAL_1_DAY }) { edges { node { name } } }""" ,
141+ )
142+ assert res ["testResults" ] == {"edges" : [{"node" : {"name" : test2 .name }}]}
143+
122144 def test_flaky_filter_on_test_results (self ) -> None :
123145 repo = RepositoryFactory (author = self .owner , active = True , private = True )
124146 test = TestFactory (repository = repo )
@@ -754,6 +776,43 @@ def test_test_results_aggregates_no_history(self) -> None:
754776 "totalSlowTestsPercentChange" : None ,
755777 }
756778
779+ def test_test_results_aggregates_no_history_7_days (self ) -> None :
780+ repo = RepositoryFactory (
781+ author = self .owner , active = True , private = True , branch = "main"
782+ )
783+
784+ for i in range (0 , 7 ):
785+ test = TestFactory (repository = repo )
786+ _ = DailyTestRollupFactory (
787+ test = test ,
788+ repoid = repo .repoid ,
789+ branch = "main" ,
790+ fail_count = 1 if i % 3 == 0 else 0 ,
791+ skip_count = 1 if i % 6 == 0 else 0 ,
792+ pass_count = 1 ,
793+ avg_duration_seconds = float (i ),
794+ last_duration_seconds = float (i ),
795+ date = datetime .date .today () - datetime .timedelta (days = i ),
796+ )
797+
798+ res = self .fetch_test_analytics (
799+ repo .name ,
800+ """testResultsAggregates(interval: INTERVAL_7_DAY) { totalDuration, slowestTestsDuration, totalFails, totalSkips, totalSlowTests, totalDurationPercentChange, slowestTestsDurationPercentChange, totalFailsPercentChange, totalSkipsPercentChange, totalSlowTestsPercentChange }""" ,
801+ )
802+
803+ assert res ["testResultsAggregates" ] == {
804+ "totalDuration" : 30.0 ,
805+ "totalDurationPercentChange" : None ,
806+ "slowestTestsDuration" : 12.0 ,
807+ "slowestTestsDurationPercentChange" : None ,
808+ "totalFails" : 3 ,
809+ "totalFailsPercentChange" : None ,
810+ "totalSkips" : 2 ,
811+ "totalSkipsPercentChange" : None ,
812+ "totalSlowTests" : 1 ,
813+ "totalSlowTestsPercentChange" : None ,
814+ }
815+
757816 def test_flake_aggregates (self ) -> None :
758817 repo = RepositoryFactory (
759818 author = self .owner , active = True , private = True , branch = "main"
0 commit comments