From 32dfb5fb676cc9adf4af9968b36b7ded038580ea Mon Sep 17 00:00:00 2001
From: Mariia Pukhliakova <mariia.pukhliakova@id.ethz.ch>
Date: Fri, 15 Nov 2019 11:38:59 +0100
Subject: [PATCH] SSDM-8848 I did test 14. refactoring

---
 .../eln-lims/html/js/test/UserTests.js        | 37 +++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)

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 a3f94abb547..313e22c8169 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
@@ -106,17 +106,7 @@ var UserTests = new function() {
         var pathToResource = "js/test/resources/bacteria_for_test_without_identifier.tsv";
         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("options-menu-btn"))
-                             .then(() => e.click("options-menu-btn"))
-                             .then(() => e.waitForId("register-object-btn"))
-                             .then(() => e.click("register-object-btn"))
-                             .then(() => e.waitForId("choose-type-btn"))
-                             .then(() => e.change("choose-type-btn", "BACTERIA", false))
-                             .then(() => TestUtil.setFile("name", baseURL + pathToResource, "text"))
-                             .then(() => e.waitForId("accept-type-file"))
-                             .then(() => e.click("accept-type-file"))
+            Promise.resolve().then(() => UserTests.importBacteriasFromFile(baseURL + pathToResource))
                              .then(() => e.waitForId("bac5-column-id"))
                              .then(() => e.waitForId("bac6-column-id"))
                              .then(() => e.waitForId("bac7-column-id"))
@@ -130,6 +120,21 @@ var UserTests = new function() {
         var pathToResource = "js/test/resources/bacteria_for_test_with_identifier.tsv";
         return new Promise(function executor(resolve, reject) {
             var e = EventUtil;
+            Promise.resolve().then(() => UserTests.importBacteriasFromFile(baseURL + pathToResource))
+                             .then(() => e.waitForId("bac10-column-id"))
+                             .then(() => e.waitForId("bac11-column-id"))
+                             .then(() => e.waitForId("next-page-id"))
+                             .then(() => e.click("next-page-id"))
+                             .then(() => e.waitForId("bac12-column-id"))
+                             .then(() => e.waitForId("bac13-column-id"))
+                             .then(() => resolve());
+        });
+    }
+
+    this.importBacteriasFromFile = function(file) {
+        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("options-menu-btn"))
@@ -138,18 +143,12 @@ var UserTests = new function() {
                              .then(() => e.click("register-object-btn"))
                              .then(() => e.waitForId("choose-type-btn"))
                              .then(() => e.change("choose-type-btn", "BACTERIA", false))
-                             .then(() => TestUtil.setFile("name", baseURL + pathToResource, "text"))
+                             .then(() => TestUtil.setFile("name", file, "text"))
                              .then(() => e.waitForId("accept-type-file"))
                              .then(() => e.click("accept-type-file"))
-                             .then(() => e.waitForId("bac10-column-id"))
-                             .then(() => e.waitForId("bac11-column-id"))
-                             .then(() => e.waitForId("next-page-id"))
-                             .then(() => e.click("next-page-id"))
-                             .then(() => e.waitForId("bac12-column-id"))
-                             .then(() => e.waitForId("bac13-column-id"))
                              .then(() => resolve());
         });
-        }
+    }
 
     this.storageTest = function() {
         return new Promise(function executor(resolve, reject) {
-- 
GitLab