You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
// apps/hq/test/milestones-templates.test.ts — per-module onboarding template resolution.
|
|
import { describe, it, expect, beforeEach } from 'vitest'
|
|
import { openDb, type DB } from '../src/db'
|
|
import { milestoneTemplate } from '../src/repos-milestones'
|
|
|
|
describe('per-module milestone templates', () => {
|
|
let db: DB
|
|
beforeEach(() => { db = openDb(':memory:') })
|
|
|
|
it('falls back to the global template when no module-specific one exists', async () => {
|
|
await db.run(`INSERT INTO setting (key, value) VALUES ('project.milestone_template', ?)`,
|
|
JSON.stringify([{ key: 'a', label: 'A' }]))
|
|
expect(await milestoneTemplate(db, 'SMS')).toEqual([{ key: 'a', label: 'A' }])
|
|
})
|
|
|
|
it('prefers the module-specific template over the global one', async () => {
|
|
await db.run(`INSERT INTO setting (key, value) VALUES ('project.milestone_template', ?)`,
|
|
JSON.stringify([{ key: 'a', label: 'A' }]))
|
|
await db.run(`INSERT INTO setting (key, value) VALUES ('project.milestone_template:SMS', ?)`,
|
|
JSON.stringify([{ key: 'doc', label: 'Document collection' }]))
|
|
expect(await milestoneTemplate(db, 'SMS')).toEqual([{ key: 'doc', label: 'Document collection' }])
|
|
// A different module still gets the global one.
|
|
expect(await milestoneTemplate(db, 'RTGS')).toEqual([{ key: 'a', label: 'A' }])
|
|
})
|
|
|
|
it('falls back to the code default when nothing is seeded', async () => {
|
|
const t = await milestoneTemplate(db, 'SMS')
|
|
expect(t.map((e) => e.key)).toContain('go_live')
|
|
})
|
|
})
|