@@ -149,6 +149,33 @@ describe('EditorDraftComponent', () => {
149149 expect ( component . draftText . editor ! . getContents ( ) . ops ) . toEqual ( draftDelta . ops ) ;
150150 } ) ) ;
151151
152+ it ( 'should support a timestamp earlier than the oldest draft' , fakeAsync ( ( ) => {
153+ const testProjectDoc : SFProjectProfileDoc = {
154+ data : createTestProjectProfile ( )
155+ } as SFProjectProfileDoc ;
156+ when ( mockDraftGenerationService . draftExists ( anything ( ) , anything ( ) , anything ( ) ) ) . thenReturn ( of ( true ) ) ;
157+ when ( mockDraftGenerationService . getGeneratedDraftHistory ( anything ( ) , anything ( ) , anything ( ) ) ) . thenReturn (
158+ of ( draftHistory )
159+ ) ;
160+ when ( mockActivatedProjectService . changes$ ) . thenReturn ( of ( testProjectDoc ) ) ;
161+ spyOn < any > ( component , 'getTargetOps' ) . and . returnValue ( of ( targetDelta . ops ! ) ) ;
162+ when ( mockDraftHandlingService . getDraft ( anything ( ) , anything ( ) ) ) . thenReturn ( of ( cloneDeep ( draftDelta . ops ! ) ) ) ;
163+ when ( mockDraftHandlingService . draftDataToOps ( anything ( ) , anything ( ) ) ) . thenReturn ( draftDelta . ops ! ) ;
164+ when ( mockDraftHandlingService . isDraftSegmentMap ( anything ( ) ) ) . thenReturn ( false ) ;
165+
166+ // Set the date to a time before the earliest draft
167+ fixture . componentInstance . timestamp = new Date ( '2024-03-22T03:02:01Z' ) ;
168+
169+ // SUT
170+ fixture . detectChanges ( ) ;
171+ tick ( EDITOR_READY_TIMEOUT ) ;
172+
173+ verify ( mockDraftHandlingService . getDraft ( anything ( ) , anything ( ) ) ) . once ( ) ;
174+ verify ( mockDraftHandlingService . draftDataToOps ( anything ( ) , anything ( ) ) ) . once ( ) ;
175+ expect ( component . draftCheckState ) . toEqual ( 'draft-present' ) ;
176+ expect ( component . draftText . editor ! . getContents ( ) . ops ) . toEqual ( draftDelta . ops ) ;
177+ } ) ) ;
178+
152179 it ( 'should return ops and update the editor when no revision' , fakeAsync ( ( ) => {
153180 const testProjectDoc : SFProjectProfileDoc = {
154181 data : createTestProjectProfile ( )
0 commit comments