@@ -17,7 +17,7 @@ import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKe
17
17
import { ILogService , NullLogService } from 'vs/platform/log/common/log' ;
18
18
import { IStorageService } from 'vs/platform/storage/common/storage' ;
19
19
import { ChatAgentLocation , ChatAgentService , IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
20
- import { ChatModel , ISerializableChatData1 , ISerializableChatData2 , normalizeSerializableChatData , Response } from 'vs/workbench/contrib/chat/common/chatModel' ;
20
+ import { ChatModel , ISerializableChatData1 , ISerializableChatData2 , ISerializableChatData3 , normalizeSerializableChatData , Response } from 'vs/workbench/contrib/chat/common/chatModel' ;
21
21
import { ChatRequestTextPart } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
22
22
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
23
23
import { TestExtensionService , TestStorageService } from 'vs/workbench/test/common/workbenchTestServices' ;
@@ -230,4 +230,53 @@ suite('normalizeSerializableChatData', () => {
230
230
assert . strictEqual ( newData . lastMessageDate , v2Data . lastMessageDate ) ;
231
231
assert . strictEqual ( newData . customTitle , v2Data . computedTitle ) ;
232
232
} ) ;
233
+
234
+ test ( 'old bad data' , ( ) => {
235
+ const v1Data : ISerializableChatData1 = {
236
+ // Testing the scenario where these are missing
237
+ sessionId : undefined ! ,
238
+ creationDate : undefined ! ,
239
+
240
+ initialLocation : undefined ,
241
+ isImported : false ,
242
+ requesterAvatarIconUri : undefined ,
243
+ requesterUsername : 'me' ,
244
+ requests : [ ] ,
245
+ responderAvatarIconUri : undefined ,
246
+ responderUsername : 'bot' ,
247
+ welcomeMessage : [ ]
248
+ } ;
249
+
250
+ const newData = normalizeSerializableChatData ( v1Data ) ;
251
+ assert . strictEqual ( newData . version , 3 ) ;
252
+ assert . ok ( newData . creationDate > 0 ) ;
253
+ assert . ok ( newData . lastMessageDate > 0 ) ;
254
+ assert . ok ( newData . sessionId ) ;
255
+ } ) ;
256
+
257
+ test ( 'v3 with bug' , ( ) => {
258
+ const v3Data : ISerializableChatData3 = {
259
+ // Test case where old data was wrongly normalized and these fields were missing
260
+ creationDate : undefined ! ,
261
+ lastMessageDate : undefined ! ,
262
+
263
+ version : 3 ,
264
+ initialLocation : undefined ,
265
+ isImported : false ,
266
+ requesterAvatarIconUri : undefined ,
267
+ requesterUsername : 'me' ,
268
+ requests : [ ] ,
269
+ responderAvatarIconUri : undefined ,
270
+ responderUsername : 'bot' ,
271
+ sessionId : 'session1' ,
272
+ welcomeMessage : [ ] ,
273
+ customTitle : 'computed title'
274
+ } ;
275
+
276
+ const newData = normalizeSerializableChatData ( v3Data ) ;
277
+ assert . strictEqual ( newData . version , 3 ) ;
278
+ assert . ok ( newData . creationDate > 0 ) ;
279
+ assert . ok ( newData . lastMessageDate > 0 ) ;
280
+ assert . ok ( newData . sessionId ) ;
281
+ } ) ;
233
282
} ) ;
0 commit comments