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
+20 -25
View File
@@ -71,38 +71,33 @@ 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({ create: {
where: { organizationId_roleId: { organizationId: id, roleId: "draft" } }, id: `agent_role_draft_${id}`,
update: { label: "草稿", isDefault: true, disabledAt: null }, roleId: "draft",
create: { label: "草稿",
id: `agent_role_draft_${id}`, sortOrder: 10,
organizationId: id, isDefault: true,
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({ const inbox = await prisma.folder.findFirst({
where: { organizationId: id, kind: "SYSTEM_INBOX", archivedAt: null }, where: { organizationId: id, kind: "SYSTEM_INBOX", archivedAt: null },