File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,6 +143,9 @@ const vocabSearch = Vue.createApp({
143143 if ( 'uri' in result ) { // create relative Skosmos page URL from the search result URI
144144 result . pageUrl = window . SKOSMOS . vocab + '/' + window . SKOSMOS . lang + '/page?'
145145 const urlParams = new URLSearchParams ( { uri : result . uri } )
146+ if ( this . selectedLanguage !== window . SKOSMOS . lang ) { // add content language parameter
147+ urlParams . append ( 'clang' , this . selectedLanguage )
148+ }
146149 result . pageUrl += urlParams . toString ( )
147150 }
148151 // render search result renderedTypes
Original file line number Diff line number Diff line change @@ -156,6 +156,24 @@ describe('Vocab search bar', () => {
156156 cy . get ( '#main-container' ) . click ( { force : true } ) ; // using force true to click on elements not considered actionable
157157 cy . get ( '#search-autocomplete-results' ) . should ( 'not.be.visible' ) ; // the autocomplete should disappear
158158 } )
159+ it ( 'Search language parameter is passed to the autocomplete result links' , ( ) => {
160+ cy . visit ( '/yso/sv/' )
161+
162+ // Choose 'fi' for search & content language
163+ cy . get ( '#language-selector .dropdown-toggle' ) . click ( ) ;
164+ cy . get ( '#language-list .dropdown-item' ) . contains ( 'finska' ) . click ( ) ;
165+
166+ // Searchg for 'kissa'
167+ cy . get ( '#search-field' ) . type ( 'aarre' ) ;
168+ cy . get ( '#search-autocomplete-results' , { timeout : 20000 } ) . should ( 'be.visible' ) ; // the autocomplete should appear
169+
170+ // Click the first search result
171+ cy . get ( '#search-autocomplete-results li:first-child a' ) . click ( ) ;
172+
173+ // The language parameters should persist on the concept page
174+ cy . url ( ) . should ( 'include' , '/sv/' ) ;
175+ cy . url ( ) . should ( 'include' , 'clang=fi' ) ;
176+ } )
159177 } ) ;
160178
161179 describe ( 'Search Result Rendering' , ( ) => {
You can’t perform that action at this time.
0 commit comments