@microi.net/cli 5.8.5 → 5.8.7
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.
- package/.codebuddy-plugin/marketplace.json +2 -2
- package/.codebuddy-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.workbuddy-plugin/marketplace.json +2 -2
- package/.workbuddy-plugin/plugin.json +1 -1
- package/LICENSE +21 -21
- package/README.md +71 -71
- package/assets/build-meta.json +7 -7
- package/assets/feature-matrix.json +138 -138
- package/assets/logo.svg +4 -4
- package/cordis.patch.yml +1 -1
- package/package.json +1 -1
- package/scripts/mcp-codex-stdio-adapter.js +0 -0
- package/scripts/mcp-server.js +1 -1
- package/scripts/microi-cli.js +66 -65
- package/scripts/microi-codex-broker.js +450 -450
- package/scripts/microi-codex-router.js +618 -618
- package/scripts/microi-skills.meta.json +384 -384
- package/skills/.microi-skills-version.json +2 -2
- package/skills/.progressive-disclosure-manifest.json +21 -21
- package/skills/README.md +287 -287
- package/skills/ai-engine/SKILL.md +269 -265
- package/skills/ai-engine/agents/openai.yaml +4 -4
- package/skills/ai-engine/references/ai-employees.md +48 -48
- package/skills/ai-engine/references/self-hosted-digital-human.md +59 -59
- package/skills/ai-platform-governance/SKILL.md +177 -177
- package/skills/ai-platform-governance/references/progressive-01-/345/212/237/350/203/275/345/274/200/345/205/263.md +190 -190
- package/skills/app-store/SKILL.md +525 -525
- package/skills/app-store/agents/openai.yaml +4 -4
- package/skills/business-blueprint/SKILL.md +193 -193
- package/skills/datasource-engine/SKILL.md +93 -93
- package/skills/datasource-engine/agents/openai.yaml +4 -4
- package/skills/dos-orm/SKILL.md +97 -95
- package/skills/dos-orm/references/api-reference.md +229 -229
- package/skills/email-engine/SKILL.md +81 -81
- package/skills/email-engine/references/v8-email.md +34 -34
- package/skills/job-engine/SKILL.md +176 -176
- package/skills/job-engine/agents/openai.yaml +4 -4
- package/skills/message-notification/SKILL.md +156 -156
- package/skills/message-notification/agents/openai.yaml +5 -5
- package/skills/message-notification/references/contracts.md +102 -102
- package/skills/microi/SKILL.md +14 -14
- package/skills/microi-ai-app-auth.js +652 -652
- package/skills/microi-ai-application/SKILL.md +115 -115
- package/skills/microi-ai-application/agents/openai.yaml +4 -4
- package/skills/microi-ai-application/references/frontend-baseline.md +164 -164
- package/skills/microi-client-frontend/SKILL.md +246 -244
- 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
- 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
- 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
- package/skills/microi-codex/SKILL.md +102 -100
- package/skills/microi-codex-installer/SKILL.md +231 -231
- package/skills/microi-codex-installer/agents/openai.yaml +7 -7
- package/skills/microi-datasource-mapping/SKILL.md +122 -122
- package/skills/microi-db-schema/SKILL.md +175 -175
- package/skills/microi-db-schema/agents/openai.yaml +4 -4
- package/skills/microi-db-schema/references/core-tables.md +695 -695
- package/skills/microi-db-schema/references/form-component-options.md +256 -256
- package/skills/microi-db-schema/references/schema-overview.md +202 -202
- package/skills/microi-db-schema/references/schema.md +646 -646
- package/skills/microi-db-schema/references/table-catalog.md +1599 -1599
- package/skills/microi-deployment/SKILL.md +222 -220
- package/skills/microi-deployment/references/deployment-matrix.md +109 -109
- package/skills/microi-docs-coverage/SKILL.md +133 -133
- package/skills/microi-docs-coverage/references/capability-map.md +91 -91
- package/skills/microi-docs-coverage/scripts/audit-doc-skill-coverage.mjs +894 -894
- package/skills/microi-form-engine/SKILL.md +333 -333
- package/skills/microi-form-engine/references/component-catalog.md +218 -218
- package/skills/microi-form-engine/references/data-source-events.md +124 -124
- package/skills/microi-form-layout/SKILL.md +205 -205
- 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
- package/skills/microi-frontend-sdk/SKILL.md +194 -194
- 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
- package/skills/microi-left-right-layout/SKILL.md +141 -141
- package/skills/microi-microservice/SKILL.md +328 -326
- package/skills/microi-microservice/references/runtime-delivery.md +278 -278
- package/skills/microi-mobile-app-quality/SKILL.md +185 -185
- 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
- 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
- package/skills/microi-solution-quotation/SKILL.md +78 -78
- package/skills/microi-solution-quotation/agents/openai.yaml +4 -4
- package/skills/microi-solution-quotation/scripts/build_solution_quote.py +296 -296
- package/skills/microi-sso/SKILL.md +96 -90
- package/skills/microi-sso/references/acceptance.md +49 -49
- package/skills/microi-sso/references/configuration-and-security.md +53 -53
- package/skills/microi-sso/references/inbound.md +53 -53
- package/skills/microi-sso/references/outbound.md +39 -39
- package/skills/microi-system-delivery/SKILL.md +137 -137
- 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
- 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 +217 -217
- package/skills/microi-ui/SKILL.md +192 -192
- 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
- package/skills/microi-uniapp-frontend/SKILL.md +193 -193
- 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
- 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
- package/skills/microi.v8.js +1921 -1921
- package/skills/module-engine/SKILL.md +255 -255
- package/skills/module-engine/references/module-config.md +204 -204
- package/skills/ocr-engine/SKILL.md +113 -113
- package/skills/ocr-engine/agents/openai.yaml +4 -4
- package/skills/page-engine/SKILL.md +206 -206
- package/skills/page-engine/examples/compact-dashboard.json +1444 -1444
- 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
- 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
- package/skills/performance-testing/SKILL.md +221 -221
- package/skills/playwright-e2e/SKILL.md +196 -196
- 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
- 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
- package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md +221 -221
- package/skills/playwright-e2e/references/progressive-04-ci-/345/273/272/350/256/256.md +115 -115
- package/skills/print-engine/SKILL.md +259 -259
- package/skills/production-readonly-audit/SKILL.md +41 -41
- package/skills/report-engine/SKILL.md +71 -71
- package/skills/report-engine/agents/openai.yaml +4 -4
- package/skills/scripts/optimize-progressive-disclosure.mjs +204 -204
- package/skills/scripts/refresh-progressive-disclosure.mjs +64 -64
- package/skills/scripts/sync-embedded-skills.mjs +46 -46
- package/skills/scripts/validate-progressive-disclosure.mjs +57 -57
- package/skills/search-engine/SKILL.md +75 -75
- package/skills/search-engine/agents/openai.yaml +4 -4
- package/skills/spider-engine/SKILL.md +190 -190
- package/skills/system-observability/SKILL.md +249 -246
- package/skills/system-observability/references/memory-incident-triage.md +77 -77
- package/skills/translate-engine/SKILL.md +140 -140
- package/skills/translate-engine/agents/openai.yaml +4 -4
- package/skills/ui-design/SKILL.md +223 -223
- package/skills/ui-design/assets/pattern-showcase/app.js +54 -54
- package/skills/ui-design/assets/pattern-showcase/index.html +163 -163
- package/skills/ui-design/assets/pattern-showcase/styles.css +311 -311
- package/skills/ui-design/assets/templates/MCI-DESIGN.md +206 -206
- package/skills/ui-design/references/design-pattern-library.md +184 -184
- package/skills/ui-design/references/mci-design-contract.md +163 -163
- package/skills/ui-design/references/motion-and-media.md +78 -78
- package/skills/ui-design/references/product-flow-recipes.md +94 -94
- 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
- package/skills/ui-design/references/progressive-02-/345/255/227/344/275/223.md +164 -164
- 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
- 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
- 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
- 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
- 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
- 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 +142 -142
- package/skills/uniapp-mall-assets/SKILL.md +176 -176
- package/skills/unity-integration/SKILL.md +171 -171
- package/skills/unity-integration/agents/openai.yaml +4 -4
- package/skills/unity-integration/references/ai-app-delivery.md +119 -119
- package/skills/unity-integration/references/sdk-api.md +82 -82
- package/skills/unity-integration/references/toolbox-migration.md +66 -66
- package/skills/unity-integration/references/webgl-hosting.md +57 -57
- package/skills/v8-api-config/SKILL.md +388 -388
- package/skills/v8-cache-pattern/SKILL.md +312 -312
- package/skills/v8-crud-api/SKILL.md +178 -178
- 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
- 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
- package/skills/v8-debugging/SKILL.md +284 -284
- package/skills/v8-explorer-tree/SKILL.md +228 -228
- package/skills/v8-export-import/SKILL.md +219 -219
- 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
- package/skills/v8-export-import/references/progressive-02-powerpoint-/345/257/274/345/207/272.md +202 -202
- 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
- package/skills/v8-file-upload/SKILL.md +284 -284
- 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 +263 -263
- 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 +161 -161
- package/skills/v8-formengine-http/SKILL.md +238 -238
- package/skills/v8-frontend-events/SKILL.md +180 -180
- package/skills/v8-frontend-events/references/bluetooth-print-api.md +135 -135
- package/skills/v8-frontend-events/references/bluetooth-print.md +258 -258
- package/skills/v8-frontend-events/references/progressive-01-/345/210/227/350/241/250/344/272/213/344/273/266.md +219 -219
- package/skills/v8-http-integration/SKILL.md +182 -182
- package/skills/v8-http-integration/references/progressive-01-get-/350/257/267/346/261/202.md +220 -220
- 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
- package/skills/v8-image-processing/SKILL.md +190 -190
- package/skills/v8-image-processing/agents/openai.yaml +4 -4
- package/skills/v8-image-processing/references/api-reference.md +623 -623
- package/skills/v8-menu-buttons/SKILL.md +186 -186
- 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
- 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
- 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
- package/skills/v8-mongodb/SKILL.md +200 -200
- package/skills/v8-mq-mqtt/SKILL.md +176 -176
- package/skills/v8-mq-mqtt/references/mqtt-production.md +342 -342
- package/skills/v8-mq-mqtt/references/progressive-01-v8-mqtt-iot-/347/211/251/350/201/224/347/275/221.md +181 -181
- package/skills/v8-mq-mqtt/scripts/check-mqtt-skill-coverage.mjs +203 -203
- package/skills/v8-saas-multi-tenant/SKILL.md +305 -305
- package/skills/v8-security/SKILL.md +210 -210
- package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +200 -200
- package/skills/v8-security/references/progressive-02-7-/346/227/245/345/277/227/350/256/260/345/275/225.md +160 -160
- package/skills/v8-sql-query/SKILL.md +302 -302
- package/skills/v8-table-event/SKILL.md +176 -176
- 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 +216 -216
- 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
- package/skills/v8-tcp-integration/SKILL.md +147 -147
- package/skills/v8-tcp-integration/agents/openai.yaml +4 -4
- package/skills/v8-template-engine/SKILL.md +167 -167
- package/skills/v8-utilities/SKILL.md +104 -104
- package/skills/v8-utilities/references/client-api-index.md +143 -143
- package/skills/v8-utilities/references/platform-http-routes.md +83 -83
- package/skills/v8-utilities/references/server-api-index.md +188 -188
- package/skills/v8-workflow/SKILL.md +252 -252
- 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
- package/skills/v8-workflow/references/workflow-configuration.md +49 -49
- package/skills/vision-engine/SKILL.md +160 -160
- package/skills/vision-engine/agents/openai.yaml +4 -4
- package/skills/vision-engine/references/architecture-and-acceptance.md +194 -194
- package/skills/workspace-conventions/SKILL.md +273 -273
- 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 +209 -209
- 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 +217 -217
- 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
package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md
CHANGED
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
# playwright-e2e 详细参考 3
|
|
2
|
-
|
|
3
|
-
> 按需读取;本文件由 SKILL.md 的原章节无损拆分。
|
|
4
|
-
|
|
5
|
-
<!-- microi-progressive:chunk id=playwright-e2e-016 sha256=49c59ee833b3ac8ad96d0ff5876b47459e2a26c7a6d233ff08abf082d43076dd -->
|
|
6
|
-
## Microi helper 模板
|
|
7
|
-
|
|
8
|
-
```js
|
|
9
|
-
// tests/e2e/helpers/microi.js
|
|
10
|
-
import { expect } from '@playwright/test';
|
|
11
|
-
|
|
12
|
-
export const microiEnv = {
|
|
13
|
-
apiBase: process.env.PW_API_BASE || 'https://api.example.com',
|
|
14
|
-
osClient: process.env.PW_OS_CLIENT || 'demo',
|
|
15
|
-
loginEngine: process.env.PW_LOGIN_ENGINE || 'member_login'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// 仅用于需要在 URL 中显式携带租户的普通 GET;POST 不调用此函数。
|
|
19
|
-
export function withOsClientQuery(url) {
|
|
20
|
-
const sep = url.includes('?') ? '&' : '?';
|
|
21
|
-
return `${url}${sep}OsClient=${encodeURIComponent(microiEnv.osClient)}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function callEngine(request, apiEngineKey, data = {}, token = '') {
|
|
25
|
-
const res = await request.post(`${microiEnv.apiBase}/apiengine/${apiEngineKey}`, {
|
|
26
|
-
headers: {
|
|
27
|
-
'Content-Type': 'application/json',
|
|
28
|
-
apiengine: '1',
|
|
29
|
-
osclient: microiEnv.osClient,
|
|
30
|
-
...(token ? { Token: token } : {})
|
|
31
|
-
},
|
|
32
|
-
data: { ...data, OsClient: data.OsClient || microiEnv.osClient }
|
|
33
|
-
});
|
|
34
|
-
expect(res.ok(), `${apiEngineKey} HTTP status`).toBeTruthy();
|
|
35
|
-
const json = await res.json();
|
|
36
|
-
return json;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function loginByEngine(request, account, password) {
|
|
40
|
-
const json = await callEngine(request, microiEnv.loginEngine, {
|
|
41
|
-
Account: account,
|
|
42
|
-
Phone: account,
|
|
43
|
-
Pwd: password,
|
|
44
|
-
Password: password
|
|
45
|
-
});
|
|
46
|
-
expect(json.Code, json.Msg || 'login Code').toBe(1);
|
|
47
|
-
const data = json.Data || {};
|
|
48
|
-
const token = data.Token || data.token || data.AccessToken || '';
|
|
49
|
-
expect(token, 'login token').toBeTruthy();
|
|
50
|
-
return { token, data };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function injectStorage(page, values) {
|
|
54
|
-
await page.addInitScript((storageValues) => {
|
|
55
|
-
for (const [key, value] of Object.entries(storageValues)) {
|
|
56
|
-
localStorage.setItem(key, typeof value === 'string' ? value : JSON.stringify(value));
|
|
57
|
-
}
|
|
58
|
-
}, values);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function injectH5Storage(page, token, member = null) {
|
|
62
|
-
return injectStorage(page, {
|
|
63
|
-
mall_token: token,
|
|
64
|
-
mall_member: member || {}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function assertDosResultShape(json, label = 'DosResult') {
|
|
69
|
-
expect(json, label).toBeTruthy();
|
|
70
|
-
expect(json, label).toHaveProperty('Code');
|
|
71
|
-
expect(typeof json.Code, `${label}.Code type`).toBe('number');
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
<!-- /microi-progressive:chunk -->
|
|
76
|
-
<!-- microi-progressive:chunk id=playwright-e2e-017 sha256=d837b942878764ad94bedb09869dd50b627660d86a848043984de2f05f0e071b -->
|
|
77
|
-
## 典型用例
|
|
78
|
-
|
|
79
|
-
```js
|
|
80
|
-
import { test, expect } from '@playwright/test';
|
|
81
|
-
import { callEngine, loginByEngine, injectH5Storage } from '../helpers/microi.js';
|
|
82
|
-
|
|
83
|
-
test('公开首页能打开', async ({ page }) => {
|
|
84
|
-
await page.goto(process.env.PW_HOME_PATH || '/');
|
|
85
|
-
await expect(page.locator('body')).toBeVisible();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('登录接口能拿到 Token 并进入首页', async ({ page, request }) => {
|
|
89
|
-
const { token, data } = await loginByEngine(
|
|
90
|
-
request,
|
|
91
|
-
process.env.PW_TEST_ACCOUNT || 'admin',
|
|
92
|
-
process.env.PW_TEST_PASSWORD || '123456'
|
|
93
|
-
);
|
|
94
|
-
await injectH5Storage(page, token, data.Member);
|
|
95
|
-
await page.goto(process.env.PW_HOME_PATH || '/');
|
|
96
|
-
await expect(page.locator('body')).toBeVisible();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('公开接口引擎返回标准 DosResult', async ({ request }) => {
|
|
100
|
-
const json = await callEngine(request, process.env.PW_SMOKE_ENGINE || 'home_data', {});
|
|
101
|
-
expect(json).toHaveProperty('Code');
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
<!-- /microi-progressive:chunk -->
|
|
106
|
-
<!-- microi-progressive:chunk id=playwright-e2e-018 sha256=90e55b07d1e2a71dbd9f8e82a07e361fd5ec5269753c7d193e55216eddbbc834 -->
|
|
107
|
-
## Microi 专属测试策略
|
|
108
|
-
|
|
109
|
-
1. 先用 MCP `microi_get_playwright_context` 获取当前租户的菜单路由、接口引擎、匿名状态。
|
|
110
|
-
2. 公开页面只测“能打开、关键区域可见、无横向溢出、无白屏”。
|
|
111
|
-
3. 登录态优先用接口引擎登录,再注入 `localStorage` 或 Cookie,不要在每个用例里重复点登录表单。
|
|
112
|
-
4. 业务主线只覆盖客户真正验收的动作:列表、详情、提交、状态变化、余额/库存/积分变动。
|
|
113
|
-
5. 接口引擎断言必须检查 `HTTP ok`、`Code`、`Msg` 和关键 `Data` 字段。
|
|
114
|
-
6. 涉及写库的用例必须使用专用测试账号和可重复数据,避免污染生产数据。
|
|
115
|
-
7. 截图只用于关键节点和失败场景;不要让截图成为唯一断言。
|
|
116
|
-
8. **每条业务主线 spec 必须有"图片回归检查"步骤**:在涉及商品列表、商品详情、提货卡、海报、头像、Banner 的页面,必须 `await page.screenshot({ path: 'tests/e2e/screenshots/<spec>.png', fullPage: true })`,并在测试报告生成后用 `view_image` 工具肉眼复核截图,确认:
|
|
117
|
-
- 没有出现纯渐变/首字母占位/空白图位(这通常意味着 `sanitizeAssetUrl` 等前缀工具被遗漏,或图片字段拿到了相对路径)
|
|
118
|
-
- 商品/卡片图都真实显示
|
|
119
|
-
- 价格、卖家、卡号等文案不出错位
|
|
120
|
-
- 同步参见 [microi-uniapp-frontend](../microi-uniapp-frontend/SKILL.md) 中的资源 URL 与 FileServer 前缀规范。
|
|
121
|
-
9. 用 `page.on('response', r => { if (r.url().includes('/file/') && !r.ok()) failedAssets.push(r.url()); })` 监听全部资源请求,断言 `failedAssets.length === 0`,能在断言前就抓到 404 图片。
|
|
122
|
-
|
|
123
|
-
<!-- /microi-progressive:chunk -->
|
|
124
|
-
<!-- microi-progressive:chunk id=playwright-e2e-019 sha256=76dce4264c93b7ab5be25f42dcbda55cd1f08afd2f5811998f81d9c4d26e0377 -->
|
|
125
|
-
## 最少冒烟集
|
|
126
|
-
|
|
127
|
-
任何 Microi 业务系统建议至少覆盖:
|
|
128
|
-
|
|
129
|
-
1. 公开首页或登录页能打开。
|
|
130
|
-
2. 登录接口返回非空响应,且不出现数据库连接或权限错误。
|
|
131
|
-
3. 登录态能进入首页或工作台。
|
|
132
|
-
4. 一条主业务路径能跑通。
|
|
133
|
-
5. 底部 Tab、菜单或核心导航都能加载。
|
|
134
|
-
6. 退出登录能清理 Token 并回到登录页。
|
|
135
|
-
|
|
136
|
-
<!-- /microi-progressive:chunk -->
|
|
137
|
-
<!-- microi-progressive:chunk id=playwright-e2e-020 sha256=a267a39f5fe3dab714c5275759f7bdd1b6150990fa00555e07c091aee5795a29 -->
|
|
138
|
-
## 完整业务验收门槛
|
|
139
|
-
|
|
140
|
-
当用户要求“完整测试”“全面测试”“不要让我手工测出接口 null/404/权限漏洞”时,不能只生成浅冒烟。至少补齐以下测试文件:
|
|
141
|
-
|
|
142
|
-
```text
|
|
143
|
-
tests/e2e/
|
|
144
|
-
helpers/microi.js
|
|
145
|
-
smoke.spec.js # 首屏、导航、图片、布局
|
|
146
|
-
api-contract.spec.js # 所有接口引擎契约:HTTP ok、非 null、合法 JSON、DosResult.Code
|
|
147
|
-
network.spec.js # 页面运行期拦截 404/5xx、空响应、字符串 null、意外 Code=0
|
|
148
|
-
auth.spec.js # 未登录/登录/过期 Token/退出登录
|
|
149
|
-
business-flow.spec.js # 至少一条真实写操作闭环,写后再查后端状态
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
必备断言:
|
|
153
|
-
|
|
154
|
-
1. API 响应不能是空 body、字符串 `null`、非 JSON,除明确允许外不能返回 `Code=0`。
|
|
155
|
-
2. 公开接口必须可匿名调用;受保护接口未登录必须返回 `Code=1001/1002` 或跳转登录。
|
|
156
|
-
3. 写操作必须做“前置清理 → 执行动作 → 后端查询确认 → 用例清理”。
|
|
157
|
-
4. UI 点击不能只断言 toast;必须用 `page.waitForResponse()` 捕捉对应接口,并验证响应体。
|
|
158
|
-
5. 任何 FormEngine HTTP 路由必须使用 `/api/formengine/{action}-{table}`,不要生成 `/formengine/{table}/{action}`。
|
|
159
|
-
6. ApiEngine 使用稳定路径 `/apiengine/{ApiEngineKey}`,并通过唯一的 `osclient` Header 传租户;JSON/Form Body 可冗余携带 `OsClient`。普通 POST/PUT/PATCH/DELETE 禁止追加 `--OsClient--...--`。仅第三方回调或无法设置 Header/Form/Query 的 GET/HEAD 才允许特殊路径。
|
|
160
|
-
7. 页面级测试必须把 `请求失败`、`网络错误`、`null`、`待开发`、`开发中` 当成失败信号;这些文案如果出现在页面或 toast 中,说明功能未交付或接口契约错误。
|
|
161
|
-
8. 新增、保存、结算、转赠、确认、上传等按钮不能只弹“成功/待开发”toast;必须调用真实业务接口,并通过后端查询验证状态变化。
|
|
162
|
-
9. 源码守卫可作为兜底:递归扫描 `src/**/*.vue`、`src/**/*.js`,禁止残留 `待开发|开发中` 占位文案。
|
|
163
|
-
10. 新建或更新 ApiEngine 后必须用 HTTP 路径复测一次;只用 `microi_run_engine` 通过不够,因为 HTTP 调用还受 `IsEnable`、`StopHttp`、`AllowAnonymous` 和动态路由缓存影响。
|
|
164
|
-
11. 每个移动端项目都要有“接口清单驱动”的契约测试:静态扫描或维护清单覆盖所有 `callEngine('xxx')`,逐个 HTTP 调用并断言不是 404、不是空响应、不是字符串 `null`,且必须是标准 DosResult。
|
|
165
|
-
12. 写业务闭环时必须准备可重复测试数据并清理:例如抢购要“创建测试挂单 → 调用抢购 → 验证订单 → 删除测试订单/挂单/提货卡”,购物车要“加入购物车 → 结算 → 验证订单/购物车状态 → 删除测试订单”。
|
|
166
|
-
13. 图片断言必须检查真实渲染,而不是只检查元素可见。uni-app H5 的 `<image>` 会渲染成 `UNI-IMAGE`,真实图片在内部 `div.style.backgroundImage` 或子 `img` 上;不要把宿主元素的 CSS 渐变背景算作加载成功。
|
|
167
|
-
14. 网络守卫要记录 `requestfailed`,特别是图片资源的 `net::ERR_BLOCKED_BY_ORB` / CORS / 404;首页 banner、商品主图、头像等公开图片必须实际加载。
|
|
168
|
-
15. 页面出现浏览器原生 `alert`、`confirm` 或 `prompt` 直接判失败;测试应监听 `page.on('dialog')` 记录类型和文案后关闭对话框,再要求业务改用吾码 Tips、Element Plus 或品牌化可访问弹层。长弹窗需分别滚动到顶部、中部、底部触发反馈,并断言提示/确认层的 bounding box 中心接近当前 viewport 中心且未被遮挡。
|
|
169
|
-
|
|
170
|
-
移动商城/会员 H5 额外规则:
|
|
171
|
-
|
|
172
|
-
- 商城会员 Token 来自业务接口引擎(如 `mall_member_login` 或项目自定义登录引擎),不是平台 `Sys_User` Token。
|
|
173
|
-
- 移动端会员数据查询不要直连平台 FormEngine;使用租户 ApiEngine 或安全查询代理。
|
|
174
|
-
- 商品详情“加入购物车”必须登录;登录后必须写服务端购物车,再进入购物车页验证同一商品可见。
|
|
175
|
-
- 购物车、订单、资产、团队、提货、地址、收款方式等会员数据都必须按会员 Id 做后端范围过滤。
|
|
176
|
-
- 涉及多种支付/货币类型的项目(如提货卡、积分、余额等),每种支付渠道必须独立测试,不能混用或互通;项目自定义的费率、规则参数应在各自项目的测试文件中维护。
|
|
177
|
-
- 库存/商品相关接口(如库存转让、抜购窗口)必须返回标准 DosResult,禁止返回 JS `null`;成功路径必须返回订单 Id 或结果数据。
|
|
178
|
-
- 购物车“结算”必须调用业务结算接口,不能残留“功能开发中”占位文案;真实闭环:加入购物车 → 结算 → 断言 Code=1 和订单 Id → 确认购物车已清对应商品。
|
|
179
|
-
- 首页运营 banner 推荐从公告或配置表驱动;E2E 要同时断言接口返回、图片真实加载、点击进入详情页。
|
|
180
|
-
- 涉及多种支付/货币类型的项目(如提货卡、积分、余额等),每种支付渠道必须独立测试,不能混用或互通;项目自定义的费率、规则参数应在各自项目的测试文件中维护。
|
|
181
|
-
- 库存/商品相关接口(如库存转让、抢购窗口)必须返回标准 DosResult,禁止返回 JS `null`;成功路径必须返回订单 Id 或结果数据。
|
|
182
|
-
- 购物车`结算`必须调用业务结算接口,不能残留`功能开发中`占位文案;真实闭环:加入购物车 → 结算 → 断言 Code=1 和订单 Id → 确认购物车已清对应商品。
|
|
183
|
-
- 首页运营 banner 推荐从公告或配置表驱动;E2E 要同时断言接口返回、图片真实加载、点击进入详情页。
|
|
184
|
-
|
|
185
|
-
<!-- /microi-progressive:chunk -->
|
|
186
|
-
<!-- microi-progressive:chunk id=playwright-e2e-021 sha256=3a2ad9d446d5169735e0cedfc0bec84d8a4ba5c23cd0401190bf23708d344dce -->
|
|
187
|
-
## 与 MCP 的配合
|
|
188
|
-
|
|
189
|
-
- `microi_get_db_schema`:写测试前确认表和字段。
|
|
190
|
-
- `microi_get_playwright_context`:获取可测菜单 URL、接口引擎、匿名配置。
|
|
191
|
-
- `microi_plan_playwright_e2e`:生成推荐的测试文件、环境变量和冒烟路径。
|
|
192
|
-
- `microi_run_engine`:调试单个接口引擎,不替代浏览器 E2E。
|
|
193
|
-
- `microi_set_engine_anonymous`:登录、注册、公开首页接口需要匿名访问时使用;设置后仍要验证 HTTP `/apiengine/{key}` + `osclient` Header 返回标准 DosResult。
|
|
194
|
-
|
|
195
|
-
<!-- /microi-progressive:chunk -->
|
|
196
|
-
<!-- microi-progressive:chunk id=playwright-e2e-022 sha256=4c8a62a896b5f1f97ea41bcd3afdb0dc3c3609ead6c92283dcfa703c09311b42 -->
|
|
197
|
-
## 与 VS Code 插件的配合
|
|
198
|
-
|
|
199
|
-
### Microi VS Code 插件
|
|
200
|
-
|
|
201
|
-
Microi VS Code 插件应提供三类能力:
|
|
202
|
-
|
|
203
|
-
- 初始化:创建 `playwright.config.js`、`tests/e2e/helpers/microi.js`、示例 `smoke.spec.js`、`.env.e2e.example`,并补齐 `package.json` 脚本。
|
|
204
|
-
- 运行:在当前前端项目目录执行 `npm run test:e2e`,并提供打开报告入口。
|
|
205
|
-
- 上下文:从后端 `GetPlaywrightContext` 拉取当前租户可测路由和接口引擎,写入 `tests/e2e/.microi-playwright-context.json`,供 AI 生成用例时参考。
|
|
206
|
-
|
|
207
|
-
### Playwright Test for VSCode(官方插件)
|
|
208
|
-
|
|
209
|
-
官方插件 `Playwright Test for VSCode` 与 Microi Playwright 规范不冲突。它只是同一套 `@playwright/test` 的 VS Code 测试视图/调试入口,读取项目里的 `playwright.config.js`、`testDir`、`projects`、`webServer`、`use` 配置;CLI 的 `npx playwright test` 与插件按钮运行的是同一批 spec。
|
|
210
|
-
|
|
211
|
-
推荐共用方式:
|
|
212
|
-
|
|
213
|
-
1. 项目内保留 `playwright.config.js` 作为唯一配置源,不为插件单独复制一份配置。
|
|
214
|
-
2. `webServer.reuseExistingServer: true`,这样插件运行时如果 H5 静态服务已启动就复用,否则按配置启动。
|
|
215
|
-
3. 本地 H5 先执行 `npm run build:h5:local`;插件再运行 `tests/e2e/*.spec.js` 时会服务 `dist/build/h5`。
|
|
216
|
-
4. Windows 本机推荐 `PW_BROWSER_CHANNEL=msedge` 或在配置中默认 `channel: 'msedge'`,避免每台机器重复下载 Chromium。
|
|
217
|
-
5. 需要自定义 `PW_API_BASE/PW_API_ENV/PW_PORT/PW_OS_CLIENT` 时,优先写入 `playwright.config.js` 的默认值或 VS Code 插件环境变量设置;CI 和一次性运行再用终端环境变量覆盖。
|
|
218
|
-
6. 插件适合单个用例调试、断点、Trace 查看;最终交付仍要跑 CLI 全量命令并查看 `tests/e2e/report`。
|
|
219
|
-
7. 插件截图/trace 与 CLI 使用同一目录;视觉回归仍必须 `view_image` 人眼复核关键 fullPage 截图。
|
|
220
|
-
|
|
221
|
-
<!-- /microi-progressive:chunk -->
|
|
1
|
+
# playwright-e2e 详细参考 3
|
|
2
|
+
|
|
3
|
+
> 按需读取;本文件由 SKILL.md 的原章节无损拆分。
|
|
4
|
+
|
|
5
|
+
<!-- microi-progressive:chunk id=playwright-e2e-016 sha256=49c59ee833b3ac8ad96d0ff5876b47459e2a26c7a6d233ff08abf082d43076dd -->
|
|
6
|
+
## Microi helper 模板
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
// tests/e2e/helpers/microi.js
|
|
10
|
+
import { expect } from '@playwright/test';
|
|
11
|
+
|
|
12
|
+
export const microiEnv = {
|
|
13
|
+
apiBase: process.env.PW_API_BASE || 'https://api.example.com',
|
|
14
|
+
osClient: process.env.PW_OS_CLIENT || 'demo',
|
|
15
|
+
loginEngine: process.env.PW_LOGIN_ENGINE || 'member_login'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 仅用于需要在 URL 中显式携带租户的普通 GET;POST 不调用此函数。
|
|
19
|
+
export function withOsClientQuery(url) {
|
|
20
|
+
const sep = url.includes('?') ? '&' : '?';
|
|
21
|
+
return `${url}${sep}OsClient=${encodeURIComponent(microiEnv.osClient)}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function callEngine(request, apiEngineKey, data = {}, token = '') {
|
|
25
|
+
const res = await request.post(`${microiEnv.apiBase}/apiengine/${apiEngineKey}`, {
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
apiengine: '1',
|
|
29
|
+
osclient: microiEnv.osClient,
|
|
30
|
+
...(token ? { Token: token } : {})
|
|
31
|
+
},
|
|
32
|
+
data: { ...data, OsClient: data.OsClient || microiEnv.osClient }
|
|
33
|
+
});
|
|
34
|
+
expect(res.ok(), `${apiEngineKey} HTTP status`).toBeTruthy();
|
|
35
|
+
const json = await res.json();
|
|
36
|
+
return json;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function loginByEngine(request, account, password) {
|
|
40
|
+
const json = await callEngine(request, microiEnv.loginEngine, {
|
|
41
|
+
Account: account,
|
|
42
|
+
Phone: account,
|
|
43
|
+
Pwd: password,
|
|
44
|
+
Password: password
|
|
45
|
+
});
|
|
46
|
+
expect(json.Code, json.Msg || 'login Code').toBe(1);
|
|
47
|
+
const data = json.Data || {};
|
|
48
|
+
const token = data.Token || data.token || data.AccessToken || '';
|
|
49
|
+
expect(token, 'login token').toBeTruthy();
|
|
50
|
+
return { token, data };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function injectStorage(page, values) {
|
|
54
|
+
await page.addInitScript((storageValues) => {
|
|
55
|
+
for (const [key, value] of Object.entries(storageValues)) {
|
|
56
|
+
localStorage.setItem(key, typeof value === 'string' ? value : JSON.stringify(value));
|
|
57
|
+
}
|
|
58
|
+
}, values);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function injectH5Storage(page, token, member = null) {
|
|
62
|
+
return injectStorage(page, {
|
|
63
|
+
mall_token: token,
|
|
64
|
+
mall_member: member || {}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function assertDosResultShape(json, label = 'DosResult') {
|
|
69
|
+
expect(json, label).toBeTruthy();
|
|
70
|
+
expect(json, label).toHaveProperty('Code');
|
|
71
|
+
expect(typeof json.Code, `${label}.Code type`).toBe('number');
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<!-- /microi-progressive:chunk -->
|
|
76
|
+
<!-- microi-progressive:chunk id=playwright-e2e-017 sha256=d837b942878764ad94bedb09869dd50b627660d86a848043984de2f05f0e071b -->
|
|
77
|
+
## 典型用例
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { test, expect } from '@playwright/test';
|
|
81
|
+
import { callEngine, loginByEngine, injectH5Storage } from '../helpers/microi.js';
|
|
82
|
+
|
|
83
|
+
test('公开首页能打开', async ({ page }) => {
|
|
84
|
+
await page.goto(process.env.PW_HOME_PATH || '/');
|
|
85
|
+
await expect(page.locator('body')).toBeVisible();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('登录接口能拿到 Token 并进入首页', async ({ page, request }) => {
|
|
89
|
+
const { token, data } = await loginByEngine(
|
|
90
|
+
request,
|
|
91
|
+
process.env.PW_TEST_ACCOUNT || 'admin',
|
|
92
|
+
process.env.PW_TEST_PASSWORD || '123456'
|
|
93
|
+
);
|
|
94
|
+
await injectH5Storage(page, token, data.Member);
|
|
95
|
+
await page.goto(process.env.PW_HOME_PATH || '/');
|
|
96
|
+
await expect(page.locator('body')).toBeVisible();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('公开接口引擎返回标准 DosResult', async ({ request }) => {
|
|
100
|
+
const json = await callEngine(request, process.env.PW_SMOKE_ENGINE || 'home_data', {});
|
|
101
|
+
expect(json).toHaveProperty('Code');
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
<!-- /microi-progressive:chunk -->
|
|
106
|
+
<!-- microi-progressive:chunk id=playwright-e2e-018 sha256=90e55b07d1e2a71dbd9f8e82a07e361fd5ec5269753c7d193e55216eddbbc834 -->
|
|
107
|
+
## Microi 专属测试策略
|
|
108
|
+
|
|
109
|
+
1. 先用 MCP `microi_get_playwright_context` 获取当前租户的菜单路由、接口引擎、匿名状态。
|
|
110
|
+
2. 公开页面只测“能打开、关键区域可见、无横向溢出、无白屏”。
|
|
111
|
+
3. 登录态优先用接口引擎登录,再注入 `localStorage` 或 Cookie,不要在每个用例里重复点登录表单。
|
|
112
|
+
4. 业务主线只覆盖客户真正验收的动作:列表、详情、提交、状态变化、余额/库存/积分变动。
|
|
113
|
+
5. 接口引擎断言必须检查 `HTTP ok`、`Code`、`Msg` 和关键 `Data` 字段。
|
|
114
|
+
6. 涉及写库的用例必须使用专用测试账号和可重复数据,避免污染生产数据。
|
|
115
|
+
7. 截图只用于关键节点和失败场景;不要让截图成为唯一断言。
|
|
116
|
+
8. **每条业务主线 spec 必须有"图片回归检查"步骤**:在涉及商品列表、商品详情、提货卡、海报、头像、Banner 的页面,必须 `await page.screenshot({ path: 'tests/e2e/screenshots/<spec>.png', fullPage: true })`,并在测试报告生成后用 `view_image` 工具肉眼复核截图,确认:
|
|
117
|
+
- 没有出现纯渐变/首字母占位/空白图位(这通常意味着 `sanitizeAssetUrl` 等前缀工具被遗漏,或图片字段拿到了相对路径)
|
|
118
|
+
- 商品/卡片图都真实显示
|
|
119
|
+
- 价格、卖家、卡号等文案不出错位
|
|
120
|
+
- 同步参见 [microi-uniapp-frontend](../microi-uniapp-frontend/SKILL.md) 中的资源 URL 与 FileServer 前缀规范。
|
|
121
|
+
9. 用 `page.on('response', r => { if (r.url().includes('/file/') && !r.ok()) failedAssets.push(r.url()); })` 监听全部资源请求,断言 `failedAssets.length === 0`,能在断言前就抓到 404 图片。
|
|
122
|
+
|
|
123
|
+
<!-- /microi-progressive:chunk -->
|
|
124
|
+
<!-- microi-progressive:chunk id=playwright-e2e-019 sha256=76dce4264c93b7ab5be25f42dcbda55cd1f08afd2f5811998f81d9c4d26e0377 -->
|
|
125
|
+
## 最少冒烟集
|
|
126
|
+
|
|
127
|
+
任何 Microi 业务系统建议至少覆盖:
|
|
128
|
+
|
|
129
|
+
1. 公开首页或登录页能打开。
|
|
130
|
+
2. 登录接口返回非空响应,且不出现数据库连接或权限错误。
|
|
131
|
+
3. 登录态能进入首页或工作台。
|
|
132
|
+
4. 一条主业务路径能跑通。
|
|
133
|
+
5. 底部 Tab、菜单或核心导航都能加载。
|
|
134
|
+
6. 退出登录能清理 Token 并回到登录页。
|
|
135
|
+
|
|
136
|
+
<!-- /microi-progressive:chunk -->
|
|
137
|
+
<!-- microi-progressive:chunk id=playwright-e2e-020 sha256=a267a39f5fe3dab714c5275759f7bdd1b6150990fa00555e07c091aee5795a29 -->
|
|
138
|
+
## 完整业务验收门槛
|
|
139
|
+
|
|
140
|
+
当用户要求“完整测试”“全面测试”“不要让我手工测出接口 null/404/权限漏洞”时,不能只生成浅冒烟。至少补齐以下测试文件:
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
tests/e2e/
|
|
144
|
+
helpers/microi.js
|
|
145
|
+
smoke.spec.js # 首屏、导航、图片、布局
|
|
146
|
+
api-contract.spec.js # 所有接口引擎契约:HTTP ok、非 null、合法 JSON、DosResult.Code
|
|
147
|
+
network.spec.js # 页面运行期拦截 404/5xx、空响应、字符串 null、意外 Code=0
|
|
148
|
+
auth.spec.js # 未登录/登录/过期 Token/退出登录
|
|
149
|
+
business-flow.spec.js # 至少一条真实写操作闭环,写后再查后端状态
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
必备断言:
|
|
153
|
+
|
|
154
|
+
1. API 响应不能是空 body、字符串 `null`、非 JSON,除明确允许外不能返回 `Code=0`。
|
|
155
|
+
2. 公开接口必须可匿名调用;受保护接口未登录必须返回 `Code=1001/1002` 或跳转登录。
|
|
156
|
+
3. 写操作必须做“前置清理 → 执行动作 → 后端查询确认 → 用例清理”。
|
|
157
|
+
4. UI 点击不能只断言 toast;必须用 `page.waitForResponse()` 捕捉对应接口,并验证响应体。
|
|
158
|
+
5. 任何 FormEngine HTTP 路由必须使用 `/api/formengine/{action}-{table}`,不要生成 `/formengine/{table}/{action}`。
|
|
159
|
+
6. ApiEngine 使用稳定路径 `/apiengine/{ApiEngineKey}`,并通过唯一的 `osclient` Header 传租户;JSON/Form Body 可冗余携带 `OsClient`。普通 POST/PUT/PATCH/DELETE 禁止追加 `--OsClient--...--`。仅第三方回调或无法设置 Header/Form/Query 的 GET/HEAD 才允许特殊路径。
|
|
160
|
+
7. 页面级测试必须把 `请求失败`、`网络错误`、`null`、`待开发`、`开发中` 当成失败信号;这些文案如果出现在页面或 toast 中,说明功能未交付或接口契约错误。
|
|
161
|
+
8. 新增、保存、结算、转赠、确认、上传等按钮不能只弹“成功/待开发”toast;必须调用真实业务接口,并通过后端查询验证状态变化。
|
|
162
|
+
9. 源码守卫可作为兜底:递归扫描 `src/**/*.vue`、`src/**/*.js`,禁止残留 `待开发|开发中` 占位文案。
|
|
163
|
+
10. 新建或更新 ApiEngine 后必须用 HTTP 路径复测一次;只用 `microi_run_engine` 通过不够,因为 HTTP 调用还受 `IsEnable`、`StopHttp`、`AllowAnonymous` 和动态路由缓存影响。
|
|
164
|
+
11. 每个移动端项目都要有“接口清单驱动”的契约测试:静态扫描或维护清单覆盖所有 `callEngine('xxx')`,逐个 HTTP 调用并断言不是 404、不是空响应、不是字符串 `null`,且必须是标准 DosResult。
|
|
165
|
+
12. 写业务闭环时必须准备可重复测试数据并清理:例如抢购要“创建测试挂单 → 调用抢购 → 验证订单 → 删除测试订单/挂单/提货卡”,购物车要“加入购物车 → 结算 → 验证订单/购物车状态 → 删除测试订单”。
|
|
166
|
+
13. 图片断言必须检查真实渲染,而不是只检查元素可见。uni-app H5 的 `<image>` 会渲染成 `UNI-IMAGE`,真实图片在内部 `div.style.backgroundImage` 或子 `img` 上;不要把宿主元素的 CSS 渐变背景算作加载成功。
|
|
167
|
+
14. 网络守卫要记录 `requestfailed`,特别是图片资源的 `net::ERR_BLOCKED_BY_ORB` / CORS / 404;首页 banner、商品主图、头像等公开图片必须实际加载。
|
|
168
|
+
15. 页面出现浏览器原生 `alert`、`confirm` 或 `prompt` 直接判失败;测试应监听 `page.on('dialog')` 记录类型和文案后关闭对话框,再要求业务改用吾码 Tips、Element Plus 或品牌化可访问弹层。长弹窗需分别滚动到顶部、中部、底部触发反馈,并断言提示/确认层的 bounding box 中心接近当前 viewport 中心且未被遮挡。
|
|
169
|
+
|
|
170
|
+
移动商城/会员 H5 额外规则:
|
|
171
|
+
|
|
172
|
+
- 商城会员 Token 来自业务接口引擎(如 `mall_member_login` 或项目自定义登录引擎),不是平台 `Sys_User` Token。
|
|
173
|
+
- 移动端会员数据查询不要直连平台 FormEngine;使用租户 ApiEngine 或安全查询代理。
|
|
174
|
+
- 商品详情“加入购物车”必须登录;登录后必须写服务端购物车,再进入购物车页验证同一商品可见。
|
|
175
|
+
- 购物车、订单、资产、团队、提货、地址、收款方式等会员数据都必须按会员 Id 做后端范围过滤。
|
|
176
|
+
- 涉及多种支付/货币类型的项目(如提货卡、积分、余额等),每种支付渠道必须独立测试,不能混用或互通;项目自定义的费率、规则参数应在各自项目的测试文件中维护。
|
|
177
|
+
- 库存/商品相关接口(如库存转让、抜购窗口)必须返回标准 DosResult,禁止返回 JS `null`;成功路径必须返回订单 Id 或结果数据。
|
|
178
|
+
- 购物车“结算”必须调用业务结算接口,不能残留“功能开发中”占位文案;真实闭环:加入购物车 → 结算 → 断言 Code=1 和订单 Id → 确认购物车已清对应商品。
|
|
179
|
+
- 首页运营 banner 推荐从公告或配置表驱动;E2E 要同时断言接口返回、图片真实加载、点击进入详情页。
|
|
180
|
+
- 涉及多种支付/货币类型的项目(如提货卡、积分、余额等),每种支付渠道必须独立测试,不能混用或互通;项目自定义的费率、规则参数应在各自项目的测试文件中维护。
|
|
181
|
+
- 库存/商品相关接口(如库存转让、抢购窗口)必须返回标准 DosResult,禁止返回 JS `null`;成功路径必须返回订单 Id 或结果数据。
|
|
182
|
+
- 购物车`结算`必须调用业务结算接口,不能残留`功能开发中`占位文案;真实闭环:加入购物车 → 结算 → 断言 Code=1 和订单 Id → 确认购物车已清对应商品。
|
|
183
|
+
- 首页运营 banner 推荐从公告或配置表驱动;E2E 要同时断言接口返回、图片真实加载、点击进入详情页。
|
|
184
|
+
|
|
185
|
+
<!-- /microi-progressive:chunk -->
|
|
186
|
+
<!-- microi-progressive:chunk id=playwright-e2e-021 sha256=3a2ad9d446d5169735e0cedfc0bec84d8a4ba5c23cd0401190bf23708d344dce -->
|
|
187
|
+
## 与 MCP 的配合
|
|
188
|
+
|
|
189
|
+
- `microi_get_db_schema`:写测试前确认表和字段。
|
|
190
|
+
- `microi_get_playwright_context`:获取可测菜单 URL、接口引擎、匿名配置。
|
|
191
|
+
- `microi_plan_playwright_e2e`:生成推荐的测试文件、环境变量和冒烟路径。
|
|
192
|
+
- `microi_run_engine`:调试单个接口引擎,不替代浏览器 E2E。
|
|
193
|
+
- `microi_set_engine_anonymous`:登录、注册、公开首页接口需要匿名访问时使用;设置后仍要验证 HTTP `/apiengine/{key}` + `osclient` Header 返回标准 DosResult。
|
|
194
|
+
|
|
195
|
+
<!-- /microi-progressive:chunk -->
|
|
196
|
+
<!-- microi-progressive:chunk id=playwright-e2e-022 sha256=4c8a62a896b5f1f97ea41bcd3afdb0dc3c3609ead6c92283dcfa703c09311b42 -->
|
|
197
|
+
## 与 VS Code 插件的配合
|
|
198
|
+
|
|
199
|
+
### Microi VS Code 插件
|
|
200
|
+
|
|
201
|
+
Microi VS Code 插件应提供三类能力:
|
|
202
|
+
|
|
203
|
+
- 初始化:创建 `playwright.config.js`、`tests/e2e/helpers/microi.js`、示例 `smoke.spec.js`、`.env.e2e.example`,并补齐 `package.json` 脚本。
|
|
204
|
+
- 运行:在当前前端项目目录执行 `npm run test:e2e`,并提供打开报告入口。
|
|
205
|
+
- 上下文:从后端 `GetPlaywrightContext` 拉取当前租户可测路由和接口引擎,写入 `tests/e2e/.microi-playwright-context.json`,供 AI 生成用例时参考。
|
|
206
|
+
|
|
207
|
+
### Playwright Test for VSCode(官方插件)
|
|
208
|
+
|
|
209
|
+
官方插件 `Playwright Test for VSCode` 与 Microi Playwright 规范不冲突。它只是同一套 `@playwright/test` 的 VS Code 测试视图/调试入口,读取项目里的 `playwright.config.js`、`testDir`、`projects`、`webServer`、`use` 配置;CLI 的 `npx playwright test` 与插件按钮运行的是同一批 spec。
|
|
210
|
+
|
|
211
|
+
推荐共用方式:
|
|
212
|
+
|
|
213
|
+
1. 项目内保留 `playwright.config.js` 作为唯一配置源,不为插件单独复制一份配置。
|
|
214
|
+
2. `webServer.reuseExistingServer: true`,这样插件运行时如果 H5 静态服务已启动就复用,否则按配置启动。
|
|
215
|
+
3. 本地 H5 先执行 `npm run build:h5:local`;插件再运行 `tests/e2e/*.spec.js` 时会服务 `dist/build/h5`。
|
|
216
|
+
4. Windows 本机推荐 `PW_BROWSER_CHANNEL=msedge` 或在配置中默认 `channel: 'msedge'`,避免每台机器重复下载 Chromium。
|
|
217
|
+
5. 需要自定义 `PW_API_BASE/PW_API_ENV/PW_PORT/PW_OS_CLIENT` 时,优先写入 `playwright.config.js` 的默认值或 VS Code 插件环境变量设置;CI 和一次性运行再用终端环境变量覆盖。
|
|
218
|
+
6. 插件适合单个用例调试、断点、Trace 查看;最终交付仍要跑 CLI 全量命令并查看 `tests/e2e/report`。
|
|
219
|
+
7. 插件截图/trace 与 CLI 使用同一目录;视觉回归仍必须 `view_image` 人眼复核关键 fullPage 截图。
|
|
220
|
+
|
|
221
|
+
<!-- /microi-progressive:chunk -->
|