Skip to content

fix(web-integration): avoid enametoolong in playwright report filenames - #2915

Open
xianglongfei-8888 wants to merge 1 commit into
web-infra-dev:mainfrom
xianglongfei-8888:main
Open

fix(web-integration): avoid enametoolong in playwright report filenames#2915
xianglongfei-8888 wants to merge 1 commit into
web-infra-dev:mainfrom
xianglongfei-8888:main

Conversation

@xianglongfei-8888

@xianglongfei-8888 xianglongfei-8888 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

issues:#2905

根因分析:
一.1.7.3 正常的原因
当时 PlaywrightAiFixture 的 reportFileName 用的是:
playwright-${testInfo.testId}-${pageUuid}
文件名短且稳定,不依赖中文标题长度,所以不会触发 ENAMETOOLONG

二.1.10.4+ 出现异常的原因
后续版本引入了“可读标题文件名”逻辑
改成把长测试标题直接拼到 reportFileName
中文标题按 UTF-8 计字节,很容易超过单文件名上限 255 bytes

修复:
1.packages/web-integration/src/playwright/ai-fixture.ts
引入短文件名策略:
playwright-${短标题前缀}-${10位稳定hash}-${pageUuid}
使用 UTF-8 字节截断,而不是字符截断
保留可读性与唯一性,同时避免超长

2.packages/web-integration/src/playwright/reporter/index.ts
separate reporter 模式也采用同样的短文件名策略
避免最终 report 导出时再次因为长标题报错

测试修复 补充并执行了回归测试:

packages/web-integration/tests/unit-test/playwright-ai-fixture-report-filename.test.ts
packages/web-integration/tests/unit-test/playwright-reporter.test.ts
测试内容覆盖:

超长标题场景下,report 文件名不会继续无限增长
文件名包含稳定 hash 和唯一 page uuid
separate reporter 模式生成的最终文件名也受控
单测中的 longTitle 已改为英文长标题
断言改为基于 UTF-8 字节长度,更符合真实文件系统限制

执行结果:
Test Files 2 passed (2)
Tests 17 passed (17)

@xianglongfei-8888

xianglongfei-8888 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

先修复CI的问题:#2919

再重新触发CI

@yuyutaotao 可以帮忙review一下嘛,谢谢

@xianglongfei-8888

Copy link
Copy Markdown
Contributor Author

@yuyutaotao 可以帮忙review下这个提交嘛

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