carDamagePerfMetrics.spec.js
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* 权益列表表格性能相关静态指标(用于回归对比,非运行时 benchmark)
*/
const fs = require("fs");
const path = require("path");
const CAR_DAMAGE_VUE = fs.readFileSync(
path.resolve(__dirname, "../../../../src/views/orderManage/carDamage.vue"),
"utf8",
);
function countMatches(source, pattern) {
const matches = source.match(pattern);
return matches ? matches.length : 0;
}
describe("carDamagePerfMetrics", () => {
it("operation column should keep fixed right per product requirement", () => {
expect(CAR_DAMAGE_VUE).toMatch(
/<el-table-column[^>]*fixed="right"[^>]*label="操作"/,
);
});
it("operation buttons should remain separate auth-button entries", () => {
const operationSection = CAR_DAMAGE_VUE.match(
/<el-table-column[^>]*label="操作"[\s\S]*?<\/el-table-column>/,
);
expect(operationSection).toBeTruthy();
expect(operationSection[0]).toContain("auth-button");
expect(operationSection[0]).not.toContain("el-dropdown");
});
it("sub-order columns should be in expand row not main v-for columns", () => {
const mainSubOrderVFor = CAR_DAMAGE_VUE.match(
/<el-table-column[^>]*label="商品名称"[\s\S]*?v-for="\(item, index\) in scope\.row\.subOrderList"/,
);
expect(mainSubOrderVFor).toBeNull();
});
it("should use row display mapper in getList", () => {
expect(CAR_DAMAGE_VUE).toContain("mapCarDamageListRow");
});
it("page size max should be 20", () => {
expect(CAR_DAMAGE_VUE).toMatch(/:page-sizes="\[10,\s*20\]/);
});
it("expand area should use native table instead of nested el-table", () => {
expect(CAR_DAMAGE_VUE).not.toMatch(/<el-table :data="row\.subOrderDisplayList"/);
expect(CAR_DAMAGE_VUE).toContain("order-sub-goods-table");
});
it("should use accordion expand-row-keys", () => {
expect(CAR_DAMAGE_VUE).toContain(":expand-row-keys=\"expandedOrderCodes\"");
expect(CAR_DAMAGE_VUE).toContain("@expand-change=\"handleExpandChange\"");
expect(CAR_DAMAGE_VUE).toContain("handleExpandChange(row, expandedRows)");
});
it("main table has fewer columns than legacy ~50", () => {
const mainColumnCount = countMatches(CAR_DAMAGE_VUE, /<el-table-column/g);
expect(mainColumnCount).toBeLessThan(40);
expect(mainColumnCount).toBeGreaterThan(25);
});
});