Skip to content

test(mobile): 个人中心从相册换头像进 Maestro 冒烟链 · 修头像上传(#381) - #439

Merged
yile2020 merged 4 commits into
mainfrom
test/issue-381
Nov 22, 2026
Merged

yile2020 merged 4 commits into
mainfrom
test/issue-381

Conversation

@yile2020

@yile2020 yile2020 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Refs #381(只做第 1 条的自动化部分)

做了什么

  • 相册里放图:CI 跑 Maestro 前执行 apps/mobile/e2e/seed-gallery.sh:adb push 一张 400×400 的 PNG 到 /sdcard/Pictures/,发 MEDIA_SCANNER_SCAN_FILE,再回查 MediaStore 确认真的进了索引。查不到就当场红,不让流程在系统界面上干等
  • 新流程 flows/profile-avatar.yaml:登录 → 我的 → 资料 → 编辑 → 从相册选择 → 系统照片选择器(按 resource-id …:id/icon_thumbnail 找,AOSP 和 Google 两个包名都能匹配)→ 裁剪页(CanHub cropper 的 …:id/crop_image_menu_crop)→ 上传
  • 断言:成功 toast、地址框换成 /uploads/… 公开直链、图真的加载出来(编辑屏和「我的」页顶部两处都查)
  • UserAvatar 加 testID:图片加载成功后是 <id>-loaded,加载中是 <id>-image,显示首字时是 <id>-fallback。只看地址换没换的话,裂图也能过
  • setup.mjs 先把 admin 的头像清成 null,重跑时起点一致

顺手修了一个真 bug:移动端头像上传原来是坏的

流程第一次跑(run 44965454415)就红了:选图、裁剪都过了,回来是 toast「Avatar upload failed · Can't reach the server (http://10.0.2.2:8001): Unsupported FormDataPart implementation」。

  • 根因:Expo 57 的 winter 运行时把全局 fetch 换成了 expo/fetch,它的 multipart 编码不认 RN 的 { uri, name, type } 文件描述,直接抛错,客户端又把这个错包成了「连不上服务器」。lib/avatar.ts 原来走的是 sendRaw(fetch)
  • 修法:改走 api.sendUpload(XHR,走 RN 自己的网络层),和审批附件是同一条路

CI 结果(maestro · 移动端 E2E)

run 提交 结果
44965454415 只加了测试 ❌ profile-avatar 红在 toast-success,原因就是上面那个 bug(截图在 maestro-debug 里)
44966902550 修上传 ✅ 四条流程全过(profile-avatar 39 秒)
44968267534 补分册 ✅ 四条流程全过(profile-avatar 1 分 24 秒)

结论记进了 apps/mobile/e2e/AGENTS.md「换头像」一节,src/app/AGENTS.md 头像上传那一节也改了(这份已经到了 500 行的预算,只留了一条指向 e2e 分册的说明)。

没做 / 没覆盖

  • 真机验证没做:只在 CI 的 Android 模拟器(API 34 AOSP)上跑过,真机上的选图 / 裁剪 / 上传还要有人手动走一遍
  • 其他 API 级别的照片选择器没验(resource-id 可能不一样),带 Google 服务的镜像也没跑过
  • iOS 没覆盖(PHPicker,要 macOS runner)
  • 第 2 条(select / textarea / switch / radio-group 原语)这次不做:按 issue 里写明的约定「等第一个用得上的屏再加,不提前铺」

🤖 Generated with Claude Code

@yile2020 yile2020 changed the title test(mobile): 个人中心从相册换头像进 Maestro 冒烟链(#381) test(mobile): 个人中心从相册换头像进 Maestro 冒烟链 · 修头像上传(#381) Nov 22, 2026
yile2020 and others added 4 commits November 22, 2026 09:44
- CI 跑 Maestro 前往模拟器相册推一张测试图(seed-gallery.sh:adb push + 媒体扫描 + 回查 MediaStore)
- 新流程 profile-avatar:登录 → 我的 → 资料 → 编辑 → 从相册选择 → 系统照片选择器 → 裁剪确认 → 上传
  → 断言地址换成 /uploads 直链、图真的加载出来(编辑屏和「我的」页两处)
- UserAvatar 加 testID:加载成功才是 <id>-loaded,地址换成裂图时不会冒充成功
- setup.mjs 先把 admin 的头像清空,重跑时起点一致

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expo 57 的 winter 运行时把全局 fetch 换成了 expo/fetch,它的 multipart 编码遇到
RN 的 `{ uri, name, type }` 描述对象直接抛 `Unsupported FormDataPart implementation`,
被客户端包成「连不上服务器」。上一个提交的 Maestro 流程在 CI 模拟器上红在这一步
(截图:「Avatar upload failed · Can't reach the server … Unsupported FormDataPart
implementation」)。改走 `api.sendUpload`(XHR,RN 自己的网络层),和审批附件同一条路。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…· 相册回查防 SIGPIPE(#381)

- sendUpload 的 onerror 把 RN XHR 放在 responseText 里的原生错误原文带进报错,
  不再只有一句 `upload failed`(client.test.ts 两条,修前红)
- 新增 apps/mobile/tests/avatar-upload.test.mjs:守住头像上传走 sendUpload、
  不走 sendRaw / fetch;换回修前 avatar.ts 即红
- 编辑资料:头像已写进服务端后 reload() 失败,单独提示「头像已保存,但刷新资料失败」,
  地址框照样换成新地址(原来报「上传失败」,用户会重传、留下孤儿文件)
- UserAvatar:source 按地址 useMemo,避免原语每次渲染把状态重置成 loading / 坏图反复重挂
- seed-gallery.sh:先收进变量再 grep,避免 pipefail 下 grep -q 早退导致 SIGPIPE 误判
- e2e 分册:重跑前要先跑 setup.mjs 的前提写清楚

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yile2020
yile2020 enabled auto-merge November 22, 2026 01:44
@yile2020
yile2020 merged commit 1f35650 into main Nov 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant