mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 13:08:42 +00:00
* feat(agent): support AI embedding, autofill, and read_asset for 3D assets * feat(agent): support 3D degree comments, markup annotations, and config3d in read_asset * fix(agent): resolve 3D session annotations to turntable degree frame time
1247 lines
40 KiB
TypeScript
1247 lines
40 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
import { createReadAssetTool, type ReadAssetAuthContext } from './read-asset'
|
|
import {
|
|
prisma,
|
|
WorkflowTaskType,
|
|
WorkflowTaskStatus,
|
|
type Asset,
|
|
type WorkflowTask,
|
|
} from '@shumai/db'
|
|
import { s3Service } from '@shumai/core/src/s3/s3'
|
|
import { workflowService } from '@shumai/workflow-core'
|
|
import { authzService } from '@shumai/core/src/authz/authz'
|
|
import * as annotationResolver from './annotation-resolver'
|
|
import { degreeToSecond } from '@shumai/core/src/utils/model3d'
|
|
|
|
vi.mock('@shumai/db', async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import('@shumai/db')>()
|
|
return {
|
|
...actual,
|
|
prisma: {
|
|
asset: {
|
|
findUnique: vi.fn(),
|
|
findFirst: vi.fn(),
|
|
},
|
|
workflowTask: {
|
|
create: vi.fn(),
|
|
},
|
|
},
|
|
}
|
|
})
|
|
|
|
vi.mock('@shumai/core/src/s3/s3', () => ({
|
|
s3Service: {
|
|
getObject: vi.fn(),
|
|
presign: vi.fn().mockResolvedValue('https://mock-presigned-url.com'),
|
|
},
|
|
}))
|
|
|
|
vi.mock('@shumai/workflow-core', () => ({
|
|
workflowService: {
|
|
executeWait: vi.fn(),
|
|
},
|
|
}))
|
|
|
|
vi.mock('@shumai/core/src/authz/authz', () => ({
|
|
authzService: {
|
|
hasPermission: vi.fn(),
|
|
},
|
|
Permission: { Read: 'Read' },
|
|
ResourceType: { Asset: 'asset' },
|
|
}))
|
|
|
|
describe('readAssetTool', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
vi.spyOn(annotationResolver, 'resolveAnnotationsById').mockResolvedValue({
|
|
annotations: null,
|
|
timestamp: null,
|
|
})
|
|
})
|
|
|
|
it('should throw authorization error if user ID is empty', async () => {
|
|
const tool = createReadAssetTool('')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'asset-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('User ID is required for authorization.')
|
|
})
|
|
|
|
it('should throw error if asset not found', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue(null)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'asset-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Asset with ID asset-1 not found.')
|
|
})
|
|
|
|
describe('Image Assets', () => {
|
|
it('should read image and return ImageContent and S3 key', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'img-1',
|
|
name: 'photo.png',
|
|
mediaType: 'image/png',
|
|
storageKey: { key: 'raw/photo.png' },
|
|
media: {
|
|
proxyType: 'image',
|
|
imageTranscodes: [{ key: 'proxy/photo.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('fake-image-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'img-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user-1' },
|
|
permission: 'Read',
|
|
type: 'asset',
|
|
id: 'img-1',
|
|
})
|
|
expect(s3Service.getObject).toHaveBeenCalledWith('shumai', 'proxy/photo.webp')
|
|
|
|
const textItem = result.content[0] as { type: 'text'; text: string }
|
|
const imageItem = result.content[1] as { type: 'image'; data: string; mimeType: string }
|
|
|
|
expect(textItem.text).toContain('proxy/photo.webp')
|
|
expect(imageItem.type).toBe('image')
|
|
expect(imageItem.data).toBe(Buffer.from('fake-image-bytes').toString('base64'))
|
|
expect(result.details.key).toBe('proxy/photo.webp')
|
|
})
|
|
|
|
it('should trigger image annotation transcode workflow when annotationId is provided', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'img-1',
|
|
name: 'photo.png',
|
|
mediaType: 'image/png',
|
|
projectId: 'project-1',
|
|
storageKey: { key: 'raw/photo.png' },
|
|
media: {
|
|
proxyType: 'image',
|
|
imageTranscodes: [{ key: 'proxy/photo.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.spyOn(annotationResolver, 'resolveAnnotationsById').mockResolvedValue({
|
|
annotations: [
|
|
{
|
|
type: 'arrow',
|
|
color: '#ff0000',
|
|
points: [
|
|
[0, 0],
|
|
[10, 10],
|
|
],
|
|
},
|
|
],
|
|
timestamp: null,
|
|
})
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-anno',
|
|
} as unknown as WorkflowTask)
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-anno',
|
|
output: { key: 'annotated/photo.webp' },
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('annotated-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'img-1',
|
|
annotationId: 'comment-1',
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(prisma.workflowTask.create).toHaveBeenCalledWith({
|
|
data: {
|
|
assetId: 'img-1',
|
|
projectId: 'project-1',
|
|
type: WorkflowTaskType.transcode_image_annotation,
|
|
status: WorkflowTaskStatus.pending,
|
|
payload: {
|
|
projectId: 'project-1',
|
|
imageAnnotation: {
|
|
annotations: [
|
|
{
|
|
type: 'arrow',
|
|
color: '#ff0000',
|
|
points: [
|
|
[0, 0],
|
|
[10, 10],
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
expect(s3Service.getObject).toHaveBeenCalledWith('shumai', 'annotated/photo.webp')
|
|
expect(result.details.key).toBe('annotated/photo.webp')
|
|
})
|
|
})
|
|
|
|
describe('3D Assets', () => {
|
|
it('should read 3D asset 4-views image and return image with quadrant layout description', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
storageKey: { key: 'raw/robot.glb' },
|
|
media: {
|
|
proxyType: '3d',
|
|
imageTranscodes: [{ key: 'proxy/views.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('fake-views-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-3d', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user-1' },
|
|
permission: 'Read',
|
|
type: 'asset',
|
|
id: 'model-1',
|
|
})
|
|
expect(s3Service.getObject).toHaveBeenCalledWith('shumai', 'proxy/views.webp')
|
|
|
|
const textItem = result.content[0] as { type: 'text'; text: string }
|
|
const imageItem = result.content[1] as { type: 'image'; data: string; mimeType: string }
|
|
|
|
expect(textItem.text).toContain('Orthogonal 4-view composite image')
|
|
expect(textItem.text).toContain('Top-Left quadrant: Front view (0°)')
|
|
expect(textItem.text).toContain('Top-Right quadrant: Right side view (90°)')
|
|
expect(textItem.text).toContain('Bottom-Left quadrant: Back view (180°)')
|
|
expect(textItem.text).toContain('Bottom-Right quadrant: Left side view (270°)')
|
|
expect(imageItem.type).toBe('image')
|
|
expect(imageItem.data).toBe(Buffer.from('fake-views-bytes').toString('base64'))
|
|
expect(result.details.key).toBe('proxy/views.webp')
|
|
})
|
|
|
|
it('should support s3KeyOnly mode for 3D assets', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
media: {
|
|
proxyType: '3d',
|
|
imageTranscodes: [{ key: 'proxy/views.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-3d-s3', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
s3KeyOnly: true,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(result.content).toHaveLength(1)
|
|
const textItem = result.content[0] as { type: 'text'; text: string }
|
|
expect(textItem.text).toContain('proxy/views.webp')
|
|
expect(textItem.text).toContain('Front view (0°)')
|
|
expect(result.details.key).toBe('proxy/views.webp')
|
|
})
|
|
|
|
it('should throw error if videoConfig is passed for 3D assets', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
media: {
|
|
proxyType: '3d',
|
|
imageTranscodes: [{ key: 'proxy/views.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-3d-err', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: { start: 0, end: 4, count: 4 },
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow(
|
|
"To inspect specific angles pass 'config3d: { degree: ... }'; do not pass videoConfig",
|
|
)
|
|
})
|
|
|
|
it('should throw error if 3D asset imageTranscodes is missing when overview is requested', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
media: {
|
|
proxyType: '3d',
|
|
imageTranscodes: [],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-3d-err2', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('4-views image (views.webp) is missing')
|
|
})
|
|
|
|
it('should extract specific turntable frame when config3d.degree is provided', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
projectId: 'proj-1',
|
|
media: {
|
|
proxyType: '3d',
|
|
videoTranscodes: [{ key: 'proxy/turntable.mp4' }],
|
|
imageTranscodes: [{ key: 'proxy/views.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-shot-3d',
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-shot-3d',
|
|
status: WorkflowTaskStatus.completed,
|
|
output: {
|
|
screenshots: [{ key: 'proxy/shot-45.webp', timestamp: 0.5833 }],
|
|
},
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('fake-shot-45-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-3d-degree', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
config3d: { degree: 45 },
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(prisma.workflowTask.create).toHaveBeenCalledWith({
|
|
data: expect.objectContaining({
|
|
type: WorkflowTaskType.transcode_screenshot,
|
|
assetId: 'model-1',
|
|
payload: {
|
|
projectId: 'proj-1',
|
|
screenshot: {
|
|
start: expect.any(Number),
|
|
end: expect.any(Number),
|
|
count: 1,
|
|
commentTimestamp: expect.any(Number),
|
|
annotations: undefined,
|
|
},
|
|
},
|
|
}),
|
|
})
|
|
|
|
const textItem = result.content[0] as { type: 'text'; text: string }
|
|
const imageItem = result.content[1] as { type: 'image'; data: string; mimeType: string }
|
|
|
|
expect(textItem.text).toContain('view at 45°:')
|
|
expect(imageItem.data).toBe(Buffer.from('fake-shot-45-bytes').toString('base64'))
|
|
expect(result.details.key).toBe('proxy/shot-45.webp')
|
|
})
|
|
|
|
it('should throw error when config3d.degree is not a multiple of 15 or out of range', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
media: {
|
|
proxyType: '3d',
|
|
videoTranscodes: [{ key: 'proxy/turntable.mp4' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
|
|
await expect(
|
|
tool.execute('call-3d-invalid-deg', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
config3d: { degree: 40 },
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Invalid turntable degree: 40')
|
|
|
|
await expect(
|
|
tool.execute('call-3d-out-of-range', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
config3d: { degree: 360 },
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Invalid turntable degree: 360')
|
|
})
|
|
|
|
it('should extract frame with overlaid markups when annotationId is provided on 3D asset', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
projectId: 'proj-1',
|
|
media: {
|
|
proxyType: '3d',
|
|
videoTranscodes: [{ key: 'proxy/turntable.mp4' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.spyOn(annotationResolver, 'resolveAnnotationsById').mockResolvedValue({
|
|
annotations: [
|
|
{
|
|
type: 'freehand',
|
|
color: '#ff0000',
|
|
points: [
|
|
[0, 0],
|
|
[10, 10],
|
|
],
|
|
},
|
|
],
|
|
timestamp: 0.5, // 0.5s = 45°
|
|
})
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-shot-ann',
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-shot-ann',
|
|
status: WorkflowTaskStatus.completed,
|
|
output: {
|
|
screenshots: [{ key: 'proxy/shot-annotated.webp', timestamp: 0.5 }],
|
|
},
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('fake-shot-ann-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-3d-ann', {
|
|
assetId: 'model-1',
|
|
annotationId: 'comm-1',
|
|
config3d: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(prisma.workflowTask.create).toHaveBeenCalledWith({
|
|
data: expect.objectContaining({
|
|
type: WorkflowTaskType.transcode_screenshot,
|
|
assetId: 'model-1',
|
|
payload: {
|
|
projectId: 'proj-1',
|
|
screenshot: {
|
|
start: 0.5,
|
|
end: 0.5,
|
|
count: 1,
|
|
commentTimestamp: 0.5,
|
|
annotations: [
|
|
{
|
|
type: 'freehand',
|
|
color: '#ff0000',
|
|
points: [
|
|
[0, 0],
|
|
[10, 10],
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
}),
|
|
})
|
|
|
|
const textItem = result.content[0] as { type: 'text'; text: string }
|
|
expect(textItem.text).toContain('view at 45° with visual markups overlaid:')
|
|
expect(result.details.key).toBe('proxy/shot-annotated.webp')
|
|
})
|
|
|
|
it('should extract turntable frame at resolved degree angle for 3D session annotations', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
projectId: 'proj-1',
|
|
media: {
|
|
proxyType: '3d',
|
|
videoTranscodes: [{ key: 'proxy/turntable.mp4' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const expectedTime = degreeToSecond(90)
|
|
vi.spyOn(annotationResolver, 'resolveAnnotationsById').mockResolvedValue({
|
|
annotations: [
|
|
{
|
|
type: 'box',
|
|
color: '#00ff00',
|
|
points: [
|
|
[10, 20],
|
|
[40, 60],
|
|
],
|
|
},
|
|
],
|
|
timestamp: expectedTime,
|
|
})
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-shot-3d-session',
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-shot-3d-session',
|
|
status: WorkflowTaskStatus.completed,
|
|
output: {
|
|
screenshots: [{ key: 'proxy/shot-annotated-90.webp', timestamp: expectedTime }],
|
|
},
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('fake-shot-90-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-3d-session-ann', {
|
|
assetId: 'model-1',
|
|
annotationId: 'session-entry-1',
|
|
config3d: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(prisma.workflowTask.create).toHaveBeenCalledWith({
|
|
data: expect.objectContaining({
|
|
type: WorkflowTaskType.transcode_screenshot,
|
|
assetId: 'model-1',
|
|
payload: {
|
|
projectId: 'proj-1',
|
|
screenshot: {
|
|
start: expectedTime,
|
|
end: expectedTime,
|
|
count: 1,
|
|
commentTimestamp: expectedTime,
|
|
annotations: [
|
|
{
|
|
type: 'box',
|
|
color: '#00ff00',
|
|
points: [
|
|
[10, 20],
|
|
[40, 60],
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
}),
|
|
})
|
|
|
|
const textItem = result.content[0] as { type: 'text'; text: string }
|
|
expect(textItem.text).toContain('view at 90° with visual markups overlaid:')
|
|
expect(result.details.key).toBe('proxy/shot-annotated-90.webp')
|
|
})
|
|
|
|
it('should throw error if config3d.degree conflicts with annotation angle', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
projectId: 'proj-1',
|
|
media: {
|
|
proxyType: '3d',
|
|
videoTranscodes: [{ key: 'proxy/turntable.mp4' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.spyOn(annotationResolver, 'resolveAnnotationsById').mockResolvedValue({
|
|
annotations: [
|
|
{
|
|
type: 'box',
|
|
color: '#ff0000',
|
|
points: [
|
|
[0, 0],
|
|
[10, 10],
|
|
],
|
|
},
|
|
],
|
|
timestamp: 0.5, // 45°
|
|
})
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-3d-conflict', {
|
|
assetId: 'model-1',
|
|
annotationId: 'comm-1',
|
|
config3d: { degree: 90 }, // Conflicts with 45°
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow(
|
|
'Annotation "comm-1" was drawn at 45°, but degree 90° was specified. Do not pass a conflicting degree with annotationId.',
|
|
)
|
|
})
|
|
|
|
it('should throw error if 3D asset turntable video is missing when angle inspection is requested', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'model-1',
|
|
name: 'robot.glb',
|
|
mediaType: 'model/gltf-binary',
|
|
media: {
|
|
proxyType: '3d',
|
|
videoTranscodes: [],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-3d-missing-turntable', {
|
|
assetId: 'model-1',
|
|
annotationId: null,
|
|
config3d: { degree: 45 },
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('turntable video (turntable.mp4) is missing')
|
|
})
|
|
})
|
|
|
|
describe('Video Assets', () => {
|
|
it('should throw error if videoConfig is missing for video assets', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'vid-1',
|
|
name: 'video.mp4',
|
|
mediaType: 'video/mp4',
|
|
media: { proxyType: 'video' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'vid-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('videoConfig with start, end, and count is required')
|
|
})
|
|
|
|
it('should throw error on invalid video time range', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'vid-1',
|
|
name: 'video.mp4',
|
|
mediaType: 'video/mp4',
|
|
media: { proxyType: 'video' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'vid-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: { start: 10, end: 5, count: 1 },
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow(
|
|
'Invalid video time range: start (10) must be less than or equal to end (5).',
|
|
)
|
|
})
|
|
|
|
it('should extract frames and return ImageContent array and keys', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'vid-1',
|
|
name: 'video.mp4',
|
|
mediaType: 'video/mp4',
|
|
projectId: 'project-1',
|
|
media: { proxyType: 'video' },
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-shot',
|
|
} as unknown as WorkflowTask)
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-shot',
|
|
output: {
|
|
screenshots: [
|
|
{ key: 'screenshots/shot1.webp', timestamp: 2.0 },
|
|
{ key: 'screenshots/shot2.webp', timestamp: 4.0 },
|
|
],
|
|
},
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(s3Service.getObject).mockImplementation(async (_bucket, key) => ({
|
|
buffer: Buffer.from(`bytes-for-${key}`),
|
|
contentType: 'image/webp',
|
|
}))
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'vid-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: { start: 2.0, end: 4.0, count: 2 },
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(prisma.workflowTask.create).toHaveBeenCalledWith({
|
|
data: {
|
|
assetId: 'vid-1',
|
|
projectId: 'project-1',
|
|
type: WorkflowTaskType.transcode_screenshot,
|
|
status: WorkflowTaskStatus.pending,
|
|
payload: {
|
|
projectId: 'project-1',
|
|
screenshot: {
|
|
start: 2.0,
|
|
end: 4.0,
|
|
count: 2,
|
|
commentTimestamp: null,
|
|
annotations: null,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
expect(result.content.length).toBe(3) // 1 text + 2 images
|
|
expect(result.details.keys).toEqual(['screenshots/shot1.webp', 'screenshots/shot2.webp'])
|
|
})
|
|
})
|
|
|
|
describe('Document Assets', () => {
|
|
it('should throw error if docConfig is missing for document assets', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-1',
|
|
name: 'doc.pdf',
|
|
mediaType: 'application/pdf',
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'doc-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('docConfig with mode ("pages" or "text") is required')
|
|
})
|
|
|
|
it('should render PDF pages in mode: "pages"', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-1',
|
|
name: 'doc.pdf',
|
|
mediaType: 'application/pdf',
|
|
projectId: 'project-1',
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-pdf',
|
|
} as unknown as WorkflowTask)
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-pdf',
|
|
output: {
|
|
pages: [
|
|
{ key: 'pdf_pages/page1.webp', page: 1 },
|
|
{ key: 'pdf_pages/page2.webp', page: 2 },
|
|
],
|
|
},
|
|
} as unknown as WorkflowTask)
|
|
|
|
vi.mocked(s3Service.getObject).mockImplementation(async (_bucket, key) => ({
|
|
buffer: Buffer.from(`bytes-for-${key}`),
|
|
contentType: 'image/webp',
|
|
}))
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'doc-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'pages', startPage: 1, endPage: 2 },
|
|
})
|
|
|
|
expect(result.content.length).toBe(3) // 1 text + 2 images
|
|
expect(result.details.keys).toEqual(['pdf_pages/page1.webp', 'pdf_pages/page2.webp'])
|
|
})
|
|
|
|
it('should throw error in mode: "pages" when page range exceeds 20 pages', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-1',
|
|
name: 'doc.pdf',
|
|
mediaType: 'application/pdf',
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'doc-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'pages', startPage: 1, endPage: 25 },
|
|
}),
|
|
).rejects.toThrow('exceeds the maximum limit of 20 pages')
|
|
})
|
|
|
|
it('should throw error in mode: "text" when called on binary PDF', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-1',
|
|
name: 'manual.pdf',
|
|
mediaType: 'application/pdf',
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'doc-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'text', startPage: null, endPage: null },
|
|
}),
|
|
).rejects.toThrow('is a binary PDF/document and cannot be read as raw text')
|
|
})
|
|
|
|
it('should throw error in mode: "text" when annotationId is provided', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-1',
|
|
name: 'notes.md',
|
|
mediaType: 'text/markdown',
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'doc-1',
|
|
annotationId: 'comment-123',
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'text', startPage: null, endPage: null },
|
|
}),
|
|
).rejects.toThrow('annotationId cannot be used with docConfig mode "text"')
|
|
})
|
|
|
|
it('should throw error in mode: "text" when startPage or endPage is non-null', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-1',
|
|
name: 'notes.md',
|
|
mediaType: 'text/markdown',
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'doc-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'text', startPage: 1, endPage: 2 },
|
|
}),
|
|
).rejects.toThrow('startPage and endPage must be null when docConfig mode is "text"')
|
|
})
|
|
|
|
it('should read raw text from S3 in mode: "text" for markdown files', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-md',
|
|
name: 'README.md',
|
|
mediaType: 'text/markdown',
|
|
storageKey: { key: 'raw/README.md' },
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('# Hello Shumai\nThis is markdown text.'),
|
|
contentType: 'text/markdown',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'doc-md',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'text', startPage: null, endPage: null },
|
|
})
|
|
|
|
expect(s3Service.getObject).toHaveBeenCalledWith('shumai', 'raw/README.md')
|
|
expect(result.content[0].type).toBe('text')
|
|
expect((result.content[0] as { type: 'text'; text: string }).text).toContain(
|
|
'# Hello Shumai\nThis is markdown text.',
|
|
)
|
|
expect(result.details.key).toBe('raw/README.md')
|
|
})
|
|
})
|
|
|
|
describe('Version Stack Resolution', () => {
|
|
it('should resolve version_stack to latest version asset', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'stack-1',
|
|
name: '',
|
|
type: 'version_stack',
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(prisma.asset.findFirst).mockResolvedValue({
|
|
id: 'file-v2',
|
|
name: 'diagram_v2.png',
|
|
type: 'file',
|
|
mediaType: 'image/png',
|
|
storageKey: { key: 'raw/diagram_v2.png' },
|
|
media: {
|
|
proxyType: 'image',
|
|
imageTranscodes: [{ key: 'proxy/diagram_v2.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(s3Service.getObject).mockResolvedValue({
|
|
buffer: Buffer.from('v2-image-bytes'),
|
|
contentType: 'image/webp',
|
|
} as unknown as { buffer: Buffer; contentType: string })
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'stack-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(prisma.asset.findFirst).toHaveBeenCalledWith({
|
|
where: { parentId: 'stack-1', isDeleted: false },
|
|
orderBy: { sortIndex: 'asc' },
|
|
include: { storageKey: true },
|
|
})
|
|
expect(result.details.name).toBe('diagram_v2.png')
|
|
expect(result.details.key).toBe('proxy/diagram_v2.webp')
|
|
})
|
|
})
|
|
|
|
describe('s3KeyOnly mode', () => {
|
|
it('returns only S3 key and MIME in text for image assets without fetching S3 buffer or attaching base64 image', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'img-1',
|
|
name: 'photo.png',
|
|
mediaType: 'image/png',
|
|
storageKey: { key: 'raw/photo.png' },
|
|
media: {
|
|
proxyType: 'image',
|
|
imageTranscodes: [{ key: 'proxy/photo.webp' }],
|
|
},
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'img-1',
|
|
annotationId: null,
|
|
s3KeyOnly: true,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(s3Service.getObject).not.toHaveBeenCalled()
|
|
expect(result.content.length).toBe(1)
|
|
expect(result.content[0].type).toBe('text')
|
|
expect((result.content[0] as { type: 'text'; text: string }).text).toBe(
|
|
'Image asset "photo.png" (ID: img-1, MIME: image/webp, S3 Key: "proxy/photo.webp")',
|
|
)
|
|
expect(result.details.key).toBe('proxy/photo.webp')
|
|
})
|
|
|
|
it('returns only frame S3 keys and MIME in text for video assets without fetching S3 buffers or attaching base64 images', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'vid-1',
|
|
name: 'clip.mp4',
|
|
mediaType: 'video/mp4',
|
|
projectId: 'project-1',
|
|
media: { proxyType: 'video' },
|
|
} as unknown as Asset)
|
|
|
|
vi.mocked(prisma.workflowTask.create).mockResolvedValue({
|
|
id: 'task-shot',
|
|
} as unknown as WorkflowTask)
|
|
vi.mocked(workflowService.executeWait).mockResolvedValue({
|
|
id: 'task-shot',
|
|
output: {
|
|
screenshots: [{ key: 'screenshots/shot1.webp', timestamp: 1.5 }],
|
|
},
|
|
} as unknown as WorkflowTask)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'vid-1',
|
|
annotationId: null,
|
|
s3KeyOnly: true,
|
|
imageConfig: null,
|
|
videoConfig: { start: 1.5, end: 1.5, count: 1 },
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(s3Service.getObject).not.toHaveBeenCalled()
|
|
expect(result.content.length).toBe(1)
|
|
expect(result.content[0].type).toBe('text')
|
|
const text = (result.content[0] as { type: 'text'; text: string }).text
|
|
expect(text).toContain('- Frame at 1.5s (S3 Key: "screenshots/shot1.webp", MIME: image/webp)')
|
|
expect(result.details.keys).toEqual(['screenshots/shot1.webp'])
|
|
})
|
|
|
|
it('returns only document S3 key and MIME in text for text mode without fetching S3 buffer', async () => {
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue()
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'doc-md',
|
|
name: 'notes.md',
|
|
mediaType: 'text/markdown',
|
|
storageKey: { key: 'raw/notes.md' },
|
|
media: { proxyType: 'pdf' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool('user-1')
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'doc-md',
|
|
annotationId: null,
|
|
s3KeyOnly: true,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: { mode: 'text', startPage: null, endPage: null },
|
|
})
|
|
|
|
expect(s3Service.getObject).not.toHaveBeenCalled()
|
|
expect(result.content.length).toBe(1)
|
|
expect(result.content[0].type).toBe('text')
|
|
expect((result.content[0] as { type: 'text'; text: string }).text).toBe(
|
|
'Document "notes.md" (ID: doc-md, MIME: text/markdown, S3 Key: "raw/notes.md")',
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('ReadAssetAuthContext & Security Boundaries', () => {
|
|
it('throws authorization error if chat agent lacks userId', async () => {
|
|
const tool = createReadAssetTool({
|
|
agentType: 'chat',
|
|
teamId: 'team-1',
|
|
})
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'asset-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('User ID is required for authorization.')
|
|
})
|
|
|
|
it('throws error if autofill agent lacks targetAssetId', async () => {
|
|
const tool = createReadAssetTool({
|
|
agentType: 'autofill',
|
|
teamId: 'team-1',
|
|
} as unknown as ReadAssetAuthContext)
|
|
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'asset-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Target asset ID is required for autofill agent authorization.')
|
|
})
|
|
|
|
it('throws error if autofill agent lacks teamId', async () => {
|
|
const tool = createReadAssetTool({
|
|
agentType: 'autofill',
|
|
targetAssetId: 'asset-1',
|
|
} as unknown as ReadAssetAuthContext)
|
|
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'asset-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Team ID is required for autofill agent authorization.')
|
|
})
|
|
|
|
it('denies autofill agent if asset belongs to another team', async () => {
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'asset-1',
|
|
project: { teamId: 'other-team' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool({
|
|
agentType: 'autofill',
|
|
teamId: 'team-1',
|
|
targetAssetId: 'asset-1',
|
|
})
|
|
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'asset-1',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Access denied: asset asset-1 does not belong to team team-1.')
|
|
})
|
|
|
|
it('denies autofill agent if reading an unrelated asset not matching targetAssetId', async () => {
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'other-asset',
|
|
parentId: null,
|
|
project: { teamId: 'team-1' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool({
|
|
agentType: 'autofill',
|
|
teamId: 'team-1',
|
|
targetAssetId: 'target-asset-id',
|
|
})
|
|
|
|
await expect(
|
|
tool.execute('call-1', {
|
|
assetId: 'other-asset',
|
|
annotationId: null,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
}),
|
|
).rejects.toThrow('Access denied: autofill agent can only read target asset target-asset-id.')
|
|
})
|
|
|
|
it('allows autofill agent to read target asset without userId', async () => {
|
|
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
|
id: 'target-asset-id',
|
|
name: 'test.png',
|
|
mediaType: 'image/png',
|
|
storageKey: { key: 'raw/test.png' },
|
|
media: { proxyType: 'image' },
|
|
project: { teamId: 'team-1' },
|
|
} as unknown as Asset)
|
|
|
|
const tool = createReadAssetTool({
|
|
agentType: 'autofill',
|
|
teamId: 'team-1',
|
|
targetAssetId: 'target-asset-id',
|
|
})
|
|
|
|
const result = await tool.execute('call-1', {
|
|
assetId: 'target-asset-id',
|
|
annotationId: null,
|
|
s3KeyOnly: true,
|
|
imageConfig: null,
|
|
videoConfig: null,
|
|
docConfig: null,
|
|
})
|
|
|
|
expect(authzService.hasPermission).not.toHaveBeenCalled()
|
|
expect(result.content.length).toBe(1)
|
|
expect((result.content[0] as { type: 'text'; text: string }).text).toContain(
|
|
'target-asset-id',
|
|
)
|
|
})
|
|
})
|
|
})
|