Repository: arenadata/adcm (language: python)

Issue:
ADCM-2783_1 skip test_check_pagination_on_service_list_page



Discussion / hints:

Fix patch:
diff --git a/web/src/app/components/cluster/services/services.component.ts b/web/src/app/components/cluster/services/services.component.ts
index fd92e60a64..cde02cfe62 100644
--- a/web/src/app/components/cluster/services/services.component.ts
+++ b/web/src/app/components/cluster/services/services.component.ts
@@ -43,6 +43,7 @@ export class ServicesComponent extends ConcernListDirective<IClusterService> {
     ListFactory.actionsButton(this),
     ListFactory.importColumn(this),
     ListFactory.configColumn(this),
+    ListFactory.deleteColumn(this),
   ] as IColumns<IClusterService>;
 
 }
diff --git a/web/src/app/shared/components/list/base-list.directive.ts b/web/src/app/shared/components/list/base-list.directive.ts
index 7712dbfb6e..8e731cad45 100644
--- a/web/src/app/shared/components/list/base-list.directive.ts
+++ b/web/src/app/shared/components/list/base-list.directive.ts
@@ -158,13 +158,21 @@ export class BaseListDirective {
 
   socketListener(m: EventMessage): void {
     const stype = (x: string) => `${m.object.type}${m.object.details.type ? `2${m.object.details.type}` : ''}` === x;
-
-    const checkUpgradable = () => (m.event === 'create' || m.event === 'delete') && m.object.type === 'bundle' && this.typeName === 'cluster';
     const changeList = (name?: string) => stype(name ?? this.typeName) && (m.event === 'create' || m.event === 'delete' || m.event === 'add' || m.event === 'remove');
     const createHostPro = () => stype('host2provider') && m.event === 'create';
     const jobComplete = () => (m.event === 'change_job_status') && m.object.type === 'task' && m.object.details.value === 'success';
     const rewriteRow = (row: Entities) => this.service.checkItem(row).subscribe((item) => Object.keys(row).map((a) => (row[a] = item[a])));
 
+    const checkUpgradable = () => {
+      const events = ['create', 'delete'];
+      const pairs = {
+        bundle: ['cluster'],
+        service: ['service2cluster']
+      };
+
+      return events.includes(m.event) && pairs[m.object.type]?.includes(this.typeName);
+    }
+
     if (checkUpgradable() || changeList(TemporaryEntityNameConverter(this.typeName)) || createHostPro() || jobComplete()) {
       this.refresh(m.object.id);
       return;


Test patch:
diff --git a/tests/ui_tests/app/page/cluster/locators.py b/tests/ui_tests/app/page/cluster/locators.py
index 5fc95309dd..49e0cf4d48 100644
--- a/tests/ui_tests/app/page/cluster/locators.py
+++ b/tests/ui_tests/app/page/cluster/locators.py
@@ -55,6 +55,7 @@ class ServiceTableRow:
         actions = Locator(By.CSS_SELECTOR, "app-actions-button button", "Service actions")
         service_import = Locator(By.CSS_SELECTOR, "mat-cell:nth-child(6) button", "Service import")
         config = Locator(By.CSS_SELECTOR, "mat-cell:nth-child(7) button", "Service config")
+        delete_btn = Locator(By.CSS_SELECTOR, "mat-cell:nth-child(8) button", "Row delete button")
 
 
 class ClusterHostLocators:
diff --git a/tests/ui_tests/app/page/cluster/page.py b/tests/ui_tests/app/page/cluster/page.py
index 4372bf69f0..026616fb53 100644
--- a/tests/ui_tests/app/page/cluster/page.py
+++ b/tests/ui_tests/app/page/cluster/page.py
@@ -219,6 +219,13 @@ def click_action_btn_in_row(self, row: WebElement):
         """Click on Action button from the row"""
         self.find_child(row, ClusterServicesLocators.ServiceTableRow.actions).click()
 
+    def click_delete_btn_in_row(self, row: WebElement):
+        """Click on delete button from the row"""
+        self.find_child(row, ClusterServicesLocators.ServiceTableRow.delete_btn).click()
+        self.wait_element_visible(DeleteDialog.body)
+        self.find_and_click(DeleteDialog.yes)
+        self.wait_element_hide(DeleteDialog.body)
+
     def click_import_btn_in_row(self, row: WebElement):
         """Click on Import button from the row"""
         self.find_child(row, ClusterServicesLocators.ServiceTableRow.service_import).click()
diff --git a/tests/ui_tests/app/page/common/table/page.py b/tests/ui_tests/app/page/common/table/page.py
index 731bc2a279..484ee9017e 100644
--- a/tests/ui_tests/app/page/common/table/page.py
+++ b/tests/ui_tests/app/page/common/table/page.py
@@ -42,10 +42,10 @@ def row_count(self) -> int:
         """Get amount of rows on page"""
         return len(self.get_all_rows())
 
-    def get_all_rows(self) -> list:
+    def get_all_rows(self, timeout=5) -> list:
         """Get all rows from the table"""
         try:
-            return self.find_elements(self.locators.visible_row, timeout=5)
+            return self.find_elements(self.locators.visible_row, timeout=timeout)
         except TimeoutException:
             return []
 
@@ -97,6 +97,7 @@ def click_page_by_number(self, number: int):
     def check_pagination(self, second_page_item_amount: int):
         """Check pagination"""
         params = {"fist_page_cluster_amount": 10}
+        self.wait_element_hide(CommonToolbarLocators.progress_bar, timeout=60)
         with self.wait_rows_change():
             self.click_page_by_number(2)
         assert self.row_count == second_page_item_amount, f"Second page should contains {second_page_item_amount} items"
diff --git a/tests/ui_tests/test_cluster_list_page.py b/tests/ui_tests/test_cluster_list_page.py
index 8871071f19..51783eba8a 100644
--- a/tests/ui_tests/test_cluster_list_page.py
+++ b/tests/ui_tests/test_cluster_list_page.py
@@ -522,6 +522,7 @@ def test_check_service_list_page_open_service_config(self, app_fs, create_commun
         service_conf_page.wait_page_is_opened()
         service_conf_page.check_service_toolbar(CLUSTER_NAME, SERVICE_NAME)
 
+    @pytest.mark.skip("https://arenadata.atlassian.net/browse/ADCM-2790")
     def test_check_pagination_on_service_list_page(self, sdk_client_fs: ADCMClient, app_fs):
         """Test pagination on cluster/{}/service page"""
         bundle = cluster_bundle(sdk_client_fs, BUNDLE_WITH_SERVICES)
@@ -531,6 +532,16 @@ def test_check_pagination_on_service_list_page(self, sdk_client_fs: ADCMClient,
         cluster_service_page.wait_page_is_opened()
         cluster_service_page.table.check_pagination(second_page_item_amount=2)
 
+    def test_delete_service_on_service_list_page(self, app_fs, create_community_cluster_with_service):
+        """Test delete service from cluster/{}/service page"""
+
+        cluster, service = create_community_cluster_with_service
+        cluster_service_page = ClusterServicesPage(app_fs.driver, app_fs.adcm.url, cluster.id).open()
+        row = cluster_service_page.table.get_all_rows()[0]
+        cluster_service_page.click_delete_btn_in_row(row)
+        with allure.step("Check that after deleting service row there are no rows"):
+            assert len(cluster_service_page.table.get_all_rows(timeout=2)) == 0, "There should not be any rows"
+
 
 class TestClusterHostPage:
     """Tests for the /cluster/{}/host page"""