Files
shumai/apps/web/e2e/helpers/team.ts
T
yiling 3789366d35 test(e2e): add file, share, and collection web app e2e tests
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.
2026-08-03 16:34:37 +08:00

27 lines
781 B
TypeScript

import type { PrismaClient } from '../../../../packages/db/src/generated/prisma/client'
import { uniqueEmail } from './auth'
export interface SeededMember {
userId: string
email: string
}
/**
* Seeds a new user with a team membership of the given role directly through
* the database (fast, no UI). The user is not authenticated.
*/
export async function seedTeamMember(
prisma: PrismaClient,
teamId: string,
role: 'owner' | 'editor' | 'reviewer',
): Promise<SeededMember> {
const email = uniqueEmail(`member-${role}`)
const user = await prisma.user.create({
data: { name: email, email, password: 'Password123!' },
})
await prisma.teamMember.create({
data: { teamId, userId: user.id, role, scope: 'team' },
})
return { userId: user.id, email }
}