@@ -199,7 +199,7 @@ const Container = styled.div<{ $height: number }>`
199199 height: ${ ( { $height } ) => $height } px;
200200` ;
201201
202- const Cells = ( {
202+ function Cells ( {
203203 cols,
204204 reservationUnitPk,
205205 date,
@@ -211,7 +211,7 @@ const Cells = ({
211211 date : Date ;
212212 setModalContent : ( content : JSX . Element | null , isHds ?: boolean ) => void ;
213213 onComplete : ( ) => void ;
214- } ) => {
214+ } ) {
215215 const now = new Date ( ) ;
216216
217217 const isPast = ( index : number ) => {
@@ -234,14 +234,21 @@ const Cells = ({
234234 ) ;
235235 } ;
236236
237+ const testId = `UnitCalendar__RowCalendar--cells-${ reservationUnitPk } ` ;
238+ const cellTestId = `UnitCalendar__RowCalendar--cell-${ reservationUnitPk } ` ;
237239 return (
238- < CellContent $numCols = { cols } >
240+ < CellContent $numCols = { cols } data-testid = { testId } >
239241 { Array . from ( Array ( cols ) . keys ( ) ) . map ( ( i ) => (
240- < Cell key = { i } onClick = { onClick ( i ) } $isPast = { isPast ( i ) } />
242+ < Cell
243+ key = { i }
244+ onClick = { onClick ( i ) }
245+ $isPast = { isPast ( i ) }
246+ data-testid = { `${ cellTestId } -${ i } ` }
247+ />
241248 ) ) }
242249 </ CellContent >
243250 ) ;
244- } ;
251+ }
245252const PreBuffer = ( {
246253 event,
247254 hourPercent,
@@ -274,7 +281,7 @@ const PreBuffer = ({
274281 return null ;
275282} ;
276283
277- const PostBuffer = ( {
284+ function PostBuffer ( {
278285 event,
279286 hourPercent,
280287 right,
@@ -284,27 +291,28 @@ const PostBuffer = ({
284291 hourPercent : number ;
285292 right : string ;
286293 style ?: CSSProperties ;
287- } ) : JSX . Element | null => {
294+ } ) : JSX . Element | null {
288295 const buffer = event . event ?. bufferTimeAfter ;
289296 const { t } = useTranslation ( ) ;
290297
291- if ( buffer ) {
292- const width = `calc(${ ( hourPercent * buffer ) / 3600 } % - 1px)` ;
293- return (
294- < div
295- style = { {
296- ...POST_PAUSE . style ,
297- ...style ,
298- left : right ,
299- width,
300- } }
301- title = { t ( "MyUnits.Calendar.legend.pause" ) }
302- key = { `${ event . event ?. pk } -post` }
303- />
304- ) ;
298+ if ( buffer == null ) {
299+ return null ;
305300 }
306- return null ;
307- } ;
301+
302+ const width = `calc(${ ( hourPercent * buffer ) / 3600 } % - 1px)` ;
303+ return (
304+ < div
305+ style = { {
306+ ...POST_PAUSE . style ,
307+ ...style ,
308+ left : right ,
309+ width,
310+ } }
311+ title = { t ( "MyUnits.Calendar.legend.pause" ) }
312+ key = { `${ event . event ?. pk } -post` }
313+ />
314+ ) ;
315+ }
308316
309317function getEventTitle ( {
310318 reservation : { title, event } ,
@@ -342,7 +350,7 @@ const EventContainer = styled.div`
342350 left: 0;
343351` ;
344352
345- const Events = ( {
353+ function Events ( {
346354 firstHour,
347355 events,
348356 eventStyleGetter,
@@ -352,10 +360,10 @@ const Events = ({
352360 events : CalendarEventType [ ] ;
353361 eventStyleGetter : EventStyleGetter ;
354362 numHours : number ;
355- } ) => {
363+ } ) {
356364 const { t } = useTranslation ( ) ;
357365 return (
358- < EventContainer >
366+ < EventContainer data-testid = "UnitCalendar__RowCalendar--events" >
359367 { events . map ( ( e ) => {
360368 const title = getEventTitle ( { reservation : e , t } ) ;
361369 const startDate = new Date ( e . start ) ;
@@ -377,6 +385,7 @@ const Events = ({
377385 100 / numHours
378386 } % + 1px)`;
379387
388+ const testId = `UnitCalendar__RowCalendar--event-${ e . event ?. pk } ` ;
380389 return (
381390 < Fragment key = { `${ title } -${ startDate . toISOString ( ) } ` } >
382391 < PreBuffer
@@ -395,7 +404,10 @@ const Events = ({
395404 zIndex : 5 ,
396405 } }
397406 >
398- < EventContent style = { { ...eventStyleGetter ( e ) . style } } >
407+ < EventContent
408+ style = { { ...eventStyleGetter ( e ) . style } }
409+ data-testid = { testId }
410+ >
399411 < p > { title } </ p >
400412 { /* NOTE don't set position on Popup it breaks responsiveness */ }
401413 < Popup trigger = { EventTriggerButton } >
@@ -414,16 +426,16 @@ const Events = ({
414426 } ) }
415427 </ EventContainer >
416428 ) ;
417- } ;
429+ }
418430
419- const sortByDraftStatusAndTitle = ( resources : Resource [ ] ) => {
431+ function sortByDraftStatusAndTitle ( resources : Resource [ ] ) {
420432 return resources . sort ( ( a , b ) => {
421433 const draftComparison : number = Number ( a . isDraft ) - Number ( b . isDraft ) ;
422434 const titleComparison = sortByName ( a . title , b . title ) ;
423435
424436 return draftComparison || titleComparison ;
425437 } ) ;
426- } ;
438+ }
427439
428440function UnitCalendar ( { date, resources, refetch } : Props ) : JSX . Element {
429441 const calendarRef = useRef < HTMLDivElement > ( null ) ;
0 commit comments