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", () => {
246
246
247
247
const category = await createCategory ( ) ;
248
248
249
- const { createProduct, updateProduct } = useProductManageHandler ( {
249
+ const { createProduct, updateProduct, getProduct } = useProductManageHandler ( {
250
250
...manageOpts
251
251
} ) ;
252
252
@@ -322,6 +322,24 @@ describe("richTextField", () => {
322
322
}
323
323
}
324
324
} ) ;
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
+ } ) ;
325
343
/**
326
344
* We now update the rich text field with some value.
327
345
*/
@@ -347,5 +365,22 @@ describe("richTextField", () => {
347
365
}
348
366
}
349
367
} ) ;
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
+ } ) ;
350
385
} ) ;
351
386
} ) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ export class GzipCompression extends CompressionPlugin {
23
23
}
24
24
25
25
public override async compress ( data : any ) : Promise < ICompressedValue > {
26
+ if ( data === null || data === undefined ) {
27
+ return data ;
28
+ }
26
29
// This stringifies both regular strings and JSON objects.
27
30
const value = await gzip ( JSON . stringify ( data ) ) ;
28
31
@@ -43,6 +46,11 @@ export class GzipCompression extends CompressionPlugin {
43
46
}
44
47
45
48
public override async decompress ( data : ICompressedValue ) : Promise < any > {
49
+ if ( ! data ) {
50
+ return data ;
51
+ } else if ( ! data . value ) {
52
+ return null ;
53
+ }
46
54
try {
47
55
const buf = await ungzip ( convertToBuffer ( data . value ) ) ;
48
56
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 {
17
17
}
18
18
19
19
public override async compress ( data : any ) : Promise < ICompressedValue > {
20
+ if ( data === null || data === undefined ) {
21
+ return data ;
22
+ }
20
23
const value = await compress ( data ) ;
21
24
22
25
return {
@@ -37,6 +40,11 @@ export class JsonpackCompression extends CompressionPlugin {
37
40
}
38
41
39
42
public override async decompress ( data : ICompressedValue ) : Promise < any > {
43
+ if ( ! data ) {
44
+ return data ;
45
+ } else if ( ! data . value ) {
46
+ return null ;
47
+ }
40
48
try {
41
49
return await decompress ( data . value ) ;
42
50
} catch ( ex ) {
You can’t perform that action at this time.
0 commit comments