File tree 5 files changed +53
-14
lines changed
integration_tests/pages/apply
views/applications/partials
5 files changed +53
-14
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ export default class ShowPage extends Page {
125
125
timelineEvents [ index ] . createdBy . name ,
126
126
)
127
127
}
128
+ cy . get ( '.govuk-link' ) . should ( 'have.attr' , { time : timelineEvents [ index ] . associatedUrls [ 0 ] . url } )
129
+ cy . get ( '.govuk-link' ) . should ( 'contain' , timelineEvents [ index ] . associatedUrls [ 0 ] . type )
128
130
cy . get ( 'time' ) . should ( 'contain' , DateFormats . isoDateTimeToUIDateTime ( timelineEvents [ index ] . occurredAt ) )
129
131
} )
130
132
} )
Original file line number Diff line number Diff line change @@ -25,4 +25,5 @@ export default Factory.define<TimelineEvent>(() => ({
25
25
] as const ) ,
26
26
content : Math . random ( ) < 0.5 ? faker . lorem . sentences ( ) : undefined ,
27
27
createdBy : userFactory . build ( ) ,
28
+ associatedUrls : [ { type : 'application' , url : faker . internet . url ( ) } ] ,
28
29
} ) )
Original file line number Diff line number Diff line change @@ -667,6 +667,30 @@ describe('utils', () => {
667
667
describe ( 'mapTimelineEventsForUi' , ( ) => {
668
668
it ( 'maps the events into the format required by the MoJ UI Timeline component' , ( ) => {
669
669
const timelineEvents = timelineEventFactory . buildList ( 1 )
670
+ expect ( mapTimelineEventsForUi ( timelineEvents ) ) . toEqual ( [
671
+ {
672
+ datetime : {
673
+ timestamp : timelineEvents [ 0 ] . occurredAt ,
674
+ date : DateFormats . isoDateTimeToUIDateTime ( timelineEvents [ 0 ] . occurredAt ) ,
675
+ } ,
676
+ label : {
677
+ text : eventTypeTranslations [ timelineEvents [ 0 ] . type ] ,
678
+ } ,
679
+ content : timelineEvents [ 0 ] . content ,
680
+ createdBy : timelineEvents [ 0 ] . createdBy . name ,
681
+ associatedUrls : [
682
+ {
683
+ type : timelineEvents [ 0 ] . associatedUrls [ 0 ] . type ,
684
+ url : timelineEvents [ 0 ] . associatedUrls [ 0 ] . url ,
685
+ } ,
686
+ ] ,
687
+ } ,
688
+ ] )
689
+ } )
690
+
691
+ it ( 'maps the events into the format required by the MoJ UI Timeline component without associatedUrls' , ( ) => {
692
+ const timelineEvents = timelineEventFactory . buildList ( 1 , { associatedUrls : undefined } )
693
+
670
694
expect ( mapTimelineEventsForUi ( timelineEvents ) ) . toEqual ( [
671
695
{
672
696
datetime : {
Original file line number Diff line number Diff line change @@ -297,6 +297,7 @@ const mapTimelineEventsForUi = (timelineEvents: Array<TimelineEvent>): Array<UiT
297
297
date : DateFormats . isoDateTimeToUIDateTime ( timelineEvent . occurredAt ) ,
298
298
} ,
299
299
content : timelineEvent . content ,
300
+ associatedUrls : timelineEvent . associatedUrls ,
300
301
}
301
302
if ( timelineEvent . createdBy ?. name ) {
302
303
return {
Original file line number Diff line number Diff line change 29
29
30
30
<div class =" moj-timeline__header" >
31
31
<h3 class =" moj-timeline__title" >{{ event .label .text }} </h3 >
32
- {% if event .createdBy %}
33
- <p class =" moj-timeline__byline" >by {{ event .createdBy }} </p >
32
+ {% if event .createdBy %}
33
+ <p class =" moj-timeline__byline" >by {{ event .createdBy }} </p >
34
34
{% endif %}
35
- </div >
35
+ </div >
36
36
37
- <p class =" moj-timeline__date" >
38
- <time datetime =" {{event.datetime.timestamp}}" >{{ event .datetime .date }} </time >
39
- </p >
37
+ <p class =" moj-timeline__date" >
38
+ <time datetime =" {{event.datetime.timestamp}}" >{{ event .datetime .date }} </time >
39
+ </p >
40
40
41
- {% if event .content %}
42
- <div class =" moj-timeline__description" >
43
- <p >{{ event .content }} </p >
44
- </div >
45
- {% endif %}
41
+ {% if event .content %}
42
+ <div class =" moj-timeline__description" >
43
+ <p >{{ event .content }} </p >
44
+ </div >
45
+ {% endif %}
46
+ {% if event .associatedUrls %}
47
+ {% for associatedUrl in event .associatedUrls %}
48
+ <div class =" moj-timeline__description" >
49
+ <ul class =" govuk-list govuk-list--bullet" >
50
+ <li >
51
+ <a class =" govuk-link" href =" {{associatedUrl.url}}" >View {{ associatedUrl .type }} </a >
52
+ </li >
53
+ </ul >
54
+ </div >
55
+ {% endfor %}
56
+ {% endif %}
57
+ </div >
58
+ {% endfor %}
46
59
</div >
47
- {% endfor %}
48
- </div >
49
60
50
- {% endmacro %}
61
+ {% endmacro %}
You can’t perform that action at this time.
0 commit comments