Skip to content

Commit

Permalink
feat: Update useBundleAssets to fetch routes field (#3527)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov authored Dec 6, 2024
1 parent 354e880 commit e3294d3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AssetsTable, ChangeOverTime } from './AssetsTable'
const mockAssets = (hasNextPage = true) => {
const asset1 = {
name: 'asset-1',
routes: ['/'],
extension: 'js',
bundleData: {
loadTime: { threeG: 2000, highSpeed: 2000 },
Expand All @@ -32,6 +33,7 @@ const mockAssets = (hasNextPage = true) => {

const asset2 = {
name: 'asset-2',
routes: ['/about'],
extension: 'js',
bundleData: {
loadTime: { threeG: 2000, highSpeed: 2000 },
Expand All @@ -48,6 +50,7 @@ const mockAssets = (hasNextPage = true) => {

const asset3 = {
name: 'asset-3',
routes: ['/login'],
extension: 'js',
bundleData: {
loadTime: { threeG: 2000, highSpeed: 2000 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,22 @@ const mockedBundleAssets = {
{
node: {
name: 'asset-1',
routes: ['/'],
extension: 'js',
bundleData: {
loadTime: {
threeG: 1,
highSpeed: 2,
},
size: {
uncompress: 3,
gzip: 4,
},
loadTime: { threeG: 1, highSpeed: 2 },
size: { uncompress: 3, gzip: 4 },
},
measurements: {
change: {
size: {
uncompress: 5,
},
},
change: { size: { uncompress: 5 } },
measurements: [
{ timestamp: '2022-10-10T11:59:59', avg: 6 },
],
},
},
},
],
pageInfo: {
hasNextPage: false,
endCursor: null,
},
pageInfo: { hasNextPage: false, endCursor: null },
},
},
},
Expand Down Expand Up @@ -165,42 +153,21 @@ describe('useBundleAssetsTable', () => {
{
assets: [
{
name: 'asset-1',
routes: ['/'],
extension: 'js',
bundleData: {
loadTime: {
highSpeed: 2,
threeG: 1,
},
size: {
gzip: 4,
uncompress: 3,
},
loadTime: { highSpeed: 2, threeG: 1 },
size: { gzip: 4, uncompress: 3 },
},
extension: 'js',
measurements: {
change: {
size: {
uncompress: 5,
},
},
measurements: [
{
avg: 6,
timestamp: '2022-10-10T11:59:59',
},
],
change: { size: { uncompress: 5 } },
measurements: [{ avg: 6, timestamp: '2022-10-10T11:59:59' }],
},
name: 'asset-1',
},
],
bundleData: {
size: {
uncompress: 12,
},
},
pageInfo: {
endCursor: null,
hasNextPage: false,
},
bundleData: { size: { uncompress: 12 } },
pageInfo: { endCursor: null, hasNextPage: false },
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const mockAssets = {
{
node: {
name: 'asset-1',
routes: ['/'],
extension: 'js',
bundleData: {
loadTime: {
Expand Down
3 changes: 3 additions & 0 deletions src/services/bundleAnalysis/useBundleAssets.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useBundleAssets } from './useBundleAssets'

const node1 = {
name: 'asset-1',
routes: ['/'],
extension: 'js',
bundleData: {
loadTime: { threeG: 1, highSpeed: 2 },
Expand All @@ -25,6 +26,7 @@ const node1 = {

const node2 = {
name: 'asset-2',
routes: ['/login'],
extension: 'js',
bundleData: {
loadTime: { threeG: 1, highSpeed: 2 },
Expand All @@ -38,6 +40,7 @@ const node2 = {

const node3 = {
name: 'asset-3',
routes: ['/about'],
extension: 'js',
bundleData: {
loadTime: { threeG: 1, highSpeed: 2 },
Expand Down
2 changes: 2 additions & 0 deletions src/services/bundleAnalysis/useBundleAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const AssetMeasurementsSchema = z.object({

const BundleAssetSchema = z.object({
name: z.string(),
routes: z.array(z.string()).nullable(),
extension: z.string(),
bundleData: BundleDataSchema,
measurements: AssetMeasurementsSchema.nullable(),
Expand Down Expand Up @@ -151,6 +152,7 @@ query BundleAssets(
edges {
node {
name
routes
extension
bundleData {
loadTime {
Expand Down

0 comments on commit e3294d3

Please sign in to comment.