Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit f6b2bb0

Browse files
committed
feat: add total_{fail, pass, skip}_count field to TestResult GQL model
1 parent e6b4d27 commit f6b2bb0

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed

graphql_api/tests/test_test_result.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,96 @@ def test_fetch_test_result_avg_duration(self) -> None:
227227
assert result["owner"]["repository"]["testAnalytics"]["testResults"]["edges"][
228228
0
229229
]["node"]["avgDuration"] == (5.6 / 3)
230+
231+
def test_fetch_test_result_total_fail_count(self) -> None:
232+
query = """
233+
query {
234+
owner(username: "%s") {
235+
repository(name: "%s") {
236+
... on Repository {
237+
testAnalytics {
238+
testResults {
239+
edges {
240+
node {
241+
totalFailCount
242+
}
243+
}
244+
}
245+
}
246+
}
247+
}
248+
}
249+
}
250+
""" % (self.owner.username, self.repository.name)
251+
252+
result = self.gql_request(query, owner=self.owner)
253+
254+
assert "errors" not in result
255+
assert (
256+
result["owner"]["repository"]["testAnalytics"]["testResults"]["edges"][0][
257+
"node"
258+
]["totalFailCount"]
259+
== 9
260+
)
261+
262+
def test_fetch_test_result_total_skip_count(self) -> None:
263+
query = """
264+
query {
265+
owner(username: "%s") {
266+
repository(name: "%s") {
267+
... on Repository {
268+
testAnalytics {
269+
testResults {
270+
edges {
271+
node {
272+
totalSkipCount
273+
}
274+
}
275+
}
276+
}
277+
}
278+
}
279+
}
280+
}
281+
""" % (self.owner.username, self.repository.name)
282+
283+
result = self.gql_request(query, owner=self.owner)
284+
285+
assert "errors" not in result
286+
assert (
287+
result["owner"]["repository"]["testAnalytics"]["testResults"]["edges"][0][
288+
"node"
289+
]["totalSkipCount"]
290+
== 6
291+
)
292+
293+
def test_fetch_test_result_total_pass_count(self) -> None:
294+
query = """
295+
query {
296+
owner(username: "%s") {
297+
repository(name: "%s") {
298+
... on Repository {
299+
testAnalytics {
300+
testResults {
301+
edges {
302+
node {
303+
totalPassCount
304+
}
305+
}
306+
}
307+
}
308+
}
309+
}
310+
}
311+
}
312+
""" % (self.owner.username, self.repository.name)
313+
314+
result = self.gql_request(query, owner=self.owner)
315+
316+
assert "errors" not in result
317+
assert (
318+
result["owner"]["repository"]["testAnalytics"]["testResults"]["edges"][0][
319+
"node"
320+
]["totalPassCount"]
321+
== 3
322+
)

graphql_api/types/test_results/test_results.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ type TestResult {
66
flakeRate: Float!
77
avgDuration: Float!
88
lastDuration: Float!
9+
totalFailCount: Int!
10+
totalSkipCount: Int!
11+
totalPassCount: Int!
912
}

graphql_api/types/test_results/test_results.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class TestDict(TypedDict):
1313
avg_duration: float
1414
last_duration: float
1515
flake_rate: float
16+
total_fail_count: int
17+
total_skip_count: int
18+
total_pass_count: int
1619

1720

1821
test_result_bindable = ObjectType("TestResult")
@@ -51,3 +54,18 @@ def resolve_avg_duration(test: TestDict, _: GraphQLResolveInfo) -> float:
5154
@test_result_bindable.field("lastDuration")
5255
def resolve_last_duration(test: TestDict, _: GraphQLResolveInfo) -> float:
5356
return test["last_duration"]
57+
58+
59+
@test_result_bindable.field("totalFailCount")
60+
def resolve_total_fail_count(test: TestDict, _: GraphQLResolveInfo) -> int:
61+
return test["total_fail_count"]
62+
63+
64+
@test_result_bindable.field("totalSkipCount")
65+
def resolve_total_skip_count(test: TestDict, _: GraphQLResolveInfo) -> int:
66+
return test["total_skip_count"]
67+
68+
69+
@test_result_bindable.field("totalPassCount")
70+
def resolve_total_pass_count(test: TestDict, _: GraphQLResolveInfo) -> int:
71+
return test["total_pass_count"]

utils/test_results.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def generate_test_results(
172172
total_flaky_fail_count=Cast(
173173
Sum(F("flaky_fail_count")), output_field=FloatField()
174174
),
175+
total_skip_count=Cast(Sum(F("skip_count")), output_field=FloatField()),
176+
total_pass_count=Cast(Sum(F("pass_count")), output_field=FloatField()),
175177
failure_rate=Case(
176178
When(
177179
total_test_count=0,

0 commit comments

Comments
 (0)