/** * 默认超时配置(毫秒) * * @description * 定义各种操作的默认超时时间。所有工具函数都应该使用这些常量而不是硬编码超时值。 * * @example * ```ts * const timeout = options.timeout ?? DEFAULT_TIMEOUTS.static; * ``` */ export const DEFAULT_TIMEOUTS = { /** 静态选项超时(5秒)- 增加以适应不同环境*/ static: 5000, /** 异步选项超时(10秒)- 增加以适应网络慢的环境*/ async: 10000, /** 网络空闲超时(15秒)- 增加以适应网络慢的环境*/ networkIdle: 15000 } as const; /** * 选择器策略常量 * * @description * 定义选择器查找的优先级顺序,用于应对 Radix UI 版本升级。 * * 优先级顺序: * 1. `data-testid` - 最稳定,推荐用于测试 * 2. `aria-label + role` - 无障碍属性,较为稳定 * 3. `text content + role` - 文本内容,最不稳定但最通用 * * @example * ```ts * // 按优先级尝试选择器 * for (const strategy of SELECTOR_STRATEGIES) { * const element = await findByStrategy(strategy, label); * if (element) return element; * } * ``` */ export const SELECTOR_STRATEGIES = [ 'data-testid', 'aria-label + role', 'text content + role' ] as const; /** * 选择器策略类型 * * @description * 选择器策略的联合类型,用于类型检查。 * * @example * ```ts * function findByStrategy(strategy: SelectorStrategy, label: string) { * // ... * } * ``` */ export type SelectorStrategy = typeof SELECTOR_STRATEGIES[number];