合入主线登录和营业时段策略,对齐旧界面与 React 访问流程
This commit is contained in:
commit
42395de23a
113 files changed
+1915
-558
No files matched your search
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('node:assert/strict');
|
||||
const test = require('node:test');
|
||||
const { compare } = require('../e2e/lib/diff');
|
||||
const { expectedTranscript, expectedTables } = require('../e2e/lib/main-business-hours');
|
||||
|
||||
test('营业时间的黄金期望仍拒绝缺失、错误时段、员工可见和原金额变化', () => {
|
||||
const config = { version: 1, revision: 3, storeName: '测试', profitShareHistory: [], feeDefaults: { shipping: '6' } };
|
||||
const staff = { storeName: '测试' };
|
||||
const original = [
|
||||
{ actor: 'owner', method: 'GET', path: '/api/state', status: 200, body: { shopSettings: config } },
|
||||
{ actor: 'assistant', method: 'GET', path: '/api/shop-settings', status: 200, body: staff },
|
||||
];
|
||||
const expected = expectedTranscript(original);
|
||||
assert.deepEqual(expected[1], original[1]);
|
||||
assert.equal(Object.hasOwn(config, 'businessHours'), false);
|
||||
assert.equal(expected[0].body.shopSettings.businessHours, null);
|
||||
const changes = [
|
||||
rows => delete rows[0].body.shopSettings.businessHours,
|
||||
rows => (rows[0].body.shopSettings.businessHours = { open: '09:00', close: '18:00' }),
|
||||
rows => (rows[1].body.businessHours = null),
|
||||
rows => (rows[0].body.shopSettings.feeDefaults.shipping = '6.01'),
|
||||
];
|
||||
for (const change of changes) {
|
||||
const candidate = structuredClone(expected);
|
||||
change(candidate);
|
||||
assert.equal(compare(expected, candidate).diffs.length, 1);
|
||||
}
|
||||
|
||||
const audit = { before: config, after: { ...config, revision: 4 }, note: '原值' };
|
||||
const result = { ok: true, shopSettings: config, printing: { rows: 8 } };
|
||||
const tables = {
|
||||
audit: [{ entity: 'shop-settings', action: '更新店铺配置', detail: JSON.stringify(audit) }],
|
||||
meta: [{ key: 'shop-settings-v1', value: JSON.stringify(config) }],
|
||||
operations: [{ id: 'old-op', hash: 'frozen', result }],
|
||||
};
|
||||
const expectedDb = expectedTables(tables);
|
||||
assert.deepEqual(JSON.parse(expectedDb.audit[0].detail).after, { ...audit.after, businessHours: null });
|
||||
assert.deepEqual(JSON.parse(expectedDb.meta[0].value), { ...config, businessHours: null });
|
||||
assert.deepEqual(expectedDb.operations[0].result, { ...result, shopSettings: { ...config, businessHours: null } });
|
||||
assert.equal(tables.operations[0].result.shopSettings.businessHours, undefined);
|
||||
});
|
||||
Reference in new issue
Block a user