S12 - turned schedule status into enum and some other review comments
All checks were successful
Build, test and publish / verify (push) Successful in 7m6s
All checks were successful
Build, test and publish / verify (push) Successful in 7m6s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { SchedulingRun, SchedulingStatus } from './scheduling-status';
|
||||
import { SchedulingRun, SchedulingState, SchedulingStatus } from './scheduling-status';
|
||||
|
||||
class FakeEventSource {
|
||||
static current: FakeEventSource;
|
||||
@@ -14,7 +14,7 @@ class FakeEventSource {
|
||||
}
|
||||
}
|
||||
|
||||
function run(state: string, runId = 'run-1'): SchedulingRun {
|
||||
function run(state: SchedulingState, runId = 'run-1'): SchedulingRun {
|
||||
return {
|
||||
runId,
|
||||
schoolId: 1,
|
||||
@@ -82,6 +82,19 @@ describe('Scheduling status over SSE', () => {
|
||||
expect(status.notifications()).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('announces a locally started run completed before the first SSE snapshot', () => {
|
||||
FakeEventSource.current.onerror?.();
|
||||
status.started(run('RUNNING'));
|
||||
vi.advanceTimersByTime(3000);
|
||||
FakeEventSource.current.send([run('OPTIMAL'), run('VALID', 'historical')]);
|
||||
expect(status.notifications().map((item) => item.runId)).toEqual(['run-1']);
|
||||
status.dismiss();
|
||||
FakeEventSource.current.onerror?.();
|
||||
vi.advanceTimersByTime(3000);
|
||||
FakeEventSource.current.send([run('OPTIMAL'), run('VALID', 'historical')]);
|
||||
expect(status.notifications()).toEqual([]);
|
||||
});
|
||||
|
||||
it('retains a fast completion when the start response arrives after SSE', () => {
|
||||
FakeEventSource.current.send([]);
|
||||
FakeEventSource.current.send([run('OPTIMAL')]);
|
||||
|
||||
Reference in New Issue
Block a user