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:
2026-07-30 14:05:22 +08:00
parent 0ebfeb927a
commit 751d0c4100
+14 -19
View File
@@ -71,37 +71,32 @@ export async function resetDb(): Promise<void> {
`); `);
await seedTestOrganization(); await seedTestOrganization();
} }
export async function seedTestOrganization( export async function seedTestOrganization(
id: string = DEFAULT_ORG_ID, id: string = DEFAULT_ORG_ID,
slug: string = "test-default", slug: string = "test-default",
): Promise<void> { ): 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 prisma.$transaction(async (tx) => {
await tx.organization.upsert({ await tx.organization.deleteMany({ where: { OR: [{ id }, { slug }] } });
where: { id }, await tx.organization.create({
update: {}, data: {
create: { id, slug, name: "Test Default Organization" }, id,
}); slug,
await tx.organizationProjectSettings.upsert({ name: "Test Default Organization",
where: { organizationId: id }, projectSettings: {
update: {}, create: { membersCanCreateProjects: true },
create: { organizationId: id, membersCanCreateProjects: true }, },
}); agentRoles: {
const defaultRole = await tx.organizationAgentRole.upsert({
where: { organizationId_roleId: { organizationId: id, roleId: "draft" } },
update: { label: "草稿", isDefault: true, disabledAt: null },
create: { create: {
id: `agent_role_draft_${id}`, id: `agent_role_draft_${id}`,
organizationId: id,
roleId: "draft", roleId: "draft",
label: "草稿", label: "草稿",
sortOrder: 10, sortOrder: 10,
isDefault: true, isDefault: true,
}, },
}); },
await tx.organizationAgentRole.updateMany({ },
where: { organizationId: id, id: { not: defaultRole.id }, isDefault: true },
data: { isDefault: false },
}); });
}); });
const inbox = await prisma.folder.findFirst({ const inbox = await prisma.folder.findFirst({