test: add test infrastructure for frontend and server
- Frontend: vitest.config.ts with vue plugin + jsdom, dummy component test - Server: in-memory SQLite test DB factory + Hono testClient helper + smoke test - CI: add pnpm audit and server coverage threshold steps - Root: vitest workspace config for multi-project test discovery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6f0eb92ebb
commit
d9e32123fe
@@ -0,0 +1,35 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { createTestDb, insertTestBot } from './db.js'
|
||||
|
||||
describe('test helpers', () => {
|
||||
it('creates in-memory DB, inserts a bot, and queries it back', () => {
|
||||
const { db, schema } = createTestDb()
|
||||
|
||||
const bot = insertTestBot(db, { name: 'SatoshiBot' })
|
||||
|
||||
const found = db
|
||||
.select()
|
||||
.from(schema.bots)
|
||||
.where(eq(schema.bots.id, bot.id))
|
||||
.get()
|
||||
|
||||
expect(found).toBeDefined()
|
||||
expect(found!.name).toBe('SatoshiBot')
|
||||
expect(found!.eloRating).toBe(1200)
|
||||
expect(found!.webhookUrl).toBe('http://test.local/webhook')
|
||||
})
|
||||
|
||||
it('each createTestDb is isolated', () => {
|
||||
const { db: db1, schema: s1 } = createTestDb()
|
||||
const { db: db2, schema: s2 } = createTestDb()
|
||||
|
||||
insertTestBot(db1, { name: 'BotInDb1' })
|
||||
|
||||
const inDb1 = db1.select().from(s1.bots).all()
|
||||
const inDb2 = db2.select().from(s2.bots).all()
|
||||
|
||||
expect(inDb1).toHaveLength(1)
|
||||
expect(inDb2).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user