@@ -515,4 +515,66 @@ describe('Line & Route Change History', { tags }, () => {
515515 . getAllGroupElements ( )
516516 . should ( 'have.length' , 0 ) ;
517517 } ) ;
518+
519+ it ( 'Should display 3 latest change history items on line details page' , ( ) => {
520+ cy . section ( 'Verify initial state' , ( ) => {
521+ LineDetailsPage . latestChangeHistory . container ( ) . shouldBeVisible ( ) ;
522+ LineDetailsPage . latestChangeHistory
523+ . title ( )
524+ . shouldBeVisible ( )
525+ . should ( 'contain.text' , 'Muutoshistoria' ) ;
526+
527+ LineDetailsPage . latestChangeHistory . getItems ( ) . should ( 'have.length' , 3 ) ;
528+ } ) ;
529+
530+ cy . section ( 'Make multiple changes to create history' , ( ) => {
531+ // Change 1
532+ LineDetailsPage . getEditLineButton ( ) . click ( ) ;
533+ LineForm . getFinnishNameInput ( ) . clearAndType ( 'First change' ) ;
534+ LineForm . save ( ) ;
535+ LineForm . checkLineSubmitSuccess ( ) ;
536+
537+ // Change 2
538+ LineDetailsPage . getEditLineButton ( ) . click ( ) ;
539+ LineForm . getFinnishNameInput ( ) . clearAndType ( 'Second change' ) ;
540+ LineForm . save ( ) ;
541+ LineForm . checkLineSubmitSuccess ( ) ;
542+
543+ // Change 3
544+ LineDetailsPage . getEditLineButton ( ) . click ( ) ;
545+ LineForm . getFinnishNameInput ( ) . clearAndType ( 'Third change' ) ;
546+ LineForm . save ( ) ;
547+ LineForm . checkLineSubmitSuccess ( ) ;
548+
549+ // Change 4 to ensure only 3 latest changes are shown
550+ LineDetailsPage . getEditLineButton ( ) . click ( ) ;
551+ LineForm . getFinnishNameInput ( ) . clearAndType ( 'Fourth change' ) ;
552+ LineForm . save ( ) ;
553+ LineForm . checkLineSubmitSuccess ( ) ;
554+ } ) ;
555+
556+ cy . section ( 'Verify 3 latest changes are displayed' , ( ) => {
557+ LineDetailsPage . latestChangeHistory . getItems ( ) . should ( 'have.length' , 3 ) ;
558+
559+ LineDetailsPage . latestChangeHistory
560+ . getNthItem ( 0 )
561+ . should ( 'contain.text' , 'Linja 901' )
562+ . and ( 'contain.text' , 'Fourth change' ) ;
563+
564+ LineDetailsPage . latestChangeHistory
565+ . getNthItem ( 1 )
566+ . should ( 'contain.text' , 'Linja 901' )
567+ . and ( 'contain.text' , 'Third change' ) ;
568+
569+ LineDetailsPage . latestChangeHistory
570+ . getNthItem ( 2 )
571+ . should ( 'contain.text' , 'Linja 901' )
572+ . and ( 'contain.text' , 'Second change' ) ;
573+ } ) ;
574+
575+ cy . section ( 'Verify "Show all" link' , ( ) => {
576+ LineDetailsPage . latestChangeHistory . showAllLink ( ) . click ( ) ;
577+ cy . url ( ) . should ( 'include' , '/lines/901/history' ) ;
578+ } ) ;
579+ } ) ;
518580} ) ;
0 commit comments