openxiangda-cli 2.0.0-alpha.93 → 2.0.0-alpha.96
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/package.json +1 -1
- package/template/apps/server/package.json +1 -1
- package/template/apps/web/e2e/workflow.spec.ts +7 -2
- package/template/apps/web/package.json +1 -1
- package/template/apps/web/playwright.config.ts +1 -0
- package/template/apps/web/scripts/verify-build.mjs +3 -36
- package/template/apps/web/test/contracts.test.ts +9 -0
- package/template/package.json +1 -1
package/package.json
CHANGED
|
@@ -317,8 +317,13 @@ test('renders the independent mobile task and executes only a Surface operation'
|
|
|
317
317
|
test('shows an explicit authorization error instead of an empty work center', async ({
|
|
318
318
|
page,
|
|
319
319
|
}) => {
|
|
320
|
+
test.setTimeout(45_000);
|
|
320
321
|
await mockWorkflow(page, { forbidden: true });
|
|
321
|
-
await page.goto(`${runtimeBase}/admin/work-center
|
|
322
|
-
|
|
322
|
+
await page.goto(`${runtimeBase}/admin/work-center`, {
|
|
323
|
+
waitUntil: 'domcontentloaded',
|
|
324
|
+
});
|
|
325
|
+
await expect(page.getByRole('alert')).toContainText('HTTP_403: forbidden', {
|
|
326
|
+
timeout: 30_000,
|
|
327
|
+
});
|
|
323
328
|
await expect(page.getByRole('link', { name: '采购申请审批' })).toHaveCount(0);
|
|
324
329
|
});
|
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { gzipSync } from "node:zlib";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
1
|
+
import { verifyOpenXiangdaWebBuild } from 'openxiangda/testing';
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
const assets = join(dist, "assets");
|
|
7
|
-
const names = readdirSync(assets);
|
|
8
|
-
const files = names.map((name) => join(assets, name));
|
|
9
|
-
const total = files.reduce((bytes, file) => bytes + statSync(file).size, 0);
|
|
10
|
-
// Workflow pages are an optional route-level chunk. Preserve the stricter
|
|
11
|
-
// initial and gzip budgets below while bounding the complete deployable set.
|
|
12
|
-
if (total > 2_650_000)
|
|
13
|
-
throw new Error(`WEB_DIST_BUDGET_EXCEEDED:${total}>2650000`);
|
|
14
|
-
const javascript = files.filter((file) => file.endsWith(".js"));
|
|
15
|
-
const gzip = javascript.reduce(
|
|
16
|
-
(bytes, file) =>
|
|
17
|
-
bytes + gzipSync(readFileSync(file), { level: 9 }).byteLength,
|
|
18
|
-
0
|
|
19
|
-
);
|
|
20
|
-
if (gzip > 800_000)
|
|
21
|
-
throw new Error(`WEB_JS_GZIP_BUDGET_EXCEEDED:${gzip}>800000`);
|
|
22
|
-
if (names.some((name) => name.endsWith(".map")))
|
|
23
|
-
throw new Error("WEB_SOURCE_MAP_FORBIDDEN");
|
|
24
|
-
const html = readFileSync(join(dist, "index.html"), "utf8");
|
|
25
|
-
if (!html.includes('<div id="root"></div>'))
|
|
26
|
-
throw new Error("WEB_ROOT_MISSING");
|
|
27
|
-
const initialNames = [
|
|
28
|
-
...html.matchAll(/(?:src|href)="\.\/assets\/([^"]+\.js)"/g),
|
|
29
|
-
].map((match) => match[1]);
|
|
30
|
-
const initialGzip = [...new Set(initialNames)].reduce((bytes, name) => {
|
|
31
|
-
const file = join(assets, name);
|
|
32
|
-
return bytes + gzipSync(readFileSync(file), { level: 9 }).byteLength;
|
|
33
|
-
}, 0);
|
|
34
|
-
if (initialGzip > 600_000) {
|
|
35
|
-
throw new Error(`WEB_INITIAL_JS_GZIP_BUDGET_EXCEEDED:${initialGzip}>600000`);
|
|
36
|
-
}
|
|
3
|
+
const result = verifyOpenXiangdaWebBuild(new URL('../dist', import.meta.url));
|
|
37
4
|
process.stdout.write(
|
|
38
|
-
`Verified Vite build: ${
|
|
5
|
+
`Verified Vite build: ${result.totalBytes} bytes, ${result.totalJavaScriptGzipBytes} total gzip bytes, ${result.initialJavaScriptGzipBytes} initial gzip bytes.\n`
|
|
39
6
|
);
|
|
@@ -88,3 +88,12 @@ test('published E2E harnesses do not write evidence into the platform source rep
|
|
|
88
88
|
);
|
|
89
89
|
assert.doesNotMatch(workflowSource, /docs\/architecture|evidenceDirectory/);
|
|
90
90
|
});
|
|
91
|
+
|
|
92
|
+
test('the platform package owns Web build verification policy', () => {
|
|
93
|
+
const verifier = readFileSync(
|
|
94
|
+
new URL('../scripts/verify-build.mjs', import.meta.url),
|
|
95
|
+
'utf8'
|
|
96
|
+
);
|
|
97
|
+
assert.match(verifier, /verifyOpenXiangdaWebBuild/);
|
|
98
|
+
assert.doesNotMatch(verifier, /2_650_000|800_000|600_000/);
|
|
99
|
+
});
|