Prechádzať zdrojové kódy

AMBARI-7790. Slider Wizard, step 3, add property modal error. (onechiporenko)

Oleg Nechiporenko 10 rokov pred
rodič
commit
71d79afb23

+ 1 - 1
contrib/views/slider/src/main/resources/ui/app/components/configSection.js

@@ -129,7 +129,6 @@ App.ConfigSectionComponent = Em.Component.extend({
      * @method submit
      */
     submit: function() {
-      Bootstrap.ModalManager.hide('addPropertyModal');
       var name = this.get('newConfig.name'),
         value = this.get('newConfig.value');
       if (this.get('config').mapBy('name').contains(name)) {
@@ -149,6 +148,7 @@ App.ConfigSectionComponent = Em.Component.extend({
       this.get('config').pushObject(App.ConfigProperty.create({name: name, value: value, label: name}));
       this.cleanNewConfig();
       this.toggleProperty('buttonVisible');
+      Bootstrap.ModalManager.hide('addPropertyModal');
     },
 
     /**

+ 5 - 5
contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs

@@ -41,26 +41,26 @@
       {{/each}}
     </form>
     {{#if isCustom}}
-      {{#bs-button clicked="addProperty" type="link"}}{{t configs.add_property}}...{{/bs-button}}
+      {{#bs-button clicked="addProperty" class="add-property" type="link"}}{{t configs.add_property}}...{{/bs-button}}
     {{/if}}
 {{/bs-panel}}
 {{#bs-modal name="addPropertyModal" footerButtonsBinding="addPropertyModalButtons" titleBinding="addPropertyModalTitle"}}
 {{! "Add Property"-form}}
     <form class="form-horizontal" role="form">
-        <div class="form-group">
+        <div {{bind-attr class=":form-group newConfig.hasError:has-error"}}>
             <div class="col-sm-4">
                 <label class="control-label">{{t common.key}}</label>
             </div>
             <div class="col-sm-6">
-              {{input value=newConfig.name class="form-control"}}
+              {{input value=newConfig.name class="form-control new-config-name"}}
             </div>
         </div>
-        <div {{bind-attr class=":form-group newConfig.hasError:has-error"}}>
+        <div {{bind-attr class=":form-group"}}>
             <div class="col-sm-4">
                 <label class="control-label">{{t common.value}}</label>
             </div>
             <div class="col-sm-6">
-              {{input value=newConfig.value class="form-control"}}
+              {{input value=newConfig.value class="form-control new-config-value"}}
             </div>
         </div>
         <div class="form-group">

+ 42 - 0
contrib/views/slider/src/main/resources/ui/test/integration/processes/create_new_app_test.js

@@ -78,6 +78,9 @@ var selectors = {
     buttonBack: 'button.btn:eq(1)',
     step2: {
       content: '#step2 table tbody'
+    },
+    step3: {
+      addPropertyButton: '#createAppWizard .add-property'
     }
   },
   newApp = {
@@ -276,4 +279,43 @@ test('check step2 back', function () {
     });
   });
 
+});
+
+test('check step3', function () {
+
+  visit('/createAppWizard/step1');
+  fillIn('#app-name-input', newApp.name);
+  click(selectors.buttonNext);
+
+  andThen(function () {
+    click(selectors.buttonNext);
+
+    andThen(function () {
+      // Step 3
+
+      click(selectors.step3.addPropertyButton);
+      andThen(function () {
+        fillIn('.new-config-name:eq(0)', '!!');
+        click('.modal-dialog:eq(0) .btn-success');
+        andThen(function () {
+          equal(find('.modal-dialog:eq(0) .alert').length, 1, 'Error-message for invalid config name exists');
+        });
+
+        fillIn('.new-config-name:eq(0)', 'agent.conf'); // config already exists
+        click('.modal-dialog:eq(0) .btn-success');
+        andThen(function () {
+          equal(find('.modal-dialog:eq(0) .alert').length, 1, 'Error-message for existing config name');
+        });
+
+        click('.modal-dialog:eq(0) .btn-default');
+        andThen(function () {
+          click(selectors.step3.addPropertyButton);
+          andThen(function () {
+            equal(find('.new-config-name:eq(0)').val(), '', 'New config name should be empty on second modal opening');
+            equal(find('.new-config-value:eq(0)').val(), '', 'New config value should be empty on second modal opening');
+          });
+        });
+      });
+    });
+  });
 });