//
//  UITestExpectationVerifier.swift
//  suixinkanUITests
//
//  Created by Codex on 2026/6/26.
//

import XCTest

/// 根据首页菜单目录断言页面打开结果。
enum UITestExpectationVerifier {
    /// 校验调试菜单打开后的目标页。
    static func verify(
        _ expectation: UITestHomeMenuCatalog.Expectation,
        app: SuixinkanApp,
        file: StaticString = #filePath,
        line: UInt = #line
    ) {
        switch expectation {
        case .navigationTitle(let title):
            NavigationAssertions.waitForNavigationTitle(title, in: app, file: file, line: line)
        case .anyNavigationTitle(let titles):
            _ = NavigationAssertions.waitForAnyNavigationTitle(titles, in: app, file: file, line: line)
        case .tab(let tab):
            switch tab {
            case .orders:
                NavigationAssertions.waitForNavigationTitle("订单", in: app, file: file, line: line)
            case .statistics:
                NavigationAssertions.waitForNavigationTitle("数据", in: app, file: file, line: line)
            case .home:
                XCTAssertTrue(app.application.staticTexts["常用应用"].waitForExistence(timeout: 8) || app.application.staticTexts["请选择景区"].exists, file: file, line: line)
            case .profile:
                NavigationAssertions.waitForNavigationTitle("个人信息", in: app, file: file, line: line)
            }
        case .staticText(let text):
            NavigationAssertions.waitForStaticText(text, in: app, file: file, line: line)
        case .unsupportedPlaceholder(let title):
            _ = NavigationAssertions.waitForAnyNavigationTitle([title], in: app, file: file, line: line)
        }

        NavigationAssertions.assertNotStuckOnLoading(app: app, file: file, line: line)
    }
}
