mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 03:26:53 +00:00
Add six domain-level web app e2e tests covering team member removal, file upload/delete/restore, share link creation and password protection, and collection creation. Introduce a parametrized 'file' fixture with configurable media types (text/binary/image/video/pdf) for future type-scoped tests, plus helpers for share APIs and team member seeding. Also document all web app e2e test cases in apps/web/e2e/README.md and require this documentation in AGENTS.md.
52 lines
2.2 KiB
TypeScript
52 lines
2.2 KiB
TypeScript
import { expect, test } from '../../fixtures'
|
|
import { apiAddAssetsToShare, apiCreateShare, fileCard } from '../../helpers/files'
|
|
|
|
test('owner protects a share with a password and guests must enter it to view', async ({
|
|
file,
|
|
browser,
|
|
prisma,
|
|
}) => {
|
|
const { context, page, projectId, fileName, fileId } = file
|
|
|
|
// Seed the share with the file through the API (setup, not the flow under test)
|
|
const share = await apiCreateShare(context.request, projectId, 'Shared Doc')
|
|
await apiAddAssetsToShare(context.request, share.id, [fileId])
|
|
|
|
await page.goto(`/projects/${projectId}/shares/${share.id}`)
|
|
await expect(fileCard(page, fileName)).toBeVisible()
|
|
|
|
// Open the Security accordion and enable a password
|
|
await page.getByRole('button', { name: 'Security' }).click()
|
|
const passwordRow = page.getByText('Password').locator('..')
|
|
await passwordRow.getByRole('switch').click()
|
|
|
|
const passwordInput = page.getByPlaceholder('Enter password')
|
|
await expect(passwordInput).toBeVisible()
|
|
await passwordInput.fill('secret123')
|
|
await page.getByRole('button', { name: 'Save' }).click()
|
|
await expect(page.getByText('Settings updated')).toBeVisible()
|
|
|
|
const saved = await prisma.shareLink.findUnique({ where: { id: share.id } })
|
|
expect(saved?.password).toBe('secret123')
|
|
|
|
// A guest visiting the public link hits the password gate
|
|
const guestContext = await browser.newContext()
|
|
const guestPage = await guestContext.newPage()
|
|
try {
|
|
await guestPage.goto(`/share/${share.id}`)
|
|
await expect(guestPage.getByText('Password Protected')).toBeVisible()
|
|
|
|
// Wrong password keeps the gate open with an error
|
|
await guestPage.getByPlaceholder('Enter password').fill('wrong-password')
|
|
await guestPage.getByRole('button', { name: 'Access Share' }).click()
|
|
await expect(guestPage.getByText('Incorrect password. Please try again.')).toBeVisible()
|
|
|
|
// Correct password grants access to the shared file
|
|
await guestPage.getByPlaceholder('Enter password').fill('secret123')
|
|
await guestPage.getByRole('button', { name: 'Access Share' }).click()
|
|
await expect(fileCard(guestPage, fileName)).toBeVisible()
|
|
} finally {
|
|
await guestContext.close()
|
|
}
|
|
})
|