Skip to content
Snippets Groups Projects
Commit 9c48fb07 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files
parent 29032a59
No related branches found
No related tags found
2 merge requests!139FIX: Set horizontal scroll of property names to auto,!138FIX: auto_focus on forms without forms
......@@ -23,25 +23,24 @@
'use strict';
QUnit.module("form_panel.js", {
before: function (assert) {
before: function(assert) {
},
after: function (assert) {
}
after: function(assert) {}
});
QUnit.test("availability", function (assert) {
QUnit.test("availability", function(assert) {
assert.ok(form_panel.init, "init available");
assert.ok(form_panel.create_show_form_callback , "version available");
assert.ok(form_panel.create_show_form_callback, "version available");
});
QUnit.test("create_show_form_callback ", function (assert) {
QUnit.test("create_show_form_callback ", function(assert) {
const title = "Upload CSV File"; // title of the form and text in the toolbox
const panel_id = "csv_upload_form_panel";
const server_side_script = "csv_script.py";
const tool_box = "Tools"; // Name of the drop-down menu where the button is added in the navbar
const help_text = "something";
const accepted_files_formats = [ ".csv", "text/tsv", ] // Mime types and file endings.
const accepted_files_formats = [".csv", "text/tsv", ] // Mime types and file endings.
const csv_form_config = {
script: server_side_script,
......@@ -80,3 +79,37 @@ QUnit.test("create_show_form_callback ", function (assert) {
});
QUnit.test("autofocus_without_form", function(assert) {
const title = "My not-form title";
const id = "not_form_id";
// callback function that creates a "form" without HTML form
// elements. Trivial here, but could be e.g., the file upload
// from LinkAhead WebUI Core Components.
const init_not_form_field = () => {
const container = $(`<div class="row"/>`);
return container[0];
};
// This should always work
cb_without_autofocus = form_panel.create_show_form_callback(
id,
title,
undefined,
init_not_form_field,
false
);
const nav = document.createElement("nav");
document.body.appendChild(nav);
cb_without_autofocus();
assert.ok(document.querySelector(`#${id}`), "Callback was called without autofocus.");
$(`#${id}`).remove();
cb_with_autofocus = form_panel.create_show_form_callback(
id,
title,
undefined,
init_not_form_field,
true
);
cb_with_autofocus();
assert.ok(document.querySelector(`#${id}`), "Callback was called with autofocus, bt still okay.");
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment