diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/TestUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/TestUtil.js index 535d2266442e29799d0780b4122e4914a6eba77c..d5f6a82914ddb1e7c38ad28b5036bf7acf5b5b6f 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/TestUtil.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/TestUtil.js @@ -89,4 +89,20 @@ var TestUtil = new function() { } }); } + + this.ckeditorDropFile = function(id, fileName, url) { + return new Promise(function executor(resolve, reject) { + editor = CKEditorManager.getEditorById(id); + TestUtil.fetchBytes(url, function(file) { + editor = CKEditorManager.getEditorById(id); + + file.name = fileName; + + editor.model.enqueueChange( 'default', () => { + editor.execute( 'imageUpload', { file: [file] } ); + } ); + resolve(); + }); + }); + } } \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/UserTests.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/UserTests.js index 1fc3a681305149d2be49806f5c055bc6d000b10e..225a541296e23d0bbcc65477616808fd52c0b2ba 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/UserTests.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/test/UserTests.js @@ -8,6 +8,8 @@ var UserTests = new function() { .then(() => this.inventorySpaceForTestUser()) //6. Sample Form - Creation .then(() => this.creationSampleForm()) + //7. Sample Form - Edit: Add a Photo and Parents/Children + .then(() => this.editSampleForm()) //13. Inventory Table - Imports for Create - Automatic Codes .then(() => this.importsAutomaticCodes()) //14. Inventory Table - Imports for Create - Given Codes @@ -122,6 +124,56 @@ var UserTests = new function() { }); } + this.editSampleForm = function() { + var baseURL = location.protocol + '//' + location.host + location.pathname; + var pathToResource = "js/test/resources/test-image.png"; + + return new Promise(function executor(resolve, reject) { + var e = EventUtil; + + Promise.resolve().then(() => e.waitForId("_MATERIALS_BACTERIA_BACTERIA_COLLECTION")) + .then(() => e.click("_MATERIALS_BACTERIA_BACTERIA_COLLECTION")) + .then(() => e.waitForId("bac3-column-id")) + .then(() => e.click("bac3-column-id")) + // Edit Bacteria 3 + .then(() => e.waitForId("edit-btn")) + .then(() => e.click("edit-btn")) + // add photo in Bacteria genotype + .then(() => e.waitForCkeditor("BACTERIA.GENOTYPE")) + .then(() => TestUtil.ckeditorDropFile("BACTERIA.GENOTYPE", "test-image.png", baseURL + pathToResource)) + // add mother + .then(() => e.waitForId("plus-btn-bacteria-parents")) + .then(() => e.click("plus-btn-bacteria-parents")) + .then(() => e.waitForId("bac1-column-id")) + .then(() => e.click("bac1-column-id")) + .then(() => e.waitForId("comments-bac1")) + .then(() => e.change("comments-bac1", "mother")) + // add father + .then(() => e.click("plus-btn-bacteria-parents")) + .then(() => e.waitForId("bac2-column-id")) + .then(() => e.click("bac2-column-id")) + .then(() => e.waitForId("comments-bac2")) + .then(() => e.change("comments-bac2", "father")) + // add Child + .then(() => e.waitForId("plus-btn-children-type-selector")) + .then(() => e.click("plus-btn-children-type-selector")) + .then(() => e.waitForId("sampleTypeSelector")) + .then(() => e.changeSelect2("sampleTypeSelector", "Bacteria")) + .then(() => e.waitForId("bac4-column-id")) + .then(() => e.click("bac4-column-id")) + .then(() => e.waitForId("bac4-operations-column-id")) + // save + .then(() => e.waitForId("save-btn")) + .then(() => e.click("save-btn")) + .then(() => e.waitForId("edit-btn")) + // check parents and children + .then(() => e.waitForId("bac1-column-id")) + .then(() => e.waitForId("bac2-column-id")) + .then(() => e.waitForId("bac4-column-id")) + .then(() => resolve()); + }); + } + this.importsAutomaticCodes = function() { var baseURL = location.protocol + '//' + location.host + location.pathname; var pathToResource = "js/test/resources/bacteria_for_test_without_identifier.tsv"; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/EventUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/EventUtil.js index 84520f191dda151db3378fc53bc12599d22de737..051ee89a47fba9b5641976956a32c0e971c94db9 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/EventUtil.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/EventUtil.js @@ -207,10 +207,10 @@ var EventUtil = new function() { }); }; - this.waitForCkeditor = function(id, data, timeout) { + this.waitForCkeditor = function(elementId, data, timeout) { return new Promise(function executor(resolve, reject) { - timeout = EventUtil.checkTimeout(elementId, timeout, ignoreError, resolve, reject); - editor = CKEditorManager.getEditorById(id); + timeout = EventUtil.checkTimeout(elementId, timeout, false, resolve, reject); + editor = CKEditorManager.getEditorById(elementId); if(editor === undefined) { setTimeout(executor.bind(null, resolve, reject), DEFAULT_TIMEOUT_STEP); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js index ccf71b29b781fbe35f640697e3edce81fd5e022e..fe286944ad322f6c820874878b9c98f0eafd7aab 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js @@ -54,7 +54,7 @@ function LinksView(linksController, linksModel) { var sampleTableContainerLabel = (sampleTypeLabel)?sampleTypeLabel:sampleTypeCode; $sampleTableContainer.append($("<div>").append(sampleTableContainerLabel + ":") .append(" ") - .append(linksView.getAddBtn($samplePickerContainer, sampleTypeCode)) + .append(linksView.getAddBtn($samplePickerContainer, sampleTypeCode, sampleTableContainerLabel)) .css("margin","5px")); } @@ -293,7 +293,10 @@ function LinksView(linksController, linksModel) { if(currentValue) { FormUtil.setFieldValue(propertyType, $field, currentValue); } - $field.attr("id", ""); //Fix for current summernote behaviour + + var id = propertyType.label.split(" ").join("-").toLowerCase(); + id = id + "-" + sample.code.toLowerCase(); + $field.attr("id", id); //Fix for current summernote behaviour $field.change(function() { var $field = $(this); propertyTypeValue = FormUtil.getFieldValue(propertyType, $field); @@ -452,12 +455,12 @@ function LinksView(linksController, linksModel) { dataGrids.push(dataGrid); } - linksView.getAddBtn = function($container, sampleTypeCode) { + linksView.getAddBtn = function($container, sampleTypeCode, sampleTableContainerLabel) { var enabledFunction = function() { linksView.showSamplePicker($container, sampleTypeCode); }; - var id = "plus-btn-" + sampleTypeCode.toLowerCase(); + var id = "plus-btn-" + sampleTableContainerLabel.toLowerCase().split(" ").join("-"); var $addBtn = FormUtil.getButtonWithIcon("glyphicon-plus", (linksModel.isDisabled)?null:enabledFunction, null, null, id); if(linksModel.isDisabled) { return ""; @@ -481,8 +484,8 @@ function LinksView(linksController, linksModel) { Util.unblockUI(); }); }; - - var $addBtn = FormUtil.getButtonWithIcon("glyphicon-plus", (linksModel.isDisabled)?null:enabledFunction); + var id = "plus-btn-" + linksModel.title.split(" ").join("-").toLowerCase() + "-type-selector"; + var $addBtn = FormUtil.getButtonWithIcon("glyphicon-plus", (linksModel.isDisabled)?null:enabledFunction, null, null, id); if(linksModel.isDisabled) { return "";