fix(hub): restore project create payload and stabilize integration DB seed

Explorer POST /projects was dropping projectId/folderId/workspaceDir after a
narrowed response shape, breaking admin-explorer. Make seedTestOrganization
idempotent under shared-DB isolation, force single-worker vitest, and align the
OAuth no-membership redirect expectation with authRoutes.
This commit is contained in:
2026-07-30 14:44:11 +08:00
parent 0f4377f16c
commit ee928b5832
4 changed files with 52 additions and 37 deletions
+40 -31
View File
@@ -80,42 +80,51 @@ export async function seedTestOrganization(
id: string = DEFAULT_ORG_ID,
slug: string = "test-default",
): Promise<void> {
// Serialise generate+inbox against concurrent callers in the same process.
// Integration tests share one DB and some files call seed without resetDb.
await prisma.$transaction(async (tx) => {
await tx.organization.create({
data: {
id,
slug,
name: "Test Default Organization",
projectSettings: {
create: { membersCanCreateProjects: true },
},
agentRoles: {
create: {
id: `agent_role_draft_${id}`,
roleId: "draft",
label: "草稿",
sortOrder: 10,
isDefault: true,
const existing = await tx.organization.findUnique({
where: { id },
select: { id: true },
});
if (existing === null) {
await tx.organization.create({
data: {
id,
slug,
name: "Test Default Organization",
projectSettings: {
create: { membersCanCreateProjects: true },
},
agentRoles: {
create: {
id: `agent_role_draft_${id}`,
roleId: "draft",
label: "草稿",
sortOrder: 10,
isDefault: true,
},
},
},
},
});
}
const inbox = await tx.folder.findFirst({
where: { organizationId: id, kind: "SYSTEM_INBOX", archivedAt: null },
select: { id: true },
});
if (inbox === null) {
await tx.folder.create({
data: {
id: `folder_inbox_${id}`,
organizationId: id,
name: "Inbox",
kind: "SYSTEM_INBOX",
sortKey: "000000",
},
});
}
});
const inbox = await prisma.folder.findFirst({
where: { organizationId: id, kind: "SYSTEM_INBOX", archivedAt: null },
select: { id: true },
});
if (inbox === null) {
await prisma.folder.create({
data: {
id: `folder_inbox_${id}`,
organizationId: id,
name: "Inbox",
kind: "SYSTEM_INBOX",
sortKey: "000000",
},
});
}
}
/** A logger that discards everything (tests don't need fastify's pino). */