Defer artwork comments from initial render

This commit is contained in:
2026-08-29 12:07:08 +02:00
parent 8a80aae21e
commit 4ab315e9d7
8 changed files with 267 additions and 138 deletions
@@ -42,7 +42,7 @@ describe('ArtworkRecommendationsRails', () => {
vi.restoreAllMocks()
})
it('loads recommendation rails after mount', async () => {
it('loads normal trending rails after mount without owning Similar-AI loading', async () => {
render(
<ArtworkRecommendationsRails
artwork={{
@@ -51,6 +51,13 @@ describe('ArtworkRecommendationsRails', () => {
categories: [{ id: 5, name: 'Sci-Fi' }],
}}
related={[]}
trendingData={[{
id: 11,
title: 'Star map drift',
urls: { direct: '/art/11/star-map-drift' },
author: { name: 'Pilot' },
thumbnail_url: '/thumbs/11.webp',
}]}
/>,
)
@@ -58,7 +65,7 @@ describe('ArtworkRecommendationsRails', () => {
expect(screen.getByText('Trending in Sci-Fi')).not.toBeNull()
})
expect(global.fetch).toHaveBeenCalledWith('/api/art/69827/similar-ai', { credentials: 'same-origin' })
expect(global.fetch).toHaveBeenCalledWith('/api/rank/category/5?type=trending', { credentials: 'same-origin' })
expect(global.fetch).not.toHaveBeenCalledWith('/api/art/69827/similar-ai', { credentials: 'same-origin' })
expect(global.fetch).not.toHaveBeenCalled()
})
})
})