diff --git a/apps/api/src/api-v1/deployments/create-deployment.ts b/apps/api/src/api-v1/deployments/create-deployment.ts index 6bb1e2fb..7062ab80 100644 --- a/apps/api/src/api-v1/deployments/create-deployment.ts +++ b/apps/api/src/api-v1/deployments/create-deployment.ts @@ -69,12 +69,32 @@ export function registerV1DeploymentsCreateDeployment( `Invalid project identifier "${projectIdentifier}"` ) - const project = await db.query.projects.findFirst({ + let project = await db.query.projects.findFirst({ where: eq(schema.projects.identifier, projectIdentifier), with: { 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}"`) await acl(c, project, { label: 'Project' }) const projectId = project.id diff --git a/apps/e2e/src/e2e.test.ts b/apps/e2e/src/e2e.test.ts index 923cbfdc..53d6afb8 100644 --- a/apps/e2e/src/e2e.test.ts +++ b/apps/e2e/src/e2e.test.ts @@ -14,7 +14,8 @@ const fixtures = [ 'pricing-pay-as-you-go', 'pricing-3-plans', 'pricing-monthly-annual', - 'pricing-custom-0' + 'pricing-custom-0', + 'basic-openapi' ] const fixturesDir = path.join( @@ -27,37 +28,23 @@ const fixturesDir = path.join( 'fixtures' ) const validFixturesDir = path.join(fixturesDir, 'valid') -console.log(validFixturesDir) -describe('loadAgenticConfig', () => { - for (const fixture of fixtures) { - test( - `${fixture}`, - { - timeout: 60_000 - }, - async () => { - const fixtureDir = path.join(validFixturesDir, fixture) - - const config = await loadAgenticConfig({ cwd: fixtureDir }) - 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() - } - ) - } +const client = new AgenticApiClient({ + apiBaseUrl: process.env.AGENTIC_API_BASE_URL }) +await client.setRefreshAuthToken(process.env.AGENTIC_API_REFRESH_TOKEN!) + +for (const fixture of fixtures) { + test( + `${fixture}`, + { + timeout: 60_000 + }, + async () => { + const fixtureDir = path.join(validFixturesDir, fixture) + + const config = await loadAgenticConfig({ cwd: fixtureDir }) + expect(config).toMatchSnapshot() + } + ) +} diff --git a/eslint.config.js b/eslint.config.js index e6e0ffad..ec4d424c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -18,7 +18,7 @@ export default [ } }, { - files: ['packages/cli/src/**/*.ts'], + files: ['packages/cli/src/**/*.ts', '**/*.test.ts'], rules: { 'no-console': 'off', 'no-process-env': 'off',