feat: refactor and WIP add e2e tests

pull/715/head
Travis Fischer 2025-06-03 03:15:33 +07:00
rodzic 2c42715cce
commit 6b6f934911
3 zmienionych plików z 42 dodań i 35 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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()
}
)
}

Wyświetl plik

@ -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',