File tree Expand file tree Collapse file tree 3 files changed +52
-1
lines changed
api-headless-cms/__tests__/contentAPI
utils/src/compression/plugins Expand file tree Collapse file tree 3 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ describe("richTextField", () => {
246246
247247 const category = await createCategory ( ) ;
248248
249- const { createProduct, updateProduct } = useProductManageHandler ( {
249+ const { createProduct, updateProduct, getProduct } = useProductManageHandler ( {
250250 ...manageOpts
251251 } ) ;
252252
@@ -322,6 +322,24 @@ describe("richTextField", () => {
322322 }
323323 }
324324 } ) ;
325+
326+ const product = createProductResponse . data . createProduct . data ;
327+
328+ const [ getAfterCreateResult ] = await getProduct ( {
329+ revision : product . id
330+ } ) ;
331+
332+ expect ( getAfterCreateResult ) . toMatchObject ( {
333+ data : {
334+ getProduct : {
335+ data : {
336+ id : product . id ,
337+ ...productData
338+ } ,
339+ error : null
340+ }
341+ }
342+ } ) ;
325343 /**
326344 * We now update the rich text field with some value.
327345 */
@@ -347,5 +365,22 @@ describe("richTextField", () => {
347365 }
348366 }
349367 } ) ;
368+
369+ const [ getAfterUpdateResult ] = await getProduct ( {
370+ revision : product . id
371+ } ) ;
372+
373+ expect ( getAfterUpdateResult ) . toMatchObject ( {
374+ data : {
375+ getProduct : {
376+ data : {
377+ id : product . id ,
378+ ...productData ,
379+ richText : richTextMock
380+ } ,
381+ error : null
382+ }
383+ }
384+ } ) ;
350385 } ) ;
351386} ) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ export class GzipCompression extends CompressionPlugin {
2323 }
2424
2525 public override async compress ( data : any ) : Promise < ICompressedValue > {
26+ if ( data === null || data === undefined ) {
27+ return data ;
28+ }
2629 // This stringifies both regular strings and JSON objects.
2730 const value = await gzip ( JSON . stringify ( data ) ) ;
2831
@@ -43,6 +46,11 @@ export class GzipCompression extends CompressionPlugin {
4346 }
4447
4548 public override async decompress ( data : ICompressedValue ) : Promise < any > {
49+ if ( ! data ) {
50+ return data ;
51+ } else if ( ! data . value ) {
52+ return null ;
53+ }
4654 try {
4755 const buf = await ungzip ( convertToBuffer ( data . value ) ) ;
4856 const value = buf . toString ( FROM_STORAGE_ENCODING ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ export class JsonpackCompression extends CompressionPlugin {
1717 }
1818
1919 public override async compress ( data : any ) : Promise < ICompressedValue > {
20+ if ( data === null || data === undefined ) {
21+ return data ;
22+ }
2023 const value = await compress ( data ) ;
2124
2225 return {
@@ -37,6 +40,11 @@ export class JsonpackCompression extends CompressionPlugin {
3740 }
3841
3942 public override async decompress ( data : ICompressedValue ) : Promise < any > {
43+ if ( ! data ) {
44+ return data ;
45+ } else if ( ! data . value ) {
46+ return null ;
47+ }
4048 try {
4149 return await decompress ( data . value ) ;
4250 } catch ( ex ) {
You can’t perform that action at this time.
0 commit comments