@@ -24,6 +24,7 @@ import { resetDateTime } from '@/utils/date-utils';
24
24
import {
25
25
clickCalendarDate ,
26
26
clickSelectBtn ,
27
+ getCalendarCell ,
27
28
getCellClasses ,
28
29
getMonthName ,
29
30
hoverCalendarDate ,
@@ -94,11 +95,11 @@ describe('It should validate various picker scenarios', () => {
94
95
it ( 'Should not switch calendars in 1 month range with multi-calendars enabled (#472)' , async ( ) => {
95
96
const start = set ( new Date ( ) , { month : 5 } ) ;
96
97
const dp = await openMenu ( { multiCalendars : true , range : true , startDate : start } ) ;
97
- const firstDate = resetDateTime ( start ) ;
98
- const secondDate = resetDateTime ( set ( firstDate , { month : getMonth ( addMonths ( firstDate , 1 ) ) , date : 15 } ) ) ;
98
+ // const firstDate = resetDateTime(start);
99
+ const end = set ( start , { month : getMonth ( addMonths ( start , 1 ) ) , date : 15 } ) ;
99
100
100
- const firstDateEl = dp . find ( `[data-test-id=" ${ firstDate } "]` ) ;
101
- const secondDateEl = dp . find ( `[data-test-id=" ${ secondDate } "]` ) ;
101
+ const firstDateEl = getCalendarCell ( dp , start ) ;
102
+ const secondDateEl = getCalendarCell ( dp , end ) ;
102
103
103
104
await firstDateEl . trigger ( 'click' ) ;
104
105
await secondDateEl . trigger ( 'click' ) ;
@@ -246,23 +247,20 @@ describe('It should validate various picker scenarios', () => {
246
247
} ) ;
247
248
248
249
it ( 'Should not break flow on changing months and years when calendar is first step (#553)' , async ( ) => {
249
- const start = startOfYear ( new Date ( ) ) ;
250
+ const start = addDays ( startOfYear ( new Date ( ) ) , 1 ) ;
250
251
const flow = [ FlowStep . calendar , FlowStep . time ] ;
251
252
const dp = await openMenu ( { flow, startDate : start } ) ;
252
- const today = resetDateTime ( start ) ;
253
- const nextMonth = addMonths ( today , 1 ) ;
253
+ const nextMonth = addMonths ( start , 1 ) ;
254
254
255
- await clickCalendarDate ( dp , today ) ;
255
+ await clickCalendarDate ( dp , start ) ;
256
256
257
257
expect ( dp . html ( ) ) . toContain ( 'dp__overlay' ) ;
258
258
259
259
await reOpenMenu ( dp ) ;
260
260
261
261
await dp . find ( `[data-test-id="month-toggle-overlay-0"]` ) . trigger ( 'click' ) ;
262
262
await dp . find ( `[data-test-id="${ getMonthName ( nextMonth ) } "]` ) . trigger ( 'click' ) ;
263
-
264
- const cell = dp . find ( `[data-test-id="${ nextMonth } "]` ) ;
265
-
263
+ const cell = getCalendarCell ( dp , nextMonth ) ;
266
264
expect ( cell . html ( ) ) . toBeTruthy ( ) ;
267
265
dp . unmount ( ) ;
268
266
} ) ;
@@ -297,7 +295,7 @@ describe('It should validate various picker scenarios', () => {
297
295
298
296
const selectRange = async ( ) => {
299
297
await clickCalendarDate ( dp , today ) ;
300
- await dp . find ( `[data-test-id=" ${ secondDate } "]` ) . trigger ( 'click' ) ;
298
+ await getCalendarCell ( dp , secondDate ) . trigger ( 'click' ) ;
301
299
} ;
302
300
303
301
await selectRange ( ) ;
@@ -401,7 +399,7 @@ describe('It should validate various picker scenarios', () => {
401
399
402
400
const dp = await openMenu ( { highlight } ) ;
403
401
404
- const calendarCell = dp . find ( `[data-test-id=" ${ resetDateTime ( start ) } "]` ) . find ( '.dp__cell_inner' ) ;
402
+ const calendarCell = getCalendarCell ( dp , start ) . find ( '.dp__cell_inner' ) ;
405
403
406
404
expect ( calendarCell . classes ( ) ) . toContain ( 'dp__cell_highlight' ) ;
407
405
0 commit comments