@@ -8,14 +8,28 @@ describe('Event Calendar Block Tests', () => {
8
8
cy . intercept ( 'PATCH' , '/**/my-page' ) . as ( 'save' ) ;
9
9
10
10
const now = new Date ( ) ;
11
- startDate = new Date ( now ) ;
12
- startDate . setMonth ( startDate . getMonth ( ) + 1 ) ;
13
11
14
- // End = start + 7 days
15
- endDate = new Date ( startDate . getTime ( ) + 7 * 24 * 60 * 60 * 1000 ) ;
12
+ // Start = 7th of month
13
+ startDate = new Date ( now . getFullYear ( ) , now . getMonth ( ) , 7 ) ;
14
+
15
+ // End = 14th of same month
16
+ endDate = new Date ( startDate . getFullYear ( ) , startDate . getMonth ( ) , 14 ) ;
17
+
18
+ // Always 11th for eventStart
19
+ const eventStart = new Date (
20
+ startDate . getFullYear ( ) ,
21
+ startDate . getMonth ( ) ,
22
+ 11 ,
23
+ ) ;
24
+
25
+ // Always 12th for eventEnd
26
+ const eventEnd = new Date (
27
+ startDate . getFullYear ( ) ,
28
+ startDate . getMonth ( ) ,
29
+ 12 ,
30
+ ) ;
31
+
16
32
const formatDate = ( date ) => date . toISOString ( ) . replace ( '.000Z' , '+00:00' ) ;
17
- const eventStart = new Date ( ( startDate . getTime ( ) + endDate . getTime ( ) ) / 2 ) ;
18
- const eventEnd = new Date ( eventStart . getTime ( ) + 2 * 24 * 60 * 60 * 1000 ) ;
19
33
20
34
// given a logged in editor and a page in edit mode
21
35
cy . autologin ( ) ;
@@ -48,6 +62,15 @@ describe('Event Calendar Block Tests', () => {
48
62
contentType : 'Event' ,
49
63
contentId : 'my-second-event' ,
50
64
contentTitle : 'Second Event' ,
65
+ bodyModifier ( body ) {
66
+ const baseYear = now . getFullYear ( ) ;
67
+ const baseMonth = now . getMonth ( ) ;
68
+ const startDate = new Date ( baseYear , baseMonth , 16 ) ;
69
+ body . start = formatDate ( startDate ) ;
70
+ body . end = formatDate ( new Date ( startDate . getTime ( ) + 1000 ) ) ;
71
+
72
+ return body ;
73
+ } ,
51
74
} ) ;
52
75
cy . visit ( '/my-page' ) ;
53
76
cy . wait ( '@content' ) ;
@@ -72,7 +95,7 @@ describe('Event Calendar Block Tests', () => {
72
95
. should ( 'not.exist' ) ;
73
96
} ) ;
74
97
75
- it . skip ( 'Add Event Calendar block and test the daterange' , ( ) => {
98
+ it ( 'Add Event Calendar block and test the daterange' , ( ) => {
76
99
// Adding new event calendar block and setting the date of evet.
77
100
78
101
cy . addNewBlock ( 'event' ) ;
@@ -84,7 +107,7 @@ describe('Event Calendar Block Tests', () => {
84
107
. type ( startDate . getDate ( ) . toString ( ) ) ;
85
108
cy . get ( '.react-aria-Group [slot="start"] [data-type="month"]' )
86
109
. focus ( )
87
- . type ( ( startDate . getMonth ( ) + 1 ) . toString ( ) ) ;
110
+ . type ( ( startDate . getMonth ( ) + 1 ) . toString ( ) ) ; // we have to add one here because the month index starts from 0. but above not because formatDate function takes care of that.
88
111
89
112
cy . get ( '.react-aria-Group [slot="start"] [data-type="year"]' )
90
113
. focus ( )
@@ -243,7 +266,7 @@ describe('Event Calendar Block Tests', () => {
243
266
} ) ;
244
267
} ) ;
245
268
246
- it . skip ( 'Test the daterange with facet and input' , ( ) => {
269
+ it ( 'Test the daterange with facet and input' , ( ) => {
247
270
// Adding new event calendar block and setting the two event content published.
248
271
cy . setWorkflow ( {
249
272
path : 'my-first-event' ,
@@ -409,17 +432,15 @@ describe('Event Calendar Block Tests', () => {
409
432
cy . get ( '#toolbar-save' ) . click ( ) ;
410
433
cy . wait ( '@content' ) ;
411
434
cy . url ( ) . should ( 'eq' , Cypress . config ( ) . baseUrl + '/my-page' ) ;
412
- cy . get ( '.card-listing' )
413
- . contains ( 'My First Event' )
414
- . closest ( '.card-listing' )
415
- . find ( '.image-wrapper .date-inset' )
416
- . should ( 'have.class' , 'has-end-date' ) ;
417
-
418
- cy . get ( '.card-listing' )
419
- . contains ( 'Second Event' )
420
- . closest ( '.card-listing' )
421
- . find ( '.image-wrapper .date-inset' )
435
+ cy . get ( 'a[href="/my-second-event"]' )
436
+ . next ( 'div.card-inner' )
437
+ . find ( '.date-inset' )
422
438
. should ( 'not.have.class' , 'has-end-date' ) ;
439
+
440
+ cy . get ( 'a[href="/my-first-event"]' )
441
+ . next ( 'div.card-inner' )
442
+ . find ( '.date-inset' )
443
+ . should ( 'have.class' , 'has-end-date' ) ;
423
444
} ) ;
424
445
425
446
it ( 'Add eventCalendar Block - sort by Order in folder and sort_order:descending' , ( ) => {
0 commit comments