mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 08:19:06 +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.
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import type { APIRequestContext, Locator, Page } from '@playwright/test'
|
|
|
|
interface CreateShareResponse {
|
|
id?: string
|
|
name?: string
|
|
}
|
|
|
|
/**
|
|
* Locates a file/folder card by its name. File names are rendered as
|
|
* `EditableText` inputs (not text nodes), so `getByText` does not match them.
|
|
* The returned locator points at the card wrapper div (right-clickable to open
|
|
* the card context menu).
|
|
*/
|
|
export function fileCard(page: Page, name: string): Locator {
|
|
return page
|
|
.locator('div.group')
|
|
.filter({ has: page.locator(`input[value="${name}"]`) })
|
|
.first()
|
|
}
|
|
|
|
/** Creates a share link through the API for the authenticated request context. */
|
|
export async function apiCreateShare(
|
|
request: APIRequestContext,
|
|
projectId: string,
|
|
name: string,
|
|
): Promise<{ id: string; name: string }> {
|
|
const res = await request.post(`/api/projects/${projectId}/shares`, {
|
|
data: { name },
|
|
})
|
|
if (!res.ok()) {
|
|
throw new Error(`Create share API failed (${res.status()}): ${await res.text()}`)
|
|
}
|
|
const body = (await res.json()) as CreateShareResponse
|
|
if (!body.id || !body.name) {
|
|
throw new Error(`Create share returned an unexpected response: ${JSON.stringify(body)}`)
|
|
}
|
|
return { id: body.id, name: body.name }
|
|
}
|
|
|
|
/** Adds assets to a share link through the API. */
|
|
export async function apiAddAssetsToShare(
|
|
request: APIRequestContext,
|
|
shareId: string,
|
|
assetIds: string[],
|
|
): Promise<void> {
|
|
const res = await request.post(`/api/shares/${shareId}/assets`, {
|
|
data: { assetIds },
|
|
})
|
|
if (!res.ok()) {
|
|
throw new Error(`Add assets to share API failed (${res.status()}): ${await res.text()}`)
|
|
}
|
|
}
|