import unittest import allure import pytest from assertpy import assert_that from ui_automation_framework.utils import CoreConfig from app.src.pages.login_page import LoginPage from app.src.pages.profile_page import ProfilePage from app.src.pages.search_page import SearchPage @pytest.mark.usefixtures("set_up", "one_time_set_up", "authorized_api") class LoginTest(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) @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Sign in with correct credentials") @allure.description("User should be able to successfully logged in") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-983") @pytest.mark.smoke def test_successful_login(self): self.loginPage.login_as_regular_user() @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Sing in with incorrect credentials (email/password)") @allure.description("'Wrong email or password' message should be shown on Sign In form") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-984") @pytest.mark.smoke def test_login_with_invalid_credentials(self): self.loginPage.go_to_login_form().enter_login_credentials(CoreConfig.USER_EMAIL, "1").click_login() assert_that(self.loginPage.is_wrong_credentials_error_message_shown(), "Error message is shown").is_true() self.loginPage.enter_login_credentials("invalid@gmail.com", CoreConfig.USER_PASSWORD).click_login() assert_that(self.loginPage.is_wrong_credentials_error_message_shown(), "Error message is shown").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Try to sign in with empty email and password") @allure.description("'Can't be blank' label and red frames are shown for Email and Password text-fields") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-995") @pytest.mark.smoke def test_login_with_empty_credentials(self): self.loginPage.go_to_login_form().click_login() assert_that(self.loginPage.are_empty_credentials_error_messages_shown(), "Error messages are shown").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Email Validation") @allure.description("Appropriate label and red frames should be shown for password field") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-2482") @pytest.mark.smoke def test_email_validation_rules(self): login = CoreConfig.USER_EMAIL self.loginPage.go_to_login_form().enter_login_credentials("dxd@we", "1").click_login() assert_that(self.loginPage.is_invalid_email_error_message_shown(), "Error message is shown").is_true() self.loginPage.enter_login_credentials(login, "1") assert_that(self.loginPage.is_invalid_email_error_message_hidden(), "Error message is hidden").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-4758") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Relogin with another user") @allure.description("Another user should be able to login") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-1006") @pytest.mark.smoke def test_relogin_with_another_user(self): login = CoreConfig.USER_EMAIL password = CoreConfig.USER_PASSWORD notifications_login = CoreConfig.NOTIFICATIONS_EMAIL notifications_password = CoreConfig.NOTIFICATIONS_PASSWORD self.loginPage.login(login, password) assert_that(self.loginPage.is_logged_in(), "user is logged in").is_true() self.loginPage.select_profile_tab() profile_emial = self.profilePage.get_user_email() assert_that(profile_emial).is_equal_to(login) self.profilePage.logout() self.loginPage.login(notifications_login, notifications_password) assert_that(self.loginPage.is_logged_in(), "user is logged in").is_true() self.loginPage.select_profile_tab() profile_email = self.profilePage.get_user_email() assert_that(profile_email).is_equal_to(notifications_login) @allure.story("https://data-analytics.atlassian.net/browse/AG-8559") @allure.severity(allure.severity_level.CRITICAL) @allure.title("Forgot password form") @allure.description("Check the validation form in case the password were forgotten") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-1001" "https://data-analytics.atlassian.net/browse/AG-1001") @pytest.mark.regression def test_login_forgot_password(self): self.loginPage.go_to_login_form().click_forgot_password() assert_that(self.loginPage.are_forgot_password_messages_shown(), "Error message is shown").is_true()