class LoginDashboardTest(BaseTest):
    def test_login_superadmin_success(self):
        """
        Test case untuk berhasil login sebagai superadmin

        """
        # membuat objek loginpage
        self.loginpage = LoginPage(self.driver)

        # Step 1 - input username dan password sebagai superadmin kemudian klik login
        self.loginpage.login_superadmin_success()

        # membuat objek dashboard page
        self.dashboardpage = DashboardPage(self.driver)

        # Step 2 - Assertion
        self.dashboardpage.is_visible(Locators.LOGO_DASHBOARD_HEADER)
        self.dashboardpage.is_visible(Locators.ADMIN_MANAGEMENT_MENU_SIDER)

    def test_login_admin_success(self):
        """
        Test case untuk berhasil login sebagai admin

        """
        # membuat objek loginpage
        self.loginpage = LoginPage(self.driver)

        # Step 1 - input username dan password sebagai admiin kemudian klik login
        self.loginpage.login_admin_success()

        # membuat objek dashboard page
        self.dashboardpage = DashboardPage(self.driver)

        # Step 2 - Assertion
        self.dashboardpage.is_visible(Locators.LOGO_DASHBOARD_HEADER)

    def test_login_failed_wrong_username(self):
        """
        Test case untuk memastikan bahwa login akan gagal kemudian muncul toast alert jika username salah

        """
        # membuat objek loginpage
        self.loginpage = LoginPage(self.driver)

        # Step 1 - input wrong username, input password kemudian klik tombol login
        self.loginpage.login_failed_if_wrong_username()

        # Step 2 - Assertion
        self.loginpage.is_visible(Locators.LOGIN_ALERT_TOAST)

    def test_login_failed_wrong_password(self):
        """
        Test case untuk memastikan bahwa login akan gagal kemudian muncul toast alert jika password salah

        """
        # membuat objek loginpage
        self.loginpage = LoginPage(self.driver)

        # Step 1 - input  username, input wrong password kemudian klik tombol login
        self.loginpage.login_failed_if_wrong_password()

        # Step 2 - Assertion
        self.loginpage.is_visible(Locators.LOGIN_ALERT_TOAST)

    def test_login_failed_no_fill_username_password(self):
        """
        Test case untuk memastikan bahwa login akan gagal kemudian mucul warning alert jika tidak menginput username dan password
        """
        # membuat objek loginpage
        self.loginpage = LoginPage(self.driver)

        # Step 1 - no fill username and password, click login button
        self.loginpage.login_login_failed_if_no_fill_username_password()

        # Step 2 - Assertion
        element_text = self.loginpage.get_text(
            Locators.LOGIN_ERROR_ALERT_USERNAME)
        element_text1 = self.loginpage.get_text(
            Locators.LOGIN_ERROR_ALERT_PASSWORD)
        self.assertEqual("Mohon masukkan username", element_text)
        self.assertEqual("Mohon masukkan password", element_text1)
class LoginDashboardTest(BaseTest):
    def test_login_superadmin_success(self):
        """
        Test case Login success as a Super Admin
        """

        # create Login page object
        self.loginpage = LoginPage(self.driver)

        # Step 1 - Input username and password as a Super Admin then click Login button
        self.loginpage.login_superadmin_success()

        # create Dashboard page object
        self.dashboardpage = DashboardPage(self.driver)

        # Step 2 - Assertion : Admin Management side menu is visible
        self.dashboardpage.is_visible(Locators.ADMIN_MANAGEMENT_MENU_SIDE)

    def test_login_admin_success(self):
        """
        Test case Login success as an Admin
        """

        # create Login page object
        self.loginpage = LoginPage(self.driver)

        # Step 1 - Input username and password as an admin then click Login button
        self.loginpage.login_admin_success()

        # create Dashboard page object
        self.dashboardpage = DashboardPage(self.driver)

        # Step 2 - Assertion : Admin Management side menu is not visible
        self.dashboardpage.is_invisible(Locators.ADMIN_MANAGEMENT_MENU_SIDE)

    def test_login_failed_wrong_username(self):
        """
        Test case Login failed with wrong username
        """

        # create Login page object
        self.loginpage = LoginPage(self.driver)

        # Step 1 - Input wrong username, input correct password then click Login button
        self.loginpage.login_failed_if_wrong_username()

        # Step 2 - Assertion : Toast alert is visible
        self.loginpage.is_visible(Locators.LOGIN_ALERT_TOAST)

    def test_login_failed_wrong_password(self):
        """
        Test case Login failed with wrong password
        """

        # create Login page object
        self.loginpage = LoginPage(self.driver)

        # Step 1 - Input correct username, input wrong password then click Login button
        self.loginpage.login_failed_if_wrong_password()

        # Step 2 - Assertion : Toast alert is visible
        self.loginpage.is_visible(Locators.LOGIN_ALERT_TOAST)

    def test_login_failed_no_fill_username_password(self):
        """
        Test case Login failed with no input
        """

        # create Login page object
        self.loginpage = LoginPage(self.driver)

        # Step 1 - Fill no username and password, then click Login button
        self.loginpage.login_login_failed_if_no_fill_username_password()

        # Step 2 - Assertion : Alert message is visible
        element_text1 = self.loginpage.get_text(Locators.LOGIN_ERROR_ALERT_USERNAME)
        element_text2 = self.loginpage.get_text(Locators.LOGIN_ERROR_ALERT_PASSWORD)
        self.assertEqual("Mohon masukkan username", element_text1)
        self.assertEqual("Mohon masukkan password", element_text2)