补齐固定旧版的浏览器逐笔写入对照并记录账务差异
This commit is contained in:
1 parent
e77588b337
commit
7d2007955f
39 files changed
+3653
-41
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { action, navigate, write, fill, submit } from './ui.mjs';
|
||||
|
||||
export default async function settings(ctx) {
|
||||
const owner = await ctx.pageFor('owner');
|
||||
await navigate(owner, ctx.version, 'settings');
|
||||
const cost = owner.locator('#shop-cost-form');
|
||||
await action(owner, 'shop-cost-add').click();
|
||||
await fill(cost, { name: '对照测试成本', amount: ctx.prove && ctx.version === 'new' ? '3.22' : '3.21' });
|
||||
await write(ctx, owner, '新增成本配置', '/api/shop-settings', () => submit(cost));
|
||||
const costRow = owner.locator('[data-cost-row]').filter({ hasText: '对照测试成本' });
|
||||
await action(costRow, 'shop-cost-edit').click();
|
||||
await fill(cost, { amount: '3.23' });
|
||||
await write(ctx, owner, '修改成本配置', '/api/shop-settings', () => submit(cost));
|
||||
await action(costRow, 'shop-cost-delete').click();
|
||||
await write(ctx, owner, '删除成本配置', '/api/shop-settings', () => submit(cost));
|
||||
|
||||
await action(owner, 'employee-reload').click();
|
||||
await owner.waitForLoadState('networkidle');
|
||||
await action(owner, 'employee-add').click();
|
||||
const employee = owner.locator('#employee-form');
|
||||
const password = 'ledger-fixture-employee-password';
|
||||
await fill(employee, { label: '测试员工', operatorName: '测试开单人', loginName: '13900000019', password });
|
||||
await write(ctx, owner, '新增员工', '/api/employees', () => submit(employee));
|
||||
const row = owner.locator('[data-employee]').filter({ hasText: '测试员工' });
|
||||
const member = await row.getAttribute('data-employee');
|
||||
const checkPasswordStorage = async () =>
|
||||
assert.equal(
|
||||
await owner.evaluate(
|
||||
p => [localStorage, sessionStorage].some(s => Object.values(s).some(value => value.includes(p))),
|
||||
password,
|
||||
),
|
||||
false,
|
||||
);
|
||||
await checkPasswordStorage();
|
||||
await action(row, 'employee-edit').click();
|
||||
await fill(employee, { operatorName: '新开单人' });
|
||||
const endpoint = '/api/employees/' + member + '/';
|
||||
await write(ctx, owner, '修改员工', endpoint + 'update', () => submit(employee));
|
||||
for (const [verb, title] of [
|
||||
['deactivate', '停用'],
|
||||
['reactivate', '恢复'],
|
||||
['delete', '删除'],
|
||||
]) {
|
||||
await action(row, 'employee-' + verb).click();
|
||||
const form = owner.locator('#employee-status-form');
|
||||
await form.locator('[name=verified]').check();
|
||||
await write(ctx, owner, title + '员工', endpoint + verb, () => submit(form));
|
||||
}
|
||||
const shop = owner.locator('#shop-settings-form'),
|
||||
print = owner.locator('#print-settings');
|
||||
await fill(shop, { storeName: '迁移对照店铺' });
|
||||
await fill(print, { rows: '8' });
|
||||
await write(ctx, owner, '保存店铺名称', '/api/shop-settings', () => submit(shop));
|
||||
assert.equal(await print.locator('[name=rows]').inputValue(), '8');
|
||||
await write(ctx, owner, '保存打印设置', '/api/printing', () => owner.locator('button[form=print-settings]').click());
|
||||
await ctx.step('备份并下载完整账本', async () => {
|
||||
const [file] = await Promise.all([owner.waitForEvent('download'), action(owner, 'backup').click()]);
|
||||
assert.match(file.suggestedFilename(), /\.sqlite$/);
|
||||
const filePath = await file.path();
|
||||
assert.ok(fs.statSync(filePath).size);
|
||||
const db = new DatabaseSync(filePath, { readOnly: true });
|
||||
try {
|
||||
assert.equal(db.prepare('PRAGMA integrity_check').get().integrity_check, 'ok');
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
await owner.waitForLoadState('networkidle');
|
||||
});
|
||||
const sync = action(owner, 'sync');
|
||||
const result = await write(ctx, owner, '手动同步', '/api/sync', () => sync.click());
|
||||
assert.match(result.error, /逐笔对照模拟同步失败/);
|
||||
await owner
|
||||
.getByText(/逐笔对照模拟同步失败/)
|
||||
.first()
|
||||
.waitFor();
|
||||
|
||||
const staff = await ctx.pageFor('assistant');
|
||||
await navigate(staff, ctx.version, 'settings');
|
||||
const form = staff.locator('#password-form');
|
||||
await fill(form, { current: ctx.passwords.assistant, password: 'changed-parity-password' });
|
||||
await write(ctx, staff, '店员修改密码', '/api/password', () => submit(form));
|
||||
}
|
||||
Reference in new issue
Block a user