bde148f286
* wip * some extra fixes * stuff kinda works? * need to figure out mocks * need to figure out mocks * fix db listener * gqlgen fix * minor gqlgen watch adjustment * lint fixes * delete old codegen file * converting migrations to ESM * getModuleDIrectory * vitest sort of works * added back ts-vitest * resolve gql double load * fixing test timeout configs * TSC lint fix * fix automate tests * moar debugging * debugging * more debugging * codegen update * server works * yargs migrated * chore(server): getting rid of global mocks for Server ESM (#5046) * got rid of email mock * got rid of comment mocks * got rid of multi region mocks * got rid of stripe mock * admin override mock updated * removed final mock * fixing import.meta.resolve calls * another import.meta.resolve fix * added requested test * nyc ESM fix * removed unneeded deps + linting * yarn lock forgot to commit * tryna fix flakyness * email capture util fix * sendEmail fix * fix TSX check * sender transporter fix + CR comments * merge main fix * test fixx * circleci fix * gqlgen bigint fix * error formatter fix * more error formatting improvements * esmloader added to Dockerfile * more dockerfile fixes * bg jobs fix
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import {
|
|
createBranchFactory,
|
|
getStreamBranchByNameFactory
|
|
} from '@/modules/core/repositories/branches'
|
|
import { createBranchAndNotifyFactory } from '@/modules/core/services/branch/management'
|
|
import { getProjectDbClient } from '@/modules/multiregion/utils/dbSelector'
|
|
import { getEventBus } from '@/modules/shared/services/eventBus'
|
|
import { BasicTestUser } from '@/test/authHelper'
|
|
import { BasicTestStream } from '@/test/speckle-helpers/streamHelper'
|
|
import { omit } from 'lodash-es'
|
|
|
|
export type BasicTestBranch = {
|
|
name: string
|
|
description?: string
|
|
/**
|
|
* The ID of the stream. Will be filled in by createTestBranch().
|
|
*/
|
|
streamId: string
|
|
/**
|
|
* The ID of the owner. Will be filled in by createTestBranch().
|
|
*/
|
|
authorId: string
|
|
|
|
/**
|
|
* The ID of the branch. Will be filled in by createTestBranch().
|
|
*/
|
|
id: string
|
|
}
|
|
|
|
export async function createTestBranch(params: {
|
|
branch: BasicTestBranch
|
|
stream: BasicTestStream
|
|
owner: BasicTestUser
|
|
}) {
|
|
const { branch, stream, owner } = params
|
|
branch.streamId = stream.id
|
|
branch.authorId = owner.id
|
|
|
|
const projectDb = await getProjectDbClient({ projectId: stream.id })
|
|
|
|
const createBranchAndNotify = createBranchAndNotifyFactory({
|
|
getStreamBranchByName: getStreamBranchByNameFactory({ db: projectDb }),
|
|
createBranch: createBranchFactory({ db: projectDb }),
|
|
eventEmit: getEventBus().emit
|
|
})
|
|
|
|
const id = (
|
|
await createBranchAndNotify(
|
|
{
|
|
...omit(branch, ['id']),
|
|
description: branch.description || null
|
|
},
|
|
owner.id
|
|
)
|
|
).id
|
|
branch.id = id
|
|
}
|
|
|
|
export async function createTestBranches(
|
|
branches: Array<Parameters<typeof createTestBranch>[0]>
|
|
) {
|
|
await Promise.all(branches.map((p) => createTestBranch(p)))
|
|
}
|