mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 14:34:40 +00:00
feat(asset): Recently Deleted previews, retention countdown, and version stack delete/restore (#418)
* feat(asset): improve Recently Deleted previews and retention indicators - Include soft-deleted children when building folder previews for the Recently Deleted view, and resolve deleted version stacks to their latest version so a trashed folder shows what was inside it. - Add a "days left" badge (clock + Nd) to file and folder cards in the Recently Deleted view, placed to the left of the comments badge. - Fix an issue where deleting or restoring a version stack from the file list did nothing because the WebUI dropped version_stack items before calling the API. - Share the 30-day trash retention window through TRASH_RETENTION_DAYS. * test(asset): use typed MediaInfo in recently-deleted preview tests Replace the explicit any cast with a fully typed MediaInfo object so the new tests comply with the no-explicit-any policy.
This commit is contained in:
@@ -223,15 +223,16 @@ describe('FileCard', () => {
|
||||
|
||||
renderComponent({ item: itemWithComments })
|
||||
|
||||
const wrapper = screen.getByTestId('file-card-preview-badges')
|
||||
expect(wrapper.className).toContain('absolute')
|
||||
expect(wrapper.className).toContain('bottom-1')
|
||||
expect(wrapper.className).toContain('left-1')
|
||||
expect(wrapper.className).toContain('pointer-events-none')
|
||||
|
||||
const commentsBadge = screen.getByTestId('file-card-comments-count')
|
||||
expect(commentsBadge).toBeTruthy()
|
||||
expect(commentsBadge.textContent).toContain('5')
|
||||
expect(commentsBadge.className).toContain('absolute')
|
||||
expect(commentsBadge.className).toContain('bottom-1')
|
||||
expect(commentsBadge.className).toContain('left-1')
|
||||
expect(commentsBadge.className).toContain('bg-black/60')
|
||||
expect(commentsBadge.className).toContain('text-white')
|
||||
expect(commentsBadge.className).toContain('pointer-events-none')
|
||||
expect(commentsBadge.className).toContain('tabular-nums')
|
||||
})
|
||||
|
||||
@@ -253,4 +254,45 @@ describe('FileCard', () => {
|
||||
renderComponent({ item: itemNoComments })
|
||||
expect(screen.queryByTestId('file-card-comments-count')).toBeNull()
|
||||
})
|
||||
|
||||
it('renders the days-left badge in preview area for recently deleted items', () => {
|
||||
const deletedItem: AssetInfo = {
|
||||
...fileItem,
|
||||
deletedAt: new Date().toISOString(),
|
||||
} as AssetInfo
|
||||
|
||||
renderComponent({ item: deletedItem, isRecentlyDeleted: true })
|
||||
|
||||
const badge = screen.getByTestId('file-card-days-left')
|
||||
expect(badge.textContent).toMatch(/30\s*(d|天)/)
|
||||
})
|
||||
|
||||
it('places the comments badge to the right of the days-left badge', () => {
|
||||
const deletedItem: AssetInfo = {
|
||||
...fileItem,
|
||||
deletedAt: new Date().toISOString(),
|
||||
commentsCount: 3,
|
||||
} as AssetInfo
|
||||
|
||||
renderComponent({ item: deletedItem, isRecentlyDeleted: true })
|
||||
|
||||
const wrapper = screen.getByTestId('file-card-preview-badges')
|
||||
const order = Array.from(wrapper.children).map((child) => child.getAttribute('data-testid'))
|
||||
expect(order).toEqual(['file-card-days-left', 'file-card-comments-count'])
|
||||
})
|
||||
|
||||
it('does not render the days-left badge outside of recently deleted', () => {
|
||||
const deletedItem: AssetInfo = {
|
||||
...fileItem,
|
||||
deletedAt: new Date().toISOString(),
|
||||
} as AssetInfo
|
||||
|
||||
renderComponent({ item: deletedItem, isRecentlyDeleted: false })
|
||||
expect(screen.queryByTestId('file-card-days-left')).toBeNull()
|
||||
})
|
||||
|
||||
it('does not render the days-left badge when deletedAt is missing', () => {
|
||||
renderComponent({ item: fileItem, isRecentlyDeleted: true })
|
||||
expect(screen.queryByTestId('file-card-days-left')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user