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
67 changes: 67 additions & 0 deletions graphql_api/tests/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3256,3 +3256,70 @@ def test_bundle_analysis_report_size_filtered_no_value(self, get_storage_service
"bundleDataFiltered": {"size": {"gzip": 20, "uncompress": 20}},
},
}

@patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
def test_bundle_analysis_asset_routes(self, get_storage_service):
storage = MemoryStorageService({})
get_storage_service.return_value = storage

head_commit_report = CommitReportFactory(
commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
)

with open(
"./services/tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
) as f:
storage_path = StoragePaths.bundle_report.path(
repo_key=ArchiveService.get_archive_hash(self.repo),
report_key=head_commit_report.external_id,
)
storage.write_file(get_bucket_name(), storage_path, f)

query = """
query FetchCommit($org: String!, $repo: String!, $commit: String!) {
owner(username: $org) {
repository(name: $repo) {
... on Repository {
commit(id: $commit) {
bundleAnalysis {
bundleAnalysisReport {
__typename
... on BundleAnalysisReport {
bundle(name: "b5") {
asset(name: "assets/LazyComponent-fcbb0922.js") {
name
normalizedName
routes
}
}
}
}
}
}
}
}
}
}
"""

variables = {
"org": self.org.username,
"repo": self.repo.name,
"commit": self.commit.commitid,
}
data = self.gql_request(query, variables=variables)
commit = data["owner"]["repository"]["commit"]

asset_report = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"][
"asset"
]

assert asset_report is not None
assert asset_report["name"] == "assets/LazyComponent-fcbb0922.js"
assert asset_report["normalizedName"] == "assets/LazyComponent-*.js"
assert asset_report["routes"] == [
"/",
"/about",
"/login",
"/super/long/url/path",
]
1 change: 1 addition & 0 deletions graphql_api/types/bundle_analysis/base.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type BundleAsset {
after: DateTime
branch: String
): BundleAnalysisMeasurements
routes: [String!]
}

type BundleReport {
Expand Down
7 changes: 7 additions & 0 deletions graphql_api/types/bundle_analysis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ def resolve_asset_report_measurements(
return bundle_analysis_measurements.compute_asset(bundle_asset)


@bundle_asset_bindable.field("routes")
def resolve_routes(
bundle_asset: AssetReport, info: GraphQLResolveInfo
) -> Optional[List[str]]:
return ["/", "/about", "/login", "/super/long/url/path"]


# ============= Bundle Report Bindable =============


Expand Down
Loading