import unittest import allure import pytest from parameterized import parameterized 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_search import GlobalSearch 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 from app.src.pages.tt_dashboard_page import TTDashboardPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class TTDashboardPageTest(unittest.TestCase): first_half_date = "01/08" second_half_date = "21" expected_date = "2021-08-01" date_1 = "2021-08-02" date_2 = "2021-07-11" invalid_dates = ["31/01/1999", "22/02/03", "January 3, 2022", "2/3/22", "3/2/22", "22/2/3", "220203", "03Jan22", "22Jan03", "Jan 03, 2022", "Jan-03-2022", "2022-Jan-03", "03-Jan-2022", "3 January, 2022", "2022, January 3", "03 Jan, 2022", "2022, Jan 03", "01/01"] symbols = ["#", "<", "@", "/"] @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tt_dashboard = TTDashboardPage(self.driver) self.trackPage = TrackPage(self.driver) self.topChartsPage = TopChartsPage(self.driver) self.gtp = GlobalTrackPrioritiesPage(self.driver) self.global_search = GlobalSearch(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @parameterized.expand([("by-creations", "7days"), ("by-creations", "daily"), ("by-creations-change", "7days"), ("by-creations-change", "daily")]) @allure.story("AP-7494") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6908][TT Dashboard> By Creations Change Daily] Date picker> Manual entry field verification.") @allure.description("""TC verifies datepicker manual entry for the TikTok Dashboard Page.""") def test_tt_dashboard_datepicker_manual_entry(self, tab, view): self.loginPage.login_with_worker() self.trackPage.select_market(AppConfig.get("market")["us"]["name"]) self.tt_dashboard.open() self.tt_dashboard.select_tab(tab) self.tt_dashboard.select_view(view) api_tt_date = self.api_client.get_tiktok_top_tracks()["items"][0]["metrics"]["date"] # step 1 self.gtp.expand_datepicker() self.gtp.check_datepicker_manual_entry_field() # step 2 self.gtp.clear_date_manually() # step 3 self.global_search.click_beyond_search_field() self.gtp.verify_collapsed_datepicker(expected_selected_date=api_tt_date, location="tt_dashboard") # step 5-6 self.gtp.clear_date_manually() self.gtp.verify_datepicker_invalid_date_manual_entering(date=self.first_half_date) # step 7 self.gtp.enter_any_value_to_datepicker_manually(value=self.second_half_date) self.gtp.verify_collapsed_datepicker(expected_selected_date=self.expected_date, location="tt_dashboard") # step 9 self.gtp.clear_date_manually() self.gtp.enter_datepicker_date_manually(date=self.date_1, location="tt_dashboard") self.gtp.verify_collapsed_datepicker(expected_selected_date=self.date_1, location="tt_dashboard") # step 10-12 self.gtp.verify_datepicker_grid_selected_date(expected_selected_date=self.date_1) self.gtp.open_datepicker_prev_month_grid() self.gtp.verify_datepicker_grid_no_date_selected() # step 13 self.gtp.reset_datepicker(expected_default_date=api_tt_date) # step 14 self.gtp.expand_datepicker() self.gtp.verify_datepicker_datefield_not_in_focus_after_swipe() # step 15 self.gtp.expand_datepicker() self.global_search.click_beyond_search_field() # step 16 for date in self.invalid_dates: self.gtp.verify_datepicker_invalid_date_manual_entering(date=date) for date in self.symbols: self.gtp.verify_datepicker_invalid_date_manual_entering(date=date) # NOT AUTOMATED steps 4, 5, 8, 17