blob: f30cc32edf02d5b9dbcdcd3b67243fca1a503d8f [file] [log] [blame]
hebasta75cfca52019-02-19 13:15:27 +01001/**
2 * Test suite for guided tour.
3 *
4 * @author Helge Stallkamp
5 */
6
hebasta5df796f2019-05-21 15:27:12 +02007define(['tour/tours', 'vc', 'session'], function(tourClass, vcClass, sessionClass){
hebasta75cfca52019-02-19 13:15:27 +01008 const loc = KorAP.Locale;
9
10 //TODO Read this file from the file system, see https://korap.ids-mannheim.de/gerrit/#/c/KorAP/Kalamar/+/2241/
hebasta0c93d8e2019-05-15 12:06:16 +020011 var introKorAP =
12 "<form autocomplete='off' action='/' id='searchform'>" +
13 "<div id='searchbar' class=''>" +
14 "<input autocapitalize='off' autocomplete='off' autocorrect='off' autofocus='autofocus' id='q-field' name='q' placeholder='Finde ...' spellcheck='false' type='search'>" +
hebasta5df796f2019-05-21 15:27:12 +020015 "<button type='submit' id='qsubmit' title='Los!'><span>Los!</span></button>" +
hebasta0c93d8e2019-05-15 12:06:16 +020016 "</div>" +
17 "<!-- Search in the following virtual collection -->"+
18 "<div id='vc-view'></div>" +
19 "in" +
20 "<span id='vc-choose' class='select'><span>allen Korpora</span></span>" +
21 "<input id='collection' name='collection' type='text' style='display: none;'>" +
22 "mit" +
23 "<span class='select'>" +
24 "<select id='ql-field' name='ql' style='display: none;'>" +
25 "<option value='poliqarp'>Poliqarp</option>" +
26 "<option value='cosmas2'>Cosmas II</option>" +
27 "<option value='annis'>Annis QL</option>" +
28 "<option value='cql'>CQL v1.2</option>" +
29 "<option value='fcsql'>FCSQL</option>" +
30 "</select>" +
31 "<span style='display: inline;'> Poliqarp</span>" +
32 "<ul style='outline: currentcolor none 0px;' tabindex='0' class='menu roll'>" +
33 "<span class='pref'></span>" +
34 "<div class='lengthField'>" +
35 "<span>Poliqarp--</span>" +
36 "<span>Cosmas II--</span>" +
37 "<span>Annis QL--</span>" +
38 "<span>CQL v1.2--</span>" +
39 "<span>FCSQL--</span>" +
40 "</div><div class='ruler' style='display: none;'><span></span><div></div>" +
41 "</div>" +
42 "</ul>" +
43 "</span>" +
44 "<div class='button right'>" +
45 "<input checked='' class='checkbox' id='q-cutoff-field' name='cutoff' type='checkbox' value='1'>" +
46 "<label for='q-cutoff-field' title='Zeige nur die ersten Treffer in beliebiger Reihenfolge'><span id='glimpse'></span>Glimpse</label>" +
47 "<a class='tutorial' id='view-tutorial' tabindex='-1' title='Einführung'><span>Einführung</span></a>"+
48 "</div>" +
49 "<div class='clear'></div>"+
50 "</form>" +
51 "<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;'>" +
52 "<span></span>" +
53 "<div id='hint' class=''>" +
54 "<div style='display: none;' class='alert hint'></div>" +
55 "<ul style='outline: currentcolor none 0px;' tabindex='0' class='menu roll hint'>" +
56 "<span class='pref'></span>" +
57 "<div class='lengthField'>" +
58 "<span>Base Annotation--</span>" +
59 "<span class='desc'>Structure--</span>" +
60 "<span>DeReKo--</span><span class='desc'>Structure--</span>"+
61 "</div>"
62 "<div class='ruler' style='display: none;'><span></span><div></div></div>"
63 "</ul>" +
64 "</div>" +
65 "</div>";
hebasta75cfca52019-02-19 13:15:27 +010066
67 let template = document.createElement('template');
hebasta5df796f2019-05-21 15:27:12 +020068 html = introKorAP.trim(); // Do not return a text node of whitespace as the result
hebasta75cfca52019-02-19 13:15:27 +010069 template.innerHTML = html;
hebasta0c93d8e2019-05-15 12:06:16 +020070 intrkorap = template.content;
hebasta75cfca52019-02-19 13:15:27 +010071
72 //TODO Add hint and vc-choose, they are not part of the generated file
73 describe('KorAP.GuidedTour', function(){
74 it('IDs and classes, that are needed for the guided tour should be in existence', function(){
75 expect(intrkorap.querySelector('#searchbar')).not.toBeNull();
76 expect(intrkorap.querySelector('#q-field')).not.toBeNull();
hebasta0c93d8e2019-05-15 12:06:16 +020077 expect(intrkorap.querySelector('#hint')).not.toBeNull();
78 expect(intrkorap.querySelector('#vc-choose')).not.toBeNull();
hebasta75cfca52019-02-19 13:15:27 +010079 expect(intrkorap.querySelector('#vc-view')).not.toBeNull();
80 expect(intrkorap.querySelector('#ql-field').parentNode).not.toBeNull();
Akrone9e5e832019-04-02 14:56:23 +020081 expect(intrkorap.querySelector('#glimpse')).not.toBeNull();
hebasta75cfca52019-02-19 13:15:27 +010082 expect(intrkorap.querySelector('#view-tutorial')).not.toBeNull();
hebasta5df796f2019-05-21 15:27:12 +020083 expect(intrkorap.querySelector('#qsubmit')).not.toBeNull();
hebasta75cfca52019-02-19 13:15:27 +010084 });
85
86
hebasta0c93d8e2019-05-15 12:06:16 +020087
hebasta75cfca52019-02-19 13:15:27 +010088 it('Guided Tour should be started and display steps and labels in the right order', function(){
hebasta5df796f2019-05-21 15:27:12 +020089 let searchTour = tourClass.gTstartSearch(intrkorap);
90 searchTour.start();
91 let totalSteps = searchTour.stepCount;
hebasta75cfca52019-02-19 13:15:27 +010092 expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(loc.TOUR_sear1);
93 expect(document.querySelector(".introjs-skipbutton").textContent).toEqual(loc.TOUR_lskip);
94 expect(document.querySelector(".introjs-prevbutton").textContent).toEqual(loc.TOUR_lprev);
95 expect(document.querySelector(".introjs-nextbutton").textContent).toEqual(loc.TOUR_lnext);
hebasta5df796f2019-05-21 15:27:12 +020096 searchTour.exit();
hebasta75cfca52019-02-19 13:15:27 +010097
98 for(let i = 2; i <= totalSteps; i++){
hebasta5df796f2019-05-21 15:27:12 +020099 searchTour.goToStepNumber(i);
100 expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(searchTour.testIntros[i-1]);
hebasta75cfca52019-02-19 13:15:27 +0100101 if(i == totalSteps){
hebasta5df796f2019-05-21 15:27:12 +0200102 expect(document.querySelector(".introjs-donebutton").textContent).toEqual(loc.TOUR_seargo);
103 expect(document.querySelector(".introjs-prevbutton").textContent).toEqual(loc.TOUR_lprev);
104 expect(document.querySelector(".introjs-nextbutton").classList.contains("introjs-disabled")).toBe(true);
hebasta0c93d8e2019-05-15 12:06:16 +0200105 }
hebasta5df796f2019-05-21 15:27:12 +0200106 searchTour.exit();
107 }
108
109 let resultTour = tourClass.gTshowResults(intrkorap);
110 KorAP.session = sessionClass.create('KalamarJSDem');
111 resultTour.start();
112 expect(document.querySelector(".introjs-tooltiptext").textContent).toEqual(loc.TOUR_result);
113 expect(document.querySelector(".introjs-donebutton").textContent).toEqual(loc.TOUR_ldone);
114 resultTour.exit();
115
hebasta75cfca52019-02-19 13:15:27 +0100116 });
117 });
118}
119);