mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 13:34:33 +00:00
feat(storage): add archive storage support for assets (#514)
* feat(storage): add archive storage support for assets * fix(webui): show archive icon in front of file name in breadcrumb bar * fix(webui): display archive icon in breadcrumbs when restoring * refactor(transcode): simplify restore asset workflow to single while loop * docs(configuration): add archive storage documentation and readme entries * fix(webui): show archive icon in front of version names and prevent version card overflow * fix(webui): fix overflow in manage versions dialog scroll area * fix(webui): prevent manage versions dialog overflow on long file names * docs(configuration): fix archive storage environment variables and defaults * fix(storage): address code review findings for archive storage
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { expect, test } from '../../fixtures'
|
||||
import { fileCard } from '../../helpers/files'
|
||||
|
||||
test('owner archives a file to archive storage and restores it back to main storage', async ({
|
||||
file,
|
||||
prisma,
|
||||
}) => {
|
||||
const { page, projectId, fileName, fileId } = file
|
||||
|
||||
await page.goto(`/projects/${projectId}`)
|
||||
const card = fileCard(page, fileName)
|
||||
await expect(card).toBeVisible()
|
||||
|
||||
// 1. Archive via context menu + confirmation dialog
|
||||
await card.click({ button: 'right' })
|
||||
await page.getByTestId('context-menu-archive').click()
|
||||
|
||||
const confirmDialog = page.getByTestId('archive-confirm-dialog')
|
||||
await expect(confirmDialog).toBeVisible()
|
||||
await page.getByTestId('archive-confirm-submit').click()
|
||||
|
||||
// Wait for the DBOS archive workflow to finish and the card badge to settle to Archived
|
||||
await expect(card.getByTestId('file-card-archived-badge')).toBeVisible({ timeout: 15000 })
|
||||
|
||||
const archivedAsset = await prisma.asset.findUniqueOrThrow({
|
||||
where: { id: fileId },
|
||||
include: { storageKey: true },
|
||||
})
|
||||
expect(archivedAsset.status).toBe('archived')
|
||||
expect(archivedAsset.storageKey?.isArchived).toBe(true)
|
||||
|
||||
// 2. Open detail page and verify Archived header badge + disabled original download button
|
||||
await card.dblclick()
|
||||
await expect(page.getByTestId('detail-header-archived-badge')).toBeVisible()
|
||||
await expect(page.getByTestId('default-viewer-download-button')).toBeDisabled()
|
||||
|
||||
// 3. Return to project file list and restore from archive
|
||||
await page.goto(`/projects/${projectId}`)
|
||||
await expect(card.getByTestId('file-card-archived-badge')).toBeVisible()
|
||||
|
||||
await card.click({ button: 'right' })
|
||||
await page.getByTestId('context-menu-restore-archive').click()
|
||||
|
||||
await expect(confirmDialog).toBeVisible()
|
||||
await page.getByTestId('archive-confirm-submit').click()
|
||||
|
||||
// Wait for the DBOS restore workflow to finish and the Archived badge to disappear
|
||||
await expect(card.getByTestId('file-card-archived-badge')).not.toBeVisible({ timeout: 15000 })
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const restored = await prisma.asset.findUnique({
|
||||
where: { id: fileId },
|
||||
include: { storageKey: true },
|
||||
})
|
||||
return {
|
||||
status: restored?.status,
|
||||
isArchived: restored?.storageKey?.isArchived,
|
||||
}
|
||||
},
|
||||
{ timeout: 10000 },
|
||||
)
|
||||
.toEqual({ status: 'processed', isArchived: false })
|
||||
})
|
||||
@@ -231,3 +231,76 @@ test('moving a shared file into a shared version stack leaves only 1 stack card
|
||||
const updatedShareRoot = await prisma.asset.findUnique({ where: { id: share.rootFolderId } })
|
||||
expect(updatedShareRoot?.fileCount).toBe(1)
|
||||
})
|
||||
|
||||
test('manage versions dialog constrains card width and truncates long file names without dialog overflow', async ({
|
||||
project,
|
||||
prisma,
|
||||
}) => {
|
||||
const { page, projectId, rootFolderId } = project
|
||||
|
||||
const longName =
|
||||
'super-extremely-long-asset-name-for-testing-manage-versions-dialog-card-overflow-issue-that-keeps-expanding-without-truncating-properly.mp4'
|
||||
const fileA = await seedFile(prisma, projectId, rootFolderId, longName)
|
||||
const fileB = await seedFile(prisma, projectId, rootFolderId, `short-${Date.now()}.mp4`)
|
||||
|
||||
await page.goto(`/projects/${projectId}`)
|
||||
await expect(fileCard(page, fileA.name)).toBeVisible()
|
||||
await expect(fileCard(page, fileB.name)).toBeVisible()
|
||||
|
||||
// Create version stack: drag B on A
|
||||
await dragCard(page, fileCard(page, fileB.name), fileCard(page, fileA.name))
|
||||
await expect(page.getByText('v2', { exact: true })).toBeVisible()
|
||||
|
||||
const stack = await prisma.asset.findFirstOrThrow({
|
||||
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
|
||||
})
|
||||
|
||||
// Navigate to file viewer for the stack
|
||||
await page.goto(`/projects/${projectId}/files/${stack.id}`)
|
||||
|
||||
// Open breadcrumb menu and click "Manage versions..."
|
||||
await page.getByRole('button', { name: new RegExp(fileB.name) }).click()
|
||||
await page.getByRole('menuitem', { name: 'Versions', exact: true }).hover()
|
||||
await page.getByRole('button', { name: /manage versions$/i }).click()
|
||||
|
||||
const dialog = page.getByRole('dialog')
|
||||
await expect(dialog).toBeVisible()
|
||||
|
||||
const rowA = dialog.locator('div.group', { hasText: longName })
|
||||
await expect(rowA).toBeVisible()
|
||||
|
||||
// Measure the dialog and version row
|
||||
const metrics = await page.evaluate(() => {
|
||||
const dialogEl = document.querySelector('[role="dialog"]') as HTMLElement | null
|
||||
if (!dialogEl) return null
|
||||
const row = dialogEl.querySelector('div.group') as HTMLElement | null
|
||||
return {
|
||||
dialogScrollWidth: dialogEl.scrollWidth,
|
||||
dialogClientWidth: dialogEl.clientWidth,
|
||||
dialogOffsetWidth: dialogEl.offsetWidth,
|
||||
rowScrollWidth: row?.scrollWidth,
|
||||
rowClientWidth: row?.clientWidth,
|
||||
}
|
||||
})
|
||||
|
||||
expect(metrics).not.toBeNull()
|
||||
// Dialog should not horizontally scroll or overflow
|
||||
expect(metrics!.dialogScrollWidth).toBeLessThanOrEqual(metrics!.dialogClientWidth)
|
||||
// Row clientWidth should be bounded within the dialog
|
||||
expect(metrics!.rowClientWidth).toBeLessThanOrEqual(metrics!.dialogClientWidth)
|
||||
expect(metrics!.rowScrollWidth).toBeLessThanOrEqual(metrics!.rowClientWidth!)
|
||||
|
||||
// Hover over the row and verify the more-options button is visible and within bounds
|
||||
await rowA.hover()
|
||||
const moreButton = rowA.getByRole('button', { name: 'More options' })
|
||||
await expect(moreButton).toBeVisible()
|
||||
const moreBtnBox = await moreButton.boundingBox()
|
||||
const dialogBox = await dialog.boundingBox()
|
||||
expect(moreBtnBox).not.toBeNull()
|
||||
expect(dialogBox).not.toBeNull()
|
||||
expect(moreBtnBox!.x + moreBtnBox!.width).toBeLessThanOrEqual(dialogBox!.x + dialogBox!.width)
|
||||
|
||||
// Click more options button and verify menu opens
|
||||
await moreButton.click()
|
||||
await expect(page.getByRole('menuitem', { name: /remove from stack/i })).toBeVisible()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user