1 parent
afc37f8fdb
commit
c5691da2b8
47 files changed
+278
-9
No files matched your search
@@ -7,6 +7,7 @@ export class IssueWithUsersDto {
|
||||
content: string | null;
|
||||
status: string;
|
||||
priority: number;
|
||||
type: string;
|
||||
assigneeId: string | null;
|
||||
reporterId: string | null;
|
||||
assignee: UserDto | null;
|
||||
|
||||
@@ -5,6 +5,7 @@ export class IssueDto {
|
||||
content: string | null;
|
||||
status: string;
|
||||
priority: number;
|
||||
type: string;
|
||||
assigneeId: string | null;
|
||||
reporterId: string | null;
|
||||
projectId: string;
|
||||
|
||||
@@ -12,6 +12,7 @@ export class IssueApplicationMapper {
|
||||
content: issue.content,
|
||||
status: issue.status,
|
||||
priority: issue.priority,
|
||||
type: issue.type,
|
||||
assigneeId: issue.assignee,
|
||||
reporterId: issue.reporter,
|
||||
projectId: issue.projectId,
|
||||
@@ -30,6 +31,7 @@ export class IssueApplicationMapper {
|
||||
content: issue.content,
|
||||
status: issue.status,
|
||||
priority: issue.priority,
|
||||
type: issue.type,
|
||||
assigneeId: issue.assignee,
|
||||
reporterId: issue.reporter,
|
||||
assignee: issue.assignee ? (usersById.get(issue.assignee) ?? null) : null,
|
||||
|
||||
@@ -24,6 +24,7 @@ const buildIssue = (overrides: Partial<{ assignee: string | null; reporter: stri
|
||||
content: null,
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: 'assignee' in overrides ? (overrides.assignee ?? null) : 'user-2',
|
||||
reporter: overrides.reporter ?? 'user-1',
|
||||
projectId: 'project-1',
|
||||
|
||||
@@ -8,5 +8,6 @@ export class CreateIssueCommand {
|
||||
public readonly priority?: number,
|
||||
public readonly assignee?: string,
|
||||
public readonly dueDate?: Date,
|
||||
public readonly type?: string,
|
||||
) {}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ describe('CreateIssueUseCase', () => {
|
||||
content: issue.content,
|
||||
status: issue.status,
|
||||
priority: issue.priority,
|
||||
type: issue.type,
|
||||
assignee: issue.assignee,
|
||||
reporter: issue.reporter,
|
||||
projectId: issue.projectId,
|
||||
@@ -82,6 +83,7 @@ describe('CreateIssueUseCase', () => {
|
||||
title: 'Fix login bug',
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
reporterId: 'user-1',
|
||||
});
|
||||
});
|
||||
@@ -113,6 +115,7 @@ describe('CreateIssueUseCase', () => {
|
||||
content: issue.content,
|
||||
status: issue.status,
|
||||
priority: issue.priority,
|
||||
type: issue.type,
|
||||
assignee: issue.assignee,
|
||||
reporter: issue.reporter,
|
||||
projectId: issue.projectId,
|
||||
@@ -161,4 +164,26 @@ describe('CreateIssueUseCase', () => {
|
||||
|
||||
expect(notificationsService.notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('creates a TASK by default and accepts an explicit type', async () => {
|
||||
vi.mocked(repository.create).mockImplementation(async (issue) => issue);
|
||||
|
||||
const task = await useCase.execute(new CreateIssueCommand('ISSUE-4', 'Something', 'user-1', 'project-1'));
|
||||
const bug = await useCase.execute(
|
||||
new CreateIssueCommand(
|
||||
'ISSUE-5',
|
||||
'Crash on start',
|
||||
'user-1',
|
||||
'project-1',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'BUG',
|
||||
),
|
||||
);
|
||||
|
||||
expect(task.type).toBe('TASK');
|
||||
expect(bug.type).toBe('BUG');
|
||||
});
|
||||
});
|
||||
@@ -30,6 +30,7 @@ export class CreateIssueUseCase {
|
||||
title: command.title,
|
||||
content: command.content,
|
||||
priority: command.priority,
|
||||
type: command.type,
|
||||
assignee: command.assignee,
|
||||
reporter: command.reporter,
|
||||
projectId: command.projectId,
|
||||
|
||||
@@ -14,6 +14,7 @@ const buildIssue = () =>
|
||||
content: null,
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: null,
|
||||
reporter: 'user-1',
|
||||
projectId: 'project-1',
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ const buildIssue = () =>
|
||||
content: null,
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: 'user-2',
|
||||
reporter: 'user-1',
|
||||
projectId: 'project-1',
|
||||
|
||||
@@ -15,6 +15,7 @@ const buildIssue = () =>
|
||||
content: null,
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: 'user-2',
|
||||
reporter: 'user-1',
|
||||
projectId: 'project-1',
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ const buildIssue = (id: number) =>
|
||||
content: null,
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: null,
|
||||
reporter: 'user-1',
|
||||
projectId: 'project-1',
|
||||
|
||||
@@ -8,5 +8,6 @@ export class ListIssuesQuery {
|
||||
public readonly text?: string,
|
||||
public readonly assigneeId?: string,
|
||||
public readonly hasDueDate?: boolean,
|
||||
public readonly type?: string[],
|
||||
) {}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ const buildIssue = (id: number) =>
|
||||
content: null,
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: null,
|
||||
reporter: 'user-1',
|
||||
projectId: 'project-1',
|
||||
|
||||
@@ -23,6 +23,7 @@ export class ListIssuesUseCase {
|
||||
text: query.text,
|
||||
assigneeId: query.assigneeId,
|
||||
hasDueDate: query.hasDueDate,
|
||||
type: query.type,
|
||||
});
|
||||
|
||||
return { list: await this.issueUserExpander.expandAll(list), meta };
|
||||
|
||||
@@ -8,5 +8,6 @@ export class UpdateIssueCommand {
|
||||
public readonly priority?: number,
|
||||
public readonly assignee?: string | null,
|
||||
public readonly dueDate?: Date | null,
|
||||
public readonly type?: string,
|
||||
) {}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ const buildIssue = () =>
|
||||
content: 'Original content',
|
||||
status: 'OPEN',
|
||||
priority: 0,
|
||||
type: 'TASK',
|
||||
assignee: null,
|
||||
reporter: 'user-1',
|
||||
projectId: 'project-1',
|
||||
@@ -155,4 +156,14 @@ describe('UpdateIssueUseCase', () => {
|
||||
|
||||
expect(notificationsService.notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('changes the issue type', async () => {
|
||||
vi.mocked(repository.findById).mockResolvedValue(buildIssue());
|
||||
|
||||
const dto = await useCase.execute(
|
||||
new UpdateIssueCommand(1, 'user-1', undefined, undefined, undefined, undefined, undefined, undefined, 'BUG'),
|
||||
);
|
||||
|
||||
expect(dto.type).toBe('BUG');
|
||||
});
|
||||
});
|
||||
@@ -47,6 +47,10 @@ export class UpdateIssueUseCase {
|
||||
issue.changePriority(command.priority);
|
||||
}
|
||||
|
||||
if (command.type !== undefined) {
|
||||
issue.changeType(command.type);
|
||||
}
|
||||
|
||||
if (command.assignee !== undefined) {
|
||||
if (command.assignee === null || command.assignee === '') {
|
||||
issue.unassign();
|
||||
|
||||
Reference in new issue
Block a user