//
//  TasksUITests.swift
//  suixinkanUITests
//

import XCTest

final class TasksUITests: AuthenticatedUITestCase {
    /// 测试任务列表可进入详情，发布任务页可打开。
    func testTaskListDetailAndCreateValidation() throws {
        try openTaskManagement()

        let firstCell = app.application.cells.element(boundBy: 0)
        if firstCell.waitForExistence(timeout: 10) {
            firstCell.tap()
            NavigationAssertions.waitForNavigationTitle("任务详情", in: app)
            BackNavigator.goBack(app: app)
        } else {
            throw XCTSkip("测试账号暂无任务数据，跳过详情流测试。")
        }

        app = try UITestSession.relaunch(openMenu: "发布任务")
        NavigationAssertions.waitForNavigationTitle("发布任务", in: app)
    }

    /// 直达任务管理页。
    private func openTaskManagement() throws {
        app = try UITestSession.relaunch(openMenu: "任务管理")
        NavigationAssertions.waitForNavigationTitle("任务管理", in: app)
    }
}
