- 移除微信订阅推送功能(云函数/订阅管理页),回归纯客户端零后端架构 - 新增今日黄历默认展示卡片 TodayAlmanacCard(9 语言翻译) - i18n 修复:启用 globalInjection 修复 $t 未注入,插值消息全部改为 Messages Functions 适配小程序端(63 处) - 修复底部导航切换失效与运势页数据不刷新 - 统一设计令牌(深褐主色 + 印红强调色),组件 UI 规范重构 - 图标 iconfont 化(FontAwesome 子集化,修复 Android 豆腐块) - 新增 postcss-px2rpx 机型自适应(仅 mp-weixin 构建生效) - 新增 5 个用户旅程 E2E 测试(31 用例)与验收报告 - 补充微信小程序项目配置(appid)
58 lines
2.5 KiB
TypeScript
58 lines
2.5 KiB
TypeScript
import type { Page } from '@playwright/test'
|
|
|
|
/**
|
|
* 用户旅程测试共享工具函数(可复用)
|
|
*
|
|
* 统一 uni-app H5 端的交互辅助逻辑,供 e2e/journeys/*.spec.ts 复用。
|
|
* 关键实现说明:
|
|
* - uni-app 日期选择器在 H5 渲染为隐藏的 input[type=date],通过设置 value 并派发 change 触发组件更新
|
|
* - uni-app 输入框渲染为 <uni-input> 包装,需对其内部 <input> 真实输入(pressSequentially)才能触发 @input
|
|
*/
|
|
|
|
/** 设置日期输入(隐藏的 input[type=date],派发 change 触发组件更新) */
|
|
export async function setDateInput(page: Page, selector: string, value: string): Promise<void> {
|
|
await page.evaluate(([sel, v]) => {
|
|
const input = document.querySelector(sel) as HTMLInputElement | null
|
|
if (!input) return
|
|
input.value = v
|
|
input.dispatchEvent(new Event('change', { bubbles: true }))
|
|
}, [selector, value] as const)
|
|
await page.waitForTimeout(400)
|
|
}
|
|
|
|
/** 输入文本到 uni-input 包装的输入框(真实输入以触发 @input) */
|
|
export async function typeIntoInput(page: Page, selector: string, value: string, waitMs = 900): Promise<void> {
|
|
await page.locator(selector).pressSequentially(value, { delay: 30 })
|
|
await page.waitForTimeout(waitMs)
|
|
}
|
|
|
|
/** 输入出生地(uni-input 包装,触发坐标自动识别) */
|
|
export async function setBirthPlace(page: Page, value: string): Promise<void> {
|
|
await typeIntoInput(page, 'uni-input.text-input input', value)
|
|
}
|
|
|
|
/** 点击指定文本的按钮(.button-text 内容匹配) */
|
|
export async function clickButton(page: Page, text: string | RegExp): Promise<void> {
|
|
await page.locator('.button-text', { hasText: text }).first().click()
|
|
await page.waitForTimeout(500)
|
|
}
|
|
|
|
/** 打开 uni-app 自定义选择器并验证其弹出(返回是否打开) */
|
|
export async function openCustomPicker(page: Page): Promise<boolean> {
|
|
const opened = await page.evaluate(() => document.querySelectorAll('.uni-picker-item').length > 0)
|
|
return opened
|
|
}
|
|
|
|
/** 关闭 uni-app 自定义选择器(Cancel,容错) */
|
|
export async function closeCustomPicker(page: Page): Promise<void> {
|
|
await page.locator('.uni-picker-action-cancel').click({ force: true, timeout: 3000 }).catch(() => {})
|
|
await page.waitForTimeout(300)
|
|
}
|
|
|
|
/** 直接导航到指定页面 */
|
|
export async function gotoPage(page: Page, path: string): Promise<void> {
|
|
await page.goto(`/#${path}`)
|
|
await page.waitForLoadState('networkidle')
|
|
await page.waitForTimeout(1000)
|
|
}
|