fix: youtube macro gets some spacing aftert the player
This commit is contained in:
@@ -136,4 +136,51 @@ describe('GenerationRouteRendererFactory', () => {
|
||||
expect(dayTwoHtml).toContain('Post On Day Two');
|
||||
expect(dayTwoHtml).not.toContain('Post On Day One');
|
||||
});
|
||||
|
||||
it('includes youtube macro spacing styles in preview-backed generated html routes', async () => {
|
||||
const post = makePost({
|
||||
id: 'youtube-1',
|
||||
slug: 'youtube-spacing',
|
||||
title: 'YouTube Spacing',
|
||||
content: ['Intro paragraph.', '[[youtube id="dQw4w9WgXcQ"]]', 'Paragraph after video.'].join('\n\n'),
|
||||
createdAt: new Date('2025-01-15T10:00:00.000Z'),
|
||||
});
|
||||
|
||||
const postEngine = {
|
||||
getPostsFiltered: vi.fn(async () => [post]),
|
||||
getPublishedVersion: vi.fn(async () => null),
|
||||
findPublishedBySlug: vi.fn(async (slug: string) => (slug === post.slug ? post : null)),
|
||||
getPost: vi.fn(async (id: string) => (id === post.id ? post : null)),
|
||||
hasPublishedVersion: vi.fn(async () => false),
|
||||
setProjectContext: vi.fn(),
|
||||
};
|
||||
|
||||
const renderRoute = createPreviewBackedGenerationRouteRenderer({
|
||||
options: {
|
||||
projectId: 'project',
|
||||
dataDir: '/tmp',
|
||||
projectName: 'Project',
|
||||
},
|
||||
maxPostsPerPage: 50,
|
||||
publishedPostsForLookup: [post],
|
||||
engines: {
|
||||
postEngine,
|
||||
mediaEngine: {
|
||||
getAllMedia: vi.fn(async () => []),
|
||||
setProjectContext: vi.fn(),
|
||||
},
|
||||
postMediaEngine: {
|
||||
setProjectContext: vi.fn(),
|
||||
getLinkedMediaForPost: vi.fn(async () => []),
|
||||
getLinkedMediaDataForPost: vi.fn(async () => []),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const html = await renderRoute('/2025/01/15/youtube-spacing');
|
||||
|
||||
expect(html).toContain('class="macro-youtube"');
|
||||
expect(html).toContain('youtube.com/embed/dQw4w9WgXcQ?rel=0');
|
||||
expect(html).toContain('.macro-youtube, .macro-vimeo { margin-bottom: 1rem; }');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1570,6 +1570,37 @@ describe('PreviewServer', () => {
|
||||
expect(html).toContain('/media/2025/02/archive.jpg');
|
||||
});
|
||||
|
||||
it('adds paragraph-like spacing after youtube macro embeds in generated HTML', async () => {
|
||||
const post = makePost({
|
||||
id: 'macro-youtube-spacing-1',
|
||||
slug: 'macro-youtube-spacing',
|
||||
title: 'Macro YouTube Spacing',
|
||||
content: [
|
||||
'Intro paragraph before video.',
|
||||
'',
|
||||
'[[youtube id="dQw4w9WgXcQ"]]',
|
||||
'',
|
||||
'Paragraph after video.',
|
||||
].join('\n'),
|
||||
});
|
||||
|
||||
server = new PreviewServer({
|
||||
postEngine: makeEngine([post]),
|
||||
settingsEngine: makeSettings(50),
|
||||
getActiveProjectContext: async () => ({ projectId: 'default' }),
|
||||
});
|
||||
|
||||
await server.start(0);
|
||||
|
||||
const response = await fetch(`${server.getBaseUrl()}/`);
|
||||
expect(response.status).toBe(200);
|
||||
const html = await response.text();
|
||||
|
||||
expect(html).toContain('class="macro-youtube"');
|
||||
expect(html).toContain('youtube.com/embed/dQw4w9WgXcQ?rel=0');
|
||||
expect(html).toContain('.macro-youtube, .macro-vimeo { margin-bottom: 1rem; }');
|
||||
});
|
||||
|
||||
it('resolves gallery linked images via post-media links even when media.linkedPostIds is empty', async () => {
|
||||
const post = makePost({
|
||||
id: 'macro-junction-1',
|
||||
|
||||
Reference in New Issue
Block a user