feat: a trash for tickets

Deleting a ticket now sends it to the trash, for whoever opened it or an
admin: it disappears from boards, searches and statistics, cannot change,
and comes back from the ticket page or the trash page for 30 days. After
that it is deleted for good with the usual cascade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 18:47:30 +02:00
parent 71b807b94b
commit bec39da46d
49 changed files with 1671 additions and 9 deletions

View File

@@ -78,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 { RestoreIssueCommand, TrashIssueCommand } from './trash';
import { BulkResult, BulkUpdateIssuesCommand } from './bulk-update-issues';
import { UpdateProjectSettingsCommand } from './update-project-settings.command';
import { ReadAccess } from '../queries/read-access';
@@ -666,6 +667,24 @@ describe('tracker commands (event sourced)', () => {
).rejects.toThrow(/Nothing to change/);
});
it('sends tickets to the trash and back; trashed ones cannot change', async () => {
const { run, rehydrator } = await setup();
const projectId = await projectWithTeam(run);
const issue = await run(
new CreateIssueCommand('qa', projectId, IssueType.BUG, 'Crash', {}),
);
await expect(run(new TrashIssueCommand('dev', issue.id))).rejects.toThrow(
ForbiddenError,
);
await run(new TrashIssueCommand('qa', issue.id));
await expect(
run(new AssignIssueCommand('owner', issue.id, 'dev')),
).rejects.toThrow(/trash/);
await run(new RestoreIssueCommand('owner', issue.id));
await run(new AssignIssueCommand('owner', issue.id, 'dev'));
expect((await rehydrator.rehydrate(issue.id, Issue)).trashedAt).toBeNull();
});
it('does not let viewers modify tickets', async () => {
const { run } = await setup();
const projectId = await projectWithTeam(run);