1
- import { render , screen , fireEvent , waitFor } from '@testing-library/react' ;
1
+ import { render , screen , waitFor , fireEvent } from '@testing-library/react' ;
2
+ import { CLEAR_HISTORY_REMINDER_TIME } from '../../constants' ;
2
3
import { getIpcApi } from '../../lib/get-ipc-api' ;
3
4
import AIClearHistoryReminder from '../ai-clear-history-reminder' ;
4
5
import type { Message } from '../../hooks/use-assistant' ;
@@ -7,15 +8,15 @@ jest.mock( '../../lib/get-ipc-api' );
7
8
8
9
describe ( 'AIClearHistoryReminder' , ( ) => {
9
10
let clearConversation : jest . Mock ;
10
- const MOCKED_TIME = 1718882159928 ;
11
- const TWO_HOURS_DIFF = 2 * 60 * 60 * 1000 ;
11
+ const MOCKED_CURRENT_TIME = 1718882159928 ;
12
+ const OLD_MESSAGE_TIME = MOCKED_CURRENT_TIME - CLEAR_HISTORY_REMINDER_TIME - 1 ;
12
13
13
14
beforeEach ( ( ) => {
14
15
window . HTMLElement . prototype . scrollIntoView = jest . fn ( ) ;
15
16
clearConversation = jest . fn ( ) ;
16
17
jest . clearAllMocks ( ) ;
17
18
jest . useFakeTimers ( ) ;
18
- jest . setSystemTime ( MOCKED_TIME ) ;
19
+ jest . setSystemTime ( MOCKED_CURRENT_TIME ) ;
19
20
} ) ;
20
21
21
22
afterEach ( ( ) => {
@@ -25,7 +26,7 @@ describe( 'AIClearHistoryReminder', () => {
25
26
it ( 'should display a reminder when the conversation is stale' , ( ) => {
26
27
const message : Message = {
27
28
id : 0 ,
28
- createdAt : MOCKED_TIME - TWO_HOURS_DIFF ,
29
+ createdAt : OLD_MESSAGE_TIME ,
29
30
content : '' ,
30
31
role : 'assistant' ,
31
32
} ;
@@ -42,7 +43,7 @@ describe( 'AIClearHistoryReminder', () => {
42
43
} ) ;
43
44
const message : Message = {
44
45
id : 0 ,
45
- createdAt : MOCKED_TIME - TWO_HOURS_DIFF ,
46
+ createdAt : OLD_MESSAGE_TIME ,
46
47
content : '' ,
47
48
role : 'assistant' ,
48
49
} ;
@@ -65,7 +66,7 @@ describe( 'AIClearHistoryReminder', () => {
65
66
} ) ;
66
67
const message : Message = {
67
68
id : 0 ,
68
- createdAt : MOCKED_TIME - TWO_HOURS_DIFF ,
69
+ createdAt : OLD_MESSAGE_TIME ,
69
70
content : '' ,
70
71
role : 'assistant' ,
71
72
} ;
0 commit comments