@contrail/flexplm 1.7.1-alpha.261418a → 1.7.1-alpha.78479d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/util/thumbnail-util.spec.js +1 -120
- package/package.json +1 -1
|
@@ -319,7 +319,7 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
319
319
|
tinyViewableUrl: null,
|
|
320
320
|
};
|
|
321
321
|
mockContentCreate.mockResolvedValue(createdContent);
|
|
322
|
-
const event = { data: { [thumbnail_util_1.ThumbnailUtil.
|
|
322
|
+
const event = { data: { [thumbnail_util_1.ThumbnailUtil.THUMBNAIL]: '/rest/thumbnail/thumb.png' } };
|
|
323
323
|
await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
|
|
324
324
|
expect(mockGetRequest).toHaveBeenCalledWith({ urlPath: '/rest/thumbnail/thumb.png', includeUrlContext: false, returnFullResponse: true });
|
|
325
325
|
expect(mockContentCreate).toHaveBeenCalledWith(expect.objectContaining({
|
|
@@ -437,123 +437,4 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
437
437
|
expect(mockEntitiesDelete).not.toHaveBeenCalled();
|
|
438
438
|
});
|
|
439
439
|
});
|
|
440
|
-
describe('ThumbnailUtil - iteratedThumbnailId (THUMBNAIL key)', () => {
|
|
441
|
-
const config = {};
|
|
442
|
-
let tu;
|
|
443
|
-
beforeEach(() => {
|
|
444
|
-
jest.clearAllMocks();
|
|
445
|
-
tu = new thumbnail_util_1.ThumbnailUtil(config);
|
|
446
|
-
mockEntitiesGet.mockImplementation((opts) => {
|
|
447
|
-
if (opts.entityName === 'content-custom-size')
|
|
448
|
-
return Promise.resolve([]);
|
|
449
|
-
return Promise.resolve({});
|
|
450
|
-
});
|
|
451
|
-
mockEntitiesUpdate.mockImplementation((opts) => Promise.resolve({ id: opts.id }));
|
|
452
|
-
mockEntitiesDelete.mockImplementation((opts) => Promise.resolve({ id: opts.id }));
|
|
453
|
-
});
|
|
454
|
-
it('does not break when THUMBNAIL value is not available in the event', async () => {
|
|
455
|
-
// No THUMBNAIL key (and no other thumbnail keys) -> iteratedThumbnailId is undefined
|
|
456
|
-
const event = { data: {} };
|
|
457
|
-
let result;
|
|
458
|
-
await expect((async () => {
|
|
459
|
-
result = await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
|
|
460
|
-
})()).resolves.not.toThrow();
|
|
461
|
-
// Falls through to the "no thumbnail URL" early return
|
|
462
|
-
expect(result).toBeUndefined();
|
|
463
|
-
expect(mockContentCreate).not.toHaveBeenCalled();
|
|
464
|
-
expect(mockEntitiesUpdate).not.toHaveBeenCalled();
|
|
465
|
-
expect(mockEntitiesDelete).not.toHaveBeenCalled();
|
|
466
|
-
});
|
|
467
|
-
it('does not break when THUMBNAIL key is present but explicitly empty/falsy', async () => {
|
|
468
|
-
// THUMBNAIL present but falsy -> iteratedThumbnailId is falsy, no crash
|
|
469
|
-
const event = { data: { [thumbnail_util_1.ThumbnailUtil.THUMBNAIL]: '' } };
|
|
470
|
-
let result;
|
|
471
|
-
await expect((async () => {
|
|
472
|
-
result = await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'item' });
|
|
473
|
-
})()).resolves.not.toThrow();
|
|
474
|
-
expect(result).toBeUndefined();
|
|
475
|
-
expect(mockContentCreate).not.toHaveBeenCalled();
|
|
476
|
-
expect(mockEntitiesUpdate).not.toHaveBeenCalled();
|
|
477
|
-
expect(mockEntitiesDelete).not.toHaveBeenCalled();
|
|
478
|
-
});
|
|
479
|
-
it('syncs using iteratedThumbnailId when a THUMBNAIL value is available (no existing primaryViewable)', async () => {
|
|
480
|
-
const mockResponse = {
|
|
481
|
-
arrayBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(8)),
|
|
482
|
-
headers: { get: jest.fn().mockReturnValue('image/png') },
|
|
483
|
-
};
|
|
484
|
-
mockGetRequest.mockResolvedValue(mockResponse);
|
|
485
|
-
const createdContent = {
|
|
486
|
-
id: 'iteratedContent1',
|
|
487
|
-
contentType: 'image/png',
|
|
488
|
-
fileName: 'iterated.png',
|
|
489
|
-
primaryFileUrl: 'https://files/primary.png',
|
|
490
|
-
largeViewableUrl: 'https://files/large.png',
|
|
491
|
-
mediumLargeViewableUrl: null,
|
|
492
|
-
mediumViewableUrl: null,
|
|
493
|
-
smallViewableUrl: null,
|
|
494
|
-
tinyViewableUrl: null,
|
|
495
|
-
};
|
|
496
|
-
mockContentCreate.mockResolvedValue(createdContent);
|
|
497
|
-
const thumbnailUrl = '/rest/thumbnail/iterated.png';
|
|
498
|
-
const event = { data: { [thumbnail_util_1.ThumbnailUtil.THUMBNAIL]: thumbnailUrl } };
|
|
499
|
-
await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
|
|
500
|
-
// Uses the THUMBNAIL value to fetch + create the content
|
|
501
|
-
expect(mockGetRequest).toHaveBeenCalledWith({
|
|
502
|
-
urlPath: thumbnailUrl,
|
|
503
|
-
includeUrlContext: false,
|
|
504
|
-
returnFullResponse: true,
|
|
505
|
-
});
|
|
506
|
-
expect(mockContentCreate).toHaveBeenCalledWith(expect.objectContaining({
|
|
507
|
-
fileName: 'iterated.png',
|
|
508
|
-
contentType: 'image/png',
|
|
509
|
-
contentHolderReference: 'color:entity1',
|
|
510
|
-
}));
|
|
511
|
-
// Stamps the content with the THUMBNAIL url
|
|
512
|
-
expect(mockEntitiesUpdate).toHaveBeenCalledWith(expect.objectContaining({
|
|
513
|
-
entityName: 'content',
|
|
514
|
-
id: 'iteratedContent1',
|
|
515
|
-
object: { flexplmThumbnailUrl: thumbnailUrl },
|
|
516
|
-
}));
|
|
517
|
-
// Updates the main entity
|
|
518
|
-
expect(mockEntitiesUpdate).toHaveBeenCalledWith(expect.objectContaining({ entityName: 'color', id: 'entity1' }));
|
|
519
|
-
});
|
|
520
|
-
it('iteratedThumbnailId (THUMBNAIL) takes precedence over NEW/EXISTING thumbnail ids', async () => {
|
|
521
|
-
const mockResponse = {
|
|
522
|
-
arrayBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(8)),
|
|
523
|
-
headers: { get: jest.fn().mockReturnValue('image/png') },
|
|
524
|
-
};
|
|
525
|
-
mockGetRequest.mockResolvedValue(mockResponse);
|
|
526
|
-
mockContentCreate.mockResolvedValue({
|
|
527
|
-
id: 'iteratedContent2',
|
|
528
|
-
contentType: 'image/png',
|
|
529
|
-
fileName: 'iterated.png',
|
|
530
|
-
primaryFileUrl: 'https://files/primary.png',
|
|
531
|
-
largeViewableUrl: null,
|
|
532
|
-
mediumLargeViewableUrl: null,
|
|
533
|
-
mediumViewableUrl: null,
|
|
534
|
-
smallViewableUrl: null,
|
|
535
|
-
tinyViewableUrl: null,
|
|
536
|
-
});
|
|
537
|
-
const iteratedUrl = '/rest/thumbnail/iterated.png';
|
|
538
|
-
const event = {
|
|
539
|
-
data: {
|
|
540
|
-
[thumbnail_util_1.ThumbnailUtil.THUMBNAIL]: iteratedUrl,
|
|
541
|
-
[thumbnail_util_1.ThumbnailUtil.NEW_THUMBNAIL_ID]: '/rest/thumbnail/new.png',
|
|
542
|
-
[thumbnail_util_1.ThumbnailUtil.EXISTING_THUMBNAIL_ID]: '/rest/thumbnail/existing.png',
|
|
543
|
-
},
|
|
544
|
-
};
|
|
545
|
-
await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
|
|
546
|
-
// The THUMBNAIL value wins over NEW/EXISTING
|
|
547
|
-
expect(mockGetRequest).toHaveBeenCalledWith({
|
|
548
|
-
urlPath: iteratedUrl,
|
|
549
|
-
includeUrlContext: false,
|
|
550
|
-
returnFullResponse: true,
|
|
551
|
-
});
|
|
552
|
-
expect(mockEntitiesUpdate).toHaveBeenCalledWith(expect.objectContaining({
|
|
553
|
-
entityName: 'content',
|
|
554
|
-
id: 'iteratedContent2',
|
|
555
|
-
object: { flexplmThumbnailUrl: iteratedUrl },
|
|
556
|
-
}));
|
|
557
|
-
});
|
|
558
|
-
});
|
|
559
440
|
});
|