X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=test%2Fspec%2Fmkws-pazpar2.js;h=ceecc5ddc5de9ccac92e52eb90e94a584833d04b;hb=bb7a8e61e67b1bfd4ae000b721fbe124e241755a;hp=487636d7fc47e0881a06ea3add81fbec96b43d1f;hpb=2486a3a6a3cf359ec252100dfb8e0d398918ab58;p=mkws-moved-to-github.git diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js index 487636d..ceecc5d 100644 --- a/test/spec/mkws-pazpar2.js +++ b/test/spec/mkws-pazpar2.js @@ -30,6 +30,9 @@ var jasmine_status = { function init_jasmine_config() { var jasmine_config_default = { + // tune parameter for batch testing + batch_tuning: true, + search_query: "freebsd", max_time: 17, // in seconds @@ -55,6 +58,21 @@ function init_jasmine_config() { debug("jasmine config: " + key + " => " + jasmine_config[key]); } + // jenkins batch tests + if (jasmine_config.batch_tuning) { + var sec = mkws.getParameterByName("second", document.location); + + // run on localhost + if (!sec && document.location.href.match(/^http:\/\/localhost:4040/)) { + sec = 2000; + } + + if (sec && parseInt(sec) >= 100) { + jasmine_config.second = parseInt(sec); + debug("longer timeouts for batch testing: " + jasmine_config.second); + } + } + mkws.jasmine_done = false; }; @@ -333,6 +351,19 @@ describe("Check active clients author", function () { } }); }); + + // avoid race conditions of source facets updates + it("wait a little bit for a source facets update", function () { + // wait a half second, to show the target view + var waittime = 0.5; + var time = (new Date).getTime(); + + waitsFor(function () { + return (new Date).getTime() - time > (waittime * jasmine_config.second) ? true : false; + }, "wait some miliseconds", (waittime + 0.5) * jasmine_config.second); + + runs(function () {}); + }); }); describe("Check Source Facets", function () { @@ -506,10 +537,11 @@ describe("Check switch menu Records/Targets", function () { expect($("div.mkws-records").is(":visible")).toBe(false); // wait a half second, to show the target view + var waittime = 0.7; var time = (new Date).getTime(); waitsFor(function () { - return (new Date).getTime() - time > 700 ? true : false; - }, "wait some miliseconds", 1 * jasmine_config.second); + return (new Date).getTime() - time > (waittime * jasmine_config.second) ? true : false; + }, "wait some miliseconds", (waittime + 0.3) * jasmine_config.second); // look for table header runs(function () { @@ -526,6 +558,7 @@ describe("Check switch menu Records/Targets", function () { }); }); +// temporary disabled due records without an author, MKWS-400 describe("Check translations", function () { var $ = mkws.$; @@ -535,6 +568,7 @@ describe("Check translations", function () { debug("translate check for: " + text); return text; }; + var lang = function () { return mkws.config.lang }; @@ -543,10 +577,28 @@ describe("Check translations", function () { expect(list.length).toBe(text.length); for (var i = 0; i < text.length; i++) { - expect($(list[i]).text()).toBe(M(text[i])); + expect($(list[i]).text().match(M(text[i]))).not.toBeNull(); } } + function check_translation_list(list, keywords) { + var errors = []; + for (var i = 0; i < keywords.length; i++) { + var text = $(list[i]); + var keyword = keywords[i]; + + if (text.text().match("^" + M(keyword) + "")) { + debug("found: " + text.text() + " :: " + keyword); + } else { + debug("NOT found: " + text.text() + " :: " + keyword); + errors.push(keyword) + } + } + + // we except one missing field, or one error + expect(errors.length).not.toBeGreaterThan(1); + } + it("check language", function () { var lang = mkws.config.lang; debug("lang: " + lang); @@ -577,9 +629,14 @@ describe("Check translations", function () { "Date": "Datum", "Subject": "Schlagwort", "subject": "schlagwort", - "Location": "Ort", + "Location": "Bestand", + "Locations": "Bestand", "Records": "Datensätze", "Targets": "Datenbanken", + "relevance": "Relevanz", + "title": "Titel", + "newest": "Neueste", + "oldest": "Älteste", "dummy": "dummy" }, @@ -612,9 +669,12 @@ describe("Check translations", function () { expect("Sorter efter").toBe(M("Sort by")); expect("Sorter efter").toBe($(list[0]).text()); } + + + expect($("select.mkws-sort > option[selected=selected]").text()).toBe(M("relevance")); }); - xit("facets sidebar", function () { + it("facets sidebar", function () { var list = $(".mkws-facet-title"); var text = ["Sources", "Subjects", "Authors"]; @@ -634,19 +694,25 @@ describe("Check translations", function () { check_translation(list, text); - expect($(".mkws-next").text()).toBe(M("Next")); - expect($(".mkws-prev").text()).toBe(M("Prev")); + expect($(".mkws-next").text().match(M("Next"))).not.toBeNull(); + expect($(".mkws-next").text().match(M("NextXXX"))).toBeNull(); + expect($(".mkws-prev").text().match(M("Prev"))).not.toBeNull(); }); it("record details", function () { - var text = ["Title", "Date", "Author"]; // , "Subject", "Locations"]; + var keywords = ["Title", "Date", "Author"]; // , "Subject", "Locations"]; var list = $("div.mkws-details table > tbody > tr > th"); // compare only the first 3 elements - list = list.splice(0, text.length) - - check_translation(list, text); + // list = list.splice(0, text.length) + check_translation_list(list, keywords); }); + +/* not tested + * + * Status line: -- Active clients : 0/1 -- Retrieved records : 4/4 + * + */ }); describe("Check status client counter", function () {