import { prisma } from '@/lib/prisma' import { findBlockedVideoPreviewByUrl } from '@/lib/video-preview-access' jest.mock('@/lib/prisma', () => ({ prisma: { material: { findFirst: jest.fn() }, }, })) describe('video preview direct access wait period', () => { const now = new Date('2026-09-23T12:00:00.000Z') const previewUrl = 'https://example.com/live-preview.mp4' test('刚上传的直播切片直链不触发 15 天拦截,普通视频仍被拦截', async () => { const findFirst = prisma.material.findFirst as jest.Mock findFirst.mockResolvedValueOnce({ id: 'live-1', materialType: '直播切片', createdAt: new Date('2026-09-23T11:00:00.000Z'), }) expect(await findBlockedVideoPreviewByUrl([previewUrl], now)).toBeNull() findFirst.mockResolvedValueOnce({ id: 'video-1', materialType: '淘系-主图视频', createdAt: new Date('2026-09-23T11:00:00.000Z'), }) const blocked = await findBlockedVideoPreviewByUrl([previewUrl], now) expect(blocked?.material.id).toBe('video-1') expect(blocked?.availability.reason).toBe('VIDEO_WAIT_PERIOD') }) })