mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 06:27:42 +00:00
* feat(premiere-uxp): use native Bun bundler and build script instead of Vite * feat(premiere-uxp): switch FileListView to use Search API consistent with WebUI * feat(premiere-uxp): add on-demand jpeg preview conversion for uxp compatibility * feat(premiere-uxp): integrate spectrum web components (swc) * fix(premiere-uxp): align swc packages with 0.37.0 and fix auth layout * feat(premiere-uxp): use horizontal 2-column card view for projects and files * style(premiere-uxp): enlarge file preview by 20% and add row padding * fix(premiere-uxp): prevent card squishing and overflow with large item counts * fix(premiere-uxp): change host in manifest to single object * docs(premiere-uxp): add AGENTS.md with SWC preferences and UXP layout rules * feat(premiere-uxp): integrate spectrum web components across plugin views * fix(premiere-uxp): remove breadcrumb icons and use slash separator * feat(premiere-uxp): add collapsible folder and file sections with infinite scroll * feat(premiere-uxp): update file card layout with right column info and clean preview * fix(premiere-uxp): use raw text for file card details and fix black icons * style(premiere-uxp): use contain object-fit and black background for file card preview * fix(premiere-uxp): refine header logo, sticky title bars, circular badges, and controls * fix(premiere-uxp): replace stroke icons with spectrum workflow icons * fix(premiere-uxp): switch icon buttons to swc sp-button with icon-only and slot=icon * fix(premiere-uxp): vertically center endpoint text in header * feat(premiere-uxp): add asset and proxy import support into Premiere Pro - Implement context menu on file cards with left-click, right-click, and more action button triggers - Support raw file import for non-video assets and video assets - Support video proxy submenu listing ready transcode resolutions - Add UXP native file picker save dialog and binary download orchestration - Call Premiere Pro project.importFiles API to import downloaded assets into active project - Add non-blocking toast notification banner for progress and status reporting - Add unit tests for premiere host service and import orchestration * fix(premiere-uxp): anchor import menu directly to file card using sp-action-menu - Replace custom fixed-position ContextMenu with native SWC sp-action-menu - Anchor menu directly to the triggered file card rather than the top-left window corner - Support programmatic opening on file card click/contextmenu via imperative handle - Support video submenu with Original and ready proxy options inside sp-action-menu - Lazy load video proxies on menu open or hover - Clean up obsolete fixed-position styles and unused backdrop overlays * fix(premiere-uxp): align SWC packages to 0.37.0 and guard custom element registry - Downgrade action-menu and menu SWC packages to 0.37.0 to match the rest of the workspace - Eliminate duplicate icons-ui and sp-icon-chevron100 customElements.define calls - Add polyfill guard to customElements.define to prevent duplicate registration errors during UXP reload * fix(premiere-uxp): polyfill window.matchMedia for Adobe UXP - Add window.matchMedia polyfill in polyfills.ts - Satisfies SWC MatchMediaController used by ActionMenu and PickerBase in UXP - Prevents TypeError when opening files page * feat(premiere-uxp): replace context menu with card download action and video import dialog * fix(premiere-uxp): resolve download url before save, pass null targetBin, and center download icon * fix(premiere-uxp): resolve raw download url via download-url endpoint with fallback * feat(premiere-uxp): use native folder picker and auto-increment conflict suffixes * feat(premiere-uxp): add sequence linking, comment-marker sync, and navigation tabs - Add sequence-to-asset linking with persistent project metadata storage - Support one-way comment-to-marker timeline synchronization - Add two-tab navigation (Sequences and Browse) using Spectrum buttons - Add LinkSequenceDialog, SequencesView, and autoSyncService background engine - Enforce Spectrum Workflow Icons and UXP layout rules * feat(premiere-uxp): refine UI layouts, card interactions, and search box activation * fix(premiere-uxp): set compact fixed width for file list search box * fix(premiere-uxp): ensure search box click activation across full width in UXP * fix(premiere-uxp): revert search box hacks and restore simple default sp-search layout * feat(premiere-uxp): sync non-timestamped comments as markers at time 0 * feat(premiere-uxp): change link icon to unlink when asset is linked in file card * fix(premiere-uxp): sync linked sequences between host project and browse view * feat(premiere-uxp): remove synced markers on sequence unlink matching Frame.io * fix(premiere-uxp): ensure reliable marker GUID capture, normalization, and fallback on unlink * fix(premiere-uxp): use official Shumai logo for plugin manifest icons * fix(premiere-uxp): use official PNG icons for manifest and plugin entrypoints * refactor(premiere-uxp): use single 114x114 icon for plugin and panel * feat(premiere-uxp): show file version in file list page file card * build(premiere-uxp): check in built ccx package and update packaging configuration * fix(premiere-uxp): address code review findings for media conversion, marker sync, and link scoping - Reset hasJpegCover on project cover update and hasJpegPreview on asset media transcode - Only advance synced comment metadata after confirmed marker transaction - Normalize GUID keys and lookups in AutoSyncService map - Restrict cached sequence link lookups to project-specific keys and prevent cross-project leakage on empty sequences - Update built CCX distribution package
431 lines
13 KiB
TypeScript
431 lines
13 KiB
TypeScript
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
|
import { Hono } from 'hono'
|
|
import folderRoute from './folder'
|
|
import { assetService } from '@shumai/core/src/asset/asset'
|
|
import { searchService } from '@shumai/core/src/search/search'
|
|
import { authzService, ResourceType, Permission } from '@shumai/core/src/authz/authz'
|
|
import { authMiddleware } from './middleware/auth'
|
|
|
|
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
|
|
|
vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
|
|
auditLogService: {
|
|
logAction: vi.fn().mockResolvedValue({}),
|
|
},
|
|
}))
|
|
|
|
vi.mock('@shumai/core/src/authz/authz', () => ({
|
|
authzService: {
|
|
hasPermission: vi.fn().mockResolvedValue(undefined),
|
|
},
|
|
Permission: {
|
|
Read: 'Read',
|
|
Edit: 'Edit',
|
|
Admin: 'Admin',
|
|
},
|
|
ResourceType: {
|
|
Asset: 'asset',
|
|
},
|
|
}))
|
|
|
|
vi.mock('./middleware/auth', () => ({
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
authMiddleware: async (c: any, next: any) => {
|
|
c.set('user', { id: 'user1', name: 'Test User' })
|
|
await next()
|
|
},
|
|
}))
|
|
|
|
describe('folder api', () => {
|
|
beforeEach(() => {
|
|
vi.mocked(authzService.hasPermission).mockClear()
|
|
|
|
vi.spyOn(assetService, 'getAsset').mockImplementation(vi.fn())
|
|
vi.spyOn(assetService, 'getAssetContext').mockResolvedValue({ teamId: 'test-team' })
|
|
vi.spyOn(assetService, 'createAsset').mockImplementation(vi.fn())
|
|
vi.spyOn(assetService, 'updateAssetName').mockImplementation(vi.fn())
|
|
vi.spyOn(assetService, 'deleteAssets').mockImplementation(vi.fn())
|
|
vi.spyOn(assetService, 'restoreAssets').mockImplementation(vi.fn())
|
|
vi.spyOn(assetService, 'listChildren').mockImplementation(vi.fn())
|
|
vi.spyOn(searchService, 'search').mockImplementation(vi.fn())
|
|
})
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks()
|
|
})
|
|
|
|
it('GET /folders/:folderId', async () => {
|
|
vi.mocked(assetService.getAsset).mockResolvedValue({
|
|
id: 'test-id',
|
|
name: 'test-folder',
|
|
sizeByte: 10,
|
|
fileCount: 1,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.name).toBe('test-folder')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Read,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
})
|
|
|
|
it('PUT /folders/:folderId', async () => {
|
|
vi.mocked(assetService.updateAssetName).mockResolvedValue({
|
|
id: 'test-id',
|
|
name: 'new-name',
|
|
sizeByte: 10,
|
|
fileCount: 1,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id', {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ name: 'new-name' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.name).toBe('new-name')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
|
action: 'folder_update',
|
|
teamId: 'test-team',
|
|
userId: 'user1',
|
|
projectId: undefined,
|
|
itemId: 'test-id',
|
|
})
|
|
})
|
|
|
|
it('POST /folders', async () => {
|
|
vi.mocked(assetService.createAsset).mockResolvedValue({
|
|
id: 'new-id',
|
|
name: 'new-folder',
|
|
sizeByte: 0,
|
|
fileCount: 0,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ name: 'new-folder', parentId: 'parent-id' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.name).toBe('new-folder')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'parent-id',
|
|
})
|
|
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
|
action: 'folder_create',
|
|
teamId: 'test-team',
|
|
userId: 'user1',
|
|
projectId: undefined,
|
|
itemId: 'new-id',
|
|
})
|
|
})
|
|
|
|
it('GET /folders/:folderId/children', async () => {
|
|
vi.mocked(assetService.listChildren).mockResolvedValue({
|
|
data: [
|
|
{
|
|
id: 'child-id',
|
|
name: 'child-folder',
|
|
sizeByte: 0,
|
|
fileCount: 0,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
},
|
|
],
|
|
pageInfo: { total: 1, cursor: '' },
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/children?assetType=folder')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data).toHaveLength(1)
|
|
expect(json.data[0].name).toBe('child-folder')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Read,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
expect(assetService.listChildren).toHaveBeenCalledWith({
|
|
assetId: 'test-id',
|
|
assetType: 'folder',
|
|
})
|
|
})
|
|
|
|
it('GET /folders/:folderId/children forwards pagination parameters', async () => {
|
|
vi.mocked(assetService.listChildren).mockResolvedValue({
|
|
data: [
|
|
{
|
|
id: 'child-id-2',
|
|
name: 'child-folder-2',
|
|
sizeByte: 0,
|
|
fileCount: 0,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
},
|
|
],
|
|
pageInfo: { total: 30, cursor: 'cursorNextToken' },
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request(
|
|
'/folders/test-id/children?assetType=folder&first=20&after=cursorToken123&prefix=sub',
|
|
)
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data).toHaveLength(1)
|
|
expect(json.pageInfo.cursor).toBe('cursorNextToken')
|
|
|
|
expect(assetService.listChildren).toHaveBeenCalledWith({
|
|
assetId: 'test-id',
|
|
assetType: 'folder',
|
|
first: 20,
|
|
after: 'cursorToken123',
|
|
prefix: 'sub',
|
|
})
|
|
})
|
|
|
|
it('DELETE /folders', async () => {
|
|
vi.mocked(assetService.deleteAssets).mockResolvedValue(undefined)
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders', {
|
|
method: 'DELETE',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ ids: ['test-id'] }),
|
|
})
|
|
|
|
expect(res.status).toBe(204)
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
expect(assetService.deleteAssets).toHaveBeenCalledWith(['test-id'])
|
|
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
|
action: 'folder_delete',
|
|
teamId: 'test-team',
|
|
userId: 'user1',
|
|
projectId: undefined,
|
|
itemId: 'test-id',
|
|
})
|
|
})
|
|
|
|
it('POST /folders/restore', async () => {
|
|
vi.mocked(assetService.restoreAssets).mockResolvedValue(undefined)
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/restore', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ ids: ['test-id'] }),
|
|
})
|
|
|
|
expect(res.status).toBe(204)
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
expect(assetService.restoreAssets).toHaveBeenCalledWith(['test-id'])
|
|
})
|
|
|
|
it('POST /folders/:folderId/search', async () => {
|
|
vi.mocked(searchService.search).mockResolvedValue({
|
|
data: [
|
|
{
|
|
id: 'result-id',
|
|
name: 'result-folder',
|
|
sizeByte: 0,
|
|
fileCount: 0,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
},
|
|
],
|
|
pageInfo: { total: 1, cursor: '' },
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/search', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
conditions: [{ field: 'name', operator: 'eq', value: 'result-folder' }],
|
|
}),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data).toHaveLength(1)
|
|
expect(json.data[0].name).toBe('result-folder')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Read,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
})
|
|
|
|
it('POST /folders/:folderId/search passes previewFormat to searchService', async () => {
|
|
vi.mocked(searchService.search).mockResolvedValue({
|
|
data: [],
|
|
pageInfo: { total: 0 },
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/search', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
previewFormat: 'jpeg',
|
|
}),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
expect(searchService.search).toHaveBeenCalledWith(
|
|
'test-id',
|
|
expect.objectContaining({ previewFormat: 'jpeg' }),
|
|
)
|
|
})
|
|
|
|
it('PATCH /folders/:folderId/order', async () => {
|
|
vi.spyOn(assetService, 'updateAssetOrder').mockResolvedValue({
|
|
id: 'test-id',
|
|
name: 'test-folder',
|
|
sizeByte: 10,
|
|
fileCount: 1,
|
|
type: 'folder',
|
|
status: 'active',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
})
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/order', {
|
|
method: 'PATCH',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ beforeIndex: 'index-1' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
|
|
expect(assetService.updateAssetOrder).toHaveBeenCalledWith('test-id', {
|
|
beforeIndex: 'index-1',
|
|
})
|
|
})
|
|
|
|
it('GET /folders/:folderId/agentsmd', async () => {
|
|
vi.spyOn(assetService, 'getAgentsMd').mockResolvedValue('# Folder Guidelines')
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/agentsmd')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.content).toBe('# Folder Guidelines')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Read,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
expect(assetService.getAgentsMd).toHaveBeenCalledWith('test-id')
|
|
})
|
|
|
|
it('PATCH /folders/:folderId/agentsmd', async () => {
|
|
vi.spyOn(assetService, 'updateAgentsMd').mockResolvedValue({ content: '# Updated Guidelines' })
|
|
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/agentsmd', {
|
|
method: 'PATCH',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ content: '# Updated Guidelines' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.content).toBe('# Updated Guidelines')
|
|
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: { id: 'user1', name: 'Test User' },
|
|
permission: Permission.Admin,
|
|
type: ResourceType.Asset,
|
|
id: 'test-id',
|
|
})
|
|
expect(assetService.updateAgentsMd).toHaveBeenCalledWith('test-id', '# Updated Guidelines')
|
|
})
|
|
|
|
it('PATCH /folders/:folderId/agentsmd rejects oversized content', async () => {
|
|
const mockUpdate = vi.spyOn(assetService, 'updateAgentsMd').mockResolvedValue({ content: '' })
|
|
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
|
|
const res = await app.request('/folders/test-id/agentsmd', {
|
|
method: 'PATCH',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ content: 'x'.repeat(100_001) }),
|
|
})
|
|
|
|
expect(res.status).toBe(400)
|
|
expect(mockUpdate).not.toHaveBeenCalled()
|
|
})
|
|
})
|