fix: validate social preview metadata
This commit is contained in:
@@ -96,6 +96,30 @@ describe('safe metadata', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ name: 'audio', mediaType: 'audio/mpeg' as const, fileName: 'project-social-preview.mp3', width: null, height: null, durationMs: 1000 },
|
||||
{ name: 'video', mediaType: 'video/mp4' as const, fileName: 'project-social-preview.mp4', width: 1200, height: 630, durationMs: 1000 },
|
||||
{ name: 'vector image', mediaType: 'image/svg+xml' as const, fileName: 'project-social-preview.svg', width: 1200, height: 630, durationMs: null },
|
||||
{ name: 'wrong-size raster', mediaType: 'image/webp' as const, fileName: 'project-social-preview.webp', width: 1199, height: 630, durationMs: null },
|
||||
])('falls back to a summary card when the configured preview is $name', ({ mediaType, fileName, width, height, durationMs }) => {
|
||||
const unsafeManifest = structuredClone(manifest);
|
||||
const previewAsset = unsafeManifest.assets.find(({ id }) => id === content.metadata.socialPreviewAssetId)!;
|
||||
previewAsset.mediaType = mediaType;
|
||||
previewAsset.fileName = fileName;
|
||||
previewAsset.width = width;
|
||||
previewAsset.height = height;
|
||||
previewAsset.durationMs = durationMs;
|
||||
|
||||
const metadata = createPageMetadata(content, unsafeManifest, productionSite);
|
||||
|
||||
expect(metadata.openGraph).not.toHaveProperty('image');
|
||||
expect(metadata.twitter).toEqual({
|
||||
card: 'summary',
|
||||
title: 'Luca Pîslaru — System Administrator & Full-Stack Developer',
|
||||
description: content.metadata.description,
|
||||
});
|
||||
});
|
||||
|
||||
it('omits sameAs when no verified social profiles exist', () => {
|
||||
const withoutSocial = structuredClone(content);
|
||||
withoutSocial.contact.social = [];
|
||||
|
||||
Reference in New Issue
Block a user