# coding=utf-8
import unittest

from app.teacher.login.test_data.login_failed_toast import VALID_LOGIN_TOAST
from app.teacher.login.object_page.home_page import ThomePage
from app.teacher.login.object_page.login_page import TloginPage
from app.teacher.user_center.setting_center.object_page.setting_page import SettingPage
from app.teacher.user_center.user_information.object_page.user_center_page import TuserCenterPage, QuestionFeedback
from conf.decorator import setupclass, teardownclass, testcase
from utils.toast_find import Toast


class ProblemFeedback(unittest.TestCase):
    """问题反馈"""
    @classmethod
    @setupclass
    def setUp(cls):
        """启动应用"""
        cls.login = TloginPage()
        cls.home = ThomePage()
        cls.user = TuserCenterPage()
        cls.setting = SettingPage()
        cls.question_feedback = QuestionFeedback()

    @classmethod
    @teardownclass
    def tearDown(cls):
        pass

    @testcase
    def test_question_feedback(self):
        self.login.app_status()  # 判断APP当前状态

        if self.home.wait_check_page():  # 页面检查点
            self.home.click_tab_profile()  # 进入首页后点击‘个人中心’按钮

            if self.user.wait_check_page():  # 页面检查点
                self.user.click_setting()  # 进入设置页面

                if self.setting.wait_check_page():
                    self.setting.question_feedback()  # 进入问题反馈页面

                    if self.question_feedback.wait_check_page():  # 页面检查点
                        self.question_feedback.edit_text().send_keys("自动化测试123vxc567")
                        print('反馈的内容为:', '自动化测试123vxc567')
                        self.question_feedback.submit_button()

                        if self.setting.wait_check_page():  # 页面检查点
                            print('submit question success')
                        else:
                            print(' failed to submit question ')

                        self.home.back_up_button()  # 点击 返回按钮
                    else:
                        print("未进入问题反馈页面")

                    if self.user.wait_check_page():  # 页面检查点
                        self.home.click_tab_hw()  # 回首页
        else:
            Toast().find_toast(VALID_LOGIN_TOAST.login_failed())
            print("未进入主界面")

