diff --git a/src-ui/src/app/services/task-notification.service.spec.ts b/src-ui/src/app/services/task-notification.service.spec.ts index 2cd5b1c700..6399c38d40 100644 --- a/src-ui/src/app/services/task-notification.service.spec.ts +++ b/src-ui/src/app/services/task-notification.service.spec.ts @@ -45,7 +45,7 @@ describe('TaskNotificationService', () => { jest.useRealTimers() }) - it('replaces a queued notification with its result, retaining the task link', () => { + it('replaces a queued notification with its result, removing the task link on success', () => { service.showQueued('task-1', 'Workflow queued.', { content: 'Workflow completed.', }) @@ -53,6 +53,11 @@ describe('TaskNotificationService', () => { expect(popups).toHaveLength(0) jest.advanceTimersByTime(1) expect(popups[0].content).toBe('Workflow queued.') + expect(popups[0].actionName).toBe('View task') + popups[0].action() + expect(navigate).toHaveBeenCalledWith(['/tasks'], { + queryParams: { task_id: 'task-1' }, + }) service.complete(result()) expect(notifications).toHaveLength(1) expect(popups[1]).toEqual( @@ -60,13 +65,10 @@ describe('TaskNotificationService', () => { id: popups[0].id, content: 'Workflow completed.', level: ToastLevel.Success, - actionName: 'View task', }) ) - popups[1].action() - expect(navigate).toHaveBeenCalledWith(['/tasks'], { - queryParams: { task_id: 'task-1' }, - }) + expect(popups[1].action).toBeUndefined() + expect(popups[1].actionName).toBeUndefined() }) it('shows only the result when a task completes during the grace period', () => { @@ -90,6 +92,7 @@ describe('TaskNotificationService', () => { ) expect(notifications).toHaveLength(1) expect(notifications[0].content).toBe('Workflow completed.') + expect(notifications[0].action).toBeUndefined() }) it.each([PaperlessTaskStatus.Failure, PaperlessTaskStatus.Revoked])( diff --git a/src-ui/src/app/services/task-notification.service.ts b/src-ui/src/app/services/task-notification.service.ts index 65eab3ba8b..1e760a1208 100644 --- a/src-ui/src/app/services/task-notification.service.ts +++ b/src-ui/src/app/services/task-notification.service.ts @@ -95,7 +95,7 @@ export class TaskNotificationService implements OnDestroy { ) this.toastService.show({ id: `task-${taskId}`, - ...(canViewTasks + ...(canViewTasks && toast.level !== ToastLevel.Success ? { actionName: $localize`View task`, action: () =>