Repository: arenadata/adcm (language: python)

Issue:
ADCM-3011_1 fix tests with save button



Discussion / hints:

Fix patch:
diff --git a/web/src/app/shared/configuration/attributes/attributes/group-keys/group-keys-wrapper.component.ts b/web/src/app/shared/configuration/attributes/attributes/group-keys/group-keys-wrapper.component.ts
index 4f24df4bd8..841715179d 100644
--- a/web/src/app/shared/configuration/attributes/attributes/group-keys/group-keys-wrapper.component.ts
+++ b/web/src/app/shared/configuration/attributes/attributes/group-keys/group-keys-wrapper.component.ts
@@ -90,10 +90,12 @@ export class GroupKeysWrapperComponent extends BaseDirective implements Attribut
     });
 
     if (!enabled) {
-      this.groupControl.disable();
-      this.parameterControl().disable();
+      Promise.resolve().then(() => {
+        this.groupControl.disable();
+        this.parameterControl().disable();
 
-      this.tooltipText = text;
+        this.tooltipText = text;
+      });
     } else {
       Promise.resolve().then(() => {
         this.groupControl.enable();
diff --git a/web/src/app/shared/configuration/main/config.component.html b/web/src/app/shared/configuration/main/config.component.html
index af2fe95613..f3a12fb622 100644
--- a/web/src/app/shared/configuration/main/config.component.html
+++ b/web/src/app/shared/configuration/main/config.component.html
@@ -1,7 +1,7 @@
 <app-tools #tools (applyFilter)="filter($event)"
            (save)="save(configUrl)"
            (showHistory)="historyShow=$event"
-           [disabledSave]="isLock || !fls?.isCustomGroup || fls?.form?.invalid">
+           [disabledSave]="isLock || fls?.form?.untouched || fls?.form?.invalid">
 
 </app-tools>
 
diff --git a/web/src/app/shared/configuration/main/config.component.spec.ts b/web/src/app/shared/configuration/main/config.component.spec.ts
index 447051b586..7fab865ce0 100644
--- a/web/src/app/shared/configuration/main/config.component.spec.ts
+++ b/web/src/app/shared/configuration/main/config.component.spec.ts
@@ -162,7 +162,7 @@ describe('Configuration : ConfigComponent >> ', () => {
     fixture.detectChanges();
     component.rawConfig.next(rawConfig);
     component.cd.detectChanges();
-    component.tools.disabledSave = !component.fields.isCustomGroup || component.fields.form.invalid;
+    component.tools.disabledSave = !component.fields.form.untouched || component.fields.form.invalid;
     component.cd.detectChanges();
     const saveBtn = fixture.nativeElement.querySelector('app-tools div.control-buttons button.form_config_button_save');
     expect(saveBtn.disabled).toBeFalse();
@@ -171,6 +171,10 @@ describe('Configuration : ConfigComponent >> ', () => {
     component.cd.detectChanges();
 
     component.fields.form.get('group').get('field_in_group').setValue('string_not_valid');
+    component.fields.form.markAsTouched();
+    component.fields.form.get('group').markAsTouched();
+    component.fields.form.get('group').get('field_in_group').markAsTouched();
+    component.tools.disabledSave = !component.fields.form.untouched;
     component.cd.detectChanges();
 
     expect(saveBtn.disabled).toBeTruthy();
diff --git a/web/src/app/shared/form-elements/map.component.ts b/web/src/app/shared/form-elements/map.component.ts
index a4ac0019d7..9ab793b9c9 100644
--- a/web/src/app/shared/form-elements/map.component.ts
+++ b/web/src/app/shared/form-elements/map.component.ts
@@ -38,11 +38,15 @@ export class BaseMapListDirective extends FieldDirective implements OnInit {
       if (state === 'DISABLED') {
         this.items.controls.forEach((control) => {
           control.disable({ emitEvent: false });
+          control.markAsUntouched();
         });
+        this.control.markAsUntouched();
       } else {
         this.items.controls.forEach((control) => {
           control.enable({ emitEvent: false });
+          control.markAsTouched();
         });
+        this.control.markAsTouched();
       }
     });
   }
@@ -54,6 +58,7 @@ export class BaseMapListDirective extends FieldDirective implements OnInit {
     }), {}) : null;
     if (value && this.asList) value = (value as Array<string>).length ? value : null;
     this.control.setValue(value);
+    this.control.markAsTouched();
   }
 
   reload() {
diff --git a/web/src/app/shared/form-elements/secret-text/secret-text.component.ts b/web/src/app/shared/form-elements/secret-text/secret-text.component.ts
index 1e29a8bb52..2332e19035 100644
--- a/web/src/app/shared/form-elements/secret-text/secret-text.component.ts
+++ b/web/src/app/shared/form-elements/secret-text/secret-text.component.ts
@@ -50,8 +50,12 @@ export class SecretTextComponent extends FieldDirective implements OnInit, OnCha
     this.control.statusChanges.pipe(this.takeUntil()).subscribe((status) => {
       if (status === 'DISABLED') {
         this.dummyControl.disable();
+        this.dummyControl.markAsUntouched();
+        this.control.markAsUntouched();
       } else {
         this.dummyControl.enable();
+        this.dummyControl.markAsTouched();
+        this.control.markAsTouched();
       }
     });
   }


Test patch:
diff --git a/tests/ui_tests/app/page/common/configuration/page.py b/tests/ui_tests/app/page/common/configuration/page.py
index 97a930d92a..dc40631b99 100644
--- a/tests/ui_tests/app/page/common/configuration/page.py
+++ b/tests/ui_tests/app/page/common/configuration/page.py
@@ -27,12 +27,10 @@
 from selenium.webdriver.remote.webdriver import WebElement
 
 from tests.ui_tests.app.page.common.base_page import BasePageObject
-from tests.ui_tests.app.page.common.common_locators import (
-    ObjectPageLocators,
-)
 from tests.ui_tests.app.page.common.common_locators import (
     ObjectPageMenuLocators,
     CommonLocators,
+    ObjectPageLocators,
 )
 from tests.ui_tests.app.page.common.configuration.fields import ConfigFieldsManipulator
 from tests.ui_tests.app.page.common.configuration.locators import CommonConfigMenu
@@ -98,6 +96,7 @@ def get_textbox_rows(self, timeout=2) -> List[WebElement]:
     def save_config(self, load_timeout: int = 5):
         """Save current configuration"""
 
+        self.find_and_click(self.locators.search_input)
         self.find_and_click(self.locators.save_btn)
         self.wait_element_hide(self.locators.loading_text, timeout=load_timeout)
 
diff --git a/tests/ui_tests/test_regression.py b/tests/ui_tests/test_regression.py
index ac6a919d19..6778d80238 100644
--- a/tests/ui_tests/test_regression.py
+++ b/tests/ui_tests/test_regression.py
@@ -144,6 +144,7 @@ def _check_main_info_after_config_save(
             text_before = page.get_description()
             config_page = page.open_config_tab()
             config_page.config.set_description('New Awesome Description')
+            config_page.config.type_in_field_with_few_inputs(row="just_line", values=[" "])
             config_page.config.save_config()
             page.open()
             text_after = page.get_description()
diff --git a/tests/ui_tests/test_service_page.py b/tests/ui_tests/test_service_page.py
index 00a6370659..9d609d988e 100644
--- a/tests/ui_tests/test_service_page.py
+++ b/tests/ui_tests/test_service_page.py
@@ -303,6 +303,7 @@ def test_save_advanced_config_on_service_config_page(self, app_fs, sdk_client_fs
         service_config_page.config.compare_versions(params["config_name_old"])
         service_config_page.config.check_config_fields_history_with_test_values()
 
+    @pytest.mark.skip("https://tracker.yandex.ru/ADCM-3017")
     @pytest.mark.parametrize(
         "bundle_name", ["password_no_confirm_false_required_false", "password_no_confirm_true_required_false"]
     )