@@ -152,62 +152,6 @@ test('Messagelist should scrolled to the latest messages after being rendered in
152152 } ) ;
153153} ) ;
154154
155- test . clientScripts ( [
156- { module : 'mockdate' } ,
157- { content : 'window.MockDate = MockDate;' } ,
158- ] ) ( 'Messagelist with date headers' , async ( t ) => {
159- const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
160-
161- await testScreenshot ( t , takeScreenshot , 'Messagelist with date headers.png' , { element : '#container' } ) ;
162-
163- await t
164- . expect ( compareResults . isValid ( ) )
165- . ok ( compareResults . errorMessages ( ) ) ;
166- } ) . before ( async ( ) => {
167- await ClientFunction ( ( ) => {
168- ( window as any ) . MockDate . set ( '2024/10/27' ) ;
169- } ) ( ) ;
170-
171- const userFirst = createUser ( 1 , 'First' ) ;
172- const userSecond = createUser ( 2 , 'Second' ) ;
173- const msInDay = 86400000 ;
174- const today = new Date ( '2024/10/27' ) . setHours ( 7 , 22 , 0 , 0 ) ;
175- const yesterday = today - msInDay ;
176-
177- const items = [ {
178- timestamp : new Date ( '05.01.2024' ) ,
179- author : userFirst ,
180- text : 'AAA' ,
181- } , {
182- timestamp : new Date ( '06.01.2024' ) ,
183- author : userFirst ,
184- text : 'BBB' ,
185- } , {
186- timestamp : new Date ( '06.01.2024' ) ,
187- author : userSecond ,
188- text : 'CCC' ,
189- } , {
190- timestamp : yesterday ,
191- author : userSecond ,
192- text : 'DDD' ,
193- } , {
194- timestamp : today ,
195- author : userFirst ,
196- text : 'EEE' ,
197- } ] ;
198-
199- return createWidget ( 'dxChat' , {
200- items,
201- user : userSecond ,
202- width : 400 ,
203- height : 600 ,
204- } ) ;
205- } ) . after ( async ( ) => {
206- await ClientFunction ( ( ) => {
207- ( window as any ) . MockDate . reset ( ) ;
208- } ) ( ) ;
209- } ) ;
210-
211155test ( 'Messagelist with messageTemplate' , async ( t ) => {
212156 const chat = new Chat ( '#container' ) ;
213157 const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
@@ -290,3 +234,63 @@ test('Messagelist options showDayHeaders, showUserName and showMessageTimestamp
290234 showMessageTimestamp : false ,
291235 } ) ;
292236} ) ;
237+
238+ fixture `ChatMessageList: dayHeaders`
239+ . page ( url ( __dirname , '../container.html' ) ) ;
240+
241+ test . clientScripts ( [
242+ { module : 'mockdate' } ,
243+ { content : 'window.MockDate = MockDate;' } ,
244+ ] ) ( 'Messagelist with date headers' , async ( t ) => {
245+ const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
246+
247+ await testScreenshot ( t , takeScreenshot , 'Messagelist with date headers.png' , { element : '#container' } ) ;
248+
249+ await t
250+ . expect ( compareResults . isValid ( ) )
251+ . ok ( compareResults . errorMessages ( ) ) ;
252+ } ) . before ( async ( ) => {
253+ await ClientFunction ( ( ) => {
254+ ( window as any ) . MockDate . set ( '2024/10/27' ) ;
255+ } ) ( ) ;
256+
257+ const userFirst = createUser ( 1 , 'First' ) ;
258+ const userSecond = createUser ( 2 , 'Second' ) ;
259+ const msInDay = 86400000 ;
260+ const today = new Date ( '2024/10/27' ) . setHours ( 7 , 22 , 0 , 0 ) ;
261+ const yesterday = today - msInDay ;
262+
263+ const items = [ {
264+ timestamp : new Date ( '05.01.2024' ) ,
265+ author : userFirst ,
266+ text : 'AAA' ,
267+ } , {
268+ timestamp : new Date ( '06.01.2024' ) ,
269+ author : userFirst ,
270+ text : 'BBB' ,
271+ } , {
272+ timestamp : new Date ( '06.01.2024' ) ,
273+ author : userSecond ,
274+ text : 'CCC' ,
275+ } , {
276+ timestamp : yesterday ,
277+ author : userSecond ,
278+ text : 'DDD' ,
279+ } , {
280+ timestamp : today ,
281+ author : userFirst ,
282+ text : 'EEE' ,
283+ } ] ;
284+
285+ return createWidget ( 'dxChat' , {
286+ items,
287+ user : userSecond ,
288+ width : 400 ,
289+ height : 600 ,
290+ } ) ;
291+ } ) . after ( async ( ) => {
292+ await ClientFunction ( ( ) => {
293+ ( window as any ) . MockDate . reset ( ) ;
294+ delete ( window as any ) . MockDate ;
295+ } ) ( ) ;
296+ } ) ;
0 commit comments