import pytest import allure import random from assertpy import assert_that from src.data.entities_data import entity_ids from src.data.entities_data import entity_types @allure.description("As user I want to go back to previous page from entity's page") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-229") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-236") @pytest.mark.usefixtures("app") class TestEntityReturnButton: @allure.title("[Entity Page] Return Button absent on direct link") @pytest.mark.regression @pytest.mark.parametrize('entity_type', entity_types) def test_entity_return_btn_absent(self, entity_type): entity = self.app.api.get_random_entity(entity_type) entity_id = entity['id'] self.app.go_to(f'/{entity_type}/{entity_id}') self.common_page.btn_return.not_exist() @allure.title("[Entity Page] Check parameters state upon returning to Entity page") @pytest.mark.regression @pytest.mark.parametrize('entity_type', entity_types) def test_entity_parameters_when_return_back(self, entity_type): # Hardcoded ids to have all parameters on the screen entity_id = entity_ids[entity_type] # Proceed to entity and select parameters self.app.go_to(f'/{entity_type}/{entity_id}') self.artist_page.tab_performance.get_by('youtube').click() self.artist_page.tab_performance.get_by('tiktok').is_data_selected(False) self.artist_page.tab_performance.get_by('youtube').is_data_selected(True) self.artist_page.tab_performance.get_by('spotify').is_data_selected(False) self.artist_page.tab_performance.get_by('soundcloud').is_data_selected(False) self.artist_page.scope_bar.get_by('soundcloud').click() self.artist_page.scope_bar.get_by('soundcloud').is_active() self.artist_page.scope_bar.get_by('youtube').click() self.artist_page.scope_bar.get_by('youtube').is_active() # Go to some another page - soundcloud card details self.artist_page.btn_card_soundcloud_details.get_by(1).click() assert_that(self.app.page.url).contains('track') self.track_page.is_page_loaded() # Return and check parameters in url and on the page self.common_page.btn_return.click() assert_that(self.app.page.url).contains('?performance_tab=youtube&tracks_dsp=soundcloud&videos_dsp=youtube') self.artist_page.tab_performance.get_by('tiktok').is_data_selected(False) self.artist_page.tab_performance.get_by('youtube').is_data_selected(True) self.artist_page.tab_performance.get_by('spotify').is_data_selected(False) self.artist_page.tab_performance.get_by('soundcloud').is_data_selected(False) self.artist_page.scope_bar.get_by('soundcloud').is_active() self.artist_page.scope_bar.get_by('youtube').is_active() @allure.title("[Entity Page] Return Button - to Category") @pytest.mark.regression @pytest.mark.parametrize('entity_type', entity_types) def test_entity_return_to_category(self, entity_type): category_id = self.app.api.prepare_category_with_entity(entity_type) self.app.go_to(self.categories_page.url + f"/{category_id}") self.category_page.is_page_loaded() # Proceed to entity self.category_page.entity_card_img.get_by(1).click() self.artist_page.is_page_loaded() assert_that(self.app.page.url).contains(entity_type) # go back self.common_page.btn_return.click() self.category_page.is_page_loaded() @allure.title("[Entity Page] Return Button - to Discovery Results") @pytest.mark.regression @pytest.mark.parametrize('entity_type', entity_types) def test_entity_return_to_discovery_results(self, entity_type): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() if entity_type == 'track': self.discovery_page.switch_scope_to_tracks() # Set random parameters self.discovery_page.dsp_spotify_on(True) self.discovery_page.bn_discovery.click() self.discovery_results_page.is_page_loaded() entities = self.discovery_results_page.page_cards_id_list() entity_id = random.choice(entities) # Proceed to entity self.discovery_results_page.card_name.get_by(entity_id).click() self.artist_page.is_page_loaded() assert_that(self.app.page.url).contains(entity_type) # go back self.common_page.btn_return.click() self.discovery_results_page.is_page_loaded()