@microi.net/cli 5.7.7 → 5.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/.codebuddy-plugin/marketplace.json +2 -2
  2. package/.codebuddy-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.workbuddy-plugin/marketplace.json +2 -2
  5. package/.workbuddy-plugin/plugin.json +1 -1
  6. package/LICENSE +21 -21
  7. package/README.md +71 -71
  8. package/assets/build-meta.json +6 -6
  9. package/assets/feature-matrix.json +138 -138
  10. package/assets/logo.svg +4 -4
  11. package/cordis.patch.yml +1 -1
  12. package/package.json +1 -1
  13. package/scripts/mcp-codex-stdio-adapter.js +0 -0
  14. package/scripts/mcp-server.js +102 -101
  15. package/scripts/microi-cli.js +57 -57
  16. package/scripts/microi-codex-broker.js +450 -450
  17. package/scripts/microi-codex-router.js +0 -0
  18. package/scripts/microi-skills.meta.json +366 -366
  19. package/skills/.microi-skills-version.json +2 -2
  20. package/skills/.progressive-disclosure-manifest.json +27 -27
  21. package/skills/README.md +286 -286
  22. package/skills/ai-engine/SKILL.md +265 -265
  23. package/skills/ai-engine/agents/openai.yaml +4 -4
  24. package/skills/ai-platform-governance/SKILL.md +177 -177
  25. package/skills/ai-platform-governance/references/progressive-01-/345/212/237/350/203/275/345/274/200/345/205/263.md +190 -190
  26. package/skills/app-store/SKILL.md +392 -396
  27. package/skills/app-store/agents/openai.yaml +4 -4
  28. package/skills/business-blueprint/SKILL.md +193 -193
  29. package/skills/datasource-engine/SKILL.md +90 -90
  30. package/skills/datasource-engine/agents/openai.yaml +4 -4
  31. package/skills/dos-orm/references/api-reference.md +229 -229
  32. package/skills/email-engine/SKILL.md +78 -78
  33. package/skills/email-engine/references/v8-email.md +34 -34
  34. package/skills/job-engine/SKILL.md +171 -172
  35. package/skills/job-engine/agents/openai.yaml +4 -4
  36. package/skills/message-notification/SKILL.md +155 -156
  37. package/skills/message-notification/agents/openai.yaml +5 -5
  38. package/skills/message-notification/references/contracts.md +102 -102
  39. package/skills/microi-ai-app-auth.js +652 -652
  40. package/skills/microi-ai-application/SKILL.md +102 -106
  41. package/skills/microi-ai-application/agents/openai.yaml +4 -4
  42. package/skills/microi-ai-application/references/frontend-baseline.md +164 -164
  43. package/skills/microi-client-frontend/SKILL.md +235 -240
  44. package/skills/microi-client-frontend/references/progressive-01-3-/345/212/250/346/200/201/346/214/211/351/222/256/347/263/273/347/273/237.md +144 -144
  45. package/skills/microi-client-frontend/references/progressive-02-8-/350/277/220/350/241/214/346/227/266/351/253/230/351/242/221/345/235/221/345/244/215/347/233/230.md +196 -196
  46. package/skills/microi-client-frontend/references/progressive-03-vue3-/345/211/215/347/253/257/345/276/256/346/234/215/345/212/241/345/256/277/344/270/273/350/247/204/345/210/231.md +167 -167
  47. package/skills/microi-codex/SKILL.md +75 -75
  48. package/skills/microi-codex-installer/SKILL.md +225 -223
  49. package/skills/microi-codex-installer/agents/openai.yaml +7 -7
  50. package/skills/microi-datasource-mapping/SKILL.md +107 -111
  51. package/skills/microi-db-schema/SKILL.md +175 -175
  52. package/skills/microi-db-schema/agents/openai.yaml +4 -4
  53. package/skills/microi-db-schema/references/core-tables.md +695 -695
  54. package/skills/microi-db-schema/references/form-component-options.md +256 -256
  55. package/skills/microi-db-schema/references/schema-overview.md +202 -202
  56. package/skills/microi-db-schema/references/schema.md +646 -646
  57. package/skills/microi-db-schema/references/table-catalog.md +1599 -1599
  58. package/skills/microi-deployment/references/deployment-matrix.md +101 -101
  59. package/skills/microi-docs-coverage/references/capability-map.md +0 -1
  60. package/skills/microi-docs-coverage/scripts/audit-doc-skill-coverage.mjs +894 -894
  61. package/skills/microi-form-engine/SKILL.md +226 -226
  62. package/skills/microi-form-engine/references/component-catalog.md +216 -216
  63. package/skills/microi-form-engine/references/data-source-events.md +124 -124
  64. package/skills/microi-form-layout/SKILL.md +205 -205
  65. package/skills/microi-form-layout/references/progressive-01-3-/344/270/211/347/247/215/345/210/206/347/273/204/347/232/204/345/255/230/345/202/250/344/270/216/351/205/215/347/275/256.md +235 -235
  66. package/skills/microi-frontend-sdk/SKILL.md +188 -188
  67. package/skills/microi-frontend-sdk/references/progressive-01-token-/345/275/223/345/211/215/347/231/273/345/275/225/347/224/250/346/210/267/344/270/216/345/275/223/345/211/215/347/273/210/347/253/257/347/231/273/345/275/225/345/215/217/350/256/256.md +176 -176
  68. package/skills/microi-left-right-layout/SKILL.md +141 -141
  69. package/skills/microi-microservice/SKILL.md +322 -323
  70. package/skills/microi-microservice/references/runtime-delivery.md +278 -278
  71. package/skills/microi-mobile-app-quality/SKILL.md +181 -181
  72. package/skills/microi-mobile-app-quality/references/progressive-01-4-/351/207/215/350/246/201/346/214/211/351/222/256/345/277/205/351/241/273/345/270/246/345/233/276/346/240/207.md +213 -213
  73. package/skills/microi-mobile-app-quality/references/progressive-02-9-/344/270/273/351/242/230/345/210/207/346/215/242/345/277/205/351/241/273/347/234/237/345/256/236/344/270/224/345/205/250/345/261/200/347/224/237/346/225/210.md +128 -128
  74. package/skills/microi-solution-quotation/SKILL.md +78 -78
  75. package/skills/microi-solution-quotation/agents/openai.yaml +4 -4
  76. package/skills/microi-solution-quotation/scripts/build_solution_quote.py +296 -296
  77. package/skills/microi-sso/references/acceptance.md +49 -49
  78. package/skills/microi-sso/references/configuration-and-security.md +53 -53
  79. package/skills/microi-sso/references/inbound.md +53 -53
  80. package/skills/microi-sso/references/outbound.md +39 -39
  81. package/skills/microi-system-delivery/SKILL.md +134 -134
  82. package/skills/microi-system-delivery/references/progressive-01-/346/240/207/345/207/206/345/267/245/344/275/234/346/265/201.md +193 -193
  83. package/skills/microi-system-delivery/references/progressive-02-/350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/345/277/205/351/241/273/350/246/206/347/233/226/347/232/204/345/235/221.md +189 -189
  84. package/skills/microi-ui/SKILL.md +174 -174
  85. package/skills/microi-ui/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/234/272/346/231/257/350/223/235/345/233/276.md +183 -183
  86. package/skills/microi-uniapp-frontend/SKILL.md +193 -193
  87. package/skills/microi-uniapp-frontend/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/210/206/347/261/273-/345/217/214/346/240/217/345/210/227/350/241/250/347/213/254/347/253/213/346/273/232/345/212/250.md +225 -225
  88. package/skills/microi-uniapp-frontend/references/progressive-02-/345/205/263/351/224/256/344/270/232/345/212/241/350/265/204/344/272/247/344/270/215/345/276/227/351/273/230/350/256/244/351/200/211/344/270/255.md +154 -154
  89. package/skills/microi.v8.js +1921 -1921
  90. package/skills/module-engine/SKILL.md +237 -250
  91. package/skills/module-engine/references/module-config.md +204 -204
  92. package/skills/ocr-engine/SKILL.md +113 -113
  93. package/skills/ocr-engine/agents/openai.yaml +4 -4
  94. package/skills/page-engine/SKILL.md +180 -191
  95. package/skills/page-engine/references/progressive-01-/346/211/200/346/234/211/347/273/204/344/273/266/347/261/273/345/236/213.md +234 -234
  96. package/skills/page-engine/references/progressive-02-/347/211/210/346/234/254/345/216/206/345/217/262-/345/271/266/345/217/221/344/277/235/345/255/230/344/270/216/345/233/236/346/273/232.md +60 -60
  97. package/skills/performance-testing/SKILL.md +221 -221
  98. package/skills/playwright-e2e/SKILL.md +197 -197
  99. package/skills/playwright-e2e/references/progressive-01-/345/205/250/350/207/252/345/212/250/347/231/273/345/275/225-/345/205/215/351/252/214/350/257/201/347/240/201-/344/275/206/344/270/215/345/205/215/345/257/206/347/240/201-/345/277/205/350/257/273.md +173 -173
  100. package/skills/playwright-e2e/references/progressive-02-/346/226/207/345/255/227/345/257/271/346/257/224/345/272/246/344/270/216/345/217/257/350/257/273/346/200/247/350/207/252/345/212/250/345/214/226/346/243/200/346/237/245-/345/277/205/345/201/232.md +183 -183
  101. package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md +221 -221
  102. package/skills/playwright-e2e/references/progressive-04-ci-/345/273/272/350/256/256.md +115 -115
  103. package/skills/print-engine/SKILL.md +259 -259
  104. package/skills/production-readonly-audit/SKILL.md +41 -41
  105. package/skills/report-engine/SKILL.md +71 -71
  106. package/skills/report-engine/agents/openai.yaml +4 -4
  107. package/skills/scripts/optimize-progressive-disclosure.mjs +204 -204
  108. package/skills/scripts/refresh-progressive-disclosure.mjs +64 -64
  109. package/skills/search-engine/SKILL.md +75 -75
  110. package/skills/search-engine/agents/openai.yaml +4 -4
  111. package/skills/spider-engine/SKILL.md +190 -190
  112. package/skills/system-observability/SKILL.md +238 -238
  113. package/skills/system-observability/references/memory-incident-triage.md +70 -70
  114. package/skills/translate-engine/SKILL.md +140 -140
  115. package/skills/translate-engine/agents/openai.yaml +4 -4
  116. package/skills/ui-design/SKILL.md +191 -191
  117. package/skills/ui-design/assets/templates/MCI-DESIGN.md +198 -198
  118. package/skills/ui-design/references/design-pattern-library.md +184 -184
  119. package/skills/ui-design/references/mci-design-contract.md +163 -163
  120. package/skills/ui-design/references/progressive-01-/351/242/234/350/211/262/344/275/223/347/263/273-css-variables-/346/224/257/346/214/201/344/270/273/351/242/230/345/210/207/346/215/242.md +218 -218
  121. package/skills/ui-design/references/progressive-02-/345/255/227/344/275/223.md +137 -137
  122. package/skills/ui-design/references/progressive-03-/345/212/250/346/225/210/350/247/204/350/214/203-/344/270/260/345/257/214/344/275/206/344/270/215/345/215/241.md +235 -235
  123. package/skills/ui-design/references/progressive-04-/347/273/204/344/273/266/351/243/216/346/240/274/351/200/237/346/237/245.md +152 -152
  124. package/skills/ui-design/references/progressive-05-/347/247/273/345/212/250/347/253/257/344/270/223/347/224/250/350/247/204/350/214/203.md +238 -238
  125. package/skills/ui-design/references/progressive-06-/344/270/273/351/242/230/345/210/207/346/215/242/345/256/236/347/216/260.md +194 -194
  126. package/skills/ui-design/references/progressive-07-/351/200/237/346/237/245-/344/273/216/345/244/264/346/220/255/345/273/272/344/270/200/344/270/252/347/247/273/345/212/250/347/253/257/351/241/265/351/235/242.md +207 -207
  127. package/skills/ui-design/references/progressive-08-/350/241/250/345/215/225/345/210/206/347/273/204/350/247/204/350/214/203-tabs-vs-collapsegroup-/345/274/272/345/210/266.md +117 -117
  128. package/skills/uniapp-mall-assets/SKILL.md +176 -176
  129. package/skills/unity-integration/SKILL.md +155 -155
  130. package/skills/unity-integration/agents/openai.yaml +4 -4
  131. package/skills/unity-integration/references/ai-app-delivery.md +103 -103
  132. package/skills/unity-integration/references/sdk-api.md +82 -82
  133. package/skills/unity-integration/references/toolbox-migration.md +66 -66
  134. package/skills/unity-integration/references/webgl-hosting.md +57 -57
  135. package/skills/v8-cache-pattern/SKILL.md +306 -306
  136. package/skills/v8-crud-api/SKILL.md +175 -175
  137. package/skills/v8-crud-api/references/progressive-01-/346/237/245/350/257/242/345/210/227/350/241/250-/345/210/206/351/241/265.md +226 -226
  138. package/skills/v8-crud-api/references/progressive-02-where-/346/235/241/344/273/266/350/257/255/346/263/225/351/200/237/346/237/245.md +49 -49
  139. package/skills/v8-debugging/SKILL.md +284 -284
  140. package/skills/v8-explorer-tree/SKILL.md +228 -228
  141. package/skills/v8-export-import/SKILL.md +209 -209
  142. package/skills/v8-export-import/references/progressive-01-excellayout-/351/253/230/347/272/247/350/207/252/347/224/261/345/270/203/345/261/200.md +211 -211
  143. package/skills/v8-export-import/references/progressive-02-powerpoint-/345/257/274/345/207/272.md +202 -202
  144. package/skills/v8-export-import/references/progressive-03-/345/256/211/345/205/250-/346/200/247/350/203/275/346/263/250/346/204/217.md +42 -42
  145. package/skills/v8-file-upload/SKILL.md +256 -263
  146. package/skills/v8-file-upload/references/progressive-01-/345/205/254/346/234/211/346/241/266-vs-/347/247/201/346/234/211/346/241/266.md +101 -101
  147. package/skills/v8-file-upload/references/progressive-02-office-/346/226/207/344/273/266/345/234/250/347/272/277/347/274/226/350/276/221/347/211/210/346/234/254/345/217/267/350/247/204/345/210/231.md +150 -150
  148. package/skills/v8-formengine-http/SKILL.md +219 -219
  149. package/skills/v8-frontend-events/SKILL.md +178 -178
  150. package/skills/v8-frontend-events/references/bluetooth-print-api.md +135 -135
  151. package/skills/v8-frontend-events/references/bluetooth-print.md +246 -246
  152. package/skills/v8-frontend-events/references/progressive-01-/345/210/227/350/241/250/344/272/213/344/273/266.md +219 -219
  153. package/skills/v8-http-integration/SKILL.md +182 -182
  154. package/skills/v8-http-integration/references/progressive-01-get-/350/257/267/346/261/202.md +220 -220
  155. package/skills/v8-http-integration/references/progressive-02-/351/224/231/350/257/257/345/244/204/347/220/206/346/250/241/345/274/217.md +44 -44
  156. package/skills/v8-image-processing/SKILL.md +190 -190
  157. package/skills/v8-image-processing/agents/openai.yaml +4 -4
  158. package/skills/v8-image-processing/references/api-reference.md +623 -623
  159. package/skills/v8-menu-buttons/SKILL.md +180 -180
  160. package/skills/v8-menu-buttons/references/progressive-01-2-/346/214/211/351/222/256/345/257/271/350/261/241-schema.md +222 -222
  161. package/skills/v8-menu-buttons/references/progressive-02-8-/346/250/241/345/274/217-f-/345/220/216/345/217/260/344/273/273/345/212/241/346/214/211/351/222/256-/351/225/277/344/273/273/345/212/241.md +228 -228
  162. package/skills/v8-menu-buttons/references/progressive-03-10-/345/217/215/346/250/241/345/274/217-/351/201/277/345/205/215.md +104 -104
  163. package/skills/v8-mongodb/SKILL.md +192 -192
  164. package/skills/v8-mq-mqtt/SKILL.md +175 -176
  165. package/skills/v8-mq-mqtt/references/mqtt-production.md +342 -342
  166. package/skills/v8-mq-mqtt/references/progressive-01-v8-mqtt-iot-/347/211/251/350/201/224/347/275/221.md +181 -181
  167. package/skills/v8-mq-mqtt/scripts/check-mqtt-skill-coverage.mjs +203 -203
  168. package/skills/v8-saas-multi-tenant/SKILL.md +219 -219
  169. package/skills/v8-security/SKILL.md +168 -168
  170. package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +198 -198
  171. package/skills/v8-security/references/progressive-02-7-/346/227/245/345/277/227/350/256/260/345/275/225.md +158 -158
  172. package/skills/v8-sql-query/SKILL.md +302 -302
  173. package/skills/v8-table-event/SKILL.md +144 -144
  174. package/skills/v8-table-event/references/progressive-01-informv8-js-/350/241/250/345/215/225/346/211/223/345/274/200/344/272/213/344/273/266.md +197 -197
  175. package/skills/v8-table-event/references/progressive-02-/345/211/215/347/253/257/344/272/213/344/273/266/345/220/215-v8-eventname-/345/217/257/350/203/275/347/232/204/345/200/274.md +46 -46
  176. package/skills/v8-tcp-integration/SKILL.md +147 -147
  177. package/skills/v8-tcp-integration/agents/openai.yaml +4 -4
  178. package/skills/v8-template-engine/SKILL.md +167 -167
  179. package/skills/v8-utilities/SKILL.md +90 -90
  180. package/skills/v8-utilities/references/client-api-index.md +143 -143
  181. package/skills/v8-utilities/references/platform-http-routes.md +83 -83
  182. package/skills/v8-utilities/references/server-api-index.md +188 -188
  183. package/skills/v8-workflow/SKILL.md +216 -243
  184. package/skills/v8-workflow/references/progressive-01-/350/212/202/347/202/271/345/274/200/345/247/213-v8-/344/272/213/344/273/266.md +180 -180
  185. package/skills/vision-engine/SKILL.md +159 -159
  186. package/skills/vision-engine/agents/openai.yaml +4 -4
  187. package/skills/vision-engine/references/architecture-and-acceptance.md +194 -194
  188. package/skills/workspace-conventions/SKILL.md +261 -261
  189. package/skills/workspace-conventions/references/progressive-01-/347/211/210/346/234/254/346/233/264/346/226/260/346/227/245/345/277/227/344/277/235/346/212/244/350/247/204/345/210/231-/345/274/272/345/210/266.md +208 -208
  190. package/skills/workspace-conventions/references/progressive-02-microi-net-api-/346/234/254/345/234/260/345/220/257/345/212/250/347/272/246/345/256/232.md +216 -216
  191. package/skills/workspace-conventions/references/progressive-03-cli-/344/270/216-ide-/346/217/222/344/273/266/351/224/231/347/211/210/345/205/261/345/255/230/347/272/246/345/256/232.md +27 -27
@@ -1,183 +1,183 @@
1
- # playwright-e2e 详细参考 2
2
-
3
- > 按需读取;本文件由 SKILL.md 的原章节无损拆分。
4
-
5
- <!-- microi-progressive:chunk id=playwright-e2e-013 sha256=cce51ad8ff52cd1339b5a1ce4986d8167b5cccb77637e8a3d438da9da03b68cd -->
6
- ## 文字对比度与可读性自动化检查(必做)
7
-
8
- 凡涉及前端样式、卡片、芯片、按钮、价格区间筛选条、退出登录、徽章、覆盖文字(金色/渐变背景上的小字)、列表副标题、空状态等,**测试与人眼复核都必须执行对比度检查**。典型教训:筛选条文字、幽灵按钮、轻色副标题在近似底色下肉眼几乎不可见,但接口/DOM 断言全部通过——这类对比度问题必须通过自动化审计捕捉。
9
-
10
- ### 自动化对比度审计
11
-
12
- 对每个核心页面,遍历可见文本节点,计算前景色与最近不透明背景色的 WCAG 对比度,<4.5:1 直接失败:
13
-
14
- ```js
15
- const lowContrast = await page.evaluate(() => {
16
- const ratio = (fg, bg) => {
17
- const lum = (c) => {
18
- const v = c.map(x => x/255).map(x => x <= 0.03928 ? x/12.92 : Math.pow((x+0.055)/1.055, 2.4));
19
- return 0.2126*v[0] + 0.7152*v[1] + 0.0722*v[2];
20
- };
21
- const parse = (s) => (s.match(/\d+(\.\d+)?/g) || []).slice(0,3).map(Number);
22
- const lf = lum(parse(fg)); const lb = lum(parse(bg));
23
- return (Math.max(lf,lb)+0.05)/(Math.min(lf,lb)+0.05);
24
- };
25
- const findBg = (el) => {
26
- let cur = el;
27
- while (cur) {
28
- const c = getComputedStyle(cur).backgroundColor;
29
- if (c && c !== 'rgba(0, 0, 0, 0)' && c !== 'transparent') return c;
30
- cur = cur.parentElement;
31
- }
32
- return 'rgb(255,255,255)';
33
- };
34
- const issues = [];
35
- document.querySelectorAll('*').forEach(el => {
36
- const t = (el.innerText || '').trim();
37
- if (!t || el.children.length) return;
38
- const cs = getComputedStyle(el);
39
- if (cs.visibility === 'hidden' || cs.display === 'none' || parseFloat(cs.opacity) < 0.5) return;
40
- const fz = parseFloat(cs.fontSize);
41
- if (fz < 9) return;
42
- const r = ratio(cs.color, findBg(el));
43
- if (r < 4.5) issues.push({ text: t.slice(0,40), color: cs.color, bg: findBg(el), ratio: +r.toFixed(2), fontSize: fz });
44
- });
45
- return issues;
46
- });
47
- expect(lowContrast, '低对比度文字: ' + JSON.stringify(lowContrast.slice(0,5))).toEqual([]);
48
- ```
49
-
50
- ### 必须人眼复核(view_image)的页面
51
-
52
- 完成功能后强制 `fullPage` 截图并 `view_image` 人眼审阅以下页面,截图存入 `tests/e2e/screenshots/`:
53
-
54
- | 页面 | 路径(以项目实际路由为准) | 重点检查 |
55
- |------|------|---------|
56
- | 首页 | `/#/pages/index/index` 等 | 横幅、公告、商品卡价格 |
57
- | 分类 | `/#/pages/category/...` | tab、商品标题副信息 |
58
- | 商品详情 | `/#/pages/product/detail?id=...` | 价格、规格、按钮 |
59
- | 购物车 | `/#/pages/cart/...` | 数量、合计、结算按钮 |
60
- | 订单列表/详情 | `/#/pages/order/...` | 状态徽章、金额、提交按钮 |
61
- | 我的 | `/#/pages/mine/...` | **退出登录按钮**、菜单标签、账户信息 |
62
- | 业务专题页 | 项目自定义路径 | 核心功能区域、状态、可交互元素 |
63
-
64
- 判定标准:任意小号文字 < 12px 在彩色/渐变背景上,或纯文字按钮在与页面同色调底色上无明显边框/填充——一律视为缺陷,必须修复后再发版。
65
-
66
- ### 设计禁忌(直接判失败)
67
-
68
- 1. 幽灵按钮(ghost button)在近似底色上当独立操作按钮使用——必须改成实心按钮或显式覆盖背景填充。
69
- 2. 中性灰/浅色文字(如 `#999` 等)直接放在与其色调接近的背景上,且字号较小——WCAG 对比度 < 4.5:1 直接判失败。
70
- 3. 渐变彩色背景上展示透明度较低的小字。
71
- 4. 与背景色调接近的文字颜色放在同色调底色上——必须加深文字颜色或改变底色。
72
- 5. 价格区间、状态、筛选这类**导航/筛选元素出现在列表中部作为标题**——必须移到顶部 sticky 工具栏,并与正文形成色彩区隔。
73
-
74
- <!-- /microi-progressive:chunk -->
75
- <!-- microi-progressive:chunk id=playwright-e2e-014 sha256=3eea01cf70e67d545fede1724b049ed852da60cf0a4ea0bda6b2e1d6de84400d -->
76
- ## 安装
77
-
78
- ```bash
79
- npm i -D @playwright/test
80
- npx playwright install chromium
81
- ```
82
-
83
- ### 浏览器选择强制顺序
84
-
85
- 做本地页面级 Playwright 验收时,不能因为 Playwright 官方 Chromium 缓存缺失或下载超时就结束任务。必须按下面顺序自动兜底:
86
-
87
- 1. 优先读取 `PW_CHROMIUM_EXECUTABLE` / `PW_BROWSER_EXECUTABLE`。
88
- 2. Windows 优先探测本机 Edge / Chrome:`C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`、`C:/Program Files/Microsoft/Edge/Application/msedge.exe`、`C:/Users/Administrator/AppData/Local/Google/Chrome/Bin/chrome.exe`、`C:/Program Files/Google/Chrome/Application/chrome.exe`、`C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`。
89
- 3. 再探测工作区本地缓存:`.cache/chromium/**/chrome.exe`、`.tmp/playwright-browsers/**/chrome.exe`。
90
- 4. 仍没有浏览器时,才从吾码 CDN 下载到 `.tmp/playwright-browsers/`,并设置 `PW_CHROMIUM_EXECUTABLE`。
91
- 5. 只有系统浏览器、本地缓存和 CDN 下载全部失败时,才允许报告“浏览器不可用”;报告中必须说明已经尝试过哪些路径。
92
-
93
- 手写一次性脚本必须把浏览器探测逻辑写在 `.tmp/*.mjs` 中,截图和报告也必须输出到 `.tmp/screenshots/` 或 `.tmp/reports/`,不要写到 `Microi.Client/`、`Microi.Server/` 等子项目目录。
94
-
95
- 国内或内网环境如果下载浏览器困难,可以使用本机 Edge:
96
-
97
- ```bash
98
- $env:PW_BROWSER_CHANNEL='msedge'
99
- npx playwright test
100
- ```
101
-
102
- 如果本机没有可用 Edge,或必须使用 Chromium,优先从吾码 CDN 下载浏览器压缩包,不要反复卡在 Playwright 官方下载通道:
103
-
104
- | 系统 | CDN 地址 |
105
- |------|----------|
106
- | Windows x64 | `https://static.itdos.com/openclaw/chromium/chrome-win64-137.0.7151.68.zip` |
107
- | macOS x64 | `https://static.itdos.com/openclaw/chromium/chrome-mac-x64-137.0.7151.68.zip` |
108
- | macOS arm64 | `https://static.itdos.com/openclaw/chromium/chrome-mac-arm64-137.0.7151.68.zip` |
109
-
110
- Windows 示例:
111
-
112
- ```powershell
113
- $browserRoot = Join-Path (Resolve-Path '.tmp').Path 'playwright-browsers'
114
- New-Item -ItemType Directory -Force -Path $browserRoot | Out-Null
115
- $zipPath = Join-Path $browserRoot 'chrome-win64-137.0.7151.68.zip'
116
- Invoke-WebRequest 'https://static.itdos.com/openclaw/chromium/chrome-win64-137.0.7151.68.zip' -OutFile $zipPath
117
- Expand-Archive $zipPath -DestinationPath $browserRoot -Force
118
- $env:PW_CHROMIUM_EXECUTABLE = (Resolve-Path (Join-Path $browserRoot 'chrome-win64/chrome.exe')).Path
119
- npx playwright test
120
- ```
121
-
122
- 手写 Playwright 脚本时读取 `PW_CHROMIUM_EXECUTABLE` / `PW_BROWSER_EXECUTABLE` 并传给 `chromium.launch({ executablePath })`;Playwright Test 配置中通过 `use.launchOptions.executablePath` 读取该环境变量。只有 CDN、系统浏览器和本地缓存都不可用时,才报告浏览器不可用。
123
-
124
- <!-- /microi-progressive:chunk -->
125
- <!-- microi-progressive:chunk id=playwright-e2e-015 sha256=9b937381fb4cda1a8a010c5a0f803d48861c9dbcf503774a4b1dba4c0d33985a -->
126
- ## playwright.config.js 模板
127
-
128
- ```js
129
- import { defineConfig, devices } from '@playwright/test';
130
-
131
- const port = process.env.PW_PORT || '5180';
132
- const baseURL = process.env.PW_BASE_URL || `http://127.0.0.1:${port}`;
133
- const webServerUrl = process.env.PW_WEB_SERVER_URL || baseURL;
134
- const channel = process.env.PW_BROWSER_CHANNEL || undefined;
135
- const executablePath = process.env.PW_CHROMIUM_EXECUTABLE || process.env.PW_BROWSER_EXECUTABLE || undefined;
136
- const defaultCommand = process.env.PW_APP_TYPE === 'uniapp-h5'
137
- ? `npm run dev:h5 -- --host 0.0.0.0 --port ${port}`
138
- : `npm run dev -- --host 0.0.0.0 --port ${port}`;
139
-
140
- export default defineConfig({
141
- testDir: './tests/e2e',
142
- timeout: 60_000,
143
- expect: { timeout: 10_000 },
144
- fullyParallel: false,
145
- retries: process.env.CI ? 2 : 0,
146
- workers: process.env.CI ? 1 : undefined,
147
- reporter: [['list'], ['html', { open: 'never', outputFolder: 'tests/e2e/report' }]],
148
- use: {
149
- baseURL,
150
- ...(executablePath ? { launchOptions: { executablePath } } : {}),
151
- trace: 'retain-on-failure',
152
- screenshot: 'only-on-failure',
153
- video: 'retain-on-failure',
154
- extraHTTPHeaders: {
155
- OsClient: process.env.PW_OS_CLIENT || 'demo'
156
- }
157
- },
158
- webServer: {
159
- command: process.env.PW_WEB_SERVER_COMMAND || defaultCommand,
160
- url: webServerUrl,
161
- reuseExistingServer: true,
162
- timeout: 120_000
163
- },
164
- projects: [
165
- {
166
- name: 'desktop',
167
- use: { ...devices['Desktop Chrome'], ...(channel ? { channel } : {}) }
168
- },
169
- {
170
- name: 'mobile',
171
- use: { ...devices['iPhone 13'], ...(channel ? { channel } : {}) }
172
- }
173
- ]
174
- });
175
- ```
176
-
177
- uni-app H5 如果采用静态产物测试,可以把 `PW_WEB_SERVER_COMMAND` 设置为:
178
-
179
- ```bash
180
- npm run build:h5 && npx --yes http-server dist/build/h5 -p 5180 -s -c-1
181
- ```
182
-
183
- <!-- /microi-progressive:chunk -->
1
+ # playwright-e2e 详细参考 2
2
+
3
+ > 按需读取;本文件由 SKILL.md 的原章节无损拆分。
4
+
5
+ <!-- microi-progressive:chunk id=playwright-e2e-013 sha256=cce51ad8ff52cd1339b5a1ce4986d8167b5cccb77637e8a3d438da9da03b68cd -->
6
+ ## 文字对比度与可读性自动化检查(必做)
7
+
8
+ 凡涉及前端样式、卡片、芯片、按钮、价格区间筛选条、退出登录、徽章、覆盖文字(金色/渐变背景上的小字)、列表副标题、空状态等,**测试与人眼复核都必须执行对比度检查**。典型教训:筛选条文字、幽灵按钮、轻色副标题在近似底色下肉眼几乎不可见,但接口/DOM 断言全部通过——这类对比度问题必须通过自动化审计捕捉。
9
+
10
+ ### 自动化对比度审计
11
+
12
+ 对每个核心页面,遍历可见文本节点,计算前景色与最近不透明背景色的 WCAG 对比度,<4.5:1 直接失败:
13
+
14
+ ```js
15
+ const lowContrast = await page.evaluate(() => {
16
+ const ratio = (fg, bg) => {
17
+ const lum = (c) => {
18
+ const v = c.map(x => x/255).map(x => x <= 0.03928 ? x/12.92 : Math.pow((x+0.055)/1.055, 2.4));
19
+ return 0.2126*v[0] + 0.7152*v[1] + 0.0722*v[2];
20
+ };
21
+ const parse = (s) => (s.match(/\d+(\.\d+)?/g) || []).slice(0,3).map(Number);
22
+ const lf = lum(parse(fg)); const lb = lum(parse(bg));
23
+ return (Math.max(lf,lb)+0.05)/(Math.min(lf,lb)+0.05);
24
+ };
25
+ const findBg = (el) => {
26
+ let cur = el;
27
+ while (cur) {
28
+ const c = getComputedStyle(cur).backgroundColor;
29
+ if (c && c !== 'rgba(0, 0, 0, 0)' && c !== 'transparent') return c;
30
+ cur = cur.parentElement;
31
+ }
32
+ return 'rgb(255,255,255)';
33
+ };
34
+ const issues = [];
35
+ document.querySelectorAll('*').forEach(el => {
36
+ const t = (el.innerText || '').trim();
37
+ if (!t || el.children.length) return;
38
+ const cs = getComputedStyle(el);
39
+ if (cs.visibility === 'hidden' || cs.display === 'none' || parseFloat(cs.opacity) < 0.5) return;
40
+ const fz = parseFloat(cs.fontSize);
41
+ if (fz < 9) return;
42
+ const r = ratio(cs.color, findBg(el));
43
+ if (r < 4.5) issues.push({ text: t.slice(0,40), color: cs.color, bg: findBg(el), ratio: +r.toFixed(2), fontSize: fz });
44
+ });
45
+ return issues;
46
+ });
47
+ expect(lowContrast, '低对比度文字: ' + JSON.stringify(lowContrast.slice(0,5))).toEqual([]);
48
+ ```
49
+
50
+ ### 必须人眼复核(view_image)的页面
51
+
52
+ 完成功能后强制 `fullPage` 截图并 `view_image` 人眼审阅以下页面,截图存入 `tests/e2e/screenshots/`:
53
+
54
+ | 页面 | 路径(以项目实际路由为准) | 重点检查 |
55
+ |------|------|---------|
56
+ | 首页 | `/#/pages/index/index` 等 | 横幅、公告、商品卡价格 |
57
+ | 分类 | `/#/pages/category/...` | tab、商品标题副信息 |
58
+ | 商品详情 | `/#/pages/product/detail?id=...` | 价格、规格、按钮 |
59
+ | 购物车 | `/#/pages/cart/...` | 数量、合计、结算按钮 |
60
+ | 订单列表/详情 | `/#/pages/order/...` | 状态徽章、金额、提交按钮 |
61
+ | 我的 | `/#/pages/mine/...` | **退出登录按钮**、菜单标签、账户信息 |
62
+ | 业务专题页 | 项目自定义路径 | 核心功能区域、状态、可交互元素 |
63
+
64
+ 判定标准:任意小号文字 < 12px 在彩色/渐变背景上,或纯文字按钮在与页面同色调底色上无明显边框/填充——一律视为缺陷,必须修复后再发版。
65
+
66
+ ### 设计禁忌(直接判失败)
67
+
68
+ 1. 幽灵按钮(ghost button)在近似底色上当独立操作按钮使用——必须改成实心按钮或显式覆盖背景填充。
69
+ 2. 中性灰/浅色文字(如 `#999` 等)直接放在与其色调接近的背景上,且字号较小——WCAG 对比度 < 4.5:1 直接判失败。
70
+ 3. 渐变彩色背景上展示透明度较低的小字。
71
+ 4. 与背景色调接近的文字颜色放在同色调底色上——必须加深文字颜色或改变底色。
72
+ 5. 价格区间、状态、筛选这类**导航/筛选元素出现在列表中部作为标题**——必须移到顶部 sticky 工具栏,并与正文形成色彩区隔。
73
+
74
+ <!-- /microi-progressive:chunk -->
75
+ <!-- microi-progressive:chunk id=playwright-e2e-014 sha256=3eea01cf70e67d545fede1724b049ed852da60cf0a4ea0bda6b2e1d6de84400d -->
76
+ ## 安装
77
+
78
+ ```bash
79
+ npm i -D @playwright/test
80
+ npx playwright install chromium
81
+ ```
82
+
83
+ ### 浏览器选择强制顺序
84
+
85
+ 做本地页面级 Playwright 验收时,不能因为 Playwright 官方 Chromium 缓存缺失或下载超时就结束任务。必须按下面顺序自动兜底:
86
+
87
+ 1. 优先读取 `PW_CHROMIUM_EXECUTABLE` / `PW_BROWSER_EXECUTABLE`。
88
+ 2. Windows 优先探测本机 Edge / Chrome:`C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`、`C:/Program Files/Microsoft/Edge/Application/msedge.exe`、`C:/Users/Administrator/AppData/Local/Google/Chrome/Bin/chrome.exe`、`C:/Program Files/Google/Chrome/Application/chrome.exe`、`C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`。
89
+ 3. 再探测工作区本地缓存:`.cache/chromium/**/chrome.exe`、`.tmp/playwright-browsers/**/chrome.exe`。
90
+ 4. 仍没有浏览器时,才从吾码 CDN 下载到 `.tmp/playwright-browsers/`,并设置 `PW_CHROMIUM_EXECUTABLE`。
91
+ 5. 只有系统浏览器、本地缓存和 CDN 下载全部失败时,才允许报告“浏览器不可用”;报告中必须说明已经尝试过哪些路径。
92
+
93
+ 手写一次性脚本必须把浏览器探测逻辑写在 `.tmp/*.mjs` 中,截图和报告也必须输出到 `.tmp/screenshots/` 或 `.tmp/reports/`,不要写到 `Microi.Client/`、`Microi.Server/` 等子项目目录。
94
+
95
+ 国内或内网环境如果下载浏览器困难,可以使用本机 Edge:
96
+
97
+ ```bash
98
+ $env:PW_BROWSER_CHANNEL='msedge'
99
+ npx playwright test
100
+ ```
101
+
102
+ 如果本机没有可用 Edge,或必须使用 Chromium,优先从吾码 CDN 下载浏览器压缩包,不要反复卡在 Playwright 官方下载通道:
103
+
104
+ | 系统 | CDN 地址 |
105
+ |------|----------|
106
+ | Windows x64 | `https://static.itdos.com/openclaw/chromium/chrome-win64-137.0.7151.68.zip` |
107
+ | macOS x64 | `https://static.itdos.com/openclaw/chromium/chrome-mac-x64-137.0.7151.68.zip` |
108
+ | macOS arm64 | `https://static.itdos.com/openclaw/chromium/chrome-mac-arm64-137.0.7151.68.zip` |
109
+
110
+ Windows 示例:
111
+
112
+ ```powershell
113
+ $browserRoot = Join-Path (Resolve-Path '.tmp').Path 'playwright-browsers'
114
+ New-Item -ItemType Directory -Force -Path $browserRoot | Out-Null
115
+ $zipPath = Join-Path $browserRoot 'chrome-win64-137.0.7151.68.zip'
116
+ Invoke-WebRequest 'https://static.itdos.com/openclaw/chromium/chrome-win64-137.0.7151.68.zip' -OutFile $zipPath
117
+ Expand-Archive $zipPath -DestinationPath $browserRoot -Force
118
+ $env:PW_CHROMIUM_EXECUTABLE = (Resolve-Path (Join-Path $browserRoot 'chrome-win64/chrome.exe')).Path
119
+ npx playwright test
120
+ ```
121
+
122
+ 手写 Playwright 脚本时读取 `PW_CHROMIUM_EXECUTABLE` / `PW_BROWSER_EXECUTABLE` 并传给 `chromium.launch({ executablePath })`;Playwright Test 配置中通过 `use.launchOptions.executablePath` 读取该环境变量。只有 CDN、系统浏览器和本地缓存都不可用时,才报告浏览器不可用。
123
+
124
+ <!-- /microi-progressive:chunk -->
125
+ <!-- microi-progressive:chunk id=playwright-e2e-015 sha256=9b937381fb4cda1a8a010c5a0f803d48861c9dbcf503774a4b1dba4c0d33985a -->
126
+ ## playwright.config.js 模板
127
+
128
+ ```js
129
+ import { defineConfig, devices } from '@playwright/test';
130
+
131
+ const port = process.env.PW_PORT || '5180';
132
+ const baseURL = process.env.PW_BASE_URL || `http://127.0.0.1:${port}`;
133
+ const webServerUrl = process.env.PW_WEB_SERVER_URL || baseURL;
134
+ const channel = process.env.PW_BROWSER_CHANNEL || undefined;
135
+ const executablePath = process.env.PW_CHROMIUM_EXECUTABLE || process.env.PW_BROWSER_EXECUTABLE || undefined;
136
+ const defaultCommand = process.env.PW_APP_TYPE === 'uniapp-h5'
137
+ ? `npm run dev:h5 -- --host 0.0.0.0 --port ${port}`
138
+ : `npm run dev -- --host 0.0.0.0 --port ${port}`;
139
+
140
+ export default defineConfig({
141
+ testDir: './tests/e2e',
142
+ timeout: 60_000,
143
+ expect: { timeout: 10_000 },
144
+ fullyParallel: false,
145
+ retries: process.env.CI ? 2 : 0,
146
+ workers: process.env.CI ? 1 : undefined,
147
+ reporter: [['list'], ['html', { open: 'never', outputFolder: 'tests/e2e/report' }]],
148
+ use: {
149
+ baseURL,
150
+ ...(executablePath ? { launchOptions: { executablePath } } : {}),
151
+ trace: 'retain-on-failure',
152
+ screenshot: 'only-on-failure',
153
+ video: 'retain-on-failure',
154
+ extraHTTPHeaders: {
155
+ OsClient: process.env.PW_OS_CLIENT || 'demo'
156
+ }
157
+ },
158
+ webServer: {
159
+ command: process.env.PW_WEB_SERVER_COMMAND || defaultCommand,
160
+ url: webServerUrl,
161
+ reuseExistingServer: true,
162
+ timeout: 120_000
163
+ },
164
+ projects: [
165
+ {
166
+ name: 'desktop',
167
+ use: { ...devices['Desktop Chrome'], ...(channel ? { channel } : {}) }
168
+ },
169
+ {
170
+ name: 'mobile',
171
+ use: { ...devices['iPhone 13'], ...(channel ? { channel } : {}) }
172
+ }
173
+ ]
174
+ });
175
+ ```
176
+
177
+ uni-app H5 如果采用静态产物测试,可以把 `PW_WEB_SERVER_COMMAND` 设置为:
178
+
179
+ ```bash
180
+ npm run build:h5 && npx --yes http-server dist/build/h5 -p 5180 -s -c-1
181
+ ```
182
+
183
+ <!-- /microi-progressive:chunk -->