合入主线登录和营业时段策略,对齐旧界面与 React 访问流程
This commit is contained in:
commit
42395de23a
113 files changed
+1915
-558
No files matched your search
@@ -13,6 +13,7 @@ import { Session } from './lib/client.js';
|
||||
import { dumpDatabase } from './lib/db-dump.js';
|
||||
import { Normalizer } from './lib/normalize.js';
|
||||
import { compare, report } from './lib/diff.js';
|
||||
import { expectedTables } from './lib/main-business-hours.js';
|
||||
|
||||
const DAY = '2026-11-20';
|
||||
const TIME = DAY + 'T02:00:00Z';
|
||||
@@ -31,6 +32,34 @@ const pageTitles = {
|
||||
const roles = ['assistant', 'owner'];
|
||||
const frozenPages = JSON.parse(fs.readFileSync(new URL('./frozen-page-scenarios.json', import.meta.url), 'utf8')).pages;
|
||||
|
||||
// 旧版冻结的三个店主设置页都在联系方式和证书费用之间新增同样两个原生 time 输入。
|
||||
const ownerSettings = ['owner/settings', 'owner/mobile/settings', 'owner/settings/saved'];
|
||||
const hoursFields = [
|
||||
['businessOpen', '开始时间'],
|
||||
['businessClose', '结束时间'],
|
||||
].map(([name, label]) => ({
|
||||
name,
|
||||
labels: [label],
|
||||
type: 'time',
|
||||
value: '',
|
||||
required: false,
|
||||
disabled: false,
|
||||
readOnly: false,
|
||||
hidden: false,
|
||||
constraints: {},
|
||||
}));
|
||||
|
||||
function expectedMainPages(captures) {
|
||||
const states = { ...captures.states };
|
||||
for (const label of ownerSettings) {
|
||||
const snapshot = states[label];
|
||||
const position = snapshot.fields.findIndex(field => field.name === 'certificate');
|
||||
assert.equal(snapshot.fields[position - 1]?.name, 'contact', label + ' 营业时间位置');
|
||||
states[label] = { ...snapshot, fields: snapshot.fields.toSpliced(position, 0, ...hoursFields) };
|
||||
}
|
||||
return { ...captures, states, tables: expectedTables(captures.tables) };
|
||||
}
|
||||
|
||||
async function seed(server, base) {
|
||||
const session = new Session({ server, base });
|
||||
const yesterday = '2026-11-19';
|
||||
@@ -445,7 +474,7 @@ async function exercise(page, version, role, states, mobileWidths) {
|
||||
await capture('orders/after-sale-saved', order);
|
||||
}
|
||||
|
||||
async function run(browser, version, launchServer = startServer) {
|
||||
async function run(browser, version, launchServer = startServer, hasMainHours = true) {
|
||||
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-page-parity-'));
|
||||
const server = launchServer({ dataDir, clockStart: TIME, seed: 'page-parity' });
|
||||
const states = {},
|
||||
@@ -494,7 +523,9 @@ async function run(browser, version, launchServer = startServer) {
|
||||
assert.deepEqual(Object.keys(states), Object.keys(frozenPages.fields), version + ' 跨页实际场景与冻结清单不一致');
|
||||
assert.deepEqual(
|
||||
Object.values(states).map(state => state.fields.length),
|
||||
Object.values(frozenPages.fields),
|
||||
Object.entries(frozenPages.fields).map(
|
||||
([label, count]) => count + (hasMainHours && ownerSettings.includes(label) ? hoursFields.length : 0),
|
||||
),
|
||||
version + ' 各场景覆盖的表单控件数',
|
||||
);
|
||||
assert.deepEqual(Object.keys(mobileWidths), frozenPages.mobile, version + ' 移动页面入口');
|
||||
@@ -525,14 +556,15 @@ try {
|
||||
const referenceServer = referenceApp
|
||||
? createRequire(import.meta.url)(path.resolve(referenceApp, 'e2e/lib/server.js')).startServer
|
||||
: startServer;
|
||||
const jobs = [run(browser, 'old', referenceServer)];
|
||||
const jobs = [run(browser, 'old', referenceServer, !referenceApp)];
|
||||
if (!process.argv.includes('--legacy-only')) jobs.push(run(browser, 'new'));
|
||||
// 两个版本各用独立服务、浏览器上下文和临时数据库。都完成清理后再返回失败。
|
||||
const [reference, next] = (await Promise.allSettled(jobs)).map(result => {
|
||||
if (result.status === 'rejected') throw result.reason;
|
||||
return result.value;
|
||||
});
|
||||
const snapshots = Object.values(reference.captures.states);
|
||||
const expected = next && referenceApp ? expectedMainPages(reference.captures) : reference.captures;
|
||||
const snapshots = Object.values(expected.states);
|
||||
const fieldCount = snapshots.reduce((sum, page) => sum + page.fields.length, 0);
|
||||
const counts =
|
||||
snapshots.length +
|
||||
@@ -551,7 +583,7 @@ try {
|
||||
label + ' 文档宽度由 ' + width + 'px 增至 ' + next.mobileWidths[label] + 'px',
|
||||
);
|
||||
}
|
||||
const result = compare(reference.captures, next.captures);
|
||||
const result = compare(expected, next.captures);
|
||||
const output = path.join(import.meta.dirname, 'out', 'page-parity');
|
||||
fs.mkdirSync(output, { recursive: true });
|
||||
const summary = {
|
||||
|
||||
Reference in new issue
Block a user