import allure import pytest from assertpy import assert_that from playwright.sync_api import expect from src.helpers.date_utils import get_ui_date_from_url @pytest.mark.usefixtures("app") class TestTopChartsSpotifyTabDatePicker: @allure.title("[AP-8103][Top Charts] Spotify. Date picker verification STEPS 1-5") @allure.description("TC verifies date picker on the Top Charts → Spotify Daily charts STEPS 1-5") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-9911") @pytest.mark.regression def test_top_charts_spotify_date_picker_step_1_5(self): self.login_page.login() self.apollo_header.select_market('Global') self.app.go_to(self.top_charts_spotify_tab.url) self.top_charts_page.spotify_tab.is_selected() # steps 1-2 date_current_ui = self.top_charts_spotify_tab.period_dd_daily.get_attribute("value") date_max_ui = self.app.api.get_chats_date_range('spotify', 'global')['max_date'] date_max_ui = get_ui_date_from_url(date_max_ui) assert_that(date_current_ui).is_equal_to(date_max_ui) # step 3 self.single_date_picker.expand_datepicker_and_verify() # step 5 week_days = self.single_date_picker.weekdays_row.get_texts_from_list() week_days = [w.lower() for w in week_days] assert_that(week_days).starts_with('mo') @allure.title("[AP-8103][Top Charts] Spotify. Date picker verification STEPS 6-16") @allure.description("TC verifies date picker on the Top Charts → Spotify Daily charts STEPS 6-16") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-9911") @pytest.mark.regression def test_top_charts_spotify_date_picker_step_6_16(self): self.login_page.login() self.apollo_header.select_market('Global') self.app.go_to(self.top_charts_spotify_tab.url) self.top_charts_page.spotify_tab.is_selected() date_current_ui = self.top_charts_spotify_tab.period_dd_daily.get_attribute("value") # step 9 self.top_charts_page.spotify_tab.click() self.top_charts_spotify_tab.select_date("01/15/23", "daily") # step 16 self.single_date_picker.datepicker_input.click() self.single_date_picker.reset_button.click() date_step16 = self.top_charts_spotify_tab.period_dd_daily.get_attribute("value") assert_that(date_current_ui).is_equal_to(date_step16) # step 12 self.single_date_picker.datepicker_input.click() month_year = self.single_date_picker.month_year.get_text() self.single_date_picker.arrow_double_right.click() self.single_date_picker.arrow_right.click() month_year_after = self.single_date_picker.month_year.get_text() assert_that(month_year).is_equal_to(month_year_after) self.top_charts_page.spotify_tab.click() # step 14 self.top_charts_spotify_tab.select_date("06/15/22", "daily") self.single_date_picker.datepicker_input.click() self.single_date_picker.arrow_left.click() assert_that("May 2022").is_equal_to(self.single_date_picker.month_year.get_text()) self.single_date_picker.arrow_double_left.click() assert_that("May 2021").is_equal_to(self.single_date_picker.month_year.get_text()) self.single_date_picker.arrow_right.click() assert_that("Jun 2021").is_equal_to(self.single_date_picker.month_year.get_text()) self.single_date_picker.arrow_double_right.click() assert_that("Jun 2022").is_equal_to(self.single_date_picker.month_year.get_text()) # step 15 date_min_api = self.app.api.get_chats_date_range('spotify', 'global')['min_date'] date_min_ui = get_ui_date_from_url(date_min_api) self.top_charts_spotify_tab.select_date(date_min_ui, "daily") self.single_date_picker.datepicker_input.click() month_year_before = self.single_date_picker.month_year.get_text() self.single_date_picker.arrow_left.click() month_year_after = self.single_date_picker.month_year.get_text() assert_that(month_year_before).is_equal_to(month_year_after) @allure.title("[AP-8103][Top Charts] Spotify. Date picker verification STEPS 17-22") @allure.description("TC verifies date picker on the Top Charts → Spotify Daily charts STEPS 17-22") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-9911") @pytest.mark.regression def test_top_charts_spotify_date_picker_step_17_22(self): self.login_page.login() self.apollo_header.select_market('Global') self.app.go_to(self.top_charts_spotify_tab.url) self.top_charts_page.spotify_tab.is_selected() # step 17 self.single_date_picker.datepicker_input.click() self.top_charts_spotify_tab.page.keyboard.press("Backspace") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_empty() assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("placeholder")).is_equal_to("MM/DD/YY") # step 18 self.single_date_picker.datepicker_input.input_text("10/20/21") # step 19 self.top_charts_page.spotify_tab.click() assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to("10/20/21") # steps 20-21 self.single_date_picker.datepicker_input.input_text("12/") self.top_charts_spotify_tab.page.keyboard.press("Enter") self.single_date_picker.enter_full_date_message.exists() # step 22 self.single_date_picker.page.keyboard.type("02/22") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to("12/02/22") @allure.title("[AP-8103][Top Charts] Spotify. Date picker verification STEPS 25-30") @allure.description("TC verifies date picker on the Top Charts → Spotify Daily charts STEPS 25-30") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-9911") @pytest.mark.regression def test_top_charts_spotify_date_picker_step_25_30(self): self.login_page.login() self.apollo_header.select_market('Global') self.app.go_to(self.top_charts_spotify_tab.url) self.top_charts_page.spotify_tab.is_selected() date_current_ui = self.top_charts_spotify_tab.period_dd_daily.get_attribute("value") # step 25 self.single_date_picker.datepicker_input.input_text("25/25/25") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) self.single_date_picker.datepicker_input.input_text("25/11/21") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) self.single_date_picker.datepicker_input.input_text("11-25-21") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) self.single_date_picker.datepicker_input.input_text("11-25-2021") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) self.single_date_picker.datepicker_input.input_text("11/25/2021") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) self.single_date_picker.datepicker_input.input_text("@") assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) # step 26 self.top_charts_spotify_tab.period_dd_daily.click() self.single_date_picker.weekdays_row._element.first.click() expect(self.top_charts_spotify_tab.period_dd_daily._element).not_to_be_focused() # step 27 self.top_charts_spotify_tab.period_dd_daily.click() self.single_date_picker.arrow_double_left.click() expect(self.top_charts_spotify_tab.period_dd_daily._element).not_to_be_focused() # step 28 self.top_charts_spotify_tab.period_dd_daily.click() self.single_date_picker.datepicker_input.input_text("12/") self.top_charts_page.spotify_tab.click() assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) # step 29 self.top_charts_spotify_tab.period_dd_daily.click() self.top_charts_page.spotify_tab.click() assert_that(self.top_charts_spotify_tab.period_dd_daily.get_attribute("value")).is_equal_to(date_current_ui) # step 30 self.top_charts_spotify_tab.switch_sub_tab("weekly") self.top_charts_spotify_tab.period_dd_selected_weekly.exists() # not automated - step 4, 6-8, 10-11, 13, 23-24