forked from EduCraft/curriculum-project-hub
fix(hub): harden test org seed and run hub-check only on push
seedTestOrganization now wipes+creates instead of fragile upsert. hub-check drops pull_request triggers so push/PR pairs no longer double migrate against the runner; branch push status remains the gate.
This commit is contained in:
@@ -71,38 +71,33 @@ export async function resetDb(): Promise<void> {
|
||||
`);
|
||||
await seedTestOrganization();
|
||||
}
|
||||
|
||||
export async function seedTestOrganization(
|
||||
id: string = DEFAULT_ORG_ID,
|
||||
slug: string = "test-default",
|
||||
): Promise<void> {
|
||||
// Prefer explicit create-after-wipe over upsert: leftover half-states after
|
||||
// interrupted tests made Prisma upsert hit unique(id) while where saw zero.
|
||||
await prisma.$transaction(async (tx) => {
|
||||
await tx.organization.upsert({
|
||||
where: { id },
|
||||
update: {},
|
||||
create: { id, slug, name: "Test Default Organization" },
|
||||
});
|
||||
await tx.organizationProjectSettings.upsert({
|
||||
where: { organizationId: id },
|
||||
update: {},
|
||||
create: { organizationId: id, membersCanCreateProjects: true },
|
||||
});
|
||||
const defaultRole = await tx.organizationAgentRole.upsert({
|
||||
where: { organizationId_roleId: { organizationId: id, roleId: "draft" } },
|
||||
update: { label: "草稿", isDefault: true, disabledAt: null },
|
||||
create: {
|
||||
id: `agent_role_draft_${id}`,
|
||||
organizationId: id,
|
||||
roleId: "draft",
|
||||
label: "草稿",
|
||||
sortOrder: 10,
|
||||
isDefault: true,
|
||||
await tx.organization.deleteMany({ where: { OR: [{ id }, { slug }] } });
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await tx.organizationAgentRole.updateMany({
|
||||
where: { organizationId: id, id: { not: defaultRole.id }, isDefault: true },
|
||||
data: { isDefault: false },
|
||||
});
|
||||
});
|
||||
const inbox = await prisma.folder.findFirst({
|
||||
where: { organizationId: id, kind: "SYSTEM_INBOX", archivedAt: null },
|
||||
|
||||
Reference in New Issue
Block a user