mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat(focusMode): select task instead of auto starting one
This commit is contained in:
parent
7c900b2cd5
commit
7fb5317808
2 changed files with 6 additions and 71 deletions
|
|
@ -52,13 +52,9 @@ describe('FocusModeMainComponent', () => {
|
|||
});
|
||||
|
||||
currentTaskSubject = new BehaviorSubject<TaskCopy | null>(mockTask);
|
||||
const taskServiceSpy = jasmine.createSpyObj(
|
||||
'TaskService',
|
||||
['update', 'startFirstStartable'],
|
||||
{
|
||||
currentTask$: currentTaskSubject.asObservable(),
|
||||
},
|
||||
);
|
||||
const taskServiceSpy = jasmine.createSpyObj('TaskService', ['update'], {
|
||||
currentTask$: currentTaskSubject.asObservable(),
|
||||
});
|
||||
|
||||
const taskAttachmentServiceSpy = jasmine.createSpyObj('TaskAttachmentService', [
|
||||
'createFromDrop',
|
||||
|
|
@ -124,62 +120,6 @@ describe('FocusModeMainComponent', () => {
|
|||
expect(component.defaultTaskNotes).toBe('Default task notes template');
|
||||
});
|
||||
|
||||
it('should start first startable task if no current task', () => {
|
||||
// Create a new test setup with null task
|
||||
const nullTaskSubject = new BehaviorSubject<TaskCopy | null>(null);
|
||||
const taskServiceWithNull = jasmine.createSpyObj(
|
||||
'TaskService',
|
||||
['update', 'startFirstStartable'],
|
||||
{
|
||||
currentTask$: nullTaskSubject.asObservable(),
|
||||
},
|
||||
);
|
||||
|
||||
// Use the existing mocked services
|
||||
const globalConfigSpy = jasmine.createSpyObj('GlobalConfigService', [], {
|
||||
misc: jasmine.createSpy().and.returnValue({
|
||||
taskNotesTpl: 'Default task notes template',
|
||||
}),
|
||||
});
|
||||
|
||||
const focusModeSpy = jasmine.createSpyObj('FocusModeService', [], {
|
||||
timeElapsed: jasmine.createSpy().and.returnValue(60000),
|
||||
isCountTimeDown: jasmine.createSpy().and.returnValue(true),
|
||||
progress: jasmine.createSpy().and.returnValue(0),
|
||||
timeRemaining: jasmine.createSpy().and.returnValue(1500000),
|
||||
isSessionRunning: jasmine.createSpy().and.returnValue(false),
|
||||
isBreakActive: jasmine.createSpy().and.returnValue(false),
|
||||
currentCycle: jasmine.createSpy().and.returnValue(1),
|
||||
mode: jasmine.createSpy().and.returnValue('Pomodoro'),
|
||||
});
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FocusModeMainComponent,
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
providers: [
|
||||
{ provide: Store, useValue: mockStore },
|
||||
{ provide: GlobalConfigService, useValue: globalConfigSpy },
|
||||
{ provide: TaskService, useValue: taskServiceWithNull },
|
||||
{ provide: TaskAttachmentService, useValue: mockTaskAttachmentService },
|
||||
{ provide: IssueService, useValue: mockIssueService },
|
||||
{
|
||||
provide: SimpleCounterService,
|
||||
useValue: jasmine.createSpyObj('SimpleCounterService', ['']),
|
||||
},
|
||||
{ provide: FocusModeService, useValue: focusModeSpy },
|
||||
],
|
||||
});
|
||||
|
||||
const nullFixture = TestBed.createComponent(FocusModeMainComponent);
|
||||
nullFixture.detectChanges();
|
||||
|
||||
expect(taskServiceWithNull.startFirstStartable).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should initialize focus mode service properties', () => {
|
||||
expect(component.timeElapsed()).toBe(60000);
|
||||
expect(component.isCountTimeDown()).toBe(true);
|
||||
|
|
|
|||
|
|
@ -115,15 +115,10 @@ export class FocusModeMainComponent implements OnDestroy {
|
|||
});
|
||||
this.taskService.currentTask$.pipe(takeUntil(this._onDestroy$)).subscribe((task) => {
|
||||
this.task = task;
|
||||
if (!task) {
|
||||
this._store.dispatch(selectFocusTask());
|
||||
}
|
||||
});
|
||||
|
||||
this.taskService.currentTask$
|
||||
.pipe(first(), takeUntil(this._onDestroy$))
|
||||
.subscribe((task) => {
|
||||
if (!task) {
|
||||
this.taskService.startFirstStartable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('dragenter', ['$event']) onDragEnter(ev: DragEvent): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue