+ debug("next/prev: " + id + " click is success: " + click.length);
+ expect(click.length).toBe(1);
+ }, time * 1000);
+ }
+
+ waitsFor(function () {
+ return $("div#mkwsPager div:nth-child(2) a").length >= 2 ? true : false;
+ }, "Expect next link 2", 10 * 1000);
+
+ runs(function () {
+ // click next/prev after N seconds
+ my_click("#mkwsNext", 0);
+ });
+
+ waitsFor(function () {
+ return $("div#mkwsPager div:nth-child(2) a").length >= 3 ? true : false;
+ }, "Expect next link 3", 5 * 1000);
+
+ runs(function () {
+ // click next/prev after N seconds
+ my_click("#mkwsNext", 0);
+ my_click("#mkwsPrev", 0.2);
+ });
+ });
+});
+
+describe("Check pazpar2 hit counter", function () {
+ it("check running search hit counter", function () {
+ var max_time = 16; // in seconds
+ var expected_hits = 80; // at least expected hit counter
+ var hits = 0;
+
+ waitsFor(function () {
+ hits = get_hit_counter();
+
+ return hits > expected_hits;
+ }, "Expect " + expected_hits + " hits", max_time * 1000);
+
+
+ runs(function () {
+ debug("mkws pager found records: '" + hits + "'");
+ expect($("#mkwsPager").length).toBe(1);
+ expect(hits).toBeGreaterThan(expected_hits);
+ });
+ });
+});
+
+describe("Check Termlist", function () {
+ it("found Termlist", function () {
+ var termlist = $("div#mkwsTermlists");
+ debug("Termlist success: " + termlist.length);
+ expect(termlist.length).toBe(1);
+
+ waitsFor(function () {
+ return $("div#mkwsFacetSources").length == 1 ? true : false;
+ }, "check for facet sources", 2 * 1000);
+
+
+ // everything displayed?
+ runs(function () {
+ var sources = $("div#mkwsFacetSources");
+ debug("Termlist sources success: " + sources.length);
+ expect(sources.length).toBe(1);
+
+ var subjects = $("div#mkwsFacetSubjects");
+ expect(subjects.length).toBe(1);
+
+ var authors = $("div#mkwsFacetAuthors");
+ expect(authors.length).toBe(1);
+ });
+
+ waitsFor(function () {
+ return $("div#mkwsFacetAuthors div.term").length >= 2 ? true : false;
+ }, "At least one author link displayed", 2 * 1000);
+
+ runs(function () {
+ expect($("div#mkwsFacetAuthors div.term").length).toBeGreaterThan(1);
+ });
+ });
+
+ it("limit search to first author", function () {
+ var hits_all_targets = get_hit_counter();
+
+ var click = $("div#mkwsFacetAuthors div.term:nth-child(2) a").trigger("click");
+ debug("limit author click is success: " + click.length);
+ expect(click.length).toBe(1);
+
+ waitsFor(function () {
+ return get_hit_counter() < hits_all_targets ? true : false;
+ }, "Limited author search for less than " + hits_all_targets + " hits", 8 * 1000);
+
+ runs(function () {
+ var hits_single_target = get_hit_counter();
+ debug("get less hits for authors: " + hits_all_targets + " > " + hits_single_target);
+ expect(hits_all_targets).toBeGreaterThan(hits_single_target);
+ });
+ });
+
+ it("limit search to first source", function () {
+ var hits_all_targets = get_hit_counter();
+ var source_number = 2; // 2=first source
+ var source_name = $("div#mkwsFacetSources div.term:nth-child(" + source_number + ") a").text();
+ // do not click on wikipedia link - no author or subject facets possible
+ if (source_name.match(/wikipedia/i)) {
+ source_number++;