feat: templates per ticket type

Each ticket type can carry a starting description and a checklist, edited
in the project settings. New tickets of that type get the description
when they come without one and always get the checklist; the new ticket
form says what the template will add.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:58:37 +02:00
parent 8994590b54
commit 5863d773be
23 changed files with 565 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ import {
IssueType,
ProjectRole,
TRACKER_FACTORIES,
defaultProjectSettings,
} from '@task-stream/api/tracker/domain';
import {
FakeUserDirectory,
@@ -77,6 +78,7 @@ import { DeleteCommentCommand } from './delete-comment.command';
import { PublishReleaseCommand } from './publish-release.command';
import { SetIssueReleaseCommand } from './set-issue-release.command';
import { WriteAccess } from './write-access';
import { UpdateProjectSettingsCommand } from './update-project-settings.command';
import { ReadAccess } from '../queries/read-access';
import { FindProjectsRepository } from '../ports/find-projects.repository';
@@ -595,6 +597,35 @@ describe('tracker commands (event sourced)', () => {
).toBe('No sprint is under way');
});
it("fills a new ticket with its type's template", async () => {
const { run, rehydrator } = await setup();
const projectId = await projectWithTeam(run);
const settings = defaultProjectSettings();
settings.issueTypes[0].template = {
description: '## Pasos para reproducir',
checklist: ['Probar en Safari', 'Adjuntar captura'],
};
await run(new UpdateProjectSettingsCommand('owner', projectId, settings));
const plain = await run(
new CreateIssueCommand('qa', projectId, IssueType.BUG, 'Crash', {}),
);
const written = await run(
new CreateIssueCommand('qa', projectId, IssueType.BUG, 'Crash 2', {
description: 'Ya lo explico yo',
}),
);
const first = await rehydrator.rehydrate(plain.id, Issue);
expect(first.description).toBe('## Pasos para reproducir');
expect(first.checklist.map((i) => i.text)).toEqual([
'Probar en Safari',
'Adjuntar captura',
]);
expect((await rehydrator.rehydrate(written.id, Issue)).description).toBe(
'Ya lo explico yo',
);
});
it('does not let viewers modify tickets', async () => {
const { run } = await setup();
const projectId = await projectWithTeam(run);