import logging import unittest import allure import pytest from assertpy import assert_that 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.global_track_priorities_page import GlobalTrackPrioritiesPage 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) YT_TRENDING_DETAILS_TAB_NAME = "Details" YT_TRENDING_OVERVIEW_TAB_NAME = "Overview" YT_TRENDING_OVERVIEW_BY_MARKETS = "By Markets" YT_TRENDING_OVERVIEW_BY_REGIONS = "By Regions" YT_TRENDING_SORT_BY_VIDEO_POSITION = "Video Position" YT_TRENDING_SORT_BY_ALPHABETICAL = "Alphabetical" YT_TRENDING_FEATURED_VALUE = "Featured In" YT_TRENDING_NOT_FEATURED_VALUE = "Not Featured In" featured = "featured" not_featured = "not-featured" @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.gtp = GlobalTrackPrioritiesPage(self.driver) @allure.story("AP-6423") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-5953][Amplitude] YT Trending events") @allure.description( """TC verifies that appropriate events are logged in Amplitude when user is working with YT Trending section on the Full Performance page.""" ) def test_yt_trending(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 1 self.track_page.open_youtube_video_page(isrc=AppConfig.get("track40")["isrc"], market=AppConfig.get("market")["us"]["url"]) self.track_page.nvp_youtube_check_videos_with_trending() events = self.amplitude_helper.wait_and_get_amplitude_events(3) self.amplitude_helper.verify_for_event_type(events[2], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) # step 2 self.gtp.select_first_date_of_the_month() selected_date = self.gtp.get_datepicker_selected_date() events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_date"]).is_equal_to(selected_date) # step 3 # details tab self.track_page.nvp_youtube_trending_switch_tab(self.track_page.YT_TRENDING_DETAILS_TAB) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_tab"]).is_equal_to(self.YT_TRENDING_DETAILS_TAB_NAME) # overview tab self.track_page.nvp_youtube_trending_switch_tab(self.track_page.YT_TRENDING_OVERVIEW_TAB) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_tab"]).is_equal_to(self.YT_TRENDING_OVERVIEW_TAB_NAME) # step 4 # overview -> by markets self.track_page.nvp_youtube_trending_switch_overview_control(self.track_page.YT_TRENDING_OVERVIEW_BY_MARKETS) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_grouping"]).is_equal_to(self.YT_TRENDING_OVERVIEW_BY_MARKETS) # overview -> by regions self.track_page.nvp_youtube_trending_switch_overview_control(self.track_page.YT_TRENDING_OVERVIEW_BY_REGIONS) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_grouping"]).is_equal_to(self.YT_TRENDING_OVERVIEW_BY_REGIONS) # step 5 self.track_page.nvp_youtube_trending_filtering(sort_value=self.YT_TRENDING_SORT_BY_VIDEO_POSITION, checkbox_params=[self.featured, self.not_featured]) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_sorting"]).is_equal_to(self.YT_TRENDING_SORT_BY_VIDEO_POSITION) assert_that(events[0]["event_properties"]["trending_tp_featured"]).is_equal_to("All") # step 6 self.track_page.nvp_youtube_trending_filtering(sort_value=self.YT_TRENDING_SORT_BY_ALPHABETICAL, checkbox_params=[self.not_featured]) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_sorting"]).is_equal_to(self.YT_TRENDING_SORT_BY_ALPHABETICAL) assert_that(events[0]["event_properties"]["trending_tp_featured"]).is_equal_to(self.YT_TRENDING_NOT_FEATURED_VALUE) # step 7 self.track_page.nvp_youtube_trending_filtering(sort_value=self.YT_TRENDING_SORT_BY_ALPHABETICAL, checkbox_params=[self.featured]) events = self.amplitude_helper.wait_and_get_amplitude_events(1) self.amplitude_helper.verify_for_event_type(events[0], self.amplitude_helper.VIDEO_PAGE["trending_event_type"]) assert_that(events[0]["event_properties"]["trending_tp_featured"]).is_equal_to(self.YT_TRENDING_FEATURED_VALUE) # step 8 self.track_page.nvp_youtube_trending_switch_tab(self.track_page.YT_TRENDING_DETAILS_TAB) self.track_page.click_trending_export() events = self.amplitude_helper.wait_and_get_amplitude_events(2) self.amplitude_helper.verify_for_event_type(events[1], self.amplitude_helper.VIDEO_PAGE["trending_export"])