合入主线登录和营业时段策略,对齐旧界面与 React 访问流程
This commit is contained in:
commit
42395de23a
113 files changed
+1915
-558
No files matched your search
@@ -0,0 +1,132 @@
|
||||
// 对照 main 的 5 个访问策略提交。每个版本使用自己的服务、账号和内存账本。
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const appDir = path.resolve(import.meta.dirname, '..');
|
||||
const password = 'test-access-hours-2026';
|
||||
const at = (date, time) => Date.parse(date + 'T' + time + ':00+08:00');
|
||||
|
||||
async function exercise(dir, browser, useNext) {
|
||||
const { createApp, createUser } = require(path.join(dir, 'server.js'));
|
||||
const { Ledger } = require(path.join(dir, useNext ? 'core/ledger.js' : 'ledger.js'));
|
||||
const ledger = new Ledger(':memory:');
|
||||
createUser(ledger, '店主', 'owner', password, 'owner');
|
||||
createUser(ledger, '员工', 'assistant', password, 'assistant');
|
||||
let now = at('2026-12-04', '21:00');
|
||||
const app = createApp({
|
||||
mode: 'trial',
|
||||
ledger,
|
||||
hoursPolicy: true,
|
||||
shopAccessPolicy: true,
|
||||
hoursClock: () => now,
|
||||
feishuConfig: {},
|
||||
});
|
||||
await new Promise(resolve => app.server.listen(0, '127.0.0.1', resolve));
|
||||
const base = 'http://127.0.0.1:' + app.server.address().port;
|
||||
const context = await browser.newContext({ extraHTTPHeaders: { 'X-Ledger-Access-Zone': 'store' } });
|
||||
try {
|
||||
const results = [];
|
||||
const call = async (route, { zone = 'store', cookie, body } = {}) => {
|
||||
return fetch(base + route, {
|
||||
method: body ? 'POST' : 'GET',
|
||||
headers: {
|
||||
'X-Ledger-Access-Zone': zone,
|
||||
...(cookie && { Cookie: cookie }),
|
||||
...(body && { Origin: base, 'Content-Type': 'application/json', 'X-Requested-With': 'maimai-ledger' }),
|
||||
},
|
||||
body: body && JSON.stringify(body),
|
||||
});
|
||||
};
|
||||
async function check(label, status, response, project = value => value) {
|
||||
const res = await response;
|
||||
assert.equal(res.status, status, label);
|
||||
results.push([label, status, project(await res.json())]);
|
||||
return res;
|
||||
}
|
||||
const sign = (member, zone) => call('/api/login', { zone, body: { member, password } });
|
||||
const identity = ({ user }) => ({ member: user.member, role: user.role });
|
||||
const token = res => res.headers.get('set-cookie').split(';')[0];
|
||||
const session = ({ user, accessWindow, loginOptions }) => ({
|
||||
role: user?.role ?? null,
|
||||
accessWindow,
|
||||
loginOptions,
|
||||
});
|
||||
await check('未配置时显示可用账号', 200, call('/api/session'), session);
|
||||
await check('未配置时员工登录', 403, sign('assistant'));
|
||||
const owner = token(await check('未配置时店外店主登录', 200, sign('owner', 'owner'), identity));
|
||||
const setup = (cookie, hours) =>
|
||||
call('/api/business-hours/setup', { cookie, body: { revision: 0, businessHours: hours } });
|
||||
const hours = { open: '22:00', close: '02:00' };
|
||||
await check('首次设置须填完整', 400, setup(owner, { open: '22:00' }));
|
||||
await check('首次设置跨日时段', 200, setup(owner, hours));
|
||||
await check('重复首次设置', 409, setup(owner, hours));
|
||||
now = at('2026-12-04', '23:00');
|
||||
await check('营业中店外员工登录', 403, sign('assistant', 'owner'));
|
||||
const staff = token(await check('营业中店内员工登录', 200, sign('assistant'), identity));
|
||||
await check('营业中店外账号选项', 200, call('/api/session', { zone: 'owner' }), session);
|
||||
await check('员工已有会话离店', 403, call('/api/access-window', { zone: 'owner', cookie: staff }));
|
||||
await check('跨午夜截止时间', 200, call('/api/access-window', { cookie: staff }));
|
||||
await check('店主不受截止时间限制', 200, call('/api/access-window', { cookie: owner }));
|
||||
await check('员工读取配置隐藏营业时间', 200, call('/api/shop-settings', { cookie: staff }), settings => ({
|
||||
containsHours: Object.hasOwn(settings, 'businessHours'),
|
||||
}));
|
||||
await check('店主读取保存后的营业时间', 200, call('/api/shop-settings', { cookie: owner }), settings => ({
|
||||
hours: settings.businessHours,
|
||||
revision: settings.revision,
|
||||
}));
|
||||
now = at('2026-12-05', '01:59');
|
||||
const page = await context.newPage();
|
||||
await page.clock.install();
|
||||
await page.goto(base + (useNext ? '/next/' : '/'));
|
||||
if (useNext) {
|
||||
await page.getByTestId('login-member').locator('.ant-select-selector').click();
|
||||
await page.locator('.ant-select-item-option').filter({ hasText: '娜娜' }).click();
|
||||
} else {
|
||||
await page.locator('select[name=member]').selectOption('assistant');
|
||||
}
|
||||
await page.locator('input[name=password]').fill(password);
|
||||
await page.locator('button[type=submit]').click();
|
||||
await page.getByText('距离停止访问不足 5 分钟,请及时保存。').waitFor();
|
||||
now = at('2026-12-05', '02:00');
|
||||
await page.clock.fastForward(61_000);
|
||||
await page.locator('[data-standalone-login] select[name=member]').waitFor();
|
||||
assert.deepEqual(await page.locator('select[name=member] option').evaluateAll(xs => xs.map(x => x.value)), [
|
||||
'',
|
||||
'owner',
|
||||
]);
|
||||
assert.equal(await page.locator('script[src]').count(), 0, '闭店后只加载轻量登录页');
|
||||
for (const route of ['/api/session', '/api/state', '/api/access-window', '/print/example'])
|
||||
await check('闭店仍持员工会话 ' + route, 403, call(route, { cookie: staff }));
|
||||
await check('闭店店主会话继续使用', 200, call('/api/session', { cookie: owner }), session);
|
||||
return results;
|
||||
} finally {
|
||||
await context.close();
|
||||
await new Promise(resolve => app.server.close(resolve));
|
||||
ledger.close();
|
||||
}
|
||||
}
|
||||
|
||||
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-access-main-'));
|
||||
let browser;
|
||||
try {
|
||||
const archive = path.join(scratch, 'main.tar');
|
||||
const repo = path.dirname(appDir);
|
||||
execFileSync('git', ['-C', repo, 'archive', '--output=' + archive, '3e9af71', '--', path.basename(appDir)]);
|
||||
execFileSync('tar', ['-xf', archive, '-C', scratch]);
|
||||
browser = await chromium.launch();
|
||||
const main = await exercise(path.join(scratch, path.basename(appDir)), browser, false);
|
||||
const next = await exercise(appDir, browser, true);
|
||||
assert.deepEqual(next, main);
|
||||
console.log(
|
||||
'访问策略对照通过:' + main.length + ' 项 HTTP 结果相同;两个界面均实测员工登录、闭店提醒与自动返回轻量登录页。',
|
||||
);
|
||||
} finally {
|
||||
await browser?.close();
|
||||
fs.rmSync(scratch, { recursive: true, force: true });
|
||||
}
|
||||
+30
-1
@@ -488,6 +488,35 @@ async function flowAssistant2(b) {
|
||||
await b.logout();
|
||||
}
|
||||
|
||||
// 在 adc0ca8 与 3e9af71 上运行同一浏览器场景得到的文字增量。基线文件保留原样。
|
||||
function expectedSnapshot(label, frozen) {
|
||||
if (label === '01-login-page') {
|
||||
const oldShell = [
|
||||
'云端数据库和飞书同步的真实状态,会在系统内显示。',
|
||||
'麦麦麦珠宝开单 · 库存 · 订单利润退出',
|
||||
'01 开单02 待交付03 每日购料04 回收/置换05 订单06 库存07 每日对账08 团队账目09 私域运营概况登记人数10 店铺与打印设置一次录入,沿同一张单收款、交货、复核。',
|
||||
'金额按分记录,黄金精确到 0.001g。实际收退款由经办人核实。',
|
||||
].join('\n');
|
||||
return frozen.replace(oldShell + '\n', '');
|
||||
}
|
||||
if (['12-owner-tab-settings', '29-owner-settings-saved'].includes(label)) {
|
||||
return frozen
|
||||
.replace(
|
||||
'开单默认费用\n',
|
||||
[
|
||||
'营业时间(北京时间)',
|
||||
'开始时间',
|
||||
'结束时间',
|
||||
'结束时间早于开始时间,表示营业到次日。两项留空时暂停员工访问。超级管理员可全天登录和使用账本。',
|
||||
'开单默认费用',
|
||||
'',
|
||||
].join('\n'),
|
||||
)
|
||||
.replace('contact=\ncertificate=', 'contact=\nbusinessOpen=\nbusinessClose=\ncertificate=');
|
||||
}
|
||||
return frozen;
|
||||
}
|
||||
|
||||
function compareSnapshots(snapshots) {
|
||||
const expected = fs.existsSync(BASE_UI)
|
||||
? fs
|
||||
@@ -502,7 +531,7 @@ function compareSnapshots(snapshots) {
|
||||
for (const { label, text } of snapshots) {
|
||||
const file = path.join(BASE_UI, label + '.txt');
|
||||
if (!fs.existsSync(file)) continue;
|
||||
const a = fs.readFileSync(file, 'utf8').split('\n'),
|
||||
const a = expectedSnapshot(label, fs.readFileSync(file, 'utf8')).split('\n'),
|
||||
c = text.split('\n');
|
||||
if (a.join('\n') === c.join('\n')) continue;
|
||||
let i = 0;
|
||||
|
||||
+9
-2
@@ -14,6 +14,7 @@ const { Normalizer } = require('./lib/normalize');
|
||||
const { dumpDatabase } = require('./lib/db-dump');
|
||||
const { compare, report } = require('./lib/diff');
|
||||
const ApprovedAuditIndex = require('./lib/approved-audit-index');
|
||||
const MainHours = require('./lib/main-business-hours');
|
||||
const scenario = require('./golden-scenario');
|
||||
const args = process.argv.slice(2),
|
||||
check = args.includes('--check'),
|
||||
@@ -90,8 +91,14 @@ function describeTranscript(transcript) {
|
||||
write(OUT, result);
|
||||
const frozenDb = JSON.parse(fs.readFileSync(path.join(BASELINE, 'db.json'), 'utf8'));
|
||||
const expected = {
|
||||
transcript: JSON.parse(fs.readFileSync(path.join(BASELINE, 'transcript.json'), 'utf8')),
|
||||
db: { ...frozenDb, schema: ApprovedAuditIndex.expectedMaster(frozenDb.schema) },
|
||||
transcript: MainHours.expectedTranscript(
|
||||
JSON.parse(fs.readFileSync(path.join(BASELINE, 'transcript.json'), 'utf8')),
|
||||
),
|
||||
db: {
|
||||
...frozenDb,
|
||||
schema: ApprovedAuditIndex.expectedMaster(frozenDb.schema),
|
||||
tables: MainHours.expectedTables(frozenDb.tables),
|
||||
},
|
||||
};
|
||||
const t = compare(expected.transcript, result.transcript),
|
||||
d = compare(expected.db, result.db),
|
||||
|
||||
@@ -15,6 +15,7 @@ const { Session } = require('./lib/client');
|
||||
const { Normalizer } = require('./lib/normalize');
|
||||
const { compare, report } = require('./lib/diff');
|
||||
const ApprovedAuditIndex = require('./lib/approved-audit-index');
|
||||
const assert = require('node:assert/strict');
|
||||
const args = process.argv.slice(2),
|
||||
check = args.includes('--check');
|
||||
const FIXTURE = args.includes('--fixture')
|
||||
@@ -192,8 +193,35 @@ async function run() {
|
||||
const integrityOk = result.before.integrity.join() === 'ok' && result.after.integrity.join() === 'ok';
|
||||
if (check) {
|
||||
const frozen = JSON.parse(fs.readFileSync(BASELINE, 'utf8'));
|
||||
// 旧库基线仅存哈希。在 cdb6ba6 跑相同的旧库读取,只向店主配置加入主线的 businessHours:null,
|
||||
// 独立取得这两个新摘要。继续比较候选的完整响应,员工响应等沿用原哈希。
|
||||
const owner = { ...frozen.responses.owner };
|
||||
for (const [route, previous, hash, previousKeys, keys] of [
|
||||
[
|
||||
'/api/state',
|
||||
'af90971878daa849bc14a0336ca35c34cc55f2aa4fc337464031ed0149494ec1',
|
||||
'3630238716968a55424bd1f67436f15cd86c371790e0e79050cc5b0d0e8d1375',
|
||||
18,
|
||||
18,
|
||||
],
|
||||
[
|
||||
'/api/shop-settings',
|
||||
'85cc10305b5f132734b1912d9be1f572fc0bd175f4d1e8d267148f7411237651',
|
||||
'e31c77a6380f1cbd36a719fd24a21e0a7c1259041a62934af81d2baef29dc05f',
|
||||
12,
|
||||
13,
|
||||
],
|
||||
]) {
|
||||
assert.deepEqual(
|
||||
owner[route],
|
||||
{ status: 200, hash: previous, keys: previousKeys },
|
||||
'营业时段哈希增量的旧库起点不符:' + route,
|
||||
);
|
||||
owner[route] = { ...owner[route], hash, keys };
|
||||
}
|
||||
const expected = {
|
||||
...frozen,
|
||||
responses: { ...frozen.responses, owner },
|
||||
before: { ...frozen.before, schema: ApprovedAuditIndex.expectedLegacySchema(frozen.before.schema) },
|
||||
after: {
|
||||
...frozen.after,
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
'use strict';
|
||||
|
||||
// 主线 3e9af71 的所有旧场景都没有设置营业时段。只从旧版期望构造新增字段,实际结果原样比较。
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
function ownerConfig(config) {
|
||||
const { version, revision, ...rest } = config;
|
||||
assert.equal(version, 1);
|
||||
assert.ok(Number.isInteger(revision) && Object.hasOwn(rest, 'profitShareHistory'));
|
||||
assert.ok(!Object.hasOwn(rest, 'businessHours'), '此期望必须来自营业时间合入前的旧版');
|
||||
// 数据库 JSON 以字符串逐字比较:按主线的序列化顺序将新增键插在 revision 后。
|
||||
return { version, revision, businessHours: null, ...rest };
|
||||
}
|
||||
|
||||
function writeReceipt(body) {
|
||||
return { ...body, shopSettings: ownerConfig(body.shopSettings) };
|
||||
}
|
||||
|
||||
function expectedBody(method, endpoint, role, status, body) {
|
||||
if (role !== 'owner' || status !== 200) return body;
|
||||
if (method === 'GET' && endpoint === '/api/shop-settings') return ownerConfig(body);
|
||||
if (
|
||||
(method === 'GET' && endpoint === '/api/state') ||
|
||||
(method === 'POST' && ['/api/shop-settings', '/api/printing'].includes(endpoint))
|
||||
)
|
||||
return writeReceipt(body);
|
||||
return body;
|
||||
}
|
||||
|
||||
// 黄金和页面用 SQLite 的 columns/rows 转储,逐笔对照用具名行并已解码 operations.result。
|
||||
function expectedTables(tables) {
|
||||
const result = { ...tables };
|
||||
for (const name of ['meta', 'audit', 'operations']) {
|
||||
const source = tables[name];
|
||||
if (!source) continue;
|
||||
const columns = source.columns;
|
||||
const rows = (columns ? source.rows : source).map(row => {
|
||||
const get = key => (columns ? row[columns.indexOf(key)] : row[key]);
|
||||
const replace = (key, value) =>
|
||||
columns ? row.toSpliced(columns.indexOf(key), 1, value) : { ...row, [key]: value };
|
||||
if (name === 'meta' && get('key') === 'shop-settings-v1')
|
||||
return replace('value', JSON.stringify(ownerConfig(JSON.parse(get('value')))));
|
||||
if (name === 'audit' && get('entity') === 'shop-settings' && get('action') === '更新店铺配置') {
|
||||
const detail = JSON.parse(get('detail'));
|
||||
return replace(
|
||||
'detail',
|
||||
JSON.stringify({ ...detail, before: ownerConfig(detail.before), after: ownerConfig(detail.after) }),
|
||||
);
|
||||
}
|
||||
if (name === 'operations') {
|
||||
const stored = get('result');
|
||||
const body = typeof stored === 'string' ? JSON.parse(stored) : stored;
|
||||
// 这两种店主写入回执共用同一结构,操作表本身只存幂等键、摘要和返回值。
|
||||
if (body?.ok === true && Object.hasOwn(body, 'shopSettings') && Object.hasOwn(body, 'printing')) {
|
||||
const receipt = writeReceipt(body);
|
||||
return replace('result', typeof stored === 'string' ? JSON.stringify(receipt) : receipt);
|
||||
}
|
||||
}
|
||||
return row;
|
||||
});
|
||||
result[name] = columns ? { ...source, rows } : rows;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function expectedTranscript(entries) {
|
||||
return entries.map(entry =>
|
||||
Object.hasOwn(entry, 'body')
|
||||
? { ...entry, body: expectedBody(entry.method, entry.path, entry.actor, entry.status, entry.body) }
|
||||
: entry,
|
||||
);
|
||||
}
|
||||
|
||||
function expectedWriteResult(result) {
|
||||
const steps = {};
|
||||
for (const [label, step] of Object.entries(result.steps)) {
|
||||
const requests = step.requests.map(request => ({
|
||||
...request,
|
||||
...(Object.hasOwn(request, 'response')
|
||||
? { response: expectedBody('POST', request.endpoint, request.role, request.status, request.response) }
|
||||
: {}),
|
||||
...(request.database ? { database: expectedTables(request.database) } : {}),
|
||||
}));
|
||||
steps[label] = { ...step, requests, before: expectedTables(step.before), after: expectedTables(step.after) };
|
||||
}
|
||||
return { ...result, steps, final: expectedTables(result.final) };
|
||||
}
|
||||
|
||||
module.exports = { expectedTranscript, expectedTables, expectedWriteResult };
|
||||
@@ -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 = {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { readOnlyPost, ReadOnlyChecks } from './writes/readonly.mjs';
|
||||
import { coverage } from './write-coverage.mjs';
|
||||
import { fullGroups, contracts, assertSequence, assertStepActions, observeStep } from './lib/frozen-write-steps.mjs';
|
||||
import { compare, report } from './lib/diff.js';
|
||||
import { expectedWriteResult } from './lib/main-business-hours.js';
|
||||
|
||||
import { app, git, reference, fixedReference } from './lib/write-reference.mjs';
|
||||
|
||||
@@ -289,7 +290,10 @@ try {
|
||||
if (process.argv.includes('--prove'))
|
||||
assert.equal(process.argv[only + 1], 'settings', '使用 --only settings --prove');
|
||||
const groups = only < 0 ? [...fullGroups] : (process.argv[only + 1] ?? '').split(',');
|
||||
assert.ok(groups.every(group => Object.hasOwn(contracts, group)), '--only 需要指定已冻结的业务组');
|
||||
assert.ok(
|
||||
groups.every(group => Object.hasOwn(contracts, group)),
|
||||
'--only 需要指定已冻结的业务组',
|
||||
);
|
||||
assert.equal(new Set(groups).size, groups.length, '--only 重复指定业务组');
|
||||
const allHits = {},
|
||||
outcomes = {};
|
||||
@@ -332,13 +336,20 @@ try {
|
||||
singular.orderReads = [];
|
||||
}
|
||||
}
|
||||
const diffs = expected === old.result ? raw : compare(expected, next.result);
|
||||
const mainExpected = expectedWriteResult(expected);
|
||||
const mainChanges = compare(expected, mainExpected).diffs;
|
||||
const diffs = compare(mainExpected, next.result);
|
||||
const approved = expected === old.result ? [] : compare(old.result, expected).diffs;
|
||||
console.log(
|
||||
group,
|
||||
Object.keys(old.result.steps).length + ' 步',
|
||||
old.hits.length + '/' + next.hits.length + ' 次 POST',
|
||||
diffs.diffs.length + ' 处未预期差异,' + approved.length + ' 处已确认字段差异',
|
||||
diffs.diffs.length +
|
||||
' 处未预期差异,' +
|
||||
approved.length +
|
||||
' 处已确认字段差异,' +
|
||||
mainChanges.length +
|
||||
' 处主线营业时间字段差异',
|
||||
);
|
||||
outcomes[group] = {
|
||||
readOnly: { old: old.verifiedReads, new: next.verifiedReads },
|
||||
@@ -354,7 +365,9 @@ try {
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
...(approved.length ? { approved, rawDiffs: raw.diffs } : {}),
|
||||
...(mainChanges.length ? { mainBusinessHours: mainChanges } : {}),
|
||||
...(approved.length ? { approved } : {}),
|
||||
...(approved.length || mainChanges.length ? { rawDiffs: raw.diffs } : {}),
|
||||
};
|
||||
for (const [side, rs] of [
|
||||
['old', old],
|
||||
|
||||
@@ -7,6 +7,8 @@ import { orderActionCoverage, orderChangeCoverage } from './writes/orders-covera
|
||||
|
||||
const manifest = JSON.parse(fs.readFileSync(new URL('./writes/routes.json', import.meta.url), 'utf8'));
|
||||
const excluded = {
|
||||
'/api/business-hours/setup':
|
||||
'营业时间首次设置的 HTTP 入口没有页面按钮。两个界面的店铺配置都提交 /api/shop-settings。访问策略专项对照直接请求此接口。',
|
||||
'/api/private-operations':
|
||||
'server/routes/funds.routes.js 中 POST handler 为 notFound。实际人数写入 /api/private-operations/people。',
|
||||
'/api/people-count-history': 'server/routes/funds.routes.js 中 POST handler 为 notFound。历史列表只接受 GET。',
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"/api/logout"
|
||||
],
|
||||
"settings": [
|
||||
"/api/business-hours/setup",
|
||||
"/api/password",
|
||||
"/api/shop-settings",
|
||||
"/api/printing",
|
||||
|
||||
Reference in new issue
Block a user