将账本业务页面、表单与审批迁移到 React,并加入旧版对照验收

This commit is contained in:
黄健铭 committed 2026-12-04 22:43:40 -08:00
1 parent f1a4e69f0d
commit 00dd683116
107 files changed
+31755 -191

No files matched your search

+53 -3
View File
@@ -203,6 +203,29 @@ try {
if ((await page.locator('a.old-ui-link').getAttribute('href')) === '/') ok('顶栏有“返回旧版界面”链接');
else fail('顶栏缺少返回旧版界面链接');
await page.screenshot({ path: path.join(SHOTS, '02-demo-create.png'), fullPage: true });
await page.locator('nav:visible a[data-tab="stock"]').click();
await page.locator('#stock-form').waitFor();
await page.locator('nav:visible a[data-tab="settings"]').click();
const store = page.locator('#shop-settings-form [name=storeName]');
const changed = '验证离开时保留的店名';
await store.fill(changed);
for (const discard of [false, true]) {
await Promise.all([
page.waitForEvent('dialog').then(async dialog => {
if (!dialog.message().includes('尚未保存')) throw new Error('后退未提示设置尚未保存');
if (discard) await dialog.accept();
else await dialog.dismiss();
}),
page.evaluate(() => history.back()),
]);
if (!discard) {
await page.waitForURL('**/next/settings');
if ((await store.inputValue()) !== changed) fail('取消后退后,未保存的店名被清空');
}
}
await page.locator('#stock-form').waitFor();
ok('设置未保存时,浏览器后退可取消保留,也可确认离开');
await page.getByRole('button', { name: /退\s*出/ }).click();
await page.waitForSelector('.login-card');
ok('退出后回到登录页');
@@ -226,22 +249,45 @@ try {
else fail('初始化后店铺名称不符');
await fillOrder(page, '新版桌面客户', { external: true });
await page.screenshot({ path: path.join(SHOTS, '04-desktop-filled.png'), fullPage: true });
await issue(page, '桌面', '¥2,460');
const paperNumber = await issue(page, '桌面', '¥2,460');
await page.screenshot({ path: path.join(SHOTS, '05-desktop-issued.png'), fullPage: true });
await page.evaluate(() => Object.defineProperty(navigator, 'clipboard', { value: undefined }));
await page.getByRole('button', { name: '复制纸单号' }).click();
await page.getByText('请手动选择纸单号复制', { exact: true }).waitFor();
if (await page.getByText(/^已复制纸单号 /).count()) fail('剪贴板不可用时仍提示复制成功');
else ok('剪贴板不可用时提示手动复制');
const [popup] = await Promise.all([
const [popup, audit] = await Promise.all([
ctx.waitForEvent('page'),
page.waitForResponse(
res => res.request().method() === 'POST' && /^\/api\/orders\/[^/]+\/print$/.test(new URL(res.url()).pathname),
),
page.locator('[data-action="print-preview"]').click(),
]);
await popup.waitForLoadState('load');
const preview = new URL(popup.url());
const previewPath = new URL(audit.url()).pathname.replace('/api/orders/', '/print/').replace(/\/print$/, '');
if (
audit.ok() &&
audit.request().postDataJSON().mode === 'full' &&
preview.pathname === previewPath &&
preview.searchParams.get('mode') === 'full'
)
ok('打开销售单完整预览时记录同一张订单的预览事件');
else fail('打印预览地址或预览记录不匹配');
if ((await popup.textContent('body')).includes('新版桌面客户')) ok('打印预览 /print/<订单号> 显示新订单');
else fail('打印预览未显示新订单');
await popup.screenshot({ path: path.join(SHOTS, '06-print-preview.png'), fullPage: true });
await popup.close();
// 从开单结果打开该单详情,同时保留成功页供下一单使用。
const details = await ctx.newPage();
const detailLink = await page.getByRole('link', { name: '查看订单详情' }).getAttribute('href');
if (!detailLink?.startsWith('/next/orders?order=')) throw new Error('成功页缺少该订单的新版详情链接');
await details.goto(base + detailLink);
const identifiers = details.locator('#order-dialog[open] .order-detail-identifiers');
await identifiers.waitFor();
if (!(await identifiers.innerText()).includes(paperNumber)) fail('从成功页打开的订单详情纸单号不一致');
else ok('成功页详情链接在新版打开同一纸单号');
await details.close();
await page.locator('[data-action="new-order"]').click();
await page.waitForSelector('#order-form');
if ((await page.locator('[data-field="customer"] input').inputValue()) === '') ok('开始新的一单后表单已清空');
@@ -315,7 +361,11 @@ try {
await fillShowcase(page);
await overflow(page, '新版开单页(两行示例单)');
// 等上一张单的成功提示消失,避免遮挡截图。
await page.locator('.ant-message-notice').first().waitFor({ state: 'detached', timeout: 8000 }).catch(() => {});
await page
.locator('.ant-message-notice')
.first()
.waitFor({ state: 'detached', timeout: 8000 })
.catch(() => {});
await page.locator('#order-form [data-line]').nth(1).scrollIntoViewIfNeeded();
await page.waitForTimeout(300);
await page.screenshot({ path: path.join(COMPARE, `create-${name}-new-filled.png`) });