+ expect($(linkaddr).length).toBeGreaterThan(0);
+ });
+ });
+});
+
+describe("Show record", function () {
+ var $ = mkws.$;
+
+ var record_number = 1; // the Nth record in hit list
+ it("show record author", function () {
+ var click = $("div.mkwsRecords div.mkwsSummary: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.mkwsSummary:nth-child(" + record_number + ") > div.mkwsDetails");
+ //debug("poprecord: " + (show ? show.length : -1) + " " + $("div.mkwsRecords div.mkwsSummary").text());
+ return show != null && show.length ? true : false;
+ }, "wait some miliseconds to show up a record", 2 * jasmine_config.second);
+
+ runs(function () {
+ debug("show record pop up");
+ expect($("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div")).not.toBe(null);
+ });
+ });
+
+ it("extract URL", function () {
+ if (jasmine_config.show_record_url == false) {
+ debug("ignore test for URL in record")
+ return;
+ }
+
+ var urls = $("div.mkwsRecords div.mkwsSummary:nth-child(" + record_number + ") div table tbody tr td a");
+ debug("number of extracted URL from record: " + urls.length);
+ // expect(urls.length).toBeGreaterThan(0); // LoC has records without links
+ for (var i = 0; i < urls.length; i++) {
+ var url = $(urls[i]);
+ debug("URL: " + url.attr('href') + " text: " + url.text());
+
+ expect(url.attr('href')).not.toBe(null);
+ expect(url.attr('href')).toMatch(/^https?:\/\/[a-z0-9\-]+\.[0-9a-z].*\//i);
+ expect(url.text()).not.toBe("");
+ }
+ });
+});
+
+describe("Check switch menu Records/Targets", function () {
+ var $ = mkws.$;
+
+ it("check mkwsSwitch", function () {
+ expect($("div.mkwsSwitch").length).toBe(1);
+
+ // expect 2 clickable links
+ expect($("div.mkwsSwitch > a").length).toBe(2);
+ });
+
+ it("switch to target view", function () {
+ $("div.mkwsSwitch > a").eq(1).trigger("click");
+
+ // now the target table must be visible
+ expect($("div.mkwsTargets").is(":visible")).toBe(true);
+ expect($("div.mkwsRecords").is(":visible")).toBe(false);
+
+ // wait a half second, to show the target view
+ var time = (new Date).getTime();
+ waitsFor(function () {
+ return (new Date).getTime() - time > 700 ? true : false;
+ }, "wait some miliseconds", 1 * jasmine_config.second);
+
+ // look for table header
+ runs(function () {
+ expect($("div.mkwsTargets").html()).toMatch(/Target ID/);
+ });
+ });
+
+ it("switch back to record view", function () {
+ $("div.mkwsSwitch > a").eq(0).trigger("click");
+
+ // now the target table must be visible
+ expect($("div.mkwsTargets").is(":visible")).toBe(false);
+ expect($("div.mkwsRecords").is(":visible")).toBe(true);
+ });
+});
+
+describe("Check status client counter", function () {
+ var $ = mkws.$;
+
+ function get_time() {
+ var date = new Date();
+ return date.getTime();
+ }
+ var time = get_time();
+
+ it("check status clients", function () {
+ if (!jasmine_status.source_click) {
+ debug("skip clients check due missing source click");
+ return;
+ }
+
+ waitsFor(function () {
+ var clients = $("div.mkwsStat span.mkwsClientCount");
+ debug("clients: " + clients.text());
+ if (clients.length == 1 && clients.text().match("0/1$")) {
+ return true;
+ } else {
+ return false;
+ }
+ }, "wait for Active clients: 0/1", 4 * jasmine_config.second);
+
+ runs(function () {
+ var clients = $("div.mkwsStat span.mkwsClientCount");
+ debug("span.mkwsClientCount: " + clients.text());
+ expect(clients.text()).toMatch("0/1$");
+ });
+ });
+});
+
+/* remove the "source" and "author" facet link to get more records again */
+describe("Check removable facets links", function () {
+ var $ = mkws.$;
+
+ it("remove links for source and author", function () {
+ var waitcount = 0;
+ if (!jasmine_config.check_sortby) {
+ debug("ignore check for removable facets");
+ return;
+ }
+
+
+ runs(function () {
+ var click = $("a.mkwsRemovable").eq(0).trigger("click");
+ debug("Removed first facets link: " + click.length);
+ expect(click.length).toBe(1);
+ });
+
+ runs(function () {
+ $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+ waitcount++;
+ debug("DOM change mkwsRecords for removeable: " + waitcount);
+ });
+ });
+
+ waitsFor(function () {
+ return waitcount >= 2 && $("a.mkwsRemovable").length == 1 ? 1 : 0;
+ }, "Records DOM change mkwsRecords, removable", 2 * jasmine_config.second);
+
+ runs(function () {
+ debug("unbind removable");
+ $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
+ waitcount = 0;
+
+ $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+ waitcount++;
+ debug("DOM change mkwsRecords for removeable2: " + waitcount);
+ });
+
+ var click = $("a.mkwsRemovable").eq(0).trigger("click");
+ debug("Removed second facets link: " + click.length);
+ expect(click.length).toBe(1);
+ });
+
+ waitsFor(function () {
+ return waitcount >= 2 && $("a.mkwsRemovable").length == 0 ? true : false;
+ }, "DOM change mkwsRecords, removable2", 2 * jasmine_config.second);
+
+ runs(function () {
+ debug("unbind removable2");
+ $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
+ });
+ });
+});
+
+
+describe("Check per page options", function () {
+ var $ = mkws.$;
+
+ it("show per page", function () {
+ if (!jasmine_config.check_sortby) {
+ debug("ignore check for per page select");
+ return;
+ }
+ var waitcount = 0;
+ var per_page_number = 20;
+
+
+ runs(function () {
+ var select = $("select.mkwsPerpage option[selected='selected']");
+ debug("per page default is: " + select.text() + " and unselect it");
+ select.removeAttr('selected');
+
+ select = $("select.mkwsPerpage option[value='" + per_page_number + "']").attr('selected', true);
+ debug("per page is set to: " + select.text());
+ select.trigger("change");
+
+ $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+ waitcount++;
+ debug("DOM change mkwsRecords, per page: " + waitcount);
+ });
+ });
+
+ waitsFor(function () {
+ // debug("per page waitcounter: " + waitcount)
+ return waitcount >= (per_page_number + 10) ? true : false;
+ }, "DOM change mkwsRecords, by per page", 3 * jasmine_config.second);