+ var search_query = "freebsd"; // short hit counter with some paging
+ $("input#mkwsQuery").val(search_query);
+ debug("set search query: " + search_query)
+ expect($("input#mkwsQuery").val()).toMatch("^" + search_query + "$");
+
+ // wait for service proxy auth
+ waitsFor(function () {
+ return mkws.authenticated;
+ }, "SP auth done", 10 * 1000);
+
+ runs(function () {
+ debug("Click on submit button");
+ var click = $("input#mkwsButton").trigger("click");
+ expect(click.length).toBe(1);
+ })
+ });
+});
+
+
+/*
+ * This part runs in background. It should be rewritten with
+ * async jasmine functions
+ *
+ */
+describe("Check pazpar2 navigation", function () {
+ // Asynchronous part
+ it("check running search next/prev", function () {
+ expect($("#mkwsPager").length).toBe(1);
+
+ function my_click(id, time) {
+ setTimeout(function () {
+ debug("trigger click on id: " + id);
+ var click = $(id).trigger("click");
+
+ 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);