Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions graphql_api/tests/test_test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,40 @@ def test_fetch_test_result_name(self) -> None:
0
]["node"]["name"] == self.test.name.replace("\x1f", " ")

def test_fetch_test_result_name_with_computed_name(self) -> None:
self.test.computed_name = "Computed Name"
self.test.save()

query = """
query {
owner(username: "%s") {
repository(name: "%s") {
... on Repository {
testAnalytics {
testResults {
edges {
node {
name
}
}
}
}
}
}
}
}
""" % (self.owner.username, self.repository.name)

result = self.gql_request(query, owner=self.owner)

assert "errors" not in result
assert (
result["owner"]["repository"]["testAnalytics"]["testResults"]["edges"][0][
"node"
]["name"]
== self.test.computed_name
)

def test_fetch_test_result_updated_at(self) -> None:
query = """
query {
Expand Down
3 changes: 2 additions & 1 deletion graphql_api/types/test_results/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ class TestDict(TypedDict):
total_fail_count: int
total_skip_count: int
total_pass_count: int
computed_name: str | None


test_result_bindable = ObjectType("TestResult")


@test_result_bindable.field("name")
def resolve_name(test: TestDict, _: GraphQLResolveInfo) -> str:
return test["name"].replace("\x1f", " ")
return test.get("computed_name") or test["name"].replace("\x1f", " ")


@test_result_bindable.field("updatedAt")
Expand Down
1 change: 1 addition & 0 deletions reports/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Meta:
name = factory.Sequence(lambda n: f"{n}")
repository = factory.SubFactory(RepositoryFactory)
commits_where_fail = []
computed_name = None


class TestInstanceFactory(factory.django.DjangoModelFactory):
Expand Down
1 change: 1 addition & 0 deletions utils/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def generate_test_results(
last_duration=Value(0.0),
avg_duration=Avg("avg_duration_seconds"),
name=F("test__name"),
computed_name=F("test__computed_name"),
)

return aggregation_of_test_results
Expand Down
Loading