import logging import unittest import allure import pytest from assertpy import assert_that from parameterized import parameterized from selenium.webdriver.common.keys import Keys from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig from ui_automation_framework.utils import logger as cl from ...pages.global_search import GlobalSearch from ...pages.global_track_priorities_page import GlobalTrackPrioritiesPage from ...pages.login_page import LoginPage from ...pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class GlobalSearchTest(unittest.TestCase): log = cl.Logger(logging.DEBUG) UNSUPPORTED_URI = "spotify:episode:27ryyTcOELpxKE61DSVLgC" INVALID_TRACK_URI = "spotify:track:05CwHjIk71RXVU40boRM" invalid_spotify_uris = ["spotify:playlist:37i9dQZF1DX3rxVfibe1L", "spotify:album:3Vsbl0diFGw8HNSjG8ue9", "spotify:artist:6M2wZ9GZgrQXHCFfjv46w", "spotify:user:topsifff"] @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.gs = GlobalSearch(self.driver) self.tp = TrackPage(self.driver) self.gtp = GlobalTrackPrioritiesPage(self.driver) self.ts = TestStatus(self.driver) @parameterized.expand( [ ("spotify:track:{}".format(AppConfig.get("track3")["id"]), "track", AppConfig.get("track3")["name"]), ("spotify:playlist:{}".format(AppConfig.get("playlist2")["id"]), "playlist-spotify", AppConfig.get("playlist2")["name"]), ("spotify:album:{}".format(AppConfig.get("album2")["id"]), "album", AppConfig.get("album2")["name"]), ("spotify:artist:{}".format(AppConfig.get("artist1")["id"]), "artist", AppConfig.get("artist1")["name"]), ("spotify:user:{}".format(AppConfig.get("user1")["id"]), "account", AppConfig.get("user1")["name"]), ("https://open.spotify.com/track/{}?si=5bd01cab2a714332".format(AppConfig.get("track3")["id"]), "track", AppConfig.get("track3")["name"]), ("https://open.spotify.com/playlist/{}?si=f92eb4c9b84241a5".format(AppConfig.get("playlist2")["id"]), "playlist-spotify", AppConfig.get("playlist2")["name"]), ("https://open.spotify.com/album/{}?si=UpGHyu3MR7GtDaKsutBerA&dl_branch=1".format(AppConfig.get("album2")["id"]), "album", AppConfig.get("album2")["name"]), ("https://open.spotify.com/artist/{}?si=rs52fGXiSS-3jzfgFHrl8g&dl_branch=1".format(AppConfig.get("artist1")["id"]), "artist", AppConfig.get("artist1")["name"]), ("https://open.spotify.com/user/{}?si=892899b587dc4312".format(AppConfig.get("user1")["id"]), "account", AppConfig.get("user1")["name"]), ] ) @allure.story("AP-5883") @allure.severity(allure.severity_level.NORMAL) @allure.title("""[AP-5883][Global Search] Opening entity by Spotify URI/link""") @allure.description( """STEPS 1-3, 6. TC verifies that the user can copy a link/URI from the Spotify application and paste it in the search field to open the appropriate page on the Apollo Web portal.""" ) def test_opening_entity_by_spotify_uri_1_2_3_6(self, uri, page, title_expected): self.loginPage.login_with_worker() self.tp.select_market(AppConfig.get("market")["us"]["name"]) # steps 1-3, 6 self.gs.put_focus_to_the_search_field() self.gs.enter_search_value(uri) self.gs.verify_search_tabs_are_not_present() self.gs.enter_search_value(Keys.ENTER) title = self.gs.get_page_title(page) assert_that(title).is_equal_to(title_expected) self.gs.verify_hint_in_search_field_in_top_header() @allure.story("AP-5883") @allure.severity(allure.severity_level.NORMAL) @allure.title("""[AP-5883][Global Search] Opening entity by Spotify URI/link""") @allure.description("""STEPS 4-5. TC verifies link/URI negative checks.""") def test_opening_entity_with_invalid_spotify_uri_4_5(self): self.loginPage.login_with_worker() self.tp.select_market(AppConfig.get("market")["us"]["name"]) # step 4 self.gs.put_focus_to_the_search_field() self.gs.enter_search_value(self.UNSUPPORTED_URI) self.gs.verify_search_tabs_are_not_present() self.gs.enter_search_value(Keys.ENTER) search_field_value = self.gs.get_global_search_field_value() assert_that(search_field_value).is_equal_to(self.UNSUPPORTED_URI) # step 5 self.gs.clear_the_search_field() self.gs.enter_search_value(self.INVALID_TRACK_URI) self.gs.enter_search_value(Keys.ENTER) self.gtp.verify_404_page_present() for i in self.invalid_spotify_uris: self.gs.enter_search_value(i) self.gs.enter_search_value(Keys.ENTER) self.gs.page_has_loaded() page_text = self.gs.get_page_content() assert_that(page_text).is_empty()