import unittest import allure import pytest from assertpy import assert_that from parameterized import parameterized from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig from app.src.pages.login_page import LoginPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class DeepLinkingTrackPageTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.ts = TestStatus(self.driver) @allure.story("AP-6674") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6504] [Track Page> Performance> TikTok] Deeplinking verification. STEPS 1-14") @allure.description("DL for TikTok tab in Performance section on Track Page. STEPS 1-14") def test_tiktok_tp_performance_dl_steps_1_14(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track50")["id"], market_id=AppConfig.get("market")["us"]["url"]) # step 1 self.tp.tp_switch_to_tiktok_tab() self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_tab: 6, self.tp.tr_det_tab: 6}) url_step_1 = self.tp.get_url() # step 2 self.tp.tp_select_type_tiktok(self.tp.TIKTOK_BY_VIEWS) self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_tt: "video_views"}) url_step_2 = self.tp.get_url() # step 3 self.tp.go_back() assert_that(url_step_1).is_equal_to(self.tp.get_url()) self.tp.graph_tiktok_verify_content_type(self.tp.TIKTOK_BY_CREATIONS) # step 4 self.tp.go_forward() assert_that(url_step_2).is_equal_to(self.tp.get_url()) self.tp.graph_tiktok_verify_content_type(self.tp.TIKTOK_BY_VIEWS) # step 5 self.tp.tp_select_type_tiktok(self.tp.TIKTOK_BY_CREATIONS) self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_tt: "creations"}) # step 6 self.tp.tp_select_content_type_tiktok(self.tp.TIKTOK_By_UGC_PGC) self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_tc: "by_ugc_pgc"}) # step 7 self.tp.choose_graph_view_area_graph() self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_view: 2}) ste_7_url = self.tp.get_url() # step 8 self.tp.go_back() self.tp.refresh() self.tp.verify_graph_view_chosen("Line Graph") self.tp.verify_params_not_in_url([self.tp.str_gr_view]) # step 9 self.tp.go_back() self.tp.refresh() self.tp.tp_verify_type_tiktok(self.tp.TIKTOK_ALL_CONTENTS) self.tp.verify_params_not_in_url([self.tp.str_gr_tc]) # step 10 self.tp.go_forward() self.tp.go_forward() assert_that(ste_7_url).is_equal_to(self.tp.get_url()) self.tp.verify_graph_view_chosen("Area Graph") self.tp.tp_verify_type_tiktok(self.tp.TIKTOK_By_UGC_PGC) # step 11 self.tp.tp_select_content_type_tiktok(self.tp.TIKTOK_ALL_CONTENTS) self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_tc: "all", self.tp.str_gr_view: 1}) # step 12 self.tp.market_dd_choose_few_countries(param=[self.tp.all_markets], tab="tiktok") self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_country: 0}) # step 13 self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["canada"]["name"]], tab="tiktok") self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_country: "ca"}) # step 14 self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["canada"]["name"], AppConfig.get("market")["us"]["name"]], tab="tiktok") self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_country: "ca,us"}) @parameterized.expand([("Middle East", "rme"), ("Africa", "raf"), ("CIS", "rcs"), ("Asia", "ras"), ("Europe", "reu"), ("Latin-Iberia", "ril"), ("Oceania", "roc"), ("UK", "ruk"), ("Sony Offices", "rso"), ("Ex–US Only", "reo"), ("North America", "rna")]) @allure.story("AP-6674") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6504] [Track Page> Performance> TikTok] Deeplinking verification. STEPS 15, 18") @allure.description("DL for TikTok tab in Performance section on Track Page. STEPS 15, 18") def test_tiktok_tp_performance_dl_steps_15_18(self, region, r_url): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track50")["id"], market_id=AppConfig.get("market")["us"]["url"]) # steps 15, 18 self.tp.tp_switch_to_tiktok_tab() self.tp.stream_and_source_choose_region(param=region, dd="tiktok") self.tp.refresh() self.tp.verify_params_in_url({self.tp.str_gr_region: r_url}) self.tp.verify_params_not_in_url([self.tp.str_gr_country]) @allure.story("AP-6674") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6504] [Track Page> Performance> TikTok] Deeplinking verification. STEPS 16-17, 21") @allure.description("DL for TikTok tab in Performance section on Track Page. STEPS 16-17, 21") def test_tiktok_tp_performance_dl_steps_16_17_21(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track50")["id"], market_id=AppConfig.get("market")["us"]["url"]) # step 16 self.tp.tp_switch_to_tiktok_tab() self.tp.stream_and_source_choose_region(self.tp.REGION_OCEANIA, "tiktok") self.tp.stream_and_source_deselect_countries(market_name=[AppConfig.get("market")["australia"]["name"]], dd="tiktok") self.tp.refresh() self.tp.verify_params_not_in_url([self.tp.str_gr_region]) self.tp.verify_params_in_url({self.tp.str_gr_country: "fm,nz"}) # step 17 data_before = self.tp.get_tiktok_total_avg() self.tp.select_previous_mounth_period() start = self.tp.get_calendar_start_date() end = self.tp.get_calendar_end_date() data_after = self.tp.get_tiktok_total_avg() self.tp.verify_params_in_url({self.tp.str_gr_start_date: start, self.tp.str_gr_end_date: end}) assert_that(data_before).is_not_equal_to(data_after) # step 21 self.tp.tp_select_content_type_tiktok(self.tp.TIKTOK_By_UGC_PGC) self.tp.select_market(AppConfig.get("market")["australia"]["name"]) self.tp.is_tab_selected("track-performance-streams") @allure.story("AP-6674") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6504] [Track Page> Performance> TikTok] Deeplinking verification. STEPS 19-20") @allure.description("DL for TikTok tab in Performance section on Track Page. STEPS 19-20") def test_tiktok_tp_performance_dl_steps_19_20(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track50")["id"], market_id=AppConfig.get("market")["us"]["url"]) default_url = self.tp.get_url() # steps 19, 20 # self.tp.str_gr_tt self.tp.tp_switch_to_tiktok_tab() self.tp.tp_select_type_tiktok(self.tp.TIKTOK_BY_VIEWS) self.tp.change_param_in_url_new(self.tp.str_gr_tt, "creations") self.tp.graph_tiktok_verify_content_type(self.tp.TIKTOK_BY_CREATIONS) self.tp.change_param_in_url_new(self.tp.str_gr_tt, "$%#") self.tp.is_tab_selected("track-performance-streams") assert_that(default_url).is_equal_to(self.tp.get_url()) # self.tp.str_gr_tc self.tp.tp_switch_to_tiktok_tab() url_before = self.tp.get_url() self.tp.tp_select_content_type_tiktok(self.tp.TIKTOK_By_UGC_PGC) self.tp.open_url(url_before) self.tp.tp_verify_type_tiktok(self.tp.TIKTOK_ALL_CONTENTS) self.tp.change_param_in_url_new(self.tp.str_gr_tc, "$%#") self.tp.is_tab_selected("track-performance-streams") assert_that(default_url).is_equal_to(self.tp.get_url()) # str_gr_view self.tp.tp_switch_to_tiktok_tab() self.tp.tp_select_content_type_tiktok(self.tp.TIKTOK_By_UGC_PGC) self.tp.choose_graph_view_area_graph() self.tp.change_param_in_url_new(self.tp.str_gr_view, 1) self.tp.verify_graph_view_chosen("Line Graph") self.tp.change_param_in_url_new(self.tp.str_gr_view, "$%#") self.tp.is_tab_selected("track-performance-streams") assert_that(default_url).is_equal_to(self.tp.get_url()) # str_gr_country self.tp.tp_switch_to_tiktok_tab() self.tp.market_dd_choose_few_countries([self.tp.all_markets], "tiktok") self.tp.change_param_in_url_new(self.tp.str_gr_country, AppConfig.get("market")["australia"]["market"]) market_td_tiktok_ui = self.tp.graph_get_selected_market("tiktok") assert_that(market_td_tiktok_ui).is_equal_to(AppConfig.get("market")["australia"]["name"]) self.tp.change_param_in_url_new(self.tp.str_gr_country, "unkn") self.tp.is_tab_selected("track-performance-streams") assert_that(default_url).is_equal_to(self.tp.get_url()) # str_gr_region self.tp.tp_switch_to_tiktok_tab() self.tp.stream_and_source_choose_region("Oceania", "tiktok") self.tp.change_param_in_url_new(self.tp.str_gr_region, "reu") market_td_tiktok_ui = self.tp.graph_get_selected_market("tiktok") assert_that(market_td_tiktok_ui).is_equal_to("Europe") self.tp.change_param_in_url_new(self.tp.str_gr_country, "new") self.tp.is_tab_selected("track-performance-streams") assert_that(default_url).is_equal_to(self.tp.get_url())