import logging 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 ui_automation_framework.utils import logger as cl from app.src.pages.amplitude_helper import AmplitudeHelper from app.src.pages.dsp_comparison_page import DSPComparison 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 Amplitude(unittest.TestCase): log = cl.Logger(logging.DEBUG) kpi_for_7_days_collapse = "Collapse" kpi_for_7_days_expand = "Expand" edit = "edit" delete = "delete" down_position = "arrow-down" up_position = "arrow-up" event_edit = "Edit" event_delete = "Delete" event_down = "Down" event_up = "Up" by_markets_tab_name = "By Markets" by_performance_tab_name = "By Performance" album_source = "Album" @pytest.fixture(autouse=True) def classSetup(self): self.log = cl.Logger(logging.DEBUG) self.loginPage = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.amplitude_helper = AmplitudeHelper(self.driver) self.track_page = TrackPage(self.driver) self.dsp_comparison = DSPComparison(self.driver) @parameterized.expand(["by-performance", "by-markets"]) @allure.story("AP-6854") @allure.severity(allure.severity_level.NORMAL) @allure.title("AP-6854 [AP-6746][Amplitude] DSP Comparison events. STEPS 1-14, 16") @allure.description("""TC verifies Amplitude events on DSP Comparison page.""") def test_dsp_comparison_1_16(self, tab): self.loginPage.login_with_worker() self.track_page.select_market(AppConfig.get("market")["us"]["name"]) events = self.amplitude_helper.wait_and_get_amplitude_events(5, False) self.amplitude_helper.is_initializer_event(events[0]) self.amplitude_helper.verify_event_user_properties(events[0]) # step 1 self.track_page.open_spotify_track_page(AppConfig.get("track49")["id"]) self.track_page.tp_navigate_to_dsp_comparison() self.dsp_comparison.switch_tab(tab) events = self.amplitude_helper.wait_and_get_amplitude_events(3, False) self.amplitude_helper.verify_for_event_type(events[2], self.amplitude_helper.DSP_COMPARISON_PAGE["event_type"]) # step 2 self.dsp_comparison.kpi_for_7_days_collapse_expand() events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["filtered_event_type"]) assert_that(events[0]["event_properties"]["ttc_overview"]).is_equal_to(self.kpi_for_7_days_collapse) self.dsp_comparison.kpi_for_7_days_collapse_expand() events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["filtered_event_type"]) assert_that(events[0]["event_properties"]["ttc_overview"]).is_equal_to(self.kpi_for_7_days_expand) # step 3 # edit self.dsp_comparison.open_graph_menu_item(self.edit) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_edit) self.dsp_comparison.close_pop_up() # delete self.dsp_comparison.open_graph_menu_item(self.delete) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_delete) self.dsp_comparison.close_pop_up() # down self.dsp_comparison.open_graph_menu_item(self.down_position) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_down) # step 4 # position 2 edit # edit self.dsp_comparison.open_graph_menu_item(item=self.edit, item_position=2) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(2) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_edit) self.dsp_comparison.close_pop_up() # delete self.dsp_comparison.open_graph_menu_item(item=self.delete, item_position=2) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(2) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_delete) self.dsp_comparison.close_pop_up() # down self.dsp_comparison.open_graph_menu_item(item=self.down_position, item_position=2) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(2) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_down) # up self.dsp_comparison.open_graph_menu_item(item=self.up_position, item_position=2) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(2) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_up) # step 5 # position 3 edit # edit self.dsp_comparison.open_graph_menu_item(item=self.edit, item_position=3) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(3) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_edit) self.dsp_comparison.close_pop_up() # delete self.dsp_comparison.open_graph_menu_item(item=self.delete, item_position=3) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(3) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_delete) self.dsp_comparison.close_pop_up() # up self.dsp_comparison.open_graph_menu_item(item=self.up_position, item_position=3) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(3) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_up) # step 6 self.dsp_comparison.open_graph_menu_item(item=self.edit) self.dsp_comparison.is_edit_menu_opened() self.dsp_comparison.markets_dd_choose_markets(params=[AppConfig.get("market")["canada"]["name"]], region=False) self.dsp_comparison.choose_dsp(self.dsp_comparison.tiktok_dsp) self.dsp_comparison.choose_kpi(self.dsp_comparison.views) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.cancel_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to("Edit") assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) # step 7 self.dsp_comparison.open_graph_menu_item(item=self.edit) self.dsp_comparison.is_edit_menu_opened() self.dsp_comparison.markets_dd_choose_markets(params=[AppConfig.get("market")["canada"]["name"]], region=False) self.dsp_comparison.choose_dsp(self.dsp_comparison.tiktok_dsp) self.dsp_comparison.choose_kpi(self.dsp_comparison.views) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.save_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(2) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to("Edit") assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) self.amplitude_helper.verify_for_event_type(events[1], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_filtered"]) assert_that(events[1]["event_properties"]["ttc_gr_position"]).is_equal_to(1) assert_that(events[1]["event_properties"]["ttc_gr_market"]).is_equal_to([AppConfig.get("market")["canada"]["name"]]) assert_that(events[1]["event_properties"]["ttc_gr_dsp"]).is_equal_to(self.dsp_comparison.tiktok_dsp) assert_that(events[1]["event_properties"]["ttc_gr_kpi"]).is_equal_to(self.dsp_comparison.views) # step 8 self.dsp_comparison.open_graph_menu_item(item=self.edit, item_position=2) self.dsp_comparison.is_edit_menu_opened() self.dsp_comparison.markets_dd_choose_markets(params=[AppConfig.get("market")["canada"]["name"], AppConfig.get("market")["argentina"]["name"]], region=False) self.dsp_comparison.choose_dsp(self.dsp_comparison.spotify_dsp) self.dsp_comparison.change_sources(param=[AppConfig.get("source")["playlists"], AppConfig.get("source")["album_page"], AppConfig.get("source")["discover_weekly"]]) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.save_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(2) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to("Edit") assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(2) self.amplitude_helper.verify_for_event_type(events[1], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_filtered"]) assert_that(events[1]["event_properties"]["ttc_gr_position"]).is_equal_to(2) assert_that(events[1]["event_properties"]["ttc_gr_market"]).is_equal_to([AppConfig.get("market")["argentina"]["name"], AppConfig.get("market")["canada"]["name"]]) assert_that(events[1]["event_properties"]["ttc_gr_dsp"]).is_equal_to(self.dsp_comparison.spotify_dsp) assert_that(events[1]["event_properties"]["ttc_gr_source"]).is_equal_to([self.album_source, AppConfig.get("source")["discover_weekly"], AppConfig.get("source")["playlists"]]) # step 9 self.dsp_comparison.open_graph_menu_item(item=self.edit, item_position=3) self.dsp_comparison.is_edit_menu_opened() self.dsp_comparison.markets_dd_choose_markets(params=self.track_page.sony_offices, region=True) self.dsp_comparison.choose_dsp(self.dsp_comparison.spotify_dsp) self.dsp_comparison.change_sources(param=[AppConfig.get("source")["playlists"]]) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.save_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(2) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to("Edit") assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(3) self.amplitude_helper.verify_for_event_type(events[1], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_filtered"]) assert_that(events[1]["event_properties"]["ttc_gr_position"]).is_equal_to(3) assert_that(events[1]["event_properties"]["ttc_gr_fast_selection"]).is_equal_to(self.track_page.sony_offices) assert_that(events[1]["event_properties"]["ttc_gr_dsp"]).is_equal_to(self.dsp_comparison.spotify_dsp) assert_that(events[1]["event_properties"]["ttc_gr_source"]).is_equal_to([AppConfig.get("source")["playlists"]]) # step 10 self.dsp_comparison.delete_graph(graph_position=1) events = self.amplitude_helper.wait_and_get_amplitude_events(2) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["button_clicked"]) assert_that(events[0]["event_properties"]["ttc_gr_menu"]).is_equal_to(self.event_delete) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) self.amplitude_helper.verify_for_event_type(events[1], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_deleted"]) # step 11 self.dsp_comparison.delete_graph(graph_position=1) self.dsp_comparison.delete_graph(graph_position=1) events = self.amplitude_helper.wait_and_get_amplitude_events(4) self.amplitude_helper.verify_for_event_type(events[1], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_deleted"]) self.amplitude_helper.verify_for_event_type(events[3], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_deleted"]) # step 12 self.dsp_comparison.open_add_graph_menu() self.dsp_comparison.markets_dd_choose_markets(params=self.track_page.all_markets, region=False) self.dsp_comparison.choose_dsp(self.dsp_comparison.spotify_dsp) self.dsp_comparison.change_sources(param=[AppConfig.get("source")["all"]]) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.save_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_added"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(1) assert_that(events[0]["event_properties"]["ttc_gr_market"]).is_equal_to(self.track_page.all_markets) assert_that(events[0]["event_properties"]["ttc_gr_dsp"]).is_equal_to(self.dsp_comparison.spotify_dsp) assert_that(events[0]["event_properties"]["ttc_gr_source"]).is_equal_to(AppConfig.get("source")["all"]) # step 13 self.dsp_comparison.open_add_graph_menu() self.dsp_comparison.markets_dd_choose_markets(params=self.track_page.REGION_EUROPE, region=True) self.dsp_comparison.choose_dsp(self.dsp_comparison.tiktok_dsp) self.dsp_comparison.choose_kpi(self.dsp_comparison.creations) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.save_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_added"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(2) assert_that(events[0]["event_properties"]["ttc_gr_fast_selection"]).is_equal_to(self.track_page.REGION_EUROPE) assert_that(events[0]["event_properties"]["ttc_gr_dsp"]).is_equal_to(self.dsp_comparison.tiktok_dsp) assert_that(events[0]["event_properties"]["ttc_gr_kpi"]).is_equal_to(self.dsp_comparison.creations) # step 14 self.dsp_comparison.open_add_graph_menu() self.dsp_comparison.markets_dd_choose_markets(params=self.track_page.REGION_EX_US, region=True) self.dsp_comparison.choose_dsp(self.dsp_comparison.spotify_dsp) self.dsp_comparison.change_sources(param=[AppConfig.get("source")["album_page"], AppConfig.get("source")["chart"], AppConfig.get("source")["collection"]]) self.dsp_comparison.save_cancel_changes(self.dsp_comparison.save_btn) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["graph_added"]) assert_that(events[0]["event_properties"]["ttc_gr_position"]).is_equal_to(3) assert_that(events[0]["event_properties"]["ttc_gr_fast_selection"]).is_equal_to(self.track_page.REGION_EX_US) assert_that(events[0]["event_properties"]["ttc_gr_dsp"]).is_equal_to(self.dsp_comparison.spotify_dsp) assert_that(events[0]["event_properties"]["ttc_gr_source"]).is_equal_to([self.album_source, AppConfig.get("source")["chart"], AppConfig.get("source")["collection"]]) # step 16 implemented with parametrization @allure.story("AP-6854") @allure.severity(allure.severity_level.NORMAL) @allure.title("AP-6854 [AP-6746][Amplitude] DSP Comparison events. STEPS 15, 17, 18") @allure.description("""TC verifies Amplitude events on DSP Comparison page.""") def test_dsp_comparison_15_17_18(self): self.loginPage.login_with_worker() self.track_page.select_market(AppConfig.get("market")["us"]["name"]) events = self.amplitude_helper.wait_and_get_amplitude_events(5, False) self.amplitude_helper.is_initializer_event(events[0]) self.amplitude_helper.verify_event_user_properties(events[0]) # step 15 self.track_page.open_spotify_track_page(AppConfig.get("track49")["id"]) self.track_page.tp_navigate_to_dsp_comparison() self.dsp_comparison.switch_tab(self.dsp_comparison.by_markets_tab) events = self.amplitude_helper.wait_and_get_amplitude_events(4) self.amplitude_helper.verify_for_event_type(events[3], self.amplitude_helper.DSP_COMPARISON_PAGE["filtered_event_type"]) assert_that(events[3]["event_properties"]["ttc_tab"]).is_equal_to(self.by_markets_tab_name) # step 17 self.dsp_comparison.switch_tab(self.dsp_comparison.by_performance_tab) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.DSP_COMPARISON_PAGE["filtered_event_type"]) assert_that(events[0]["event_properties"]["ttc_tab"]).is_equal_to(self.by_performance_tab_name) # step 18 self.dsp_comparison.back_to_track_page() self.track_page.is_track_page_title_present(AppConfig.get("track49")["name"]) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.TRACK_PAGE["event_type"]) assert_that(events[0]["event_properties"]["is_sony"]).is_true() assert_that(events[0]["event_properties"]["track_artist"]).is_equal_to(AppConfig.get("track49")["artist"]) assert_that(events[0]["event_properties"]["track_id"]).is_equal_to(AppConfig.get("track49")["id"]) assert_that(events[0]["event_properties"]["track_name"]).is_equal_to(AppConfig.get("track49")["name"])