@@ -68,7 +68,7 @@ describe('DraftHistoryListComponent', () => {
68
68
const activeBuild = { state : BuildStates . Active } as BuildDto ;
69
69
const completedBuild = {
70
70
state : BuildStates . Completed ,
71
- additionalInfo : { dateGenerated : '2025-08-01T12:00:00.000Z' }
71
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
72
72
} as BuildDto ;
73
73
const env = new TestEnvironment ( [ completedBuild , activeBuild ] ) ;
74
74
expect ( env . component . history ) . toEqual ( [ activeBuild , completedBuild ] ) ;
@@ -148,13 +148,18 @@ describe('DraftHistoryListComponent', () => {
148
148
it ( 'should filter draft history and hide builds that are not saved to the database' , fakeAsync ( ( ) => {
149
149
const build = {
150
150
state : BuildStates . Completed ,
151
- additionalInfo : { dateGenerated : '2025-08-01T12:00:00.000Z' }
151
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
152
152
} as BuildDto ;
153
153
const olderBuild = {
154
154
state : BuildStates . Completed
155
155
} as BuildDto ;
156
156
const buildHistory = [ olderBuild , build ] ;
157
157
const env = new TestEnvironment ( buildHistory ) ;
158
+
159
+ // Ensure that the warning shows, even though the project ID is invalid.
160
+ env . component . showOlderDraftsNotSupportedWarning = true ;
161
+ env . fixture . detectChanges ( ) ;
162
+
158
163
expect ( env . component . history ) . toEqual ( buildHistory ) ;
159
164
expect ( env . component . savedHistoricalBuilds ) . toEqual ( [ ] ) ;
160
165
expect ( env . component . isBuildActive ) . toBe ( false ) ;
@@ -168,15 +173,17 @@ describe('DraftHistoryListComponent', () => {
168
173
const build = {
169
174
id : 'completed' ,
170
175
state : BuildStates . Completed ,
171
- additionalInfo : { dateGenerated : '2025-08-01T12:00:00.000Z' }
176
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
172
177
} as BuildDto ;
173
178
const canceled = {
174
179
id : 'canceled' ,
175
- state : BuildStates . Canceled
180
+ state : BuildStates . Canceled ,
181
+ additionalInfo : { dateRequested : '2025-07-02T12:00:00.000Z' }
176
182
} as BuildDto ;
177
183
const faulted = {
178
184
id : 'faulted' ,
179
- state : BuildStates . Faulted
185
+ state : BuildStates . Faulted ,
186
+ additionalInfo : { dateRequested : '2025-07-01T12:00:00.000Z' }
180
187
} as BuildDto ;
181
188
const buildHistory = [ faulted , canceled , build ] ;
182
189
const env = new TestEnvironment ( buildHistory ) ;
@@ -188,14 +195,48 @@ describe('DraftHistoryListComponent', () => {
188
195
expect ( env . component . nonActiveBuilds ) . toEqual ( buildHistory ) ;
189
196
} ) ) ;
190
197
198
+ it ( 'should not show the drafts not supported warning for projects created after 4 June 2025' , fakeAsync ( ( ) => {
199
+ const build = {
200
+ state : BuildStates . Completed ,
201
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
202
+ } as BuildDto ;
203
+ const olderBuild = {
204
+ state : BuildStates . Completed ,
205
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
206
+ } as BuildDto ;
207
+ const buildHistory = [ olderBuild , build ] ;
208
+ // ObjectID was created at 2025-06-03T00:00:00.000Z
209
+ const env = new TestEnvironment ( buildHistory , '683e3b000000000000000000' ) ;
210
+ expect ( env . component . history ) . toEqual ( buildHistory ) ;
211
+ expect ( env . component . nonActiveBuilds ) . toEqual ( buildHistory ) ;
212
+ expect ( env . olderDraftsMessage ) . not . toBeNull ( ) ;
213
+ } ) ) ;
214
+
215
+ it ( 'should show the drafts not supported warning for projects created before 4 June 2025' , fakeAsync ( ( ) => {
216
+ const build = {
217
+ state : BuildStates . Completed ,
218
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
219
+ } as BuildDto ;
220
+ const olderBuild = {
221
+ state : BuildStates . Completed ,
222
+ additionalInfo : { dateRequested : '2025-08-01T12:00:00.000Z' }
223
+ } as BuildDto ;
224
+ const buildHistory = [ olderBuild , build ] ;
225
+ // ObjectID was created at 2025-06-05T00:00:00.000Z
226
+ const env = new TestEnvironment ( buildHistory , '6840de000000000000000000' ) ;
227
+ expect ( env . component . history ) . toEqual ( buildHistory ) ;
228
+ expect ( env . component . nonActiveBuilds ) . toEqual ( buildHistory ) ;
229
+ expect ( env . olderDraftsMessage ) . toBeNull ( ) ;
230
+ } ) ) ;
231
+
191
232
class TestEnvironment {
192
233
component : DraftHistoryListComponent ;
193
234
fixture : ComponentFixture < DraftHistoryListComponent > ;
194
235
195
- constructor ( buildHistory : BuildDto [ ] | undefined ) {
196
- when ( mockedActivatedProjectService . projectId$ ) . thenReturn ( of ( 'project01' ) ) ;
236
+ constructor ( buildHistory : BuildDto [ ] | undefined , projectId : string = 'project01' ) {
237
+ when ( mockedActivatedProjectService . projectId$ ) . thenReturn ( of ( projectId ) ) ;
197
238
when ( mockedActivatedProjectService . changes$ ) . thenReturn ( of ( undefined ) ) ; // Required for DraftPreviewBooksComponent
198
- when ( mockedDraftGenerationService . getBuildHistory ( 'project01' ) ) . thenReturn ( new BehaviorSubject ( buildHistory ) ) ;
239
+ when ( mockedDraftGenerationService . getBuildHistory ( projectId ) ) . thenReturn ( new BehaviorSubject ( buildHistory ) ) ;
199
240
when ( mockedFeatureFlagsService . usfmFormat ) . thenReturn ( createTestFeatureFlag ( true ) ) ;
200
241
201
242
this . fixture = TestBed . createComponent ( DraftHistoryListComponent ) ;
0 commit comments