mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 12:54:55 +00:00
feat(agent): add built-in image and video generation tools and settings (#382)
* feat(agent): add built-in image and video generation tools and settings * fix(settings): refine media generation layout and expose media tools in agent and quota forms * feat(media-generation): add alibaba, bytedance, minimax, prodia, and azure providers * feat(agent): support s3 key references for media generation and s3KeyOnly in read_asset
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import React from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { AgentFormDialog } from './AgentFormDialog'
|
||||
|
||||
vi.mock('@/ui/api/client', () => ({
|
||||
client: {
|
||||
api: {
|
||||
teams: {
|
||||
':teamId': {
|
||||
providers: {
|
||||
$get: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => [],
|
||||
}),
|
||||
},
|
||||
skills: {
|
||||
$get: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ skills: [] }),
|
||||
}),
|
||||
},
|
||||
mcp: {
|
||||
servers: {
|
||||
$get: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => [],
|
||||
}),
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
$post: vi.fn(),
|
||||
':agentId': {
|
||||
$put: vi.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/ui/hooks/use-permissions', () => ({
|
||||
usePermissions: () => ({
|
||||
canAdmin: true,
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('sonner', () => ({
|
||||
toast: {
|
||||
success: vi.fn(),
|
||||
error: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
describe('AgentFormDialog', () => {
|
||||
let queryClient: QueryClient
|
||||
|
||||
beforeEach(() => {
|
||||
queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: { retry: false },
|
||||
mutations: { retry: false },
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
})
|
||||
|
||||
it('renders all builtin tools including generate_image and generate_video', () => {
|
||||
render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AgentFormDialog
|
||||
isOpen={true}
|
||||
onClose={vi.fn()}
|
||||
teamId="team-123"
|
||||
type="chat"
|
||||
title="Create Agent"
|
||||
/>
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
|
||||
expect(screen.getByText('Generate Image')).toBeDefined()
|
||||
expect(screen.getByText('Generate Video')).toBeDefined()
|
||||
expect(screen.getByText('Sandboxed Terminal')).toBeDefined()
|
||||
expect(screen.getByText('Read Asset')).toBeDefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user