import unittest from datetime import datetime from random import randint import allure import pytest from assertpy import assert_that from parameterized import parameterized from ui_automation_framework.core import TestStatus 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 from app.src.pages.tt_dashboard_page import TTDashboardPage from app.src.pages.tt_dashboard_pot_popup import TTDashboardPOTPopup @pytest.mark.usefixtures("set_up", "one_time_set_up") class TTDashboardPageTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tt_dashboard = TTDashboardPage(self.driver) self.trackPage = TrackPage(self.driver) self.tt_dashboard_potp = TTDashboardPOTPopup(self.driver) self.gtp = GlobalTrackPrioritiesPage(self.driver) self.topChartsPage = TopChartsPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @parameterized.expand( [ ("daily", "by-creations-change", "1", "creations_change"), ("daily", "by-creations", "1", "creations"), ("7days", "by-creations-change", "7", "creations_change"), ("7days", "by-creations", "7", "creations"), ] ) @allure.story("AP-7324") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6912] TikTok Dashboard. Popup - Position over Time. Period selector") @allure.description("TC verifies ‘Period’ selector on the popup - Position overtime on the TikTok Dashboard.") def test_tt_dashboard_potp_period_selector_verification(self, view, tab, days, type): self.loginPage.login_with_worker() self.tt_dashboard.open() self.tt_dashboard.select_tab(tab) self.tt_dashboard.select_view(view) date_ui = self.tt_dashboard.get_selected_date_ui() date_ui = datetime.strptime(date_ui, self.trackPage.get_date_format_from_locale()).strftime("%Y-%m-%d") index = randint(1, 6) self.tt_dashboard_potp.open(index) # step 1, 19 self.tt_dashboard_potp.verify_period_selector_label() # step 2 api_resp = self.api_client.get_tiktok_charts_tracks(date_ui, "worldwide_no_asian", days, type)[index - 1] start_api = api_resp["added_date"] end_api = api_resp["latest_date"] start_ui = self.trackPage.get_calendar_start_date() end_ui = self.trackPage.get_calendar_end_date() assert_that(start_api).is_equal_to(start_ui) assert_that(end_api).is_equal_to(end_ui) # step 3 self.tt_dashboard_potp.verify_calendar_hover() # step 4, 10, 13, 15 self.tt_dashboard_potp.graph_verify_predefined_periods() # step 5 self.tt_dashboard_potp.click_on_date_picker() self.topChartsPage.verify_datepicker() # step 7-8 self.tt_dashboard_potp.verify_datepicker_dates() self.tt_dashboard_potp.click_on_date_picker() # step 9 self.tt_dashboard_potp.select_previous_mounth_period() assert_that(self.trackPage.graph_get_count_days_from_calendar()).is_equal_to(28) # steps 6, 11-12 self.tt_dashboard_potp.click_on_date_picker() self.tt_dashboard_potp.verify_datepicker_start_end_hover() # step 14 self.tt_dashboard_potp.popup_calendar_verify_hint() # step 17 self.tt_dashboard_potp.close() self.tt_dashboard_potp.open(index) start_ui_step17 = self.trackPage.get_calendar_start_date() end_ui_step17 = self.trackPage.get_calendar_end_date() assert_that([start_ui, end_ui]).is_equal_to([start_ui_step17, end_ui_step17]) # step 18 self.tt_dashboard_potp.click_on_date_picker() self.tt_dashboard_potp.click_element("top-charts-over-time-position-tiktok-modal-window-title") assert_that(self.tt_dashboard_potp.is_element_displayed("tiktok-dashboard-tiktok-modal-window-modal-window-day-picker-2-weeks")).is_false() # NOT AUTOMATED - STEPS 16