diff --git a/test/core/js/modules/webcaosdb.js.js b/test/core/js/modules/webcaosdb.js.js index 534dc86c485ccfac184bb05bac17d595addaa3d6..deb2b1884f1ac56e75ee492748a052cb20355811 100644 --- a/test/core/js/modules/webcaosdb.js.js +++ b/test/core/js/modules/webcaosdb.js.js @@ -1212,7 +1212,7 @@ QUnit.test("bindOnClick", function (assert) { $("body").append(form); $(form).append(submitButton); submitButton.click(); - assert.equal(storage(), `FIND RECORD WHICH HAS A PROPERTY LIKE '*with double*' AND A PROPERTY LIKE '*and single*' AND A PROPERTY LIKE '*what\\'s wrong?*' AND A PROPERTY LIKE '*\\'*' AND A PROPERTY LIKE '*nothin\\'*' AND A PROPERTY LIKE '*"\\'bla*'`, "after5: stuff with quotation marks"); + assert.equal(storage(), `FIND RECORD WHICH HAS A PROPERTY LIKE '*with double*' AND A PROPERTY LIKE '*and single*' AND A PROPERTY LIKE '*what\\'s wrong?*' AND A PROPERTY LIKE '*\\'*' AND A PROPERTY LIKE '*nothin\\'*' AND A PROPERTY LIKE '*"\\'bla*'`, "after5: stuff with quotation marks"); // ... then with empty quotation marks. this will not trigger the query execution at all storage("not triggered"); @@ -1228,16 +1228,17 @@ QUnit.test("bindOnClick", function (assert) { QUnit.test("splitSearchTerms", function (assert) { assert.ok(queryForm.splitSearchTerms, "available"); const cases = [ - ["", []], - ['"', ['"']], - ["a", ["a"]], - ["a b", ["a", "b"]], - ["'a b'", ["a b"]], - ['"a b"', ["a b"]], - [`"with double" 'and single' "what's wrong?" ' "nothin'" "'bla`, - ["with double", "and single", "what's wrong?", "'", "nothin'", `"'bla`]], + ["", []], + ['"', ['"']], + ["a", ["a"]], + ["a b", ["a", "b"]], + ["'a b'", ["a b"]], + ['"a b"', ["a b"]], + [`"with double" 'and single' "what's wrong?" ' "nothin'" "'bla`, + ["with double", "and single", "what's wrong?", "'", "nothin'", `"'bla`] + ], ]; - for(let testCase of cases) { + for (let testCase of cases) { assert.deepEqual(queryForm.splitSearchTerms(testCase[0]), testCase[1], `test case ${testCase[0]}`); } }); @@ -1245,7 +1246,7 @@ QUnit.test("splitSearchTerms", function (assert) { QUnit.test("initFreeSearch", function (assert) { const form = $('<form></form>'); const inputGroup = $('<div class="input-group"></div>'); - const textArea = $( '<textarea class="caosdb-f-query-textarea" name="query"></textarea>'); + const textArea = $('<textarea class="caosdb-f-query-textarea" name="query"></textarea>'); const submitButton = $('<input class="caosdb-search-btn" type="submit">'); inputGroup.append(textArea); form.append(inputGroup).append(submitButton); @@ -1885,6 +1886,25 @@ QUnit.test("toolbox example", function (assert) { assert.equal($('.caosdb-f-navbar-toolbox[data-toolbox-name="Tools"] button').length, 3, "three 'Tools' buttons"); }); +QUnit.test("hide elements for roles", function (assert) { + navbar.add_button("TestButton"); + + // mock user role + $("#top-navbar").append(`<div class="caosdb-user-role">someRole</div>`); + navbar.hideElementForRoles($("#top-navbar").find("button"), ["someOtherRole"]); + // don't have the role, so nothing is hidden: + assert.notOk($("#top-navbar").find("button").hasClass("d-none")); + $("#top-navbar").append(`<div class="caosdb-user-role second-role">someOtherRole</div>`); + // now I do + navbar.hideElementForRoles($("#top-navbar").find("button"), ["someOtherRole"]); + assert.ok($("#top-navbar").find("button").hasClass("d-none")); + $(".second-role").remove(); + // now I don't + navbar.hideElementForRoles($("#top-navbar").find("button"), ["someOtherRole"]); + assert.notOk($("#top-navbar").find("button").hasClass("d-none")); + +}); + QUnit.module("webcaosdb.js - version_history", { before: function (assert) { connection._init();