hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 1 | /** |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 2 | * Test suite for guided tour |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 3 | * |
| 4 | * @author Helge Stallkamp |
| 5 | */ |
| 6 | |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 7 | define(['tour/tours', 'vc', 'session', 'match', 'hint', 'hint/foundries/cnx', 'selectMenu'], function(tourClass, vcClass, sessionClass, matchClass, hintClass, hintArray, selectMenuClass){ |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 8 | const loc = KorAP.Locale; |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 9 | |
hebasta | 0c93d8e | 2019-05-15 12:06:16 +0200 | [diff] [blame] | 10 | var introKorAP = |
| 11 | "<form autocomplete='off' action='/' id='searchform'>" + |
| 12 | "<div id='searchbar' class=''>" + |
| 13 | "<input autocapitalize='off' autocomplete='off' autocorrect='off' autofocus='autofocus' id='q-field' name='q' placeholder='Finde ...' spellcheck='false' type='search'>" + |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 14 | "<button type='submit' id='qsubmit' title='Los!'><span>Los!</span></button>" + |
hebasta | 0c93d8e | 2019-05-15 12:06:16 +0200 | [diff] [blame] | 15 | "</div>" + |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 16 | "<!-- Search in the following virtual corpus -->"+ |
hebasta | 0c93d8e | 2019-05-15 12:06:16 +0200 | [diff] [blame] | 17 | "<div id='vc-view'></div>" + |
| 18 | "in" + |
| 19 | "<span id='vc-choose' class='select'><span>allen Korpora</span></span>" + |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 20 | "<input id='cq' name='cq' type='text' style='display: none;'>" + |
hebasta | 0c93d8e | 2019-05-15 12:06:16 +0200 | [diff] [blame] | 21 | "mit" + |
| 22 | "<span class='select'>" + |
| 23 | "<select id='ql-field' name='ql' style='display: none;'>" + |
| 24 | "<option value='poliqarp'>Poliqarp</option>" + |
| 25 | "<option value='cosmas2'>Cosmas II</option>" + |
| 26 | "<option value='annis'>Annis QL</option>" + |
| 27 | "<option value='cql'>CQL v1.2</option>" + |
| 28 | "<option value='fcsql'>FCSQL</option>" + |
| 29 | "</select>" + |
| 30 | "<span style='display: inline;'> Poliqarp</span>" + |
| 31 | "<ul style='outline: currentcolor none 0px;' tabindex='0' class='menu roll'>" + |
| 32 | "<span class='pref'></span>" + |
| 33 | "<div class='lengthField'>" + |
| 34 | "<span>Poliqarp--</span>" + |
| 35 | "<span>Cosmas II--</span>" + |
| 36 | "<span>Annis QL--</span>" + |
| 37 | "<span>CQL v1.2--</span>" + |
| 38 | "<span>FCSQL--</span>" + |
| 39 | "</div><div class='ruler' style='display: none;'><span></span><div></div>" + |
| 40 | "</div>" + |
| 41 | "</ul>" + |
| 42 | "</span>" + |
| 43 | "<div class='button right'>" + |
| 44 | "<input checked='' class='checkbox' id='q-cutoff-field' name='cutoff' type='checkbox' value='1'>" + |
| 45 | "<label for='q-cutoff-field' title='Zeige nur die ersten Treffer in beliebiger Reihenfolge'><span id='glimpse'></span>Glimpse</label>" + |
| 46 | "<a class='tutorial' id='view-tutorial' tabindex='-1' title='Einführung'><span>Einführung</span></a>"+ |
| 47 | "</div>" + |
| 48 | "<div class='clear'></div>"+ |
| 49 | "</form>" + |
| 50 | "<div class='hint mirror' style='height: 0px; left: 238px; top: 36px; width: 1272px; padding-left: 2px; margin-left: 0px; border-left-width: 2px; border-left-style: solid; font-size: 14.6667px; font-family: Noto Sans;'>" + |
| 51 | "<span></span>" + |
| 52 | "<div id='hint' class=''>" + |
| 53 | "<div style='display: none;' class='alert hint'></div>" + |
| 54 | "<ul style='outline: currentcolor none 0px;' tabindex='0' class='menu roll hint'>" + |
| 55 | "<span class='pref'></span>" + |
| 56 | "<div class='lengthField'>" + |
| 57 | "<span>Base Annotation--</span>" + |
| 58 | "<span class='desc'>Structure--</span>" + |
| 59 | "<span>DeReKo--</span><span class='desc'>Structure--</span>"+ |
| 60 | "</div>" |
| 61 | "<div class='ruler' style='display: none;'><span></span><div></div></div>" |
| 62 | "</ul>" + |
| 63 | "</div>" + |
| 64 | "</div>"; |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 65 | |
| 66 | |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 67 | var preDefinedStat={ |
| 68 | "documents":12, |
| 69 | "tokens":2323, |
| 70 | "sentences":343434, |
| 71 | "paragraphs":45454545 |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | KorAP.API.getCorpStat = function(collQu, cb){ |
| 76 | return cb(preDefinedStat); |
| 77 | }; |
| 78 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 79 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 80 | var resultkorap = |
| 81 | "<div id='search'>" + |
| 82 | "<ol class='align-left' tabindex='-8'>" + |
| 83 | "<li data-corpus-id='WPD' " + |
| 84 | "data-doc-id='WWW'" + |
| 85 | "data-text-id='03313'" + |
| 86 | "data-match-id='p102-103'" + |
| 87 | "data-available-info='base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans xip/c=spans malt/d=rels'"+ |
| 88 | "id='WPD-WWW.03313-p102-103'" + |
| 89 | "tabindex='6'>" + |
| 90 | "<div class='meta'>WPD/WWW/03313</div>" + |
| 91 | "<div class='match-main'>" + |
| 92 | "<div class='match-wrap'>" + |
| 93 | "<div class='snippet startMore endMore'>" + |
| 94 | "<div class='flag'></div>" + |
| 95 | "<span class='context-left'>In diesem Beispiel ist zu sehen, dass die beiden Variablen a und b lediglich ihre Werte an" + |
| 96 | " die Funktion </span><mark><mark class='class-2 level-1'>Dies </mark><mark class='class-1 level-0'><mark class='class-2 level-1'><mark class='class-3 level-2'>ist</mark>" + |
| 97 | " ein</mark> Test</mark></mark><span class='context-right'> übergeben, aber im Gegensatz zu einem Referenzparamter dabei unverändert bleiben.</span></div>" + |
| 98 | "</div>"+ |
| 99 | "<!-- only inject via javascript! -->" + |
| 100 | "</div>" + |
| 101 | "<p class='ref'><strong>Wertparameter</strong> by Hubi,Zwobot,4; published on 2005-03-28 as WWW.03313 (WPD)</p>" + |
| 102 | "<!-- only inject via javascript! -->" + |
| 103 | "</li>" + |
| 104 | "</div>"; |
| 105 | |
| 106 | |
| 107 | |
| 108 | var snippet = "<span title=\"cnx/l:meist\">" + |
| 109 | " <span title=\"cnx/p:ADV\">" + |
| 110 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 111 | " <span title=\"mate/l:meist\">" + |
| 112 | " <span title=\"mate/l:meist\">" + |
| 113 | " <span title=\"mate/p:ADV\">" + |
| 114 | " <span title=\"opennlp/p:ADV\">meist</span>" + |
| 115 | " </span>" + |
| 116 | " </span>" + |
| 117 | " </span>" + |
| 118 | " </span>" + |
| 119 | " </span>" + |
| 120 | "</span>" + |
| 121 | "<mark>" + |
| 122 | "<span title=\"cnx/l:deutlich\">" + |
| 123 | " <span title=\"cnx/p:A\">" + |
| 124 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 125 | " <span title=\"mate/l:deutlich\">" + |
| 126 | " <span title=\"mate/m:degree:pos\">" + |
| 127 | " <span title=\"mate/p:ADJD\">" + |
| 128 | " <span title=\"opennlp/p:ADJD\">deutlich</span>" + |
| 129 | " </span>" + |
| 130 | " </span>" + |
| 131 | " </span>" + |
| 132 | " </span>" + |
| 133 | " </span>" + |
| 134 | "</span>" + |
| 135 | "</mark>" + |
| 136 | "<span title=\"cnx/l:fähig\">" + |
| 137 | " <span title=\"cnx/l:leistung\">" + |
| 138 | " <span title=\"cnx/p:A\">" + |
| 139 | " <span title=\"cnx/p:ADJA\">" + |
| 140 | " <span title=\"cnx/syn:@NH\">" + |
| 141 | " <span title=\"mate/l:leistungsfähig\">" + |
| 142 | " <span title=\"mate/m:degree:comp\">" + |
| 143 | " <span title=\"mate/p:ADJD\">" + |
| 144 | " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" + |
| 145 | " </span>" + |
| 146 | " </span>" + |
| 147 | " </span>" + |
| 148 | " </span>" + |
| 149 | " </span>" + |
| 150 | " </span>" + |
| 151 | " </span>" + |
| 152 | "</span>"; |
| 153 | |
| 154 | var treeSnippet = |
| 155 | "<span class=\"context-left\"></span>" + |
| 156 | "<span class=\"match\">" + |
| 157 | " <span title=\"xip/c:MC\">" + |
| 158 | " <span title=\"xip/c:TOP\">" + |
| 159 | " <span title=\"xip/c:PP\">" + |
| 160 | " <span title=\"xip/c:PREP\">Mit</span>" + |
| 161 | " <span title=\"xip/c:NP\">" + |
| 162 | " <span title=\"xip/c:DET\">dieser</span>" + |
| 163 | " <span title=\"xip/c:NPA\">" + |
| 164 | " <span title=\"xip/c:NOUN\">Methode</span>" + |
| 165 | " </span>" + |
| 166 | " </span>" + |
| 167 | " </span>" + |
| 168 | " <span title=\"xip/c:VERB\">ist</span>" + |
| 169 | " <mark>" + |
| 170 | " <span title=\"xip/c:NP\">" + |
| 171 | " <span title=\"xip/c:PRON\">es</span>" + |
| 172 | " </span>" + |
| 173 | " <span title=\"xip/c:AP\">" + |
| 174 | " <span title=\"xip/c:ADV\">nun</span>" + |
| 175 | " <span title=\"xip/c:ADJ\">möglich</span>" + |
| 176 | " </span>" + |
| 177 | " </mark>" + |
| 178 | " <span title=\"xip/c:ADV\">z. B.</span>" + |
| 179 | " <span title=\"xip/c:NPA\">" + |
| 180 | " <span title=\"xip/c:NP\">" + |
| 181 | " <span title=\"xip/c:NOUN\">Voice</span>" + |
| 182 | " </span>" + |
| 183 | " </span>" + "(" + |
| 184 | " <span title=\"xip/c:INS\">" + |
| 185 | " <span title=\"xip/c:NPA\">" + |
| 186 | " <span title=\"xip/c:NP\">" + |
| 187 | " <span title=\"xip/c:NOUN\">Sprache</span>" + |
| 188 | " </span>" + |
| 189 | " </span>" + |
| 190 | " </span>" + ")" + |
| 191 | " <span title=\"xip/c:VERB\">bevorzugt</span>" + |
| 192 | " <span title=\"xip/c:PP\">" + |
| 193 | " <span title=\"xip/c:PREP\">in</span>" + |
| 194 | " <span title=\"xip/c:NP\">" + |
| 195 | " <span title=\"xip/c:PRON\">der</span>" + |
| 196 | " </span>" + |
| 197 | " <span title=\"xip/c:NPA\">" + |
| 198 | " <span title=\"xip/c:NP\">" + |
| 199 | " <span title=\"xip/c:NOUN\">Bridge</span>" + |
| 200 | " </span>" + |
| 201 | " </span>" + |
| 202 | " </span>" + |
| 203 | " <span title=\"xip/c:INFC\">" + |
| 204 | " <span title=\"xip/c:INS\">" + |
| 205 | " <span title=\"xip/c:VERB\">weiterzugeben</span>" + |
| 206 | " </span>" + |
| 207 | " </span>" + |
| 208 | " </span>" + |
| 209 | " </span>" + |
| 210 | "</span>" + |
| 211 | "<span class=\"context-right\"></span>"; |
| 212 | |
| 213 | KorAP.API.getTextInfo = function (doc, param, cb) { |
| 214 | cb(textInfo); |
| 215 | }; |
| 216 | |
| 217 | // Override getMatchInfo API call |
| 218 | KorAP.API.getMatchInfo = function (x, param, cb) { |
| 219 | if (param['spans'] === undefined || param['spans'] === false) |
| 220 | cb({ "snippet": snippet }); |
| 221 | else |
| 222 | cb({ "snippet": treeSnippet }); |
| 223 | }; |
| 224 | |
| 225 | var textInfo = { |
| 226 | "@context":"http:\/\/korap.ids-mannheim.de\/ns\/KoralQuery\/v0.3\/context.jsonld", |
| 227 | "document":{ |
| 228 | "@type":"koral:document", |
| 229 | "fields":[ |
| 230 | { |
| 231 | "@type":"koral:field", |
| 232 | "key":"editor", |
| 233 | "type":"type:store", |
| 234 | "value":"wikipedia.org" |
| 235 | }, |
| 236 | { |
| 237 | "@type":"koral:field", |
| 238 | "key":"textSigle", |
| 239 | "type":"type:string", |
| 240 | "value":"WPD15\/264\/58336" |
| 241 | }, |
| 242 | { |
| 243 | "@type":"koral:field", |
| 244 | "key":"author", |
| 245 | "type":"type:text", |
| 246 | "value":"Sprachpfleger, u.a." |
| 247 | }, |
| 248 | { |
| 249 | "@type":"koral:field", |
| 250 | "key":"docSigle", |
| 251 | "type":"type:string", |
| 252 | "value":"WPD15\/264" |
| 253 | }, |
| 254 | { |
| 255 | "@type":"koral:field", |
| 256 | "key":"textTypeArt", |
| 257 | "type":"type:string", |
| 258 | "value":"Enzyklopädie-Artikel" |
| 259 | }, |
| 260 | { |
| 261 | "@type":"koral:field", |
| 262 | "key":"language", |
| 263 | "type":"type:string", |
| 264 | "value":"de" |
| 265 | }, |
| 266 | { |
| 267 | "@type":"koral:field", |
| 268 | "key":"docTitle", |
| 269 | "type":"type:text", |
| 270 | "value":"Wikipedia, Artikel mit Anfangszahl 2, Teil 64" |
| 271 | }, |
| 272 | { |
| 273 | "@type":"koral:field", |
| 274 | "key":"textType", |
| 275 | "type":"type:string", |
| 276 | "value":"Enzyklopädie" |
| 277 | }, |
| 278 | { |
| 279 | "@type":"koral:field", |
| 280 | "key":"availability", |
| 281 | "type":"type:string", |
| 282 | "value":"CC-BY-SA" |
| 283 | }, |
| 284 | { |
| 285 | "@type":"koral:field", |
| 286 | "key":"foundries", |
| 287 | "type":"type:keywords", |
| 288 | "value":[ |
| 289 | "corenlp", |
| 290 | "corenlp\/constituency", |
| 291 | "corenlp\/morpho", |
| 292 | "corenlp\/sentences", |
| 293 | "dereko", |
| 294 | "dereko\/structure", |
| 295 | "dereko\/structure\/base-sentences-paragraphs-pagebreaks", |
| 296 | "opennlp", |
| 297 | "opennlp\/morpho", |
| 298 | "opennlp\/sentences" |
| 299 | ] |
| 300 | }, |
| 301 | { |
| 302 | "@type":"koral:field", |
| 303 | "key":"creationDate", |
| 304 | "type":"type:date", |
| 305 | "value":"2015-04-17" |
| 306 | }, |
| 307 | { |
| 308 | "@type":"koral:field", |
| 309 | "key":"title", |
| 310 | "type":"type:text", |
| 311 | "value":"22:43 – Das Schicksal hat einen Plan" |
| 312 | }, |
| 313 | { |
| 314 | "@type":"koral:field", |
| 315 | "key":"pubDate", |
| 316 | "type":"type:date", |
| 317 | "value":"2015-05-01" |
| 318 | }, |
| 319 | { |
| 320 | "@type":"koral:field", |
| 321 | "key":"reference", |
| 322 | "type":"type:store", |
| 323 | "value":"22:43 – Das Schicksal hat einen Plan, In: Wikipedia - URL:http:\/\/de.wikipedia.org\/wiki\/22:43_–_Das_Schicksal_hat_einen_Plan: Wikipedia, 2015" |
| 324 | }, |
| 325 | { |
| 326 | "@type":"koral:field", |
| 327 | "key":"textClass", |
| 328 | "type":"type:keywords", |
| 329 | "value":["kultur","film"] |
| 330 | }, |
| 331 | { |
| 332 | "@type":"koral:field", |
| 333 | "key":"tokenSource", |
| 334 | "type":"type:store", |
| 335 | "value":"base#tokens" |
| 336 | }, |
| 337 | { |
| 338 | "@type":"koral:field", |
| 339 | "key":"publisher", |
| 340 | "type":"type:store", |
| 341 | "value":"Wikipedia" |
| 342 | }, |
| 343 | { |
| 344 | "@type":"koral:field", |
| 345 | "key":"layerInfos", |
| 346 | "type":"type:store", |
| 347 | "value":"corenlp\/c=spans corenlp\/p=tokens corenlp\/s=spans dereko\/s=spans opennlp\/p=tokens opennlp\/s=spans" |
| 348 | }, |
| 349 | { |
| 350 | "@type":"koral:field", |
| 351 | "key":"pubPlace", |
| 352 | "type":"type:string", |
| 353 | "value":"URL:http:\/\/de.wikipedia.org" |
| 354 | }, |
| 355 | { |
| 356 | "@type":"koral:field", |
| 357 | "key":"corpusTitle", |
| 358 | "type":"type:text", |
| 359 | "value":"Wikipedia" |
| 360 | }, |
| 361 | { |
| 362 | "@type":"koral:field", |
| 363 | "key":"corpusEditor", |
| 364 | "type":"type:store", |
| 365 | "value":"wikipedia.org" |
| 366 | }, |
| 367 | { |
| 368 | "@type":"koral:field", |
| 369 | "key":"corpusSigle", |
| 370 | "type":"type:string", |
| 371 | "value":"WPD15" |
| 372 | } |
| 373 | ] |
| 374 | } |
| 375 | }; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 376 | let template = document.createElement('template'); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 377 | let html = introKorAP.trim(); // Do not return a text node of whitespace as the result |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 378 | template.innerHTML = html; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 379 | let intrkorap = template.content; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 380 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 381 | let resulttemplate = document.createElement('template'); |
| 382 | let htmlZwei = resultkorap.trim(); |
| 383 | resulttemplate.innerHTML = resultkorap; |
| 384 | var resultkor = resulttemplate.content; |
| 385 | |
| 386 | resultkor.querySelector('#search > ol > li:not(.active)').addEventListener('click', function (e) { |
| 387 | if (this._match !== undefined) |
| 388 | this._match.open(); |
| 389 | else { |
| 390 | matchClass.create(this).open(); |
| 391 | } |
| 392 | }); |
| 393 | |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 394 | let vc= vcClass.create().fromJson({ |
| 395 | '@type' : 'koral:doc', |
| 396 | 'key' : 'title', |
| 397 | 'match': 'match:eq', |
| 398 | 'value' : 'TestTour!', |
| 399 | 'type' : 'type:string' |
| 400 | }); |
| 401 | |
| 402 | KorAP.vc = vc; |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 403 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 404 | describe('KorAP.GuidedTour', function(){ |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 405 | |
| 406 | afterAll(function () { |
| 407 | KorAP.API.getMatchInfo = undefined; |
| 408 | var body = document.body; |
| 409 | var i = body.children.length - 1; |
| 410 | while (i >= 0) { |
| 411 | if (body.children[i].nodeType && body.children[i].nodeType === 1) { |
| 412 | if (!body.children[i].classList.contains("jasmine_html-reporter")) { |
| 413 | body.removeChild(body.children[i]); |
| 414 | }; |
| 415 | }; |
| 416 | i--; |
| 417 | }; |
| 418 | }) |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 419 | |
| 420 | KorAP.Hint = hintClass.create({inputField: intrkorap.getElementById("q-field")}); |
| 421 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 422 | it('IDs and classes, that are needed for the guided tour should be in existence', function(){ |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 423 | //gTstartSearch |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 424 | expect(intrkorap.querySelector('#searchbar')).not.toBeNull(); |
| 425 | expect(intrkorap.querySelector('#q-field')).not.toBeNull(); |
hebasta | 0c93d8e | 2019-05-15 12:06:16 +0200 | [diff] [blame] | 426 | expect(intrkorap.querySelector('#hint')).not.toBeNull(); |
| 427 | expect(intrkorap.querySelector('#vc-choose')).not.toBeNull(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 428 | expect(intrkorap.querySelector('#vc-view')).not.toBeNull(); |
| 429 | expect(intrkorap.querySelector('#ql-field').parentNode).not.toBeNull(); |
Akron | e9e5e83 | 2019-04-02 14:56:23 +0200 | [diff] [blame] | 430 | expect(intrkorap.querySelector('#glimpse')).not.toBeNull(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 431 | expect(intrkorap.querySelector('#view-tutorial')).not.toBeNull(); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 432 | expect(intrkorap.querySelector('#qsubmit')).not.toBeNull(); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 433 | let show = document.createElement('div'); |
hebasta | d090a51 | 2019-07-10 16:36:01 +0200 | [diff] [blame] | 434 | show.appendChild(vc.element()); |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 435 | let statbut = show.querySelector('.statistic'); |
| 436 | expect(statbut).not.toBeNull(); |
| 437 | statbut.click(); |
| 438 | expect(show.querySelector('.stattable')).not.toBeNull(); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 439 | //IDs and classes, that are needed for the second guided tour(gTshowResults()) should be in existence, too |
| 440 | expect(resultkor.querySelector('#search')).not.toBeNull(); |
| 441 | expect(resultkor.querySelector('#search > ol > li')).not.toBeNull(); |
| 442 | resultkor.querySelector("#search > ol > li").click(); |
| 443 | expect(resultkor.querySelector('.action > .metatable')).not.toBeNull(); |
| 444 | resultkor.querySelector(".metatable").click(); |
| 445 | expect(resultkor.querySelector('.view.metatable')).not.toBeNull(); |
| 446 | expect(resultkor.querySelector('.action > .info')).not.toBeNull(); |
| 447 | resultkor.querySelector(".info").click(); |
| 448 | expect(resultkor.querySelector('.view.tokentable')).not.toBeNull(); |
| 449 | expect(resultkor.querySelector('.tree')).not.toBeNull(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 450 | }); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 451 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 452 | it('Guided Tour should be started and display steps and labels in the right order', function(){ |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 453 | |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 454 | let vcpanel = intrkorap.getElementById("vc-view"); |
| 455 | vcpanel.appendChild(vc.element()); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 456 | let searchTour = tourClass.gTstartSearch(intrkorap); |
| 457 | searchTour.start(); |
| 458 | let totalSteps = searchTour.stepCount; |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 459 | expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(loc.TOUR_sear1); |
| 460 | expect(document.querySelector(".introjs-skipbutton").textContent).toEqual(loc.TOUR_lskip); |
| 461 | expect(document.querySelector(".introjs-prevbutton").textContent).toEqual(loc.TOUR_lprev); |
| 462 | expect(document.querySelector(".introjs-nextbutton").textContent).toEqual(loc.TOUR_lnext); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 463 | searchTour.exit(); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 464 | |
| 465 | for(let i = 2; i <= totalSteps; i++){ |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 466 | searchTour.goToStepNumber(i); |
| 467 | expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(searchTour.testIntros[i-1]); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 468 | |
| 469 | switch(i){ |
| 470 | case 4: |
| 471 | expect(intrkorap.querySelector('#hint')).not.toBeNull(); |
| 472 | expect(KorAP.Hint).not.toBeNull(); |
| 473 | expect(KorAP.Hint.active().dontHide).toBe(true); |
| 474 | expect(KorAP.Hint._active).not.toBeNull(); |
| 475 | break; |
hebasta | 94e47cb | 2019-07-24 22:24:27 +0200 | [diff] [blame] | 476 | |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 477 | case 5: |
| 478 | expect(KorAP.Hint._active).toBeNull(); |
| 479 | break; |
| 480 | |
| 481 | case totalSteps: |
| 482 | expect(document.querySelector(".introjs-donebutton").textContent).toEqual(loc.TOUR_seargo); |
| 483 | expect(document.querySelector(".introjs-prevbutton").textContent).toEqual(loc.TOUR_lprev); |
| 484 | expect(document.querySelector(".introjs-nextbutton").classList.contains("introjs-disabled")).toBe(true); |
| 485 | break; |
| 486 | } |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 487 | searchTour.exit(); |
| 488 | } |
| 489 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 490 | let resultTour = tourClass.gTshowResults(resultkor); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 491 | KorAP.session = sessionClass.create('KalamarJSDem'); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 492 | |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 493 | resultTour.start(resultkor); |
| 494 | let totalStepsR = resultTour.stepCount; |
| 495 | expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(loc.TOUR_kwic); |
| 496 | expect(document.querySelector(".introjs-skipbutton").textContent).toEqual(loc.TOUR_lskip); |
| 497 | expect(document.querySelector(".introjs-prevbutton").textContent).toEqual(loc.TOUR_lprev); |
| 498 | expect(document.querySelector(".introjs-nextbutton").textContent).toEqual(loc.TOUR_lnext); |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 499 | resultTour.exit(); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 500 | for(let i = 2; i <= totalStepsR; i++){ |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 501 | resultTour.goToStepNumber(i); |
| 502 | expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(resultTour.testIntros[i-1]); |
| 503 | if(i == totalStepsR){ |
| 504 | expect(document.querySelector(".introjs-donebutton").textContent).toEqual(loc.TOUR_ldone); |
| 505 | } |
| 506 | resultTour.exit(); |
| 507 | } |
| 508 | }); |
hebasta | f95226b | 2019-09-19 11:37:00 +0200 | [diff] [blame^] | 509 | |
| 510 | it('Guided Tour should hide Hint and QL Menu if aborted', function(){ |
| 511 | let tourAbort = tourClass.gTstartSearch(intrkorap); |
| 512 | tourAbort.start(); |
| 513 | expect(KorAP.Hint._active).toBeNull(); |
| 514 | expect(document.querySelector(".introjs-skipbutton")).not.toBeNull(); |
| 515 | tourAbort.goToStepNumber(4); |
| 516 | expect(KorAP.Hint._active).not.toBeNull() |
| 517 | expect(KorAP.Hint.active().dontHide).toBe(true); |
| 518 | tourAbort.exit(); |
| 519 | expect(KorAP.Hint._active).toBeNull(); |
| 520 | }); |
| 521 | |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 522 | }); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 523 | }); |