From ed3d5961bd33da992fa7cf40b5528ed788482a66 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 3 Jul 2018 12:02:12 +0200 Subject: [PATCH] on saveexisting genemo test added --- .../src/main/js/gui/admin/EditGenomeDialog.js | 21 +++++++++++++++++-- .../js/gui/admin/EditGenomeDialog-test.js | 21 +++++++++++++++++++ frontend-js/src/test/js/helper.js | 2 -- .../UCSC/versions/hg38/token=MOCK_TOKEN_ID& | 1 + 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 frontend-js/testFiles/apiCalls/genomics/taxonomies/9606/genomeTypes/UCSC/versions/hg38/token=MOCK_TOKEN_ID& diff --git a/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js b/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js index 409f532147..3f0cf1646f 100644 --- a/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js +++ b/frontend-js/src/main/js/gui/admin/EditGenomeDialog.js @@ -189,7 +189,7 @@ EditGenomeDialog.prototype.createGeneralTabContent = function () { onclick: function () { return self.onSaveClicked().then(function () { return self.close(); - }, GuiConnector.alert); + }).catch(GuiConnector.alert); }, xss: false }); @@ -208,6 +208,20 @@ EditGenomeDialog.prototype.createGeneralTabContent = function () { return result; }; +/** + * + * @returns {Promise|PromiseLike} + */ +EditGenomeDialog.prototype.onSaveClicked = function () { + var self = this; + if (!self.isNew()) { + return self.callListeners("onSave"); + } else { + return self.getServerConnector().updateReferenceGenome(self.getReferenceGenome()).then(function () { + return self.callListeners("onSave"); + }); + } +}; /** * * @param {ReferenceGenome} genome @@ -289,7 +303,10 @@ EditGenomeDialog.prototype._fillTypeSelect = function (genome, selectedOrganism) */ EditGenomeDialog.prototype._fillVersionSelect = function (genome, selectedOrganism, selectedType) { var self = this; - return self.getServerConnector().getReferenceGenomeVersions({organism: selectedOrganism, type:selectedType}).then(function (versions) { + return self.getServerConnector().getReferenceGenomeVersions({ + organism: selectedOrganism, + type: selectedType + }).then(function (versions) { var genomeVersionSelect = $("[name=genomeVersionSelect]", self.getElement()); var selectedVersion; diff --git a/frontend-js/src/test/js/gui/admin/EditGenomeDialog-test.js b/frontend-js/src/test/js/gui/admin/EditGenomeDialog-test.js index 2eb9151181..5eb04f7f35 100644 --- a/frontend-js/src/test/js/gui/admin/EditGenomeDialog-test.js +++ b/frontend-js/src/test/js/gui/admin/EditGenomeDialog-test.js @@ -61,4 +61,25 @@ describe('EditGenomeDialog', function () { }); }); + describe('click save', function () { + it('existing genome', function () { + var dialog; + return ServerConnector.getReferenceGenome({organism:"9606", type:"UCSC",version:"hg38"}).then(function (genome) { + dialog = new EditGenomeDialog({ + element: testDiv, + referenceGenome: genome, + customMap: null, + serverConnector: ServerConnector + }); + return dialog.init(); + }).then(function () { + return dialog.open(); + }).then(function () { + return $("[name=saveGenome]", testDiv)[0].onclick(); + }).then(function () { + dialog.destroy(); + }); + }); + }); + }); diff --git a/frontend-js/src/test/js/helper.js b/frontend-js/src/test/js/helper.js index 351c01ae74..05ac27517c 100644 --- a/frontend-js/src/test/js/helper.js +++ b/frontend-js/src/test/js/helper.js @@ -505,8 +505,6 @@ Helper.prototype.triggerJqueryEvent = function (element, eventType) { var event = events[j]; var eventTargets = $(event.selector, domElement); for (var k = 0; k < eventTargets.length; k++) { - console.log(element); - console.log(eventTargets[k]); if (element === eventTargets[k]) { promises.push(event.handler.call(element)) } diff --git a/frontend-js/testFiles/apiCalls/genomics/taxonomies/9606/genomeTypes/UCSC/versions/hg38/token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/genomics/taxonomies/9606/genomeTypes/UCSC/versions/hg38/token=MOCK_TOKEN_ID& new file mode 100644 index 0000000000..d6e3f651ae --- /dev/null +++ b/frontend-js/testFiles/apiCalls/genomics/taxonomies/9606/genomeTypes/UCSC/versions/hg38/token=MOCK_TOKEN_ID& @@ -0,0 +1 @@ +{"downloadProgress":100.0,"geneMapping":[],"idObject":1563,"localUrl":"../minerva-big//5280/hg38.2bit","organism":{"annotatorClassName":"","descriptionByType":"","descriptionByTypeRelation":"","id":927074,"link":"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=9606","resource":"9606","type":"TAXONOMY"},"sourceUrl":"ftp://hgdownload.cse.ucsc.edu/goldenPath/hg38/bigZips/hg38.2bit","type":"UCSC","version":"hg38"} \ No newline at end of file -- GitLab