+ var clients = $("div#mkwsStat span.clients");
+ debug("span.clients: " + clients.text());
+ expect(clients.text()).toMatch("/[1-9]+[0-9]+$");
+
+ // exact match of active clients (e.g. a SP misconfiguration)
+ if (jasmine_config.active_clients) {
+ debug("check for " + jasmine_config.active_clients + " active connections");
+ expect(clients.text()).toMatch(" [0-9]+/" + jasmine_config.active_clients + "$");
+ }
+ });
+ });
+
+ it("limit search to first source", function () {
+ var hits_all_targets = get_hit_counter();
+ var source_number = 2; // 2=first source
+ // do not click on wikipedia link - no author or subject facets possible
+ var terms = $("div.mkwsFacet[data-mkws-facet='xtargets'] div.term a");
+ for (var i = 0; i < terms.length; i++) {
+ var term = $(terms[i]).text();
+ if (term.match(/wikipedia/i)) {
+ debug("ignore source facet: " + term);
+ source_number++;
+ } else {
+ break;
+ }
+ }
+ if ($("div.mkwsFacet[data-mkws-facet='xtargets'] div.term:nth-child(" + source_number + ") a").text().length == 0) {
+ debug("No good source found. Not clicking on the bad ones");
+ return;
+ }
+
+ $("div.mkwsFacet[data-mkws-facet='xtargets'] div.term:nth-child(" + source_number + ") a").trigger("click");
+
+ // wait for a stat response
+ var waitcount = 0;
+ $(".mkwsPager").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+ waitcount++;
+ debug("DOM wait for stat: " + waitcount);
+ });
+
+ waitsFor(function () {
+ if ($("div.mkwsNavi").length && $("div.mkwsNavi").text().match(/(Source|datenquelle|kilder): /i)) {
+ return true;
+ } else {
+ return false;
+ }
+ }, "Search for source in navi bar", 4 * jasmine_config.second);
+
+ // Note: it may happens that limited source search returns the same number of hits
+ // as before. Thats not really an error, but unfortunate
+ waitsFor(function () {
+ var hits_single_target = get_hit_counter();
+
+ return waitcount >= 2 && hits_single_target > 0 && hits_single_target <= hits_all_targets ? true : false;
+ }, "Limited source search for less than " + hits_all_targets + " hits", 5 * jasmine_config.second);
+
+ runs(function () {
+ var hits_single_target = get_hit_counter();
+ debug("get less hits for sources: " + hits_all_targets + " > " + hits_single_target);
+ expect(hits_all_targets).not.toBeLessThan(hits_single_target);
+ jasmine_status.source_click = 1;
+
+ $(".mkwsPager").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
+ });
+ });
+});
+
+
+describe("Check record list", function () {
+ it("check for single active client", function () {
+ if (!jasmine_status.source_click) {
+ debug("skip clients check due missing source click");
+ return;
+ }
+
+ waitsFor(function () {
+ var clients = $("div#mkwsStat span.clients");
+ //debug("clients: " + clients.text());
+ return clients.length == 1 && clients.text().match("/1$");
+ }, "wait for Active clients: x/1", 5 * jasmine_config.second);
+
+ runs(function () {
+ var clients = $("div#mkwsStat span.clients");
+ debug("span.clients: " + clients.text());
+ expect(clients.text()).toMatch("/1$");
+ });
+ });
+
+ it("got a record", function () {
+ var linkaddr = "div.mkwsRecords div.record:nth-child(1) a";
+
+ waitsFor(function () {
+ // remove + insert node: must be at least 2
+ return $(linkaddr).length > 0;
+ }, "wait until we see a new record", 2.5 * jasmine_config.second);
+
+ runs(function () {
+ expect($(linkaddr).length).toBeGreaterThan(0);
+ });
+ });
+});
+
+describe("Show record", function () {
+ var record_number = 1; // the Nth record in hit list
+ it("show record author", function () {
+ var click = $("div.mkwsRecords div.record:nth-child(" + record_number + ") a").trigger("click");
+ debug("show record click is success: " + click.length);
+ expect(click.length).toBe(1);
+
+ // wait until the record pops up
+ waitsFor(function () {
+ var show = $("div.mkwsRecords div.record:nth-child(" + record_number + ") > div.details");
+ //debug("poprecord: " + (show ? show.length : -1) + " " + $("div.mkwsRecords div.record").text());
+ return show != null && show.length ? true : false;
+ }, "wait some miliseconds to show up a record", 2 * jasmine_config.second);