import datetime import unittest import allure import pytest from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig from app.api_client import ApiClient from app.src.pages.global_track_priorities_page import GlobalTrackPrioritiesPage from app.src.pages.login_page import LoginPage from app.src.pages.top_charts_page import TopChartsPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class TopChartsPageTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.topChartsPage = TopChartsPage(self.driver) self.gtp = GlobalTrackPrioritiesPage(self.driver) self.trackPage = TrackPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @allure.story("AP-6488") @allure.severity(allure.severity_level.NORMAL) @allure.title("[6358][Charts>Trending] Date picker view verification.") @allure.description("""TC verifies datepicker behaviour for the Trending Music Videos tab on the Charts Page""") def test_charts_trending_datepicker(self): self.loginPage.login_with_worker() self.trackPage.select_market(AppConfig.get("market")["global"]["name"]) self.topChartsPage.open_top_chart_page() self.topChartsPage.switch_tab(self.topChartsPage.YOUTUBE_TYPE) # step 1-3, 6, 21 default_date_api = self.api_client.get_charts_trending_dates_markets()["charts"]["max"] self.gtp.verify_collapsed_datepicker(expected_selected_date=default_date_api, location="top_charts") # step 4, 20 self.gtp.expand_datepicker() self.trackPage.verify_trending_datepicker_last_available_date(date=default_date_api) expected_min_date_api = self.api_client.get_charts_trending_dates_markets()["charts"]["min"] self.gtp.datepicker_swipe_to_date(date=expected_min_date_api) self.trackPage.verify_trending_datepicker_first_available_date(date=expected_min_date_api) # step 5 self.gtp.reset_datepicker(expected_default_date=default_date_api) self.topChartsPage.verify_trending_info_icon() # step 7-11 self.gtp.expand_datepicker() self.trackPage.trending_datepicker_grid_verification(grid_date=default_date_api) # step 12-13, 23 self.gtp.reset_datepicker(expected_default_date=default_date_api) # step 14-16 default_date = datetime.datetime.strptime(default_date_api, "%Y-%m-%d").date() date_to_select = default_date - datetime.timedelta(days=1) self.gtp.select_date_from_datepicker_grid(date=str(date_to_select), location="top_charts") self.gtp.verify_datepicker_grid_selected_date(expected_selected_date=str(date_to_select)) self.topChartsPage.verify_trending_datepicker_last_available_date_color(date=default_date_api) # step 17-19 self.trackPage.verify_trending_datepicker_arrows_background() self.gtp.verify_datepicker_swiping_to_unavailable_date(date=expected_min_date_api, swipe="backward", year_month="year") self.gtp.verify_datepicker_swiping_to_unavailable_date(date=expected_min_date_api, swipe="forward", year_month="year") self.gtp.verify_datepicker_swiping_to_unavailable_date(date=expected_min_date_api, swipe="backward", year_month="month") self.gtp.verify_datepicker_swiping_to_unavailable_date(date=expected_min_date_api, swipe="forward", year_month="month") # step 22 self.gtp.reset_datepicker(expected_default_date=default_date_api) date_to_select_manually = default_date - datetime.timedelta(days=4) self.gtp.enter_datepicker_date_manually(date=str(date_to_select_manually), location="top_charts") self.gtp.verify_collapsed_datepicker(expected_selected_date=str(date_to_select_manually), location="top_charts") # step 24 self.topChartsPage.switch_tab(self.topChartsPage.SPOTIFY_TYPE) self.topChartsPage.switch_tab(self.topChartsPage.YOUTUBE_TYPE) self.gtp.verify_collapsed_datepicker(expected_selected_date=default_date_api, location="top_charts") # step 25 date_to_select_manually = default_date - datetime.timedelta(days=2) self.gtp.enter_datepicker_date_manually(date=str(date_to_select_manually), location="top_charts") self.topChartsPage.switch_tab(self.topChartsPage.APPLE_TYPE) self.topChartsPage.switch_tab(self.topChartsPage.YOUTUBE_TYPE) self.gtp.verify_collapsed_datepicker(expected_selected_date=default_date_api, location="top_charts") # step 26 date_to_select_manually = default_date - datetime.timedelta(days=5) self.gtp.enter_datepicker_date_manually(date=str(date_to_select_manually), location="top_charts") self.trackPage.select_market(AppConfig.get("market")["us"]["name"]) self.topChartsPage.open_top_chart_page() self.topChartsPage.switch_tab(self.topChartsPage.YOUTUBE_TYPE) self.gtp.verify_collapsed_datepicker(expected_selected_date=default_date_api, location="top_charts")