1 /* Copyright (c) 2013-2014 Index Data ApS. http://indexdata.com
3 * perform papzpar2 / pz2.js search & retrieve request in the browser
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"].info("Jasmine: " + text);
12 //mkws.log("Jasmine: " + text)
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 = {};
20 var jasmine_status = {
24 /* check config for jasmine test
26 * you can override the default values in the config
27 * object: jasmine_config = {};
30 function init_jasmine_config() {
32 var jasmine_config_default = {
33 // tune parameter for batch testing
36 search_query: "freebsd",
40 // at least expected hit counter
42 // miliseconds to seconds
43 show_record_url: true,
44 // check for valid URL in records
47 // check sort by and per page menu
53 // use default values for undefined values
54 for (var key in jasmine_config_default) {
55 if (!jasmine_config.hasOwnProperty(key)) {
56 jasmine_config[key] = jasmine_config_default[key];
58 debug("jasmine config: " + key + " => " + jasmine_config[key]);
61 // jenkins batch tests
62 if (jasmine_config.batch_tuning) {
63 var sec = mkws.getParameterByName("second", document.location);
66 if (!sec && document.location.href.match(/^http:\/\/localhost:4040/)) {
70 if (sec && parseInt(sec) >= 100) {
71 jasmine_config.second = parseInt(sec);
72 debug("longer timeouts for batch testing: " + jasmine_config.second);
76 mkws.jasmine_done = false;
79 function get_hit_counter() {
82 if ($(".mkws-pager").length == 0) return -1;
84 var found = $(".mkws-pager").text();
85 var re = /\([A-Za-z]+:\s+([0-9]+)\)/;
90 hits = parseInt(RegExp.$1);
92 debug("Oooops in get_hit_counter: " + RegExp.$1 + " '" + found + "'");
96 //debug("Hits: " + hits);
100 /******************************************************************************/
101 describe("Init jasmine config", function () {
102 it("jasmine was successfully initialized", function () {
103 init_jasmine_config();
105 expect(jasmine_config.search_query).toMatch(/\w/);
106 expect(jasmine_config.second).toBeGreaterThan(100);
107 expect(jasmine_config.max_time).toBeGreaterThan(1);
108 expect(jasmine_config.expected_hits).toBeGreaterThan(1);
113 xdescribe("Check MOTD before search", function () {
116 // Check that the MOTD has been moved into its container, and
117 // is visible before the search.
118 // the mkws-motd div was originally inside a testMOTD div, which should
120 // Note that the testMOTD is a regular div, and uses #testMOTD,
121 // since the automagic class-making does not apply to it.
122 it("MOTD is hidden", function () {
123 expect($(".mkws-motd").length).toBe(1);
124 expect($("#testMOTD").length).toBe(1);
125 expect($("#testMOTD").text()).toMatch("^ *$");
128 it("mkws-motd-container has received the text", function () {
129 expect($(".mkws-motd-container").length).toBe(1);
130 expect($(".mkws-motd-container").text()).toMatch(/MOTD/);
134 describe("Check pazpar2 search", function () {
137 it("pazpar2 was successfully initialized", function () {
138 expect(mkws.config.error).toBe(undefined);
141 it("validate HTML id's", function () {
142 expect($("input.mkws-query").length).toBe(1);
143 expect($("input.mkws-button").length).toBe(1);
145 expect($(".mkws-next").length).not.toBe(1);
146 expect($(".mkws-prev").length).not.toBe(1);
149 it("run search query", function () {
150 var search_query = jasmine_config.search_query; // short hit counter with some paging
151 $("input.mkws-query").val(search_query);
152 debug("set search query: " + search_query)
153 expect($("input.mkws-query").val()).toMatch("^" + search_query + "$");
155 if (mkws.config.use_service_proxy) {
156 // wait for service proxy auth
157 waitsFor(function () {
158 return mkws.authenticated;
159 }, "SP auth done", 10 * jasmine_config.second);
161 debug("running raw pp2, don't wait for mkws auth");
165 debug("Click on submit button");
166 $("input.mkws-button").trigger("click");
171 describe("Check MOTD after search", function () {
174 it("MOTD is hidden", function () {
175 if (!jasmine_config.check_motd) {
179 expect($(".mkws-motd").length).toBe(1);
180 expect($(".mkws-motd").is(":hidden")).toBe(true);
181 debug("motd t=" + $(".mkws-motd").text());
182 debug("motd v=" + $(".mkws-motd").is(":visible"));
188 * This part runs in background. It should be rewritten with
189 * async jasmine functions
192 describe("Check pazpar2 navigation", function () {
196 it("check running search next/prev", function () {
197 expect($(".mkws-pager").length).toBe(1);
199 function my_click(id, time) {
200 setTimeout(function () {
201 debug("trigger click on id: " + id);
202 $(id).trigger("click");
203 }, time * jasmine_config.second);
206 waitsFor(function () {
207 return $("div.mkws-pager div:nth-child(2) a").length >= 2 ? true : false;
208 }, "Expect next link 2", 10 * jasmine_config.second);
211 // click next/prev after N seconds
212 my_click(".mkws-next", 0);
215 waitsFor(function () {
216 return $("div.mkws-pager div:nth-child(2) a").length >= 3 ? true : false;
217 }, "Expect next link 3", 5 * jasmine_config.second);
220 // click next/prev after N seconds
221 my_click(".mkws-next", 0);
222 my_click(".mkws-prev", 0.2);
227 describe("Check pazpar2 hit counter", function () {
230 it("check running search hit counter", function () {
231 var max_time = jasmine_config.max_time; // in seconds
232 var expected_hits = jasmine_config.expected_hits; // at least expected hit counter
235 waitsFor(function () {
236 hits = get_hit_counter();
237 return hits > expected_hits;
238 }, "Expect " + expected_hits + " hits", max_time * jasmine_config.second);
241 debug("mkws pager found records: '" + hits + "'");
242 expect($(".mkws-pager").length).toBe(1);
243 expect(hits).toBeGreaterThan(expected_hits);
248 describe("Check Facets", function () {
251 it("found Facets", function () {
252 var facets = $("div.mkws-facets");
253 debug("Facet success: " + facets.length);
254 expect(facets.length).toBe(1);
256 waitsFor(function () {
257 return $("div.mkws-facet[data-mkws-facet='xtargets']").length == 1 ? true : false;
258 }, "check for facet sources", 4 * jasmine_config.second);
260 // everything displayed?
262 var sources = $("div.mkws-facet[data-mkws-facet='xtargets']");
263 debug("Facet sources success: " + sources.length);
264 expect(sources.length).toBe(1);
266 var subjects = $("div.mkws-facet[data-mkws-facet='subject']");
267 expect(subjects.length).toBe(1);
269 var authors = $("div.mkws-facet[data-mkws-facet='author']");
270 expect(authors.length).toBe(1);
273 waitsFor(function () {
274 return $("div.mkws-facet[data-mkws-facet='author'] div.mkws-term").length >= 2 ? true : false;
275 }, "At least two author link displayed", 4 * jasmine_config.second);
278 expect($("div.mkws-facet[data-mkws-facet='author'] div.mkws-term").length).toBeGreaterThan(1);
285 describe("Check Author Facets", function () {
288 it("limit search to first author", function () {
289 if (mkws.config.disable_facet_authors_search) {
290 debug("Facets: ignore limit search for authors");
294 var hits_all_targets = get_hit_counter();
295 var author_number = 2; // 2=first author
296 // do not click on author with numbers, e.g.: "Bower, James M. Beeman, David, 1938-"
297 // do not click on author names without a comma, e.g.: "Joe Barbara"
298 // because searching on such authors won't find anything.
300 var terms = $("div.mkws-facet[data-mkws-facet='author'] div.mkws-term a");
301 for (var i = 0; i < terms.length; i++) {
302 var term = $(terms[i]).text();
303 if (term.match(/[0-9].+[0-9]/i) || !term.match(/,/)) {
304 debug("ignore author facet: " + term);
310 if ($("div.mkws-facet[data-mkws-facet='author'] div.mkws-term:nth-child(" + author_number + ") a").text().length == 0) {
311 debug("No good authors found. Not clicking on the bad ones");
315 debug("Clicking on author (" + author_number + ") " + $("div.mkws-facet[data-mkws-facet='author'] div.mkws-term:nth-child(" + author_number + ") a").text());
316 $("div.mkws-facet[data-mkws-facet='author'] div.mkws-term:nth-child(" + author_number + ") a").trigger("click");
319 waitsFor(function () {
320 var hits_single_target = get_hit_counter();
321 // debug("hits_single_target='" + hits_single_target + "' cf. hits_all_targets='" + hits_all_targets + "'");
322 return hits_single_target > 0 && hits_single_target < hits_all_targets ? true : false;
323 }, "Limited author search for less than " + hits_all_targets + " hits", 4.5 * jasmine_config.second);
326 var hits_single_target = get_hit_counter();
327 debug("get less hits for authors: " + hits_all_targets + " > " + hits_single_target);
332 describe("Check active clients author", function () {
335 it("check for active clients after limited author search", function () {
336 waitsFor(function () {
337 var clients = $("div.mkws-stat span.mkws-client-count");
338 // debug("clients: " + clients.text());
339 return clients.length == 1 && clients.text().match("/[1-9]+[0-9]*$");
340 }, "wait for Active clients: x/y", 5.5 * jasmine_config.second);
343 var clients = $("div.mkws-stat span.mkws-client-count");
344 debug("span.mkws-client-count: " + clients.text());
345 expect(clients.text()).toMatch("/[1-9]+[0-9]*$");
347 // exact match of active clients (e.g. a SP misconfiguration)
348 if (jasmine_config.active_clients) {
349 debug("check for " + jasmine_config.active_clients + " active connections");
350 expect(clients.text()).toMatch(" [0-9]+/" + jasmine_config.active_clients + "$");
355 // avoid race conditions of source facets updates
356 it("wait a little bit for a source facets update", function () {
357 // wait a half second, to show the target view
359 var time = (new Date).getTime();
361 waitsFor(function () {
362 return (new Date).getTime() - time > (waittime * jasmine_config.second) ? true : false;
363 }, "wait some miliseconds", (waittime + 0.5) * jasmine_config.second);
365 runs(function () {});
369 describe("Check Source Facets", function () {
372 it("limit search to first source", function () {
373 var hits_all_targets = get_hit_counter();
374 var source_number = 2; // 2=first source
375 // wait for a stat response
377 // do not click on wikipedia link - no author or subject facets possible
378 var link = "div.mkws-facet[data-mkws-facet='xtargets'] div.mkws-term a";
380 // wait for a visible source link in facets
381 waitsFor(function () {
383 return terms && terms.length > 0;
384 }, "wait for source facets after author search", 5 * jasmine_config.second);
389 for (var i = 0; i < terms.length; i++) {
390 var term = $(terms[i]).text();
391 debug("check for good source: " + term);
393 if (term.match(/wikipedia/i)) {
394 debug("ignore source facet: " + term);
400 debug("Source counter: " + terms.length + ", select: " + (source_number - 1));
402 if ($("div.mkws-facet[data-mkws-facet='xtargets'] div.mkws-term:nth-child(" + source_number + ") a").text().length == 0) {
403 debug("No good source found. Not clicking on the bad ones");
407 debug("click on source link nth-child(): " + source_number);
408 $("div.mkws-facet[data-mkws-facet='xtargets'] div.mkws-term:nth-child(" + source_number + ") a").trigger("click");
410 $(".mkws-pager").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
412 debug("DOM change mkws-pager, for stat: " + waitcount);
416 waitsFor(function () {
417 if ($("div.mkws-navi").length && $("div.mkws-navi").text().match(/(Source|datenquelle|kilder): /i)) {
422 }, "Search for source in navi bar", 4 * jasmine_config.second);
424 // Note: it may happens that limited source search returns the same number of hits
425 // as before. Thats not really an error, but unfortunate
426 waitsFor(function () {
427 var hits_single_target = get_hit_counter();
429 return waitcount >= 2 && hits_single_target > 0 && hits_single_target <= hits_all_targets ? true : false;
430 }, "Limited source search for less than " + hits_all_targets + " hits", 5 * jasmine_config.second);
433 var hits_single_target = get_hit_counter();
434 debug("get less hits for sources: " + hits_all_targets + " >= " + hits_single_target);
435 expect(hits_all_targets).not.toBeLessThan(hits_single_target);
436 jasmine_status.source_click = 1;
438 $(".mkws-pager").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
444 describe("Check record list", function () {
447 it("check for single active client", function () {
448 if (!jasmine_status.source_click) {
449 debug("skip clients check due missing source click");
453 waitsFor(function () {
454 var clients = $("div.mkws-stat span.mkws-client-count");
455 //debug("clients: " + clients.text());
456 return clients.length == 1 && clients.text().match("/1$");
457 }, "wait for Active clients: x/1", 5 * jasmine_config.second);
460 var clients = $("div.mkws-stat span.mkws-client-count");
461 debug("span.mkws-client-count: " + clients.text());
462 expect(clients.text()).toMatch("/1$");
466 it("got a record", function () {
467 var linkaddr = "div.mkws-records div.mkws-summary:nth-child(1) a";
469 waitsFor(function () {
470 // remove + insert node: must be at least 2
471 return $(linkaddr).length > 0;
472 }, "wait until we see a new record", 2.5 * jasmine_config.second);
475 expect($(linkaddr).length).toBeGreaterThan(0);
480 describe("Show record", function () {
483 var record_number = 1; // the Nth record in hit list
484 it("show record author", function () {
485 var click = $("div.mkws-records div.mkws-summary:nth-child(" + record_number + ") a").trigger("click");
486 debug("show record click is success: " + click.length);
487 expect(click.length).toBe(1);
489 // wait until the record pops up
490 waitsFor(function () {
491 var show = $("div.mkws-records div.mkws-summary:nth-child(" + record_number + ") > div.mkws-details");
492 //debug("poprecord: " + (show ? show.length : -1) + " " + $("div.mkws-records div.mkws-summary").text());
493 return show != null && show.length ? true : false;
494 }, "wait some miliseconds to show up a record", 2 * jasmine_config.second);
497 debug("show record pop up");
498 expect($("div.mkws-records div.mkws-summary:nth-child(" + record_number + ") div")).not.toBe(null);
502 it("extract URL", function () {
503 if (jasmine_config.show_record_url == false) {
504 debug("ignore test for URL in record")
508 var urls = $("div.mkws-records div.mkws-summary:nth-child(" + record_number + ") div table tbody tr td a");
509 debug("number of extracted URL from record: " + urls.length);
510 // expect(urls.length).toBeGreaterThan(0); // LoC has records without links
511 for (var i = 0; i < urls.length; i++) {
512 var url = $(urls[i]);
513 debug("URL: " + url.attr('href') + " text: " + url.text());
515 expect(url.attr('href')).not.toBe(null);
516 expect(url.attr('href')).toMatch(/^https?:\/\/[a-z0-9\-]+\.[0-9a-z].*\//i);
517 expect(url.text()).not.toBe("");
522 describe("Check switch menu Records/Targets", function () {
525 it("check mkws-switch", function () {
526 expect($("div.mkws-switch").length).toBe(1);
528 // expect 2 clickable links
529 expect($("div.mkws-switch > a").length).toBe(2);
532 it("switch to target view", function () {
533 $("div.mkws-switch > a").eq(1).trigger("click");
535 // now the target table must be visible
536 expect($("div.mkws-targets").is(":visible")).toBe(true);
537 expect($("div.mkws-records").is(":visible")).toBe(false);
539 // wait a half second, to show the target view
541 var time = (new Date).getTime();
542 waitsFor(function () {
543 return (new Date).getTime() - time > (waittime * jasmine_config.second) ? true : false;
544 }, "wait some miliseconds", (waittime + 0.3) * jasmine_config.second);
546 // look for table header
548 expect($("div.mkws-targets").html()).toMatch(/Target ID/);
552 it("switch back to record view", function () {
553 $("div.mkws-switch > a").eq(0).trigger("click");
555 // now the target table must be visible
556 expect($("div.mkws-targets").is(":visible")).toBe(false);
557 expect($("div.mkws-records").is(":visible")).toBe(true);
561 // temporary disabled due records without an author, MKWS-400
562 describe("Check translations", function () {
565 // handle html entities, "Zurück" => "Zurück"
566 var M = function (string) {
567 var text = $("<span/>").html(mkws.M(string)).text()
568 debug("translate check for: " + text);
572 var lang = function () {
573 return mkws.config.lang
576 function check_translation(list, text) {
577 expect(list.length).toBe(text.length);
579 for (var i = 0; i < text.length; i++) {
580 expect($(list[i]).text().match(M(text[i]))).not.toBeNull();
584 function check_translation_list(list, keywords) {
586 for (var i = 0; i < keywords.length; i++) {
587 var text = $(list[i]);
588 var keyword = keywords[i];
590 if (text.text().match("^" + M(keyword) + "")) {
591 debug("found: " + text.text() + " :: " + keyword);
593 debug("NOT found: " + text.text() + " :: " + keyword);
598 // we except one missing field, or one error
599 expect(errors.length).not.toBeGreaterThan(1);
602 it("check language", function () {
603 var lang = mkws.config.lang;
604 debug("lang: " + lang);
605 expect(lang).toMatch(/^(de|da|)$/);
611 "Authors": "Autoren",
612 "Subjects": "Schlagwörter",
613 "Sources": "Daten und Quellen",
614 "source": "datenquelle",
615 "Facets": "Termlisten",
617 "Prev": "Zurück",
619 "Sort by": "Sortieren nach",
620 "and show": "und zeige",
621 "per page": "pro Seite",
622 "Displaying": "Zeige",
630 "Subject": "Schlagwort",
631 "subject": "schlagwort",
632 "Location": "Bestand",
633 "Locations": "Bestand",
634 "Records": "Datensätze",
635 "Targets": "Datenbanken",
636 "relevance": "Relevanz",
639 "oldest": "Älteste",
645 it("search button", function () {
646 var list = $(".mkws-pager-desc > span");
647 expect($("form > input[type=submit]").attr("value")).toBe(M("Search"));
650 it("switch", function () {
651 var list = $(".mkws-switch > a")
652 var text = ["Records", "Targets"];
654 check_translation(list, text);
658 it("ranking form", function () {
659 var list = $(".mkws-ranking > form > span");
660 var text = ["Sort by", "and show", "per page"];
662 check_translation(list, text);
666 expect("Sortieren nach").toBe(M("Sort by"));
667 expect("Sortieren nach").toBe($(list[0]).text());
668 } else if (lang == "da") {
669 expect("Sorter efter").toBe(M("Sort by"));
670 expect("Sorter efter").toBe($(list[0]).text());
674 expect($("select.mkws-sort > option[selected=selected]").text()).toBe(M("relevance"));
677 it("facets sidebar", function () {
678 var list = $(".mkws-facet-title");
679 var text = ["Sources", "Subjects", "Authors"];
681 check_translation(list, text);
684 it("facets navigation/filter", function () {
685 var list = $(".mkws-navi > span");
686 var text = ["source", "author"];
688 check_translation(list, text);
691 it("navigation", function () {
692 var list = $(".mkws-pager-desc > span");
693 var text = ["Displaying", "to", "of", "found"];
695 check_translation(list, text);
697 expect($(".mkws-next").text().match(M("Next"))).not.toBeNull();
698 expect($(".mkws-next").text().match(M("NextXXX"))).toBeNull();
699 expect($(".mkws-prev").text().match(M("Prev"))).not.toBeNull();
702 it("record details", function () {
703 var keywords = ["Title", "Date", "Author"]; // , "Subject", "Locations"];
704 var list = $("div.mkws-details table > tbody > tr > th");
706 // compare only the first 3 elements
707 // list = list.splice(0, text.length)
708 check_translation_list(list, keywords);
713 * Status line: -- Active clients : 0/1 -- Retrieved records : 4/4
718 describe("Check status client counter", function () {
721 function get_time() {
722 var date = new Date();
723 return date.getTime();
725 var time = get_time();
727 it("check status clients", function () {
728 if (!jasmine_status.source_click) {
729 debug("skip clients check due missing source click");
733 waitsFor(function () {
734 var clients = $("div.mkws-stat span.mkws-client-count");
735 debug("clients: " + clients.text());
736 if (clients.length == 1 && clients.text().match("0/1$")) {
741 }, "wait for Active clients: 0/1", 4 * jasmine_config.second);
744 var clients = $("div.mkws-stat span.mkws-client-count");
745 debug("span.mkws-client-count: " + clients.text());
746 expect(clients.text()).toMatch("0/1$");
751 /* remove the "source" and "author" facet link to get more records again */
752 describe("Check removable facets links", function () {
755 it("remove links for source and author", function () {
757 if (!jasmine_config.check_sortby) {
758 debug("ignore check for removable facets");
764 var click = $("a.mkws-removable").eq(0).trigger("click");
765 debug("Removed first facets link: " + click.length);
766 expect(click.length).toBe(1);
770 $("div.mkws-records").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
772 if (waitcount <= 5 || (waitcount % 5 == 0)) {
773 debug("DOM change mkws-records for removeable: " + waitcount);
778 waitsFor(function () {
779 return waitcount >= 2 && $("a.mkws-removable").length == 1 ? 1 : 0;
780 }, "Records DOM change mkws-records, removable", 2 * jasmine_config.second);
783 debug("unbind removable");
784 $("div.mkws-records").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
787 $("div.mkws-records").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
789 if (waitcount <= 5 || (waitcount % 5 == 0)) {
790 debug("DOM change mkws-records for removeable2: " + waitcount);
794 var click = $("a.mkws-removable").eq(0).trigger("click");
795 debug("Removed second facets link: " + click.length);
796 expect(click.length).toBe(1);
799 waitsFor(function () {
800 return waitcount >= 2 && $("a.mkws-removable").length == 0 ? true : false;
801 }, "DOM change mkws-records, removable2", 2 * jasmine_config.second);
804 debug("unbind removable2");
805 $("div.mkws-records").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
811 describe("Check per page options", function () {
814 it("show per page", function () {
815 if (!jasmine_config.check_sortby) {
816 debug("ignore check for per page select");
820 var per_page_number = 20;
824 var select = $("select.mkws-perpage option[selected='selected']");
825 debug("per page default is: " + select.text() + " and unselect it");
826 select.removeAttr('selected');
828 select = $("select.mkws-perpage option[value='" + per_page_number + "']").attr('selected', true);
829 debug("per page is set to: " + select.text());
830 select.trigger("change");
832 $("div.mkws-records").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
834 if (waitcount <= 5 || (waitcount % 10 == 0)) {
835 debug("DOM change mkws-records, per page: " + waitcount);
840 waitsFor(function () {
841 // debug("per page waitcounter: " + waitcount)
842 return waitcount >= (per_page_number + 10) ? true : false;
843 }, "DOM change mkws-records, by per page", 3 * jasmine_config.second);
846 debug("unbind per page");
847 $("div.mkws-records").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
849 var records = $("div.mkws-records > div.mkws-summary");
850 debug("Per page got now " + records.length + " records");
851 expect(records.length).toBe(per_page_number);
856 describe("Check SortBy options", function () {
859 it("sort by title", function () {
860 if (!jasmine_config.check_sortby) {
861 debug("ignore check for sort by");
866 var sort_value = 'title:1';
867 var per_page_number = 20;
869 // keep current title list
870 var title_list_old = title_list("xxx ");
872 function title_list(prefix) {
874 var terms = $("div.mkws-records > div.mkws-summary > div.mkws-field-data span.mkws-field-title");
875 for (var i = 0; i < terms.length; i++) {
876 var term = $(terms[i]).text().trim();
878 // debug(prefix + "title: " + term);
884 $("div.mkws-records").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
886 if (waitcount <= 5 || (waitcount % 10 == 0)) {
887 debug("DOM change mkws-records, sort by: " + waitcount);
891 var select = $("select.mkws-sort option[selected='selected']");
892 debug("Sort by default is: " + select.text() + " and unselect it");
893 select.removeAttr('selected');
895 select = $("select.mkws-sort option[value='" + sort_value + "']").attr('selected', true);
896 debug("sort by is set to: " + select.text());
897 select.trigger("change");
900 waitsFor(function () {
901 //debug("wait for2: " + waitcount);
902 return waitcount >= (per_page_number + 10) ? true : false;
903 }, "DOM change mkws-records, by sort page", 3 * jasmine_config.second);
906 $("div.mkws-records").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
907 debug("unbind by sort");
909 var records = $("div.mkws-records > div.mkws-summary");
910 debug("Sort by got now " + records.length + " records");
911 expect(records.length).toBe(per_page_number);
915 var title_list_new = title_list("yyy ");
917 for (var i = 0; i < title_list_old.length; i++) {
918 debug((i + 1) + ". " + title_list_old[i] + " :: " + title_list_new[i]);
920 if (title_list_old[i] != title_list_new[i]) {
924 debug("Title changes: " + diff_flag + " out of " + per_page_number);
925 expect(diff_flag).not.toBe(0);
931 xdescribe("Check async widget discovery", function () {
933 it("initialises a new widget", function () {
934 $("div.mkws-search").after('<div id="asyncSearch"><div class="mkws-search mkws-team-async"></div></div>');
935 mkws.init("Another search box", "#asyncSearch");
936 waitsFor(function () {
937 return $("#asyncSearch input").length >= 1 ? true : false;
938 }, "Call init() to build an .mkws-search", 750);
940 var numInput = $("div.mkws-search input").length;
941 debug("Input elements present: " + numInput);
942 expect(numInput).toBe(4);
943 var numRec = $("div.mkws-records > div.mkws-summary").length;
944 debug("Records should still be present. There are: " + numRec);
945 expect(numRec).toBeGreaterThan(0);
951 describe("All tests are done", function () {
952 it(">>> hooray <<<", function () {
953 mkws.jasmine_done = true;
954 debug(">>> hooray <<<");