Files
persionalBrand/apps/taro/test/build-contract.test.mjs
T
que01 29e5666d74 refactor: 共享按钮尺寸令牌改用中性命名
--taro-button-height / --taro-button-compact-height 是本仓库自有的共享令牌,却借用了
框架名。源码级中性命名比产物替换更彻底,也不会出现源码与产物两套名字,因此改为
--brand-button-height / --brand-button-compact-height,与既有的 brand-button 组件命名一致;
产物遮蔽仍按同一张表处理 Taro 自身的标识符。

验证:weapp 的 app-origin.wxss 输出 page{--brand-button-height:88rpx} 与
button{min-height:var(--brand-button-height)};H5 与后台产物的声明与引用同步改名;
六类产物残留指纹均为 0;H5 预览 11 项浏览器回归通过;遮蔽前后后台产物用生产静态
服务器跑同一套测试,失败内容逐字节一致;format、lint、typecheck 通过。
2026-10-13 23:30:07 +08:00

45 lines
2.0 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { unmask } from "./mask-names.mjs";
const root = path.resolve(import.meta.dirname, "../../..");
const templateKeys = fs
.readdirSync(path.join(root, "packages"))
.filter((directory) => directory.startsWith("template-"))
.filter((directory) => fs.existsSync(path.join(root, "packages", directory, "template.json")))
.map((directory) => directory.slice("template-".length))
.sort();
for (const key of templateKeys)
test(`${key} 两端产物有真实入口及模板导航`, () => {
const manifest = JSON.parse(
fs.readFileSync(path.join(root, `packages/template-${key}/template.json`)),
);
const base = path.join(root, `apps/taro/dist/${key}`);
const config = JSON.parse(fs.readFileSync(path.join(base, "weapp/app.json")));
assert.equal(config.pages.length, 8);
assert.deepEqual(
config.tabBar.list.map((item) => item.text),
manifest.navigation.map((item) => item.label),
);
for (const page of config.pages)
for (const ext of ["js", "wxml", "json"])
assert.ok(fs.existsSync(path.join(base, "weapp", `${page}.${ext}`)), `${page}.${ext}`);
if (fs.existsSync(path.join(base, "h5/index.html")))
assert.ok(
fs.readFileSync(path.join(base, "h5/index.html"), "utf8").includes('type="module"'),
);
assert.ok(fs.existsSync(path.join(base, "weapp/project.config.json")));
const weappStyles = fs.readFileSync(path.join(base, "weapp/common.wxss"), "utf8");
const appStyles = unmask(fs.readFileSync(path.join(base, "weapp/app-origin.wxss"), "utf8"));
assert.ok(weappStyles.length > 1000);
assert.match(appStyles, /(^|})button\{/);
assert.match(appStyles, /--brand-button-height:\s*88rpx/);
assert.match(
appStyles,
/display:flex;align-items:center;justify-content:center;width:100%;min-height:var\(--brand-button-height\)/,
);
assert.doesNotMatch(appStyles, /(^|})\.h5-button\{/);
});