import unittest import allure import pytest from assertpy import assert_that 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.search_page import SearchPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up", "authorized_api") class ProfileTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, authorized_api): self.api = authorized_api self.loginPage = LoginPage(self.driver, authorized_api) self.searchPage = SearchPage(self.driver, authorized_api) self.profilePage = ProfilePage(self.driver) self.chartDigest = ChartDigestPage(self.driver, authorized_api) self.trackPage = TrackPage(self.driver, authorized_api) @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Select market (with confirmation)") @allure.description("User should be able to switch between markets") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-1480") @pytest.mark.smoke def test_markets_selection(self): new_market = "Australia" market = "Canada" test_track_position = 1 self.loginPage.login_as_regular_user() self.profilePage.open_profile_screen_and_select_market(market).select_chart_digest_tab() self.chartDigest.open_full_charts().click_filter_selection().select_filter("Sony") self.chartDigest.open_track_from_full_charts(test_track_position) assert_that(self.trackPage.is_market_selected("CA", "Canada"), "Verified market has been selected").is_true() self.profilePage.click_back_button().click_back_button() self.profilePage.open_profile_screen_and_select_market(new_market).select_chart_digest_tab() self.chartDigest.open_full_charts().click_filter_selection().select_filter("Sony") self.chartDigest.open_track_from_full_charts(test_track_position) assert_that(self.trackPage.is_market_selected("AU", "Australia"), "Verified market has been selected").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Leave feedback") @allure.description("User should be able to open and fill leave feedback form") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-1490" "https://data-analytics.atlassian.net/browse/AG-1495") @pytest.mark.smoke def test_leave_feedback(self): self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.click_feedback() assert_that(self.profilePage.is_feedback_form_opened(), "Verified feedback form is opened").is_true() self.profilePage.click_feedback_done() assert_that( self.profilePage.is_profile_page_opened(), "User wasn't directed to profile page back from feedback screen", ).is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6805") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Profile info") @allure.description("Profile info should match with DB") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-1473" "https://data-analytics.atlassian.net/browse/AG-1474" "https://data-analytics.atlassian.net/browse/AG-1479") @pytest.mark.regression def test_profile_info(self): username = "svidzya.w+4@gmail.com" email = "svidzya.w+4@gmail.com" market = "Market Global" self.loginPage.login_as_regular_user().select_profile_tab() assert_that(self.profilePage.lb_username.label).is_equal_to(username) assert_that(self.profilePage.lb_email_value.label).is_equal_to(email) assert_that(self.profilePage.lb_current_market.label).contains(market) assert_that(self.profilePage.lb_username.is_visible()).is_true() assert_that(self.profilePage.lb_email_value.is_visible()).is_true() assert_that(self.profilePage.lb_current_market.is_visible()).is_true() assert_that(self.profilePage.is_version_format_valid(), "The version format isn't valid").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-6805") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Selecting several markets") @allure.description("User should be able to select only one market") @pytest.mark.regression def test_select_several_markets(self): first_market = "Australia" second_market = "Belarus" last_market = "Canada" test_track_position = 1 self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_markets().click_on_market_in_markets_list(first_market).click_on_market_in_markets_list(second_market).click_on_market_in_markets_list(last_market).click_markets_done().select_chart_digest_tab() self.chartDigest.open_full_charts().open_track_from_full_charts(test_track_position) assert_that(self.trackPage.is_market_selected("CA", last_market), "Verified market has been selected").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-8450") @allure.severity(allure.severity_level.NORMAL) @allure.title("Global Notifications Setting") @allure.description("Global notifications settings and integration") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-8370" "https://data-analytics.atlassian.net/browse/AG-8372" "https://data-analytics.atlassian.net/browse/AG-8408") @pytest.mark.usefixtures("with_default_settings") @pytest.mark.smoke def test_global_notifications_settings(self): self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_notification_settings() assert_that(self.profilePage.is_notifications_settings_opened(), "Settings screen isn't opened").is_true() assert_that(self.profilePage.are_settings_in_default_state(), "Settings aren't in default state").is_true() self.profilePage.click_spotify_dsp_toggle().click_apple_dsp_toggle() assert_that(self.profilePage.are_global_settings_saved_in_on_state(), "Global settings weren't saved").is_false() self.profilePage.click_notifications_toggle() assert_that(self.profilePage.are_settings_hidden(), "Settings weren't hidden").is_true() self.profilePage.click_back_button() assert_that(self.profilePage.are_global_settings_off(), "Global settings indicator is ON").is_true() self.profilePage.open_notification_settings() assert_that(self.profilePage.is_notifications_settings_opened(), "Settings screen isn't opened").is_true() assert_that(self.profilePage.are_settings_hidden(), "Settings weren't hidden").is_true() self.profilePage.click_notifications_toggle() assert_that(self.profilePage.are_global_settings_saved_in_on_state(), "Global settings weren't saved").is_false() self.profilePage.click_notification_settings_reset_button() assert_that(self.profilePage.are_global_settings_saved_in_on_state(), "Global settings weren't saved").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-8450") @allure.severity(allure.severity_level.NORMAL) @allure.title("Global Notifications Markets Selection") @allure.description("User should be able to choose own markets for notifications") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-8402" "https://data-analytics.atlassian.net/browse/AG-8406" "https://data-analytics.atlassian.net/browse/AG-5150" "https://data-analytics.atlassian.net/browse/AG-8396") @pytest.mark.smoke @pytest.mark.usefixtures("with_default_settings") def test_markets_notifications_settings(self): markets_to_select = {"Albania": "al", "United States": "us", "Australia": "au"} self.loginPage.login_as_regular_user().select_profile_tab() self.profilePage.open_notification_settings() wait(self.profilePage.is_notifications_settings_opened) self.profilePage.open_notification_markets_settings() assert_that(self.profilePage.is_notifications_market_settings_opened(), "Market settings screen wasn't open").is_true() self.profilePage.clear_all_selected_markets() assert_that(self.profilePage.is_markets_done_button_inactive(), "Done button is still active").is_true() self.profilePage.select_11_markets_from_market_list() assert_that(self.profilePage.are_10_markets_selected(), "Selected markets not equal to 10").is_true() self.profilePage.clear_all_selected_markets_from_the_list() for k, v in markets_to_select.items(): self.profilePage.select_market_via_search_without_submit(k) self.profilePage.click_markets_settings_done_button() assert_that( self.profilePage.are_selected_markets_saved_for_notifications_user(markets_to_select), "Selected markets weren't saved", ).is_true() self.profilePage.open_notification_markets_settings() for k, v in markets_to_select.items(): self.profilePage.select_market_via_search_without_submit(k) assert_that(self.profilePage.are_0_markets_selected(), "Selected market indicator not equal to 0").is_true() assert_that(self.profilePage.is_markets_done_button_inactive(), "Done button is still active").is_true() self.profilePage.clear_search_field().select_market_from_list_by_position(1).clear_all_selected_markets_via_clear_btn() assert_that(self.profilePage.are_0_markets_selected(), "Selected market indicator not equal to 0").is_true() assert_that(self.profilePage.is_markets_done_button_inactive(), "Done button is still active").is_true() self.profilePage.swipe_back().click_notification_settings_reset_button()