class IMDGClaimOfficerTest(IMDGBaseTest):
    def setUp(self):
        super().setUp()

    def test_001_login_with_claim_officer_role(self):
        #Instantiate an object of LoginPage class and login using provided credential
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        #Instantiate an object of HomePage class and go to Claim Officer role
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.claim_officer_role()

        # Assert Claim Applications table is visible and the applications with Pending Approval status
        # are clickable
        self.assertTrue(self.homePage.is_clickable(Locators.CLAIM_APPLICATION_ROW_2_APPLICANT_NAME))
        #Assert Create New Application is not visible
        self.assertFalse(self.homePage.is_visible(Locators.CREATE_NEW_APPLICATION))

    def test_002_click_pending_application(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.claim_officer_role()
        self.assertTrue(self.homePage.is_clickable(Locators.CLAIM_APPLICATION_ROW_2))

        #Click application with 'Pending Approval' status and assert redirection to Application Detail page
        self.homePage.verify_application()
        self.assertTrue(self.homePage.is_visible(Locators.VERIFY_APPLICATION_BUTTON))

    def test_003_reject_application(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.create_application()
        self.createApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Upload required documents and check a checkmark when the upload process is finished
        self.createApplicationPage.upload(Locators.UPLOAD_NRIC_BUTTON, TestData.NRIC_PATH)
        self.createApplicationPage.is_visible_long(Locators.NRIC_SUCCESS_ICON)

        #Submit the application
        self.createApplicationPage.submit_application()

        #Instantiate an object of HomePage class and check a toaster appear
        self.homePage = HomePage(self.createApplicationPage.driver)
        self.homePage.is_enabled(Locators.NOTIFICATION_TOASTER)
        self.homePage.is_clickable(Locators.CLAIM_APPLICATION_ROW_2)

        #Go to Claim Officer role and sort the claim list by the latest entries
        self.homePage.claim_officer_role()
        self.homePage.sort_by_latest()
        self.homePage.is_clickable(Locators.CLAIM_APPLICATION_ROW_1)

        # Go to the latest application details, instantiate an object of
        # ApplicationPage class and reject the application then assert
        # it has been rejected
        self.applicationDetailPage = ApplicationDetailPage(self.homePage.driver)
        self.applicationDetailPage.reject_application()
        self.applicationDetailPage.is_clickable(Locators.CLAIM_APPLICATION_ROW_2)

        self.homePage = HomePage(self.applicationDetailPage.driver)
        self.homePage.sort_by_latest()
        self.assertTrue(self.homePage.assert_element_text(Locators.CLAIM_APPLICATION_ROW_1_STATUS, TestData.STATUS_REJECTED))

    def test_004_verify_application(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.create_application()
        self.createApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Upload required documents and check a checkmark when the upload process is finished
        self.createApplicationPage.upload(Locators.UPLOAD_NRIC_BUTTON, TestData.NRIC_PATH)
        self.createApplicationPage.is_visible_long(Locators.NRIC_SUCCESS_ICON)

        #Submit the application
        self.createApplicationPage.submit_application()

        #Instantiate an object of HomePage class and check a toaster appear
        self.homePage = HomePage(self.createApplicationPage.driver)
        self.homePage.is_enabled(Locators.NOTIFICATION_TOASTER)
        self.homePage.is_clickable(Locators.CLAIM_APPLICATION_ROW_2)

        #Go to Claim Officer role and sort the claim list by the latest entries
        self.homePage.claim_officer_role()
        self.homePage.sort_by_latest()
        self.homePage.is_clickable(Locators.CLAIM_APPLICATION_ROW_1)

        # Go to the latest application details, instantiate an object of
        # ApplicationPage class and verify the application then assert
        # it has been verified
        self.applicationDetailPage = ApplicationDetailPage(self.homePage.driver)
        self.applicationDetailPage.verify_application()
        self.applicationDetailPage.is_clickable(Locators.CLAIM_APPLICATION_ROW_2)

        self.homePage = HomePage(self.applicationDetailPage.driver)
        self.homePage.sort_by_latest()
        self.assertTrue(self.homePage.assert_element_text(Locators.CLAIM_APPLICATION_ROW_1_STATUS, TestData.STATUS_VERIFIED))
class IMDGGrantApplicantTest(IMDGBaseTest):
    def setUp(self):
        super().setUp()

    def test_001_create_application_submit_uploaded_document(self):
        #Instantiate an object of LoginPage class and login using provided credential
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        #Instantiate an object of HomePage class and go to Create Application page
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.create_application()

        #Instantiate an object of CreateApplicationPage class and start to upload documents
        self.createApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Upload required documents and assert a checkmark when the upload process is finished
        self.createApplicationPage.upload_document()
        for locator in checkmark_icon_locators:
            self.assertTrue(self.createApplicationPage.is_visible(locator))

        #Submit the application
        self.createApplicationPage.submit_application()

        #Instantiate an object of HomePage class and assert a toaster appear
        self.homePage = HomePage(self.createApplicationPage.driver)
        self.assertTrue(self.homePage.is_enabled(Locators.NOTIFICATION_TOASTER))

    def test_002_create_application_remove_uploaded_document(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.create_application()
        self.createApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Upload required documents and assert a checkmark when the upload process is finished
        self.createApplicationPage.upload_document()
        for locator in checkmark_icon_locators:
            self.assertTrue(self.createApplicationPage.is_visible(locator))

        #Remove the uploaded documents & assert the checkmark disappear from its respective document
        self.createApplicationPage.remove_document()
        for locator in checkmark_icon_locators:
            self.assertFalse(self.createApplicationPage.is_visible(locator))

    def test_003_create_application_view_uploaded_document(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.create_application()
        self.createApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Upload required documents and assert a checkmark when the upload process is finished
        self.createApplicationPage.upload_document()
        for locator in checkmark_icon_locators:
            self.assertTrue(self.createApplicationPage.is_visible(locator))

        # View uploaded documents and assert the checkmarks when all the view process is finished
        self.createApplicationPage.view_document()
        for locator in checkmark_icon_locators:
            self.assertTrue(self.createApplicationPage.is_visible(locator))

    def test_004_edit_application_remove_document(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        # Instantiate an object of HomePage class and go to Edit Application page of the first application
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.edit_application()

        #Instantiate an object of CreateEditApplicationPage class and remove all the documents
        self.editApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Remove the uploaded documents & assert the checkmark disappear from its respective document
        self.editApplicationPage.remove_document()
        for locator in checkmark_icon_locators:
            self.assertFalse(self.editApplicationPage.is_visible(locator))

        #Return to Home page and assert the applicant name in the is empty
        self.editApplicationPage.back_to_application_list()
        self.assertTrue(self.editApplicationPage.assert_element_text(Locators.CLAIM_APPLICATION_ROW_2_APPLICANT_NAME, TestData.EMPTY_TEXT))

    def test_005_edit_application_upload_document(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        # Instantiate an object of HomePage class and go to Edit Application page of the first application
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.edit_application()

        #Instantiate an object of CreateEditApplicationPage class and remove all the documents
        self.editApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # Upload reqired documents and assert a checkmark when the upload process is finished
        ## NRIC
        self.editApplicationPage.upload_document()
        for locator in checkmark_icon_locators:
            self.assertTrue(self.editApplicationPage.is_visible(locator))

        #Return to Home page and assert the applicant name in the first row is not empty
        self.editApplicationPage.back_to_application_list()
        self.assertFalse(self.editApplicationPage.assert_element_text(Locators.CLAIM_APPLICATION_ROW_2_APPLICANT_NAME, TestData.EMPTY_TEXT))

    def test_006_edit_application_view_document(self):
        self.loginPage = LoginPage(self.driver)
        self.loginPage.login()

        # Instantiate an object of HomePage class and go to Edit Application page of the first application
        self.homePage = HomePage(self.loginPage.driver)
        self.homePage.edit_application()

        #Instantiate an object of CreateEditApplicationPage class and remove all the documents
        self.editApplicationPage = CreateEditApplicationPage(self.homePage.driver)

        # View uploaded documents and assert the checkmarks when all the view process is finished
        self.editApplicationPage.view_document()
        for locator in checkmark_icon_locators:
            self.assertTrue(self.editApplicationPage.is_visible(locator))