import logging import unittest import allure import pytest from assertpy import assert_that from faker import Faker from ui_automation_framework.utils import logger as cl from app.src.helpers.api_data_provider import ApiDataProvider from app.src.helpers.waiting_wrapper import wait from app.src.pages.chart_digest_page import ChartDigestPage from app.src.pages.login_page import LoginPage from app.src.pages.profile_page import ProfilePage from app.src.pages.starred_page import StarredPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up", "authorized_api") class ChartDigestTest(unittest.TestCase): log = cl.Logger(logging.DEBUG) @pytest.fixture(autouse=True) def classSetup(self, authorized_api): self.api = authorized_api self.loginPage = LoginPage(self.driver, authorized_api) self.chartDigestPage = ChartDigestPage(self.driver, authorized_api) self.starredPage = StarredPage(self.driver, authorized_api) self.trackPage = TrackPage(self.driver, authorized_api) self.profilePage = ProfilePage(self.driver) self.data_provider = ApiDataProvider(authorized_api) self.fake = Faker() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Spotify/Apple: entries, exits, major moves") @allure.description("User should be able to see available sections") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-242," "https://data-analytics.atlassian.net/browse/AG-242") @pytest.mark.smoke def test_open_chart_digest(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() assert_that(self.chartDigestPage.is_dsp_section_displayed(), "DSPs are displayed").is_true() assert_that(self.chartDigestPage.is_entries_section_displayed(), "Entries are displayed").is_true() assert_that(self.chartDigestPage.is_exits_section_displayed(), "Exits are displayed").is_true() assert_that(self.chartDigestPage.is_major_moves_section_displayed()).is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Spotify/Apple: entries, exits, major moves") @allure.description("User should be able to see available sections") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-242," "https://data-analytics.atlassian.net/browse/AG-242") @pytest.mark.smoke def test_open_chart_digest_apple(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC") assert_that(self.chartDigestPage.is_dsp_section_displayed(), "DSPs are displayed").is_true() assert_that(self.chartDigestPage.is_entries_section_displayed(), "Entries are displayed").is_true() assert_that(self.chartDigestPage.is_exits_section_displayed(), "Exits are displayed").is_true() assert_that(self.chartDigestPage.is_major_moves_section_displayed(), "Major moves are displayed").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Navigation to full chart digest pages") @allure.description("User should be able to open full chart digest pages") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-2054," "https://data-analytics.atlassian.net/browse/AG-2055") @pytest.mark.smoke def test_full_charts_navigation(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.open_full_charts() assert_that(self.chartDigestPage.is_full_charts_opened(), "Spotify full charts is opened").is_true() self.chartDigestPage.click_back_button().select_dsp("APPLE MUSIC").open_full_charts() assert_that(self.chartDigestPage.is_full_charts_opened(), "Apple full charts is opened").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Un-starring/starring track") @allure.description("User should be able to star/un-star track on full charts screen") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-261") @pytest.mark.smoke def test_star_track_major_moves_spotify(self): track_position_in_moves = 1 self.loginPage.login_as_regular_user().select_chart_digest_tab() track_name = self.chartDigestPage.get_major_moves_track_title(track_position_in_moves) self.chartDigestPage.scroll_to_major_moves().swipe_track_on_major_moves(track_position_in_moves).star_on_major_moves(track_position_in_moves).select_starred_tracks_tab() assert_that(self.starredPage.is_track_starred(track_name), "Verified track is added to the starred tracks screen").is_true() self.starredPage.select_chart_digest_tab() self.chartDigestPage.scroll_to_major_moves().swipe_track_on_major_moves(1).unstar_on_major_moves(track_position_in_moves).select_starred_tracks_tab() assert_that(self.starredPage.is_track_unstarred(track_name), "Verified track is removed from the starred tracks screen").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Un-starring/starring track") @allure.description("User should be able to star/un-star track on major moves screen") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-262") @pytest.mark.smoke def test_star_track_major_moves_apple(self): track_position_in_moves = 2 self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC") track_name = self.chartDigestPage.get_major_moves_track_title(track_position_in_moves) self.chartDigestPage.scroll_to_major_moves().swipe_down().swipe_track_on_major_moves(track_position_in_moves).star_on_major_moves(track_position_in_moves).select_starred_tracks_tab() assert_that(self.starredPage.is_track_starred(track_name), "Verified track is added to the starred tracks screen").is_true() self.starredPage.select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC").scroll_to_major_moves().swipe_down().swipe_track_on_major_moves(track_position_in_moves).unstar_on_major_moves(track_position_in_moves).select_starred_tracks_tab() assert_that(self.starredPage.is_track_unstarred(track_name), "Verified track is removed from the starred tracks screen").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Opening track details from Entries/exits/major moves sections") @allure.description("User should be able to open track details from each section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-282") @pytest.mark.smoke def test_track_opening_spotify(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() exits_track = self.chartDigestPage.get_exits_track_title(1) assert_that(exits_track).described_as("track contains position").does_not_contain("#") entries_track = self.chartDigestPage.get_entries_track_title(1) major_moves_track = self.chartDigestPage.get_major_moves_track_title(1) major_moves_info = self.chartDigestPage.get_major_moves_track_full_info(1) assert_that("\ue902" in major_moves_info or "\ue905" in major_moves_info, "Major moves don't contain trends").is_true() self.chartDigestPage.click_entries_track(1) assert_that(self.trackPage.is_track_page_opened(entries_track), "Track page was successfully opened").is_true() self.chartDigestPage.click_back_button().click_exits_track(1) assert_that(self.trackPage.is_track_page_opened(exits_track), "Track page was successfully opened").is_true() self.chartDigestPage.click_back_button().click_major_moves_track(1) assert_that(self.trackPage.is_track_page_opened(major_moves_track), "Track page was successfully opened").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Opening track details from Entries/exits/major moves sections") @allure.description("User should be able to open track details from each section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-282") @pytest.mark.smoke def test_track_opening_apple(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC") exits_track = self.chartDigestPage.get_exits_track_title(1) assert_that(exits_track).described_as("track position").does_not_contain("#") entries_track = self.chartDigestPage.get_entries_track_title(1) major_moves_track = self.chartDigestPage.get_major_moves_track_title(2) major_moves_info = self.chartDigestPage.get_major_moves_track_full_info(1) assert_that("\ue902" in major_moves_info or "\ue905" in major_moves_info, "Major moves don't contain trends").is_true() self.chartDigestPage.click_entries_track(1) assert_that(self.trackPage.is_track_page_opened(entries_track), "Track page was successfully opened").is_true() self.chartDigestPage.click_back_button().click_exits_track(1) assert_that(self.trackPage.is_track_page_opened(exits_track), "Track page was successfully opened").is_true() self.chartDigestPage.click_back_button().click_major_moves_track(2) assert_that(self.trackPage.is_track_page_opened(major_moves_track), "Track page was successfully opened").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Entries/Exits navigation to Track page") @allure.description("User should be able to open track details from each section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-294") @pytest.mark.smoke def test_entries_exits_navigation_spotify(self): vendor = "spotify" removals_markets = self.data_provider.get_top_market_with_exits(vendor) additions_markets = self.data_provider.get_top_market_with_entries(vendor) self.loginPage.login_as_regular_user() self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() self.chartDigestPage.click_entries_show_all() entries_track = self.chartDigestPage.get_full_enrties_track_title(2) self.chartDigestPage.click_track_from_exits_entries(2) assert_that(self.trackPage.is_track_page_opened(entries_track), "Track page was successfully opened").is_true() self.chartDigestPage.click_back_button().click_back_button() self.profilePage.open_profile_screen_and_select_market(removals_markets[0]).select_chart_digest_tab() self.chartDigestPage.click_exits_show_all() exits_track = self.chartDigestPage.get_full_exits_track_title(2) self.chartDigestPage.click_track_from_exits_entries(2) assert_that(self.trackPage.is_track_page_opened(exits_track), "Track page was successfully opened").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4907") @allure.severity(allure.severity_level.NORMAL) @allure.title("Entries/Exits navigation to Track page") @allure.description("User should be able to open track details from each section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-294") @pytest.mark.smoke def test_entries_exits_navigation_apple(self): vendor = "apple" removals_markets = self.data_provider.get_top_market_with_exits(vendor) additions_markets = self.data_provider.get_top_market_with_entries(vendor) self.loginPage.login_as_regular_user() self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC").click_entries_show_all() entries_track = self.chartDigestPage.get_full_enrties_track_title(2) self.chartDigestPage.click_track_from_exits_entries(2) assert_that(self.trackPage.is_track_page_opened(entries_track), "Track page was successfully opened").is_true() self.chartDigestPage.click_back_button().click_back_button() self.profilePage.open_profile_screen_and_select_market(removals_markets[0]).select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC").click_exits_show_all() exits_track = self.chartDigestPage.get_full_exits_track_title(2) self.chartDigestPage.click_track_from_exits_entries(2) assert_that(self.trackPage.is_track_page_opened(exits_track), "Track page was successfully opened").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("'Show all' tracks quantity") @allure.description("Quantity of all tracks in exits/entries show all") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-272") @pytest.mark.regression def test_show_all_quantity(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() entries_quantity = self.chartDigestPage.get_entries_show_all_quantitiy() exits_quantity = self.chartDigestPage.get_exits_show_all_quantitiy() self.chartDigestPage.click_entries_show_all() wait(lambda: self.chartDigestPage.get_exits_entries_tracks_count() == entries_quantity) self.chartDigestPage.click_back_button().click_entries_show_all() wait(lambda: self.chartDigestPage.get_exits_entries_tracks_count() == exits_quantity) @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Swipe exits/entries cards") @allure.description("User should be able to swipe tracks horizontally on exits/entries section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-273") @pytest.mark.regression def test_exits_entries_swipe(self): card_position_to_scroll_left = 2 card_position_to_scroll_right = 3 self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.swipe_exits_cards_left(card_position_to_scroll_left) assert_that(self.chartDigestPage.is_exits_card_swiped_left(card_position_to_scroll_left), "Exits cards weren't swiped").is_true() self.chartDigestPage.swipe_exits_cards_right(card_position_to_scroll_right) assert_that(self.chartDigestPage.is_exits_card_swiped_right(card_position_to_scroll_right), "Exits cards weren't swiped").is_true() self.chartDigestPage.swipe_entries_cards_left(card_position_to_scroll_left) assert_that( self.chartDigestPage.is_entries_card_swiped_left(card_position_to_scroll_left), "Entries cards weren't swiped", ).is_true() self.chartDigestPage.swipe_entries_cards_right(card_position_to_scroll_right) assert_that( self.chartDigestPage.is_entries_card_swiped_right(card_position_to_scroll_right), "Entries cards weren't swiped", ).is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Sorting on major moves") @allure.description("Sort by the number of moved positions, the minimum step for position change is 5") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-275" "https://data-analytics.atlassian.net/browse/AG-277") @pytest.mark.regression def test_major_moves_sorting_and_minimal_step(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.scroll_to_major_moves() move_up_positions = wait(self.chartDigestPage.get_major_moves_move_position) assert_that( self.chartDigestPage.is_major_moves_minimum_step(5, move_up_positions), "The minimal step isn't equal to specified", ).is_true() self.chartDigestPage.scroll_down_several_times(4) move_down_positions = wait(self.chartDigestPage.get_major_moves_move_position) assert_that( self.chartDigestPage.is_major_moves_minimum_step(5, move_down_positions), "The minimal step isn't equal to specified", ).is_true() self.chartDigestPage.select_dsp("APPLE MUSIC") self.chartDigestPage.scroll_to_major_moves() move_up_positions = wait(self.chartDigestPage.get_major_moves_move_position) assert_that( self.chartDigestPage.is_major_moves_minimum_step(5, move_up_positions), "The minimal step isn't equal to specified", ).is_true() self.chartDigestPage.scroll_down_several_times(4) move_down_positions = wait(self.chartDigestPage.get_major_moves_move_position) assert_that( self.chartDigestPage.is_major_moves_minimum_step(5, move_down_positions), "The minimal step isn't equal to specified", ).is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Back to the top") @allure.description("Back to the page top by tap on header") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-279") @pytest.mark.regression def test_back_on_top(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.scroll_down().click_on_header() assert_that(self.chartDigestPage.is_view_charts_displayed(), "Page wasn't scrolled to the top").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Cancellation of starring") @allure.description("Hiding star icon on major moves section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-280" "https://data-analytics.atlassian.net/browse/AG-281") @pytest.mark.regression def test_star_cancellation_major_moves(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.scroll_to_major_moves().swipe_track_on_major_moves(1, close_keyboard=False) assert_that(self.chartDigestPage.is_major_moves_star_icon_displayed(1), "Star icon isn't displayed").is_true() self.chartDigestPage.swipe_track_on_major_moves(2, close_keyboard=False) assert_that(self.chartDigestPage.is_major_moves_star_icon_displayed(2), "Star icon isn't displayed").is_true() assert_that(self.chartDigestPage.is_major_moves_star_icon_closed(1), "Star icon is displayed").is_true() self.chartDigestPage.swipe_right_track_on_major_moves(2, close_keyboard=False) assert_that(self.chartDigestPage.is_major_moves_star_icon_closed(2), "Star icon is displayed").is_true() self.chartDigestPage.swipe_track_on_major_moves(1, close_keyboard=False) assert_that(self.chartDigestPage.is_major_moves_star_icon_displayed(1), "Star icon isn't displayed").is_true() self.chartDigestPage.scroll_down().scroll_up() assert_that(self.chartDigestPage.is_major_moves_star_icon_closed(1), "Star icon is displayed").is_true() self.chartDigestPage.scroll_to_major_moves().swipe_track_on_major_moves(1, close_keyboard=False) assert_that(self.chartDigestPage.is_major_moves_star_icon_displayed(1), "Star icon isn't displayed").is_true() self.chartDigestPage.click_on_header().scroll_to_major_moves() assert_that(self.chartDigestPage.is_major_moves_star_icon_closed(1), "Star icon is displayed").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Chart is not available") @allure.description("Message in case chart doesn't exists for selected market") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-310" "https://data-analytics.atlassian.net/browse/AG-4789") @pytest.mark.regression def test_chart_not_exist(self): market = "Algeria" self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(market).select_chart_digest_tab() assert_that(self.chartDigestPage.is_spotify_chart_not_available_shown(), "The not available state isn't displayed").is_true() self.chartDigestPage.select_dsp("APPLE MUSIC") assert_that(self.chartDigestPage.is_apple_chart_not_available_shown(), "The not available state isn't displayed").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Charts tooltip") @allure.description("Tooltip message for available and not available market data") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-2825" "https://data-analytics.atlassian.net/browse/AG-2819" "https://data-analytics.atlassian.net/browse/AG-2829") @pytest.mark.regression def test_tooltip_messages(self): market_1 = ["China", "cn"] market_2 = ["Iceland", "is"] self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(market_1[0]).select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC").click_charts_tooltip() assert_that( self.chartDigestPage.is_full_charts_apple_available_market_data_tooltip_msg_displayed(market_1[1]), "Proper apple music tooltip message isn't displayed", ).is_true() self.chartDigestPage.close_popup_tap_outside().select_dsp("SPOTIFY").click_charts_tooltip() assert_that( self.chartDigestPage.is_full_charts_unavailable_market_data_tooltip_msg_displayed(), "Proper apple music tooltip message isn't displayed", ).is_true() self.chartDigestPage.close_popup_tap_outside().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(market_2[0]).select_chart_digest_tab() self.chartDigestPage.select_dsp("SPOTIFY").click_charts_tooltip() assert_that( self.chartDigestPage.is_full_charts_spotify_available_market_data_tooltip_msg_displayed(market_2[1]), "Proper spotify music tooltip message isn't displayed", ).is_true() self.chartDigestPage.close_popup_tap_outside().select_dsp("APPLE MUSIC").click_charts_tooltip() assert_that( self.chartDigestPage.is_full_charts_unavailable_market_data_tooltip_msg_displayed(), "Proper spotify music tooltip message isn't displayed", ).is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Exits/Entries sorting spotify tab") @allure.description("Starred tracks should have highest priority") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-3438" "https://data-analytics.atlassian.net/browse/AG-3439" "https://data-analytics.atlassian.net/browse/AG-294") @pytest.mark.smoke def test_exits_entries_starring_sorting_spotify(self): vendor = "spotify" additions_markets = self.data_provider.get_top_market_with_entries(vendor) self.loginPage.login_as_regular_user() try: self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() second_entries_track = self.chartDigestPage.click_entries_show_all().get_full_enrties_track_title(2) # switching dsp in this case is needed to refresh the charts page self.chartDigestPage.swipe_track_exits_entries(2).star_on_exits_entries(2).click_back_button().select_dsp("APPLE MUSIC").select_dsp("SPOTIFY") assert_that( self.chartDigestPage.is_entries_starred_track_is_displayed_on_first_position(second_entries_track), "Starred track is not on the first position", ).is_true() first_entries_track = self.chartDigestPage.click_entries_show_all().get_full_enrties_track_title(1) assert_that(first_entries_track, "Starred track isn't on top").contains(second_entries_track) self.chartDigestPage.click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_starred(second_entries_track), "Verified track is added to the the starred tracks screen", ).is_true() self.starredPage.select_chart_digest_tab() self.chartDigestPage.click_entries_show_all().swipe_track_exits_entries(1).unstar_on_exits_entries(1).click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_unstarred(second_entries_track), "Verified track is removed from the starred tracks screen", ).is_true() self.starredPage.select_chart_digest_tab() second_exits_track = self.chartDigestPage.click_exits_show_all().get_full_exits_track_title(2) # switching dsp in this case is needed to refresh the charts page self.chartDigestPage.swipe_track_exits_entries(2).star_on_exits_entries(2).click_back_button().select_dsp("APPLE MUSIC").select_dsp("SPOTIFY") assert_that( self.chartDigestPage.is_exits_starred_track_is_displayed_on_first_position(second_exits_track), "Starred track is not on the first position", ).is_true() first_exits_track = self.chartDigestPage.click_exits_show_all().get_full_exits_track_title(1) assert_that(first_exits_track).contains(second_exits_track) self.chartDigestPage.click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_starred(second_exits_track), "Verified track is added to the the starred tracks screen", ).is_true() self.starredPage.select_chart_digest_tab() self.chartDigestPage.click_exits_show_all().swipe_track_exits_entries(1).unstar_on_exits_entries(1).click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_unstarred(second_exits_track), "Verified track is removed from the starred tracks screen", ).is_true() except AssertionError: self.chartDigestPage.select_starred_tracks_tab() self.starredPage.unstar_all() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Exits/Entries sorting apple tab") @allure.description("Starred tracks should have higest priority") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-3438" "https://data-analytics.atlassian.net/browse/AG-3439") @pytest.mark.smoke def test_exits_entries_starring_sorting_apple(self): vendor = "apple" additions_markets = self.data_provider.get_top_market_with_entries(vendor) self.loginPage.login_as_regular_user() try: self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() second_entries_track = self.chartDigestPage.select_dsp("APPLE MUSIC").click_entries_show_all().get_full_enrties_track_title(2) # switching dsp in this case is needed to refresh the charts page self.chartDigestPage.swipe_track_exits_entries(2).star_on_exits_entries(2).click_back_button().select_dsp("SPOTIFY").select_dsp("APPLE MUSIC") assert_that( self.chartDigestPage.is_entries_starred_track_is_displayed_on_first_position(second_entries_track), "Starred track is not on the first position", ).is_true() first_entries_track = self.chartDigestPage.click_entries_show_all().get_full_enrties_track_title(1) assert_that(first_entries_track, "Starred track is on top").contains(second_entries_track) self.chartDigestPage.click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_starred(second_entries_track), "Verified track is added to the the starred tracks screen", ).is_true() self.chartDigestPage.select_chart_digest_tab().select_dsp("APPLE MUSIC").click_entries_show_all() self.chartDigestPage.swipe_track_exits_entries(1).unstar_on_exits_entries(1).click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_unstarred(second_entries_track), "Verified track is removed from the starred tracks screen", ).is_true() self.trackPage.select_chart_digest_tab() second_exits_track = self.chartDigestPage.select_dsp("APPLE MUSIC").click_exits_show_all().get_full_exits_track_title(2) # switching dsp in this case is needed to refresh the charts page self.chartDigestPage.swipe_track_exits_entries(2).star_on_exits_entries(2).click_back_button().select_dsp("SPOTIFY").select_dsp("APPLE MUSIC") assert_that( self.chartDigestPage.is_exits_starred_track_is_displayed_on_first_position(second_exits_track), "Starred track is not on the first position", ).is_true() first_exits_track = self.chartDigestPage.click_exits_show_all().get_full_exits_track_title(1) assert_that(first_exits_track, "Starred track is on top").contains(second_exits_track) self.chartDigestPage.click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_starred(second_exits_track), "Verified track is added to the the starred tracks screen", ).is_true() self.starredPage.select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC").click_exits_show_all().swipe_track_exits_entries(1).unstar_on_exits_entries(1).click_back_button().select_starred_tracks_tab() assert_that( self.starredPage.is_track_unstarred(second_exits_track), "Verified track is removed from the starred tracks screen", ).is_true() except AssertionError: self.chartDigestPage.select_starred_tracks_tab() self.starredPage.unstar_all() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Sorting on all entries screen") @allure.description("Sort by the position attribute") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-304, https://data-analytics.atlassian.net/browse/AG-335") @pytest.mark.regression def test_all_entries_sorting(self): additions_markets_spotify = self.data_provider.get_top_market_with_entries("spotify") additions_markets_apple = self.data_provider.get_top_market_with_entries("apple") self.loginPage.login_as_regular_user() self.profilePage.open_profile_screen_and_select_market(additions_markets_spotify[0]).select_chart_digest_tab() self.chartDigestPage.click_entries_show_all() positions = self.chartDigestPage.get_entries_positions_for_not_starred_tracks() assert_that(positions).described_as("Sorting order").is_sorted() self.chartDigestPage.click_back_button() self.profilePage.open_profile_screen_and_select_market(additions_markets_apple[0]).select_chart_digest_tab() self.chartDigestPage.select_dsp("APPLE MUSIC").click_entries_show_all() positions = self.chartDigestPage.get_entries_positions_for_not_starred_tracks() assert_that(positions).described_as("Sorting order").is_sorted() @allure.story("https://data-analytics.atlassian.net/browse/AG-6814") @allure.severity(allure.severity_level.NORMAL) @allure.title("Cancellation of starring on all entries/exits") @allure.description("Hiding star icon on exits/entries section") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-305") @pytest.mark.regression def test_star_cancellation_exits_entries(self): self.loginPage.login_as_regular_user().select_chart_digest_tab() self.chartDigestPage.click_entries_show_all().swipe_track_exits_entries(1) assert_that(self.chartDigestPage.is_entries_exits_star_icon_displayed(1), "Star icon isn't displayed").is_true() self.chartDigestPage.swipe_track_exits_entries(2) assert_that(self.chartDigestPage.is_entries_exits_star_icon_displayed(2), "Star icon isn't displayed").is_true() assert_that(self.chartDigestPage.is_entries_exits_star_icon_closed(1), "Star icon is displayed").is_true() self.chartDigestPage.swipe_right_track_exits_entries(2) assert_that(self.chartDigestPage.is_entries_exits_star_icon_closed(2), "Star icon is displayed").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-7447") @allure.severity(allure.severity_level.NORMAL) @allure.title("Charts API/UI integration") @allure.description("API and UI data for chart digest should match") @pytest.mark.smoke def test_charts_data_api_integration_spotify(self): vendor = "spotify" removals_markets = self.data_provider.get_top_market_with_exits(vendor) additions_markets = self.data_provider.get_top_market_with_entries(vendor) additions_data = self.api.apollo.get_charts_additions( vendor, additions_markets[1], order_by=["-is_starred_track", "position"], fields=["artist", "artists", "change", "image_url", "is_starred", "name", "position"], limit=20, )[ "body" ]["tracks"] removals_data = self.api.apollo.get_charts_removals( vendor, removals_markets[1], order_by=["-is_starred_track", "position"], fields=["artist", "artists", "change", "image_url", "is_starred", "name", "position"], limit=20, )[ "body" ]["tracks"] moves_data = self.api.apollo.get_charts_moves( vendor, "us", order_by=["moves", "track_name"], fields=["artist", "artists", "change", "is_starred", "name", "position"], ).tracks top_data = self.api.apollo.get_charts_top(vendor, "us", order_by="position", limit=20)["body"]["tracks"] self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_profile_screen_and_select_market("United States").select_chart_digest_tab() major_moves_data = self.chartDigestPage.get_major_moves_data() for i in range(len(major_moves_data)): # TODO: make it easier assert_that(major_moves_data[i]).described_as("Artist names matching").contains(moves_data[i].artist).described_as("Track names matching").contains(moves_data[i].name).described_as("Positions matching in moves").contains(str(moves_data[i].position)) if moves_data[i].change > 0: assert_that(major_moves_data[i]).described_as("Trend icon for moves").contains("\ue902") elif moves_data[i].change < 0: assert_that(major_moves_data[i]).described_as("Trend icon for moves").contains("\ue905") full_charts_data = self.chartDigestPage.swipe_back().open_full_charts().get_full_charts_data() for i in range(len(full_charts_data)): assert_that(full_charts_data[i]).described_as("Artist name matching").contains(top_data[i]["artist"]).described_as("Track name matching").contains(top_data[i]["name"]).described_as("Position in top matching").contains(str(top_data[i]["position"])) if not top_data[i]["is_new"] and not top_data[i]["is_re_enter"]: if top_data[i]["change"] > 0: assert_that(full_charts_data[i]).described_as("Trend icon").contains("\ue902") elif top_data[i]["change"] < 0: assert_that(full_charts_data[i]).described_as("Trend icon").contains("\ue905") if top_data[i]["is_sony"]: assert_that(full_charts_data[i]).described_as("Sony label").contains("SONY") self.chartDigestPage.click_back_button().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() entries_data = self.chartDigestPage.click_entries_show_all().get_exits_entries_data() for i in range(len(entries_data)): assert_that(entries_data[i].lower()).described_as("Artist name matching").contains(additions_data[i]["artist"].lower()).described_as("Track name matching").contains(additions_data[i]["name"].lower()).described_as("Position matching").contains(str(additions_data[i]["position"])) self.chartDigestPage.click_back_button().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() exits_data = self.chartDigestPage.swipe_back().click_exits_show_all().get_exits_entries_data() for i in range(len(exits_data)): assert_that(exits_data[i].lower()).described_as("Artist name matching").contains(removals_data[i]["artist"].lower()).described_as("Track name matching").contains(removals_data[i]["name"].lower()) @allure.story("https://data-analytics.atlassian.net/browse/AG-7447") @allure.severity(allure.severity_level.NORMAL) @allure.title("Charts API/UI integration") @allure.description("API and UI data for chart digest should match") @pytest.mark.smoke def test_charts_data_api_integration_apple(self): vendor = "apple" removals_markets = self.data_provider.get_top_market_with_exits(vendor) additions_markets = self.data_provider.get_top_market_with_entries(vendor) additions_data = self.api.apollo.get_charts_additions( vendor, additions_markets[1], order_by=["-is_starred_track", "position"], fields=["artist", "artists", "change", "image_url", "is_starred", "name", "position"], limit=20, )[ "body" ]["tracks"] removals_data = self.api.apollo.get_charts_removals( vendor, removals_markets[1], order_by=["-is_starred_track", "position"], fields=["artist", "artists", "change", "image_url", "is_starred", "name", "position"], limit=20, )[ "body" ]["tracks"] moves_data = self.api.apollo.get_charts_moves( vendor, "us", order_by=["moves", "track_name"], fields=["artist", "artists", "change", "is_starred", "name", "position"], ).tracks top_data = self.api.apollo.get_charts_top(vendor, "us", order_by="position", limit=20)["body"]["tracks"] self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_profile_screen_and_select_market("United States").select_chart_digest_tab() major_moves_data = self.chartDigestPage.select_dsp("APPLE MUSIC").get_major_moves_data() for major_moves, moves_api in zip(major_moves_data, moves_data): assert_that(major_moves).described_as("Artist name matching").contains(moves_api.artist).described_as("Track name matching").contains(moves_api.name).described_as("Position matching").contains(str(moves_api.position)) if moves_api.change > 0: assert_that(major_moves).described_as("Trend icon matching").contains("\ue902") elif moves_api.change < 0: assert_that(major_moves).described_as("Trend icon matching").contains("\ue905") full_charts_data = self.chartDigestPage.swipe_back().open_full_charts().get_full_charts_data() for full_chart, top_data_item in zip(full_charts_data, top_data): assert_that(full_chart).described_as("Artist name matching").contains(top_data_item["artist"]).described_as("Track name matching").contains(top_data_item["name"]).described_as("Track position matching").contains(str(top_data_item["position"])) if not top_data_item["is_new"] and not top_data_item["is_re_enter"]: if top_data_item["change"] > 0: assert_that(full_chart).described_as("Trend icon").contains("\ue902") elif top_data_item["change"] < 0: assert_that(full_chart).described_as("Trend icon").contains("\ue905") self.chartDigestPage.click_back_button().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(additions_markets[0]).select_chart_digest_tab() entries_data = self.chartDigestPage.select_dsp("APPLE MUSIC").click_entries_show_all().get_exits_entries_data() for entry, addition in zip(entries_data, additions_data): assert_that(entry).described_as("Artist name matching").contains(addition["artist"]).described_as("Track position matching").contains(str(addition["position"])).described_as("Track name matching").contains(addition["name"]) self.chartDigestPage.click_back_button().select_profile_tab() self.profilePage.open_profile_screen_and_select_market(removals_markets[0]).select_chart_digest_tab() self.chartDigestPage.swipe_back().select_dsp("APPLE MUSIC").click_exits_show_all() wait(lambda: self.chartDigestPage.lt_exist_entries_tracks.elements) for idx, removals in enumerate(removals_data, 1): assert_that(self.chartDigestPage.lt_exist_entries_tracks.get_item_by_position(idx).text).described_as("Artist name matching").contains(removals["artist"]).described_as("Track name matching").contains(removals["name"])