@@ -51,7 +51,7 @@ function request() {
5151 return createMockRequest ( 'GET' , undefined , { } , `http://localhost:3000/api/files/export/${ DOC_ID } ` )
5252}
5353
54- function assetRecord ( id : string , size : number ) {
54+ function assetRecord ( id : string , size : number | null ) {
5555 return {
5656 id,
5757 key : `workspace/ws-1/${ id } ` ,
@@ -161,6 +161,21 @@ describe('markdown export bundling', () => {
161161 expect ( zip . file ( 'assets/bad.png' ) ) . toBeNull ( )
162162 } )
163163
164+ it ( 'drops an asset with missing canonical size metadata' , async ( ) => {
165+ embeds ( 'good' , 'missing-size' )
166+ assetsResolveTo ( ( id ) => assetRecord ( id , id === 'missing-size' ? null : 1 * MB ) )
167+
168+ const response = await GET ( request ( ) , context )
169+
170+ expect ( response . status ) . toBe ( 200 )
171+ const zip = await JSZip . loadAsync ( Buffer . from ( await response . arrayBuffer ( ) ) )
172+ expect ( zip . file ( 'assets/good.png' ) ) . not . toBeNull ( )
173+ expect ( zip . file ( 'assets/missing-size.png' ) ) . toBeNull ( )
174+ expect (
175+ mockDownloadFile . mock . calls . some ( ( [ options ] ) => options . key . endsWith ( 'missing-size' ) )
176+ ) . toBe ( false )
177+ } )
178+
164179 /**
165180 * The two id representations have to stay distinct: metadata resolves by the stored id, while the
166181 * rewrite finds the embed by the spelling the document used. Collapsing them either drops the
0 commit comments