X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fspec%2Fmkws-pazpar2.js;h=50dfa94020092d9c7c50f1cb033f6e3f21cbcad4;hb=4028a2d1508ac4ce5734a6842ac16423eee327b2;hp=12677a802bff17b98fc2fd7ec1ee9ee399d34215;hpb=4ded4703dd42e64d3e4bd253c1298c35dbb9da7f;p=mkws-moved-to-github.git diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js index 12677a8..50dfa94 100644 --- a/test/spec/mkws-pazpar2.js +++ b/test/spec/mkws-pazpar2.js @@ -6,7 +6,7 @@ // get references from mkws.js, lazy evaluation var debug = function (text) { - mkws.debug(text) + mkws.debug("Jasmine: " + text) } // Define empty mkws_config for simple applications that don't define it. @@ -87,13 +87,13 @@ describe("Check MOTD before search", function () { expect($("#testMOTD").length).toBe(1); expect($("#testMOTD").text()).toMatch("^ *$"); }); - + it("mkwsMOTDContainer has received the text", function () { expect($(".mkwsMOTDContainer").length).toBe(1); expect($(".mkwsMOTDContainer").text()).toMatch(/MOTD/); }); - + }); describe("Check pazpar2 search", function () { @@ -126,8 +126,7 @@ describe("Check pazpar2 search", function () { runs(function () { debug("Click on submit button"); - var click = $("input.mkwsButton").trigger("click"); - expect(click.length).toBe(1); + $("input.mkwsButton").trigger("click"); }) }); }); @@ -158,10 +157,7 @@ describe("Check pazpar2 navigation", function () { 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); + $(id).trigger("click"); }, time * jasmine_config.second); } @@ -261,9 +257,7 @@ describe("Check Termlist", function () { } } - var click = $("div.mkwsFacetAuthors div.term:nth-child(" + author_number + ") a").trigger("click"); - debug("limit author click is success: " + click.length); - expect(click.length).toBe(1); + $("div.mkwsFacetAuthors div.term:nth-child(" + author_number + ") a").trigger("click"); waitsFor(function () { return get_hit_counter() < hits_all_targets ? true : false; @@ -291,10 +285,8 @@ describe("Check Termlist", function () { } } - var click = $("div.mkwsFacetSources div.term:nth-child(" + source_number + ") a").trigger("click"); - debug("limit source click " + (source_number - 1) + " is success: " + click.length); - expect(click.length).toBe(1); - + $("div.mkwsFacetSources div.term:nth-child(" + source_number + ") a").trigger("click"); + waitsFor(function () { if ($("div.mkwsNavi").length && $("div.mkwsNavi").text().match(/(Source|datenquelle|kilder): /i)) { return true; @@ -320,10 +312,24 @@ describe("Check Termlist", function () { 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); - + // make sure we have a link. + var linkaddr = "div.mkwsRecords div.record:nth-child(1) a"; + var waitcount = 0; + waitsFor(function() { + waitcount++; + debug("waiting for the link " + waitcount + " " + $(linkaddr) + + " =" + $(linkaddr).length + " " + $(linkaddr).text() ); + return ( $(linkaddr).length >0 ); + }, "wait until we see a link", 1 * jasmine_config.second); + + runs(function(){ + var link = $(linkaddr); + debug("== waited (" + waitcount + ") for the link..." + $(linkaddr) + + " =" + $(linkaddr).length + " " + $(linkaddr).text() ); + expect(link.length).toBe(1); + link.trigger("click"); + }); + // wait until the record pops up waitsFor(function () { var show = $("div.mkwsRecords div.record:nth-child(" + record_number + ") div"); @@ -363,9 +369,7 @@ describe("Check switch menu Records/Targets", function () { }); it("switch to target view", function () { - var click = $("div.mkwsSwitch").children('a').eq(1).trigger("click"); - debug("target view click is success: " + click.length); - expect(click.length).toBe(1); + $("div.mkwsSwitch").children('a').eq(1).trigger("click"); // now the target table must be visible expect($("div.mkwsBytarget").is(":visible")).toBe(true); @@ -384,9 +388,7 @@ describe("Check switch menu Records/Targets", function () { }); it("switch back to record view", function () { - var click = $("div.mkwsSwitch").children('a').eq(0).trigger("click"); - debug("record view click is success: " + click.length); - expect(click.length).toBe(1); + $("div.mkwsSwitch").children('a').eq(0).trigger("click"); // now the target table must be visible expect($("div.mkwsBytarget").is(":visible")).toBe(false);