def test_header_tabs_for_authorised_user(self, app_fs): """Test header buttons for authorised user""" header = PageHeader(app_fs.driver, app_fs.adcm.url) header.click_arenadata_logo_in_header() intro_page = AdminIntroPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(intro_page.path) header.click_clusters_tab_in_header() cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(cluster_page.path) header.click_hostproviders_tab_in_header() provider_page = ProviderListPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(provider_page.path) header.click_hosts_tab_in_header() host_page = HostListPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(host_page.path) header.click_jobs_tab_in_header() job_page = JobListPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(job_page.path) header.click_bundles_tab_in_header() bundle_page = BundleListPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(bundle_page.path) header.click_job_block_in_header() job_page = JobListPage(app_fs.driver, app_fs.adcm.url) header.wait_url_contains_path(job_page.path) header.check_job_popup()
def _test_run_action(page: JobListPage, action_owner: Union[Cluster, Service, Provider, Host], expected_link: str): """ Run the "Long" action Check popup info Check table info without filter (All) Activate filter "Running" Check table info """ expected_info = { 'status': JobStatus.RUNNING, 'action_name': LONG_ACTION_DISPLAY_NAME, 'invoker_objects': expected_link, } with allure.step( f'Run action "{LONG_ACTION_DISPLAY_NAME}" on {action_owner.__class__}' ), page.table.wait_rows_change(): long_action = action_owner.action( display_name=LONG_ACTION_DISPLAY_NAME) long_action.run() _check_job_info_in_popup( page, { 'status': expected_info['status'], 'action_name': expected_info['action_name'] }) _check_running_job_info_in_table(page, expected_info) page.select_filter_running_tab() _check_running_job_info_in_table(page, expected_info)
def test_run_multijob(self, cluster: Cluster, page: JobListPage): """Run action with many jobs""" with allure.step('Run action with multiple job'): action = cluster.action(display_name=MULTIJOB_ACTION_DISPLAY_NAME) task = run_cluster_action_and_assert_result(cluster, action.name) page.expand_task_in_row(0) with allure.step('Check jobs info'): expected_jobs = [{ 'name': job['name'], 'status': JobStatus.SUCCESS } for job in action.subs] jobs_info = page.get_all_jobs_info() assert (expected_amount := len(expected_jobs)) == ( actual_amount := len(jobs_info) ), ('Amount of jobs is not correct: ' f'should be {expected_amount}, but {actual_amount} was found') for i in range(actual_amount): assert (actual_info := asdict(jobs_info[i])) == ( expected_info := expected_jobs[i] ), f'Job at position #{i} should be {expected_info}, not {actual_info}' with allure.step("Open first job's page"): page.click_on_job() detail_page = JobPageStdout(page.driver, page.base_url, task.jobs[0]['id']) detail_page.wait_page_is_opened()
def test_link_to_jobs_in_header_popup(self, app_fs, job_link, job_filter): """Link to /task from popup with filter""" cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url).open() cluster_page.header.click_job_block_in_header() open_filter = getattr(cluster_page.header, job_link) open_filter() job_page = JobListPage(app_fs.driver, app_fs.adcm.url) job_page.wait_page_is_opened() assert job_page.get_selected_filter( ) == job_filter, f"Jobs should be filtered by {job_filter}"
def test_open_task_by_click_on_name(self, cluster: Cluster, page: JobListPage): """Click on task name and task page should be opened""" with allure.step('Run "Long" action'), page.table.wait_rows_change(): task = cluster.action(display_name=LONG_ACTION_DISPLAY_NAME).run() with allure.step('Click on task name'): page.click_on_action_name_in_row(page.table.get_row()) with allure.step('Check Task detailed page is opened'): job_page = JobPageStdout(page.driver, page.base_url, task.id) job_page.wait_page_is_opened() job_page.check_jobs_toolbar(LONG_ACTION_DISPLAY_NAME.upper())
def _check_link_to_invoker_object(expected_link: str, page: JobListPage, action: Action): """ Check that link to object invoked action is correct :param expected_link: "Link" to invoker objects :param page: Page with jobs table :param action: Action to run """ expected_value = {'invoker_objects': expected_link} with page.table.wait_rows_change(): action.run() wait_and_assert_ui_info( expected_value, page.get_task_info_from_table, get_info_kwargs={'full_invoker_objects_link': True}) detail_page = JobPageStdout(page.driver, page.base_url, action.task_list()[0].id).open() wait_and_assert_ui_info(expected_value, detail_page.get_job_info) page.open()
def test_six_tasks_in_header_popup(self, cluster: Cluster, app_fs): """Check list of tasks in header popup""" cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url).open() with allure.step('Run actions in cluster'): for _ in range(6): run_cluster_action_and_assert_result( cluster, cluster.action( display_name=SUCCESS_ACTION_DISPLAY_NAME).name, status='success') cluster_page.header.click_job_block_in_header() with allure.step("Check that in popup 5 tasks"): assert len(cluster_page.header.get_job_rows_from_popup() ) == 5, "Popup should contain 5 tasks" cluster_page.header.click_all_link_in_job_popup() job_page = JobListPage(app_fs.driver, app_fs.adcm.url) job_page.wait_page_is_opened() with allure.step("Check that in job list page 6 tasks"): assert job_page.table.row_count == 6, "Job list page should contain 6 tasks"
def test_check_back_button_in_browser_for_header_links( self, app_fs, sdk_client_fs): """Test browser back button after following header links""" add_dummy_objects_to_adcm(sdk_client_fs) with allure.step("Check back button for cluster page header link"): intro_page = AdminIntroPage(app_fs.driver, app_fs.adcm.url) intro_page.header.click_clusters_tab_in_header() cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url) cluster_page.wait_page_is_opened() cluster_page.click_back_button_in_browser() intro_page.wait_page_is_opened() with allure.step( "Check back button for hostprovider page header link"): cluster_page.open() cluster_page.header.click_hostproviders_tab_in_header() hostprovider_page = ProviderListPage(app_fs.driver, app_fs.adcm.url) hostprovider_page.wait_page_is_opened() hostprovider_page.click_back_button_in_browser() cluster_page.wait_page_is_opened() with allure.step("Check back button for hosts page header link"): hostprovider_page.open() hostprovider_page.header.click_hosts_tab_in_header() hosts_page = HostListPage(app_fs.driver, app_fs.adcm.url) hosts_page.wait_page_is_opened() hosts_page.click_back_button_in_browser() hostprovider_page.wait_page_is_opened() with allure.step("Check back button for jobs page header link"): hosts_page.open() hosts_page.header.click_jobs_tab_in_header() jobs_page = JobListPage(app_fs.driver, app_fs.adcm.url) jobs_page.wait_page_is_opened() jobs_page.click_back_button_in_browser() hosts_page.wait_page_is_opened() with allure.step("Check back button for bundles page header link"): jobs_page.open() jobs_page.header.click_bundles_tab_in_header() bundles_page = BundleListPage(app_fs.driver, app_fs.adcm.url) bundles_page.wait_page_is_opened() bundles_page.click_back_button_in_browser() jobs_page.wait_page_is_opened()
def test_filtering_and_pagination(self, created_hosts: List[Host], page: JobListPage): """Check filtering and pagination""" params = {'success': 6, 'failed': 5, 'second_page': 1} _run_actions_on_hosts(created_hosts, params['success'], params['failed']) with allure.step('Check status filtering'): with page.table.wait_rows_change(): page.select_filter_failed_tab() assert (row_count := page.table.row_count) == params['failed'], ( f'Tab "Failed" should have {params["failed"]} rows, ' f'but {row_count} rows are presented') with page.table.wait_rows_change(): page.select_filter_success_tab() assert (row_count := page.table.row_count) == params['success'], ( f'Tab "Success" should have {params["success"]}, ' f'but {row_count} rows are presented') with allure.step('Check pagination'): with page.table.wait_rows_change(): page.select_filter_all_tab() page.table.check_pagination(params['second_page'])
def page(app_fs: ADCMTest, login_to_adcm_over_api) -> JobListPage: """Open /task page""" return JobListPage(app_fs.driver, app_fs.adcm.url).open()