mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 13:58:00 +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
495 lines
15 KiB
TypeScript
495 lines
15 KiB
TypeScript
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
import { Hono, type Context, type Next } from 'hono'
|
|
import projectRoute from './project'
|
|
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
|
import { projectService } from '@shumai/core/src/project/project'
|
|
import { assetService } from '@shumai/core/src/asset/asset'
|
|
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
|
import type { ProjectInfo } from '@shumai/dtos'
|
|
|
|
vi.mock('./middleware/auth', () => ({
|
|
authMiddleware: async (
|
|
c: Context<{ Variables: { user: { id: string; name: string } } }>,
|
|
next: Next,
|
|
) => {
|
|
c.set('user', { id: 'user1', name: 'Test User' })
|
|
await next()
|
|
},
|
|
}))
|
|
|
|
vi.mock('@shumai/core/src/authz/authz')
|
|
vi.mock('@shumai/core/src/project/project', () => ({
|
|
projectService: {
|
|
createProject: vi.fn(),
|
|
updateProject: vi.fn(),
|
|
getProject: vi.fn(),
|
|
getProjectTeam: vi.fn().mockResolvedValue('t1'),
|
|
deleteProject: vi.fn(),
|
|
listProjects: vi.fn(),
|
|
getUserProjects: vi.fn(),
|
|
listProjectMembers: vi.fn(),
|
|
addProjectMember: vi.fn(),
|
|
updateMemberRole: vi.fn(),
|
|
removeMember: vi.fn(),
|
|
getProjectMe: vi.fn(),
|
|
},
|
|
}))
|
|
vi.mock('@shumai/core/src/asset/asset')
|
|
|
|
vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
|
|
auditLogService: {
|
|
logAction: vi.fn().mockResolvedValue({}),
|
|
listAuditLogs: vi.fn().mockResolvedValue({ nodes: [], pageInfo: {}, total: 0 }),
|
|
},
|
|
}))
|
|
|
|
describe('project api', () => {
|
|
const app = new Hono<{ Variables: { user: { id: string; name: string } } }>()
|
|
.use('*', async (c, next) => {
|
|
c.set('user', { id: 'user1', name: 'Test User' })
|
|
await next()
|
|
})
|
|
.route('/', projectRoute)
|
|
|
|
beforeEach(() => {
|
|
vi.restoreAllMocks()
|
|
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
|
|
})
|
|
|
|
it('GET /teams/:teamId/projects', async () => {
|
|
vi.mocked(projectService.listProjects).mockResolvedValue({
|
|
data: [{ id: 'foo', name: 'foo.png', rootFolder: 'uid' }] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
pageInfo: { total: 100, cursor: 'abc' },
|
|
})
|
|
|
|
const res = await app.request('/teams/t/projects?page_size=10')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data).toHaveLength(1)
|
|
expect(json.pageInfo.total).toBe(100)
|
|
expect(json.data[0].id).toBe('foo')
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Team,
|
|
id: 't',
|
|
})
|
|
})
|
|
|
|
it('GET /teams/:teamId/projects with previewFormat=jpeg', async () => {
|
|
vi.mocked(projectService.listProjects).mockResolvedValue({
|
|
data: [{ id: 'p1', name: 'p1', rootFolder: 'r1', coverImage: 'http://s3/p1.jpeg' }] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
pageInfo: { total: 1, cursor: 'abc' },
|
|
})
|
|
|
|
const res = await app.request('/teams/t/projects?previewFormat=jpeg')
|
|
|
|
expect(res.status).toBe(200)
|
|
expect(projectService.listProjects).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
teamId: 't',
|
|
previewFormat: 'jpeg',
|
|
}),
|
|
)
|
|
})
|
|
|
|
it('POST /teams/:teamId/projects', async () => {
|
|
vi.mocked(projectService.createProject).mockResolvedValue({
|
|
id: 'foo',
|
|
name: 'foo.png',
|
|
coverImage: 'http://s3/bucket/key',
|
|
} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const res = await app.request('/teams/t/projects', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ name: 'foo.png', coverImageKey: 'key' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.id).toBe('foo')
|
|
expect(json.name).toBe('foo.png')
|
|
expect(json.coverImage).toBe('http://s3/bucket/key')
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Team,
|
|
id: 't',
|
|
})
|
|
})
|
|
|
|
it('PUT /projects/:projectId', async () => {
|
|
vi.mocked(projectService.updateProject).mockResolvedValue({
|
|
id: 'foo',
|
|
name: 'updated',
|
|
coverImage: 'http://s3/bucket/key',
|
|
} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const res = await app.request('/projects/foo', {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ name: 'updated' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.name).toBe('updated')
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Project,
|
|
id: 'foo',
|
|
})
|
|
})
|
|
|
|
it('GET /projects/:projectId', async () => {
|
|
vi.mocked(projectService.getProject).mockResolvedValue({
|
|
id: 'p',
|
|
name: 'foo.png',
|
|
rootFolder: 'root_folder_id',
|
|
} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
|
const res = await app.request('/projects/p')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.rootFolder).toBe('root_folder_id')
|
|
expect(json.id).toBe('p')
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p',
|
|
})
|
|
})
|
|
|
|
it('GET /projects/:projectId/team', async () => {
|
|
vi.mocked(projectService.getProjectTeam).mockResolvedValue('teamId')
|
|
|
|
const res = await app.request('/projects/p/team')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.teamId).toBe('teamId')
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p',
|
|
})
|
|
})
|
|
|
|
it('POST /projects/:projectId/reparent', async () => {
|
|
vi.mocked(projectService.getProjectTeam).mockResolvedValue('t1')
|
|
vi.mocked(assetService.reparentAssets).mockResolvedValue(undefined)
|
|
|
|
const res = await app.request('/projects/p/reparent', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
newParentId: 'new_parent_id',
|
|
assetIds: ['asset_1', 'asset_2'],
|
|
}),
|
|
})
|
|
|
|
expect(res.status).toBe(204)
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'new_parent_id',
|
|
})
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'asset_1',
|
|
})
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Edit,
|
|
type: ResourceType.Asset,
|
|
id: 'asset_2',
|
|
})
|
|
expect(assetService.reparentAssets).toHaveBeenCalledWith({
|
|
newParentId: 'new_parent_id',
|
|
assetIds: ['asset_1', 'asset_2'],
|
|
creatorId: 'user1',
|
|
})
|
|
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
|
action: 'asset_reparent',
|
|
teamId: 't1',
|
|
userId: 'user1',
|
|
projectId: 'p',
|
|
itemId: 'asset_1',
|
|
})
|
|
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
|
action: 'asset_reparent',
|
|
teamId: 't1',
|
|
userId: 'user1',
|
|
projectId: 'p',
|
|
itemId: 'asset_2',
|
|
})
|
|
})
|
|
|
|
it('POST /projects/:projectId/copy', async () => {
|
|
vi.mocked(projectService.getProjectTeam).mockResolvedValue('t1')
|
|
vi.mocked(assetService.copyAssets).mockResolvedValue(undefined)
|
|
|
|
const res = await app.request('/projects/p/copy', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
newParentId: 'new_parent_id',
|
|
assetIds: ['asset_1'],
|
|
}),
|
|
})
|
|
|
|
expect(res.status).toBe(204)
|
|
expect(assetService.copyAssets).toHaveBeenCalledWith({
|
|
newParentId: 'new_parent_id',
|
|
assetIds: ['asset_1'],
|
|
withComments: false,
|
|
creatorId: 'user1',
|
|
})
|
|
expect(auditLogService.logAction).toHaveBeenCalledWith({
|
|
action: 'asset_copy',
|
|
teamId: 't1',
|
|
userId: 'user1',
|
|
projectId: 'p',
|
|
itemId: 'asset_1',
|
|
})
|
|
})
|
|
|
|
it('POST /projects/:projectId/empty-trash', async () => {
|
|
vi.mocked(assetService.emptyTrash).mockResolvedValue(undefined)
|
|
|
|
const res = await app.request('/projects/p1/empty-trash', {
|
|
method: 'POST',
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json).toEqual({ success: true })
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Admin,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(assetService.emptyTrash).toHaveBeenCalledWith('p1')
|
|
})
|
|
|
|
it('GET /projects/:projectId/members', async () => {
|
|
vi.mocked(projectService.listProjectMembers).mockResolvedValue([
|
|
{
|
|
id: 'user1',
|
|
name: 'Test User',
|
|
role: 'editor',
|
|
type: 'human',
|
|
},
|
|
])
|
|
|
|
const res = await app.request('/projects/p1/members')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json).toEqual([
|
|
{
|
|
id: 'user1',
|
|
name: 'Test User',
|
|
role: 'editor',
|
|
type: 'human',
|
|
},
|
|
])
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(projectService.listProjectMembers).toHaveBeenCalledWith({
|
|
projectId: 'p1',
|
|
includeAgents: false,
|
|
requesterUserId: 'user1',
|
|
})
|
|
})
|
|
|
|
it('GET /projects/:projectId/members?includeAgents=true', async () => {
|
|
vi.mocked(projectService.listProjectMembers).mockResolvedValue([
|
|
{
|
|
id: 'user1',
|
|
name: 'Test User',
|
|
role: 'editor',
|
|
type: 'human',
|
|
},
|
|
{
|
|
id: 'agent1',
|
|
name: 'Agent Bot',
|
|
role: 'bot',
|
|
type: 'agent',
|
|
},
|
|
])
|
|
|
|
const res = await app.request('/projects/p1/members?includeAgents=true')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json).toHaveLength(2)
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(projectService.listProjectMembers).toHaveBeenCalledWith({
|
|
projectId: 'p1',
|
|
includeAgents: true,
|
|
requesterUserId: 'user1',
|
|
})
|
|
})
|
|
|
|
it('POST /projects/:projectId/members', async () => {
|
|
vi.mocked(projectService.addProjectMember).mockResolvedValue(undefined)
|
|
|
|
const res = await app.request('/projects/p1/members', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ userId: 'user2', role: 'editor' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json).toEqual({ success: true })
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Admin,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(projectService.addProjectMember).toHaveBeenCalledWith({
|
|
projectId: 'p1',
|
|
userId: 'user2',
|
|
role: 'editor',
|
|
})
|
|
})
|
|
|
|
it('GET /projects/:projectId/me', async () => {
|
|
vi.mocked(projectService.getProjectMe).mockResolvedValue({
|
|
id: 'user1',
|
|
name: 'Test User',
|
|
role: 'editor',
|
|
})
|
|
|
|
const res = await app.request('/projects/p1/me')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json).toEqual({
|
|
id: 'user1',
|
|
name: 'Test User',
|
|
role: 'editor',
|
|
})
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(projectService.getProjectMe).toHaveBeenCalledWith('p1', 'user1')
|
|
})
|
|
|
|
it('GET /projects', async () => {
|
|
vi.mocked(projectService.getUserProjects).mockResolvedValue([
|
|
{
|
|
id: 'proj1',
|
|
name: 'My Project',
|
|
teamId: 'team1',
|
|
rootFolder: 'folder1',
|
|
enableNotification: true,
|
|
updatedAt: '2026-06-21T00:00:00.000Z',
|
|
},
|
|
] as unknown as ProjectInfo[])
|
|
|
|
const res = await app.request('/projects?first=10')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data).toHaveLength(1)
|
|
expect(json.data[0]).toEqual({
|
|
id: 'proj1',
|
|
name: 'My Project',
|
|
teamId: 'team1',
|
|
rootFolder: 'folder1',
|
|
enableNotification: true,
|
|
updatedAt: '2026-06-21T00:00:00.000Z',
|
|
})
|
|
expect(projectService.getUserProjects).toHaveBeenCalledWith('user1', 10)
|
|
})
|
|
|
|
it('GET /projects with previewFormat=jpeg', async () => {
|
|
vi.mocked(projectService.getUserProjects).mockResolvedValue([
|
|
{
|
|
id: 'proj1',
|
|
name: 'My Project',
|
|
teamId: 'team1',
|
|
rootFolder: 'folder1',
|
|
coverImage: 'http://s3/proj1.jpeg',
|
|
enableNotification: true,
|
|
updatedAt: '2026-06-21T00:00:00.000Z',
|
|
},
|
|
] as unknown as ProjectInfo[])
|
|
|
|
const res = await app.request('/projects?first=10&previewFormat=jpeg')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data[0].coverImage).toBe('http://s3/proj1.jpeg')
|
|
expect(projectService.getUserProjects).toHaveBeenCalledWith('user1', 10, 'jpeg')
|
|
})
|
|
|
|
it('GET /projects/:projectId/recents', async () => {
|
|
vi.mocked(assetService.listRecents).mockResolvedValue({
|
|
data: [{ id: 'file1', name: 'video.mp4', type: 'file' }] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
pageInfo: { total: 1 },
|
|
})
|
|
|
|
const res = await app.request('/projects/p1/recents?first=20')
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.data).toHaveLength(1)
|
|
expect(json.data[0].id).toBe('file1')
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(assetService.listRecents).toHaveBeenCalledWith('user1', 'p1', { first: 20 })
|
|
})
|
|
|
|
it('POST /projects/:projectId/recents/view', async () => {
|
|
vi.mocked(assetService.recordRecentView).mockResolvedValue(undefined)
|
|
|
|
const res = await app.request('/projects/p1/recents/view', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ assetId: 'file1' }),
|
|
})
|
|
|
|
expect(res.status).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.success).toBe(true)
|
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
|
user: expect.anything(),
|
|
permission: Permission.Read,
|
|
type: ResourceType.Project,
|
|
id: 'p1',
|
|
})
|
|
expect(assetService.recordRecentView).toHaveBeenCalledWith('user1', 'p1', 'file1')
|
|
})
|
|
})
|