mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 22:38:43 +00:00
Add four project-level webapp e2e tests: - invite a member to a project; the invitee only sees the invited project - drag a file into a folder and a folder into another folder - drag a file onto a file to create a version stack - drag a file onto a version stack to add a new version Supporting changes: - expose rootFolderId on the project fixture - add seedFolder/seedFile helpers and a cross-browser dragCard helper (WebKit requires pointer moves in awaited batches for dnd-kit activation) - add project-members-trigger testid to the file-browser toolbar - document the new test cases in the e2e README
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { expect, test } from '../../fixtures'
|
|
import { seedFile } from '../../helpers/assets'
|
|
import { dragCard } from '../../helpers/dnd'
|
|
import { fileCard } from '../../helpers/files'
|
|
|
|
test('owner moves a file onto another file to create a version stack', async ({
|
|
project,
|
|
prisma,
|
|
}) => {
|
|
const { page, projectId, rootFolderId } = project
|
|
|
|
const fileA = await seedFile(prisma, projectId, rootFolderId, `e2e-stack-a-${Date.now()}`)
|
|
const fileB = await seedFile(prisma, projectId, rootFolderId, `e2e-stack-b-${Date.now()}`)
|
|
|
|
await page.goto(`/projects/${projectId}`)
|
|
await expect(fileCard(page, fileA.name)).toBeVisible()
|
|
await expect(fileCard(page, fileB.name)).toBeVisible()
|
|
|
|
// Drag file B onto file A -> a version stack is created with both files
|
|
await dragCard(page, fileCard(page, fileB.name), fileCard(page, fileA.name))
|
|
|
|
// The stack card shows the latest version's name (the dragged file) and a v2 badge;
|
|
// the original two file cards are gone from the folder
|
|
await expect(fileCard(page, fileB.name)).toBeVisible()
|
|
await expect(page.getByText('v2', { exact: true })).toBeVisible()
|
|
await expect(fileCard(page, fileA.name)).not.toBeVisible()
|
|
|
|
// DB: exactly one version stack in the project root with both files as versions
|
|
await expect
|
|
.poll(async () => {
|
|
return prisma.asset.count({
|
|
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
|
|
})
|
|
})
|
|
.toBe(1)
|
|
|
|
const stack = await prisma.asset.findFirstOrThrow({
|
|
where: { projectId, parentId: rootFolderId, type: 'version_stack' },
|
|
})
|
|
expect(stack.fileCount).toBe(2)
|
|
|
|
const versions = await prisma.asset.findMany({
|
|
where: { parentId: stack.id, type: 'file' },
|
|
orderBy: { sortIndex: 'asc' },
|
|
})
|
|
expect(versions).toHaveLength(2)
|
|
expect(new Set(versions.map((v) => v.id))).toEqual(new Set([fileA.id, fileB.id]))
|
|
})
|