kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: refactor and WIP add e2e tests
rodzic
2c42715cce
commit
6b6f934911
|
@ -69,12 +69,32 @@ export function registerV1DeploymentsCreateDeployment(
|
||||||
`Invalid project identifier "${projectIdentifier}"`
|
`Invalid project identifier "${projectIdentifier}"`
|
||||||
)
|
)
|
||||||
|
|
||||||
const project = await db.query.projects.findFirst({
|
let project = await db.query.projects.findFirst({
|
||||||
where: eq(schema.projects.identifier, projectIdentifier),
|
where: eq(schema.projects.identifier, projectIdentifier),
|
||||||
with: {
|
with: {
|
||||||
lastPublishedDeployment: true
|
lastPublishedDeployment: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!project) {
|
||||||
|
// Upsert the project if it doesn't already exist
|
||||||
|
// The typecast doesn't match exactly here because we're not populating
|
||||||
|
// the lastPublishedDeployment, but that's fine because it's a new project
|
||||||
|
// so it will be empty anyway.
|
||||||
|
project = (
|
||||||
|
await db
|
||||||
|
.insert(schema.projects)
|
||||||
|
.values({
|
||||||
|
name: body.name,
|
||||||
|
identifier: projectIdentifier,
|
||||||
|
userId: user.id,
|
||||||
|
teamId: teamMember?.teamId,
|
||||||
|
_secret: await sha256()
|
||||||
|
})
|
||||||
|
.returning()
|
||||||
|
)[0] as typeof project
|
||||||
|
}
|
||||||
|
|
||||||
assert(project, 404, `Project not found "${projectIdentifier}"`)
|
assert(project, 404, `Project not found "${projectIdentifier}"`)
|
||||||
await acl(c, project, { label: 'Project' })
|
await acl(c, project, { label: 'Project' })
|
||||||
const projectId = project.id
|
const projectId = project.id
|
||||||
|
|
|
@ -14,7 +14,8 @@ const fixtures = [
|
||||||
'pricing-pay-as-you-go',
|
'pricing-pay-as-you-go',
|
||||||
'pricing-3-plans',
|
'pricing-3-plans',
|
||||||
'pricing-monthly-annual',
|
'pricing-monthly-annual',
|
||||||
'pricing-custom-0'
|
'pricing-custom-0',
|
||||||
|
'basic-openapi'
|
||||||
]
|
]
|
||||||
|
|
||||||
const fixturesDir = path.join(
|
const fixturesDir = path.join(
|
||||||
|
@ -27,10 +28,13 @@ const fixturesDir = path.join(
|
||||||
'fixtures'
|
'fixtures'
|
||||||
)
|
)
|
||||||
const validFixturesDir = path.join(fixturesDir, 'valid')
|
const validFixturesDir = path.join(fixturesDir, 'valid')
|
||||||
console.log(validFixturesDir)
|
|
||||||
|
|
||||||
describe('loadAgenticConfig', () => {
|
const client = new AgenticApiClient({
|
||||||
for (const fixture of fixtures) {
|
apiBaseUrl: process.env.AGENTIC_API_BASE_URL
|
||||||
|
})
|
||||||
|
await client.setRefreshAuthToken(process.env.AGENTIC_API_REFRESH_TOKEN!)
|
||||||
|
|
||||||
|
for (const fixture of fixtures) {
|
||||||
test(
|
test(
|
||||||
`${fixture}`,
|
`${fixture}`,
|
||||||
{
|
{
|
||||||
|
@ -43,21 +47,4 @@ describe('loadAgenticConfig', () => {
|
||||||
expect(config).toMatchSnapshot()
|
expect(config).toMatchSnapshot()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const fixture of invalidFixtures) {
|
|
||||||
test(
|
|
||||||
`invalid: ${fixture}`,
|
|
||||||
{
|
|
||||||
timeout: 60_000
|
|
||||||
},
|
|
||||||
async () => {
|
|
||||||
const fixtureDir = path.join(invalidFixturesDir, fixture)
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
loadAgenticConfig({ cwd: fixtureDir })
|
|
||||||
).rejects.toThrowErrorMatchingSnapshot()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['packages/cli/src/**/*.ts'],
|
files: ['packages/cli/src/**/*.ts', '**/*.test.ts'],
|
||||||
rules: {
|
rules: {
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
'no-process-env': 'off',
|
'no-process-env': 'off',
|
||||||
|
|
Ładowanie…
Reference in New Issue