fix waitcount for sort by
[mkws-moved-to-github.git] / test / spec / mkws-pazpar2.js
1 /* Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com
2  *
3  * perform papzpar2 / pz2.js search & retrieve request in the browser
4  *
5  */
6
7 // get references from mkws.js, lazy evaluation
8 var debug = function (text) {
9         // use a debug function with time stamps
10         mkws.teams["AUTO"].log("Jasmine: " + text);
11
12         //mkws.log("Jasmine: " + text)
13     }
14
15     // Define empty jasmine_config for simple applications that don't define it.
16 if (jasmine_config == null || typeof jasmine_config != 'object') {
17     var jasmine_config = {};
18 }
19
20 var jasmine_status = {
21     source_click: 0
22 };
23
24 /* check config for jasmine test
25  *
26  * you can override the default values in the config
27  * object: jasmine_config = {};
28  *
29  */
30 function init_jasmine_config() {
31
32     var jasmine_config_default = {
33         search_query: "freebsd",
34         max_time: 17,
35         // in seconds
36         expected_hits: 80,
37         // at least expected hit counter
38         second: 1000,
39         // miliseconds to seconds
40         show_record_url: true,
41         // check for valid URL in records
42         check_motd: true,
43
44         // check sort by and per page menu
45         check_sortby: false,
46
47         dummy: false
48     };
49
50     // use default values for undefined values
51     for (var key in jasmine_config_default) {
52         if (!jasmine_config.hasOwnProperty(key)) {
53             jasmine_config[key] = jasmine_config_default[key];
54         }
55         debug("jasmine config: " + key + " => " + jasmine_config[key]);
56     }
57
58     mkws.jasmine_done = false;
59 }
60
61 var get_hit_counter = function () {
62         // not yet here
63         if ($(".mkwsPager").length == 0) return -1;
64
65         var found = $(".mkwsPager").text();
66         var re = /\([A-Za-z]+:\s+([0-9]+)\)/;
67         re.exec(found);
68         var hits = -1;
69
70         if (RegExp.$1) {
71             hits = parseInt(RegExp.$1);
72             if (hits <= 0) {
73                 debug("Oooops in get_hit_counter: " + RegExp.$1 + " '" + found + "'");
74             }
75         }
76
77         //debug("Hits: " + hits);
78         return hits;
79     }
80
81 describe("Init jasmine config", function () {
82     it("jasmine was successfully initialized", function () {
83         init_jasmine_config();
84
85         expect(jasmine_config.search_query).toMatch(/\w/);
86         expect(jasmine_config.second).toBeGreaterThan(100);
87         expect(jasmine_config.max_time).toBeGreaterThan(1);
88         expect(jasmine_config.expected_hits).toBeGreaterThan(1);
89     });
90 });
91
92 //disabled
93 xdescribe("Check MOTD before search", function () {
94     // Check that the MOTD has been moved into its container, and
95     // is visible before the search.
96     // the mkwsMOTD div was originally inside a testMOTD div, which should
97     // now be empty
98     // Note that the testMOTD is a regular div, and uses #testMOTD,
99     // since the automagic class-making does not apply to it.
100     it("MOTD is hidden", function () {
101         expect($(".mkwsMOTD").length).toBe(1);
102         expect($("#testMOTD").length).toBe(1);
103         expect($("#testMOTD").text()).toMatch("^ *$");
104     });
105
106     it("mkwsMOTDContainer has received the text", function () {
107         expect($(".mkwsMOTDContainer").length).toBe(1);
108         expect($(".mkwsMOTDContainer").text()).toMatch(/MOTD/);
109     });
110 });
111
112 describe("Check pazpar2 search", function () {
113     var $ = mkws.$;
114
115     it("pazpar2 was successfully initialized", function () {
116         expect(mkws.config.error).toBe(undefined);
117     });
118
119     it("validate HTML id's", function () {
120         expect($("input.mkwsQuery").length).toBe(1);
121         expect($("input.mkwsButton").length).toBe(1);
122
123         expect($(".mkwsNext").length).not.toBe(1);
124         expect($(".mkwsPrev").length).not.toBe(1);
125     });
126
127     it("run search query", function () {
128         var search_query = jasmine_config.search_query; // short hit counter with some paging
129         $("input.mkwsQuery").val(search_query);
130         debug("set search query: " + search_query)
131         expect($("input.mkwsQuery").val()).toMatch("^" + search_query + "$");
132
133         if (mkws.config.use_service_proxy) {
134             // wait for service proxy auth
135             waitsFor(function () {
136                 return mkws.authenticated;
137             }, "SP auth done", 10 * jasmine_config.second);
138         } else {
139             debug("running raw pp2, don't wait for mkws auth");
140         }
141
142         runs(function () {
143             debug("Click on submit button");
144             $("input.mkwsButton").trigger("click");
145         })
146     });
147 });
148
149 describe("Check MOTD after search", function () {
150     var $ = mkws.$;
151
152     it("MOTD is hidden", function () {
153         if (!jasmine_config.check_motd) {
154             return;
155         }
156
157         expect($(".mkwsMOTD").length).toBe(1);
158         expect($(".mkwsMOTD").is(":hidden")).toBe(true);
159         debug("motd t=" + $(".mkwsMOTD").text());
160         debug("motd v=" + $(".mkwsMOTD").is(":visible"));
161     });
162 });
163
164
165 /*
166  * This part runs in background. It should be rewritten with
167  * async jasmine functions
168  *
169  */
170 describe("Check pazpar2 navigation", function () {
171     var $ = mkws.$;
172
173     // Asynchronous part
174     it("check running search next/prev", function () {
175         expect($(".mkwsPager").length).toBe(1);
176
177         function my_click(id, time) {
178             setTimeout(function () {
179                 debug("trigger click on id: " + id);
180                 $(id).trigger("click");
181             }, time * jasmine_config.second);
182         }
183
184         waitsFor(function () {
185             return $("div.mkwsPager div:nth-child(2) a").length >= 2 ? true : false;
186         }, "Expect next link 2", 10 * jasmine_config.second);
187
188         runs(function () {
189             // click next/prev after N seconds
190             my_click(".mkwsNext", 0);
191         });
192
193         waitsFor(function () {
194             return $("div.mkwsPager div:nth-child(2) a").length >= 3 ? true : false;
195         }, "Expect next link 3", 5 * jasmine_config.second);
196
197         runs(function () {
198             // click next/prev after N seconds
199             my_click(".mkwsNext", 0);
200             my_click(".mkwsPrev", 0.2);
201         });
202     });
203 });
204
205 describe("Check pazpar2 hit counter", function () {
206     var $ = mkws.$;
207
208     it("check running search hit counter", function () {
209         var max_time = jasmine_config.max_time; // in seconds
210         var expected_hits = jasmine_config.expected_hits; // at least expected hit counter
211         var hits = 0;
212
213         waitsFor(function () {
214             hits = get_hit_counter();
215             return hits > expected_hits;
216         }, "Expect " + expected_hits + " hits", max_time * jasmine_config.second);
217
218         runs(function () {
219             debug("mkws pager found records: '" + hits + "'");
220             expect($(".mkwsPager").length).toBe(1);
221             expect(hits).toBeGreaterThan(expected_hits);
222         });
223     });
224 });
225
226 describe("Check Termlist", function () {
227     var $ = mkws.$;
228
229     it("found Termlist", function () {
230         var termlist = $("div.mkwsTermlists");
231         debug("Termlist success: " + termlist.length);
232         expect(termlist.length).toBe(1);
233
234         waitsFor(function () {
235             return $("div.mkwsFacet[data-mkws-facet='xtargets']").length == 1 ? true : false;
236         }, "check for facet sources", 4 * jasmine_config.second);
237
238         // everything displayed?
239         runs(function () {
240             var sources = $("div.mkwsFacet[data-mkws-facet='xtargets']");
241             debug("Termlist sources success: " + sources.length);
242             expect(sources.length).toBe(1);
243
244             var subjects = $("div.mkwsFacet[data-mkws-facet='subject']");
245             expect(subjects.length).toBe(1);
246
247             var authors = $("div.mkwsFacet[data-mkws-facet='author']");
248             expect(authors.length).toBe(1);
249         });
250
251         waitsFor(function () {
252             return $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm").length >= 2 ? true : false;
253         }, "At least one author link displayed", 4 * jasmine_config.second);
254
255         runs(function () {
256             expect($("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm").length).toBeGreaterThan(1);
257         });
258     });
259 });
260
261
262
263 describe("Check Author Facets", function () {
264     var $ = mkws.$;
265
266     it("limit search to first author", function () {
267         if (mkws.config.disable_facet_authors_search) {
268             debug("Facets: ignore limit search for authors");
269             return;
270         }
271
272         var hits_all_targets = get_hit_counter();
273         var author_number = 2; // 2=first author
274         // do not click on author with numbers, e.g.: "Bower, James M. Beeman, David, 1938-"
275         // do not click on author names without a comma, e.g.: "Joe Barbara"
276         // because searching on such authors won't find anything.
277         runs(function () {
278             var terms = $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm a");
279             for (var i = 0; i < terms.length; i++) {
280                 var term = $(terms[i]).text();
281                 if (term.match(/[0-9].+[0-9]/i) || !term.match(/,/)) {
282                     debug("ignore author facet: " + term);
283                     author_number++;
284                 } else {
285                     break;
286                 }
287             }
288             if ($("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").text().length == 0) {
289                 debug("No good authors found. Not clicking on the bad ones");
290                 return;
291             }
292
293             debug("Clicking on author (" + author_number + ") " + $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").text());
294             $("div.mkwsFacet[data-mkws-facet='author'] div.mkwsTerm:nth-child(" + author_number + ") a").trigger("click");
295         });
296
297         waitsFor(function () {
298             var hits_single_target = get_hit_counter();
299             // debug("hits_single_target='" + hits_single_target + "' cf. hits_all_targets='" + hits_all_targets + "'");
300             return hits_single_target > 0 && hits_single_target < hits_all_targets ? true : false;
301         }, "Limited author search for less than " + hits_all_targets + " hits", 4.5 * jasmine_config.second);
302
303         runs(function () {
304             var hits_single_target = get_hit_counter();
305             debug("get less hits for authors: " + hits_all_targets + " > " + hits_single_target);
306         });
307     });
308 });
309
310 describe("Check active clients author", function () {
311     var $ = mkws.$;
312
313     it("check for active clients after limited author search", function () {
314         waitsFor(function () {
315             var clients = $("div.mkwsStat span.mkwsClientCount");
316             // debug("clients: " + clients.text());
317             return clients.length == 1 && clients.text().match("/[1-9]+[0-9]*$");
318         }, "wait for Active clients: x/y", 5.5 * jasmine_config.second);
319
320         runs(function () {
321             var clients = $("div.mkwsStat span.mkwsClientCount");
322             debug("span.mkwsClientCount: " + clients.text());
323             expect(clients.text()).toMatch("/[1-9]+[0-9]*$");
324
325             // exact match of active clients (e.g. a SP misconfiguration)
326             if (jasmine_config.active_clients) {
327                 debug("check for " + jasmine_config.active_clients + " active connections");
328                 expect(clients.text()).toMatch(" [0-9]+/" + jasmine_config.active_clients + "$");
329             }
330         });
331     });
332 });
333
334 describe("Check Source Facets", function () {
335     var $ = mkws.$;
336
337     it("limit search to first source", function () {
338         var hits_all_targets = get_hit_counter();
339         var source_number = 2; // 2=first source
340         // wait for a stat response
341         var waitcount = 0;
342         // do not click on wikipedia link - no author or subject facets possible
343         var link = "div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm a";
344
345         // wait for a visible source link in facets
346         waitsFor(function () {
347             var terms = $(link);
348             return terms && terms.length > 0;
349         }, "wait for source facets after author search", 5 * jasmine_config.second);
350
351
352         runs(function () {
353             var terms = $(link);
354             for (var i = 0; i < terms.length; i++) {
355                 var term = $(terms[i]).text();
356                 debug("check for good source: " + term);
357
358                 if (term.match(/wikipedia/i)) {
359                     debug("ignore source facet: " + term);
360                     source_number++;
361                 } else {
362                     break;
363                 }
364             }
365             debug("Source counter: " + terms.length + ", select: " + (source_number - 1));
366
367             if ($("div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm:nth-child(" + source_number + ") a").text().length == 0) {
368                 debug("No good source found. Not clicking on the bad ones");
369                 return;
370             }
371
372             debug("click on source link nth-child(): " + source_number);
373             $("div.mkwsFacet[data-mkws-facet='xtargets'] div.mkwsTerm:nth-child(" + source_number + ") a").trigger("click");
374
375             $(".mkwsPager").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
376                 waitcount++;
377                 debug("DOM change mkwsPager, for stat: " + waitcount);
378             });
379         });
380
381         waitsFor(function () {
382             if ($("div.mkwsNavi").length && $("div.mkwsNavi").text().match(/(Source|datenquelle|kilder): /i)) {
383                 return true;
384             } else {
385                 return false;
386             }
387         }, "Search for source in navi bar", 4 * jasmine_config.second);
388
389         // Note: it may happens that limited source search returns the same number of hits
390         // as before. Thats not really an error, but unfortunate
391         waitsFor(function () {
392             var hits_single_target = get_hit_counter();
393
394             return waitcount >= 2 && hits_single_target > 0 && hits_single_target <= hits_all_targets ? true : false;
395         }, "Limited source search for less than " + hits_all_targets + " hits", 5 * jasmine_config.second);
396
397         runs(function () {
398             var hits_single_target = get_hit_counter();
399             debug("get less hits for sources: " + hits_all_targets + " >= " + hits_single_target);
400             expect(hits_all_targets).not.toBeLessThan(hits_single_target);
401             jasmine_status.source_click = 1;
402
403             $(".mkwsPager").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
404         });
405     });
406 });
407
408
409 describe("Check record list", function () {
410     var $ = mkws.$;
411
412     it("check for single active client", function () {
413         if (!jasmine_status.source_click) {
414             debug("skip clients check due missing source click");
415             return;
416         }
417
418         waitsFor(function () {
419             var clients = $("div.mkwsStat span.mkwsClientCount");
420             //debug("clients: " + clients.text());
421             return clients.length == 1 && clients.text().match("/1$");
422         }, "wait for Active clients: x/1", 5 * jasmine_config.second);
423
424         runs(function () {
425             var clients = $("div.mkwsStat span.mkwsClientCount");
426             debug("span.mkwsClientCount: " + clients.text());
427             expect(clients.text()).toMatch("/1$");
428         });
429     });
430
431     it("got a record", function () {
432         var linkaddr = "div.mkwsRecords div.mkwsSummary:nth-child(1) a";
433
434         waitsFor(function () {
435             // remove + insert node: must be at least 2
436             return $(linkaddr).length > 0;
437         }, "wait until we see a new record", 2.5 * jasmine_config.second);
438
439         runs(function () {
440             expect($(linkaddr).length).toBeGreaterThan(0);
441         });
442     });
443 });
444
445 describe("Show record", function () {
446     var $ = mkws.$;
447
448     var record_number = 1; // the Nth record in hit list
449     it("show record author", function () {
450         var click = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") a").trigger("click");
451         debug("show record click is success: " + click.length);
452         expect(click.length).toBe(1);
453
454         // wait until the record pops up
455         waitsFor(function () {
456             var show = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") > div.mkwsDetails");
457             //debug("poprecord: " + (show ? show.length : -1) + " " + $("div.mkwsRecords div.mkwsSummary").text());
458             return show != null && show.length ? true : false;
459         }, "wait some miliseconds to show up a record", 2 * jasmine_config.second);
460
461         runs(function () {
462             debug("show record pop up");
463             expect($("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div")).not.toBe(null);
464         });
465     });
466
467     it("extract URL", function () {
468         if (jasmine_config.show_record_url == false) {
469             debug("ignore test for URL in record")
470             return;
471         }
472
473         var urls = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div table tbody tr td a");
474         debug("number of extracted URL from record: " + urls.length);
475         // expect(urls.length).toBeGreaterThan(0); // LoC has records without links
476         for (var i = 0; i < urls.length; i++) {
477             var url = $(urls[i]);
478             debug("URL: " + url.attr('href') + " text: " + url.text());
479
480             expect(url.attr('href')).not.toBe(null);
481             expect(url.attr('href')).toMatch(/^https?:\/\/[a-z0-9\-]+\.[0-9a-z].*\//i);
482             expect(url.text()).not.toBe("");
483         }
484     });
485 });
486
487 describe("Check switch menu Records/Targets", function () {
488     var $ = mkws.$;
489
490     it("check mkwsSwitch", function () {
491         expect($("div.mkwsSwitch").length).toBe(1);
492
493         // expect 2 clickable links
494         expect($("div.mkwsSwitch > a").length).toBe(2);
495     });
496
497     it("switch to target view", function () {
498         $("div.mkwsSwitch > a").eq(1).trigger("click");
499
500         // now the target table must be visible
501         expect($("div.mkwsTargets").is(":visible")).toBe(true);
502         expect($("div.mkwsRecords").is(":visible")).toBe(false);
503
504         // wait a half second, to show the target view
505         var time = (new Date).getTime();
506         waitsFor(function () {
507             return (new Date).getTime() - time > 700 ? true : false;
508         }, "wait some miliseconds", 1 * jasmine_config.second);
509
510         // look for table header
511         runs(function () {
512             expect($("div.mkwsTargets").html()).toMatch(/Target ID/);
513         });
514     });
515
516     it("switch back to record view", function () {
517         $("div.mkwsSwitch > a").eq(0).trigger("click");
518
519         // now the target table must be visible
520         expect($("div.mkwsTargets").is(":visible")).toBe(false);
521         expect($("div.mkwsRecords").is(":visible")).toBe(true);
522     });
523 });
524
525 describe("Check status client counter", function () {
526     var $ = mkws.$;
527
528     function get_time() {
529         var date = new Date();
530         return date.getTime();
531     }
532     var time = get_time();
533
534     it("check status clients", function () {
535         if (!jasmine_status.source_click) {
536             debug("skip clients check due missing source click");
537             return;
538         }
539
540         waitsFor(function () {
541             var clients = $("div.mkwsStat span.mkwsClientCount");
542             debug("clients: " + clients.text());
543             if (clients.length == 1 && clients.text().match("0/1$")) {
544                 return true;
545             } else {
546                 return false;
547             }
548         }, "wait for Active clients: 0/1", 4 * jasmine_config.second);
549
550         runs(function () {
551             var clients = $("div.mkwsStat span.mkwsClientCount");
552             debug("span.mkwsClientCount: " + clients.text());
553             expect(clients.text()).toMatch("0/1$");
554         });
555     });
556 });
557
558 /* remove the "source" and "author" facet link to get more records again */
559 describe("Check removable facets links", function () {
560     var $ = mkws.$;
561
562     it("remove links for source and author", function () {
563         var waitcount = 0;
564         if (!jasmine_config.check_sortby) {
565             debug("ignore check for removable facets");
566             return;
567         }
568
569
570         runs(function () {
571             var click = $("a.mkwsRemovable").eq(0).trigger("click");
572             debug("Removed first facets link: " + click.length);
573             expect(click.length).toBe(1);
574         });
575
576         runs(function () {
577             $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
578                 waitcount++;
579                 debug("DOM change mkwsRecords for removeable: " + waitcount);
580             });
581         });
582
583         waitsFor(function () {
584             return waitcount >= 2 && $("a.mkwsRemovable").length == 1 ? 1 : 0;
585         }, "Records DOM change mkwsRecords, removable", 2 * jasmine_config.second);
586
587         runs(function () {
588             debug("unbind removable");
589             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
590             waitcount = 0;
591
592             $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
593                 waitcount++;
594                 debug("DOM change mkwsRecords for removeable2: " + waitcount);
595             });
596
597             var click = $("a.mkwsRemovable").eq(0).trigger("click");
598             debug("Removed second facets link: " + click.length);
599             expect(click.length).toBe(1);
600         });
601
602         waitsFor(function () {
603             return waitcount >= 2 && $("a.mkwsRemovable").length == 0 ? true : false;
604         }, "DOM change mkwsRecords, removable2", 2 * jasmine_config.second);
605
606         runs(function () {
607             debug("unbind removable2");
608             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
609         });
610     });
611 });
612
613
614 describe("Check per page options", function () {
615     var $ = mkws.$;
616
617     it("show per page", function () {
618         if (!jasmine_config.check_sortby) {
619             debug("ignore check for per page select");
620             return;
621         }
622         var waitcount = 0;
623         var per_page_number = 20;
624
625
626         runs(function () {
627             var select = $("select.mkwsPerpage option[selected='selected']");
628             debug("per page default is: " + select.text() + " and unselect it");
629             select.removeAttr('selected');
630
631             select = $("select.mkwsPerpage option[value='" + per_page_number + "']").attr('selected', true);
632             debug("per page is set to: " + select.text());
633             select.trigger("change");
634
635             $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
636                 waitcount++;
637                 debug("DOM change mkwsRecords, per page: " + waitcount);
638             });
639         });
640
641         waitsFor(function () {
642             // debug("per page waitcounter: " + waitcount)
643             return waitcount >= (per_page_number + 10) ? true : false;
644         }, "DOM change mkwsRecords, by per page", 3 * jasmine_config.second);
645
646         runs(function () {
647             debug("unbind per page");
648             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
649
650             var records = $("div.mkwsRecords > div.mkwsSummary");
651             debug("Per page got now " + records.length + " records");
652             expect(records.length).toBe(per_page_number);
653         });
654     });
655 });
656
657 describe("Check SortBy options", function () {
658     var $ = mkws.$;
659
660     it("show per page", function () {
661         if (!jasmine_config.check_sortby) {
662             debug("ignore check for sort by");
663             return;
664         }
665
666         var waitcount = 0;
667         var sort_value = 'title:1';
668         var per_page_number = 20;
669         var title_list_old = title_list("xxx ");
670
671         function title_list(prefix) {
672             var list = [];
673             var terms = $("div.mkwsRecords > div.mkwsSummary > a");
674             for (var i = 0; i < terms.length; i++) {
675                 var term = $(terms[i]).text();
676                 list.push(term);
677                 // debug(prefix + "title: " + term);
678             }
679             return list;
680         }
681
682         runs(function () {
683             $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
684                 waitcount++;
685                 debug("DOM change mkwsRecords, sort by: " + waitcount);
686             });
687
688             var select = $("select.mkwsSort option[selected='selected']");
689             debug("Sort by default is: " + select.text() + " and unselect it");
690             select.removeAttr('selected');
691
692             select = $("select.mkwsSort option[value='" + sort_value + "']").attr('selected', true);
693             debug("sort by is set to: " + select.text());
694             select.trigger("change");
695         });
696
697         waitsFor(function () {
698             //debug("wait for2: " + waitcount);
699             return waitcount >= (per_page_number + 10)? true : false;
700         }, "DOM change mkwsRecords, by sort page", 3 * jasmine_config.second);
701
702         runs(function () {
703             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
704             debug("unbind by sort");
705
706             var records = $("div.mkwsRecords > div.mkwsSummary a");
707             debug("Sort by got now " + records.length + " records");
708             expect(records.length).toBe(per_page_number);
709         });
710
711         runs(function () {
712             var title_list_new = title_list("yyy ");
713             var diff_flag = 0;
714             for (var i = 0; i < title_list_old.length; i++) {
715                 debug(title_list_old[i] + " :: " + title_list_new[i]);
716
717                 if (title_list_old[i] != title_list_new[i]) {
718                     diff_flag++;
719                 }
720             }
721             debug("Title changes: " + diff_flag + " out of " + per_page_number);
722             expect(diff_flag).not.toBe(0);
723         });
724     });
725 });
726
727
728 /* done */
729 describe("All tests are done", function () {
730     it(">>> hooray <<<", function () {
731         mkws.jasmine_done = true;
732         debug(">>> hooray <<<");
733     });
734 });