browser-next:补充登录页、首屏与两行示例单的新旧对照截图(选择器与断言不变)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
黄健铭andClaude Opus 5.5 committed 2026-12-04 20:11:34 -08:00
1 parent 581048ba44
commit c594bf296f
1 file changed
+75
+75
View File
@@ -115,6 +115,49 @@ async function fillOrder(page, customer, { external = false } = {}) {
if (await preset.count()) await preset.first().check();
await fill(form, 'internal_note', '#浏览器 新版开单');
}
// 对照截图用的完整示例单:两行商品(一行按金价工费、一行直接填金额)、附加项目、内部成本、常用成本与整单优惠。
// 只填写不提交,用于展示常驻合计栏。
async function fillShowcase(page) {
const form = page.locator('#order-form');
const fill = (scope, field, value) =>
scope.locator(`[data-field="${field}"] input, [data-field="${field}"] textarea`).first().fill(value);
const radio = (scope, field, label) =>
scope.locator(`[data-field="${field}"] .ant-radio-button-wrapper`, { hasText: label }).first().click();
await fill(form, 'customer', '林小姐');
await radio(form, 'customer_type', '老客户');
const first = form.locator('[data-line]').first();
await fill(first, 'quantity', '5.28');
await fill(first, 'goldPrice', '958');
await fill(first, 'laborRate', '28');
await first.locator('[data-action="add-charge"]').click();
await choose(page, first.locator('[data-charge]').last(), 'chargeType', '证书');
await fill(first, 'cost-materialRate', '885');
await fill(first, 'cost-labor', '60');
await form.locator('[data-action="add-line"]').click();
const second = form.locator('[data-line]').nth(1);
await choose(page, second, 'nameType', '足金999');
await radio(second, 'pricingMode', '直接填写金额');
await fill(second, 'quantity', '3.2');
await fill(second, 'priceNote', '古法手镯 · 一口价');
await fill(second, 'baseSale', '3380');
await second.locator('[data-action="add-charge"]').click();
await fill(second, 'cost-materialRate', '880');
await fill(second, 'cost-labor', '150');
const presets = form.locator('[data-preset] input[type=checkbox]');
if (await presets.count()) await presets.first().check();
const box = form.locator('[data-preset="box"] input[type=checkbox]');
if (await box.count()) {
await box.check();
await fill(form, 'cost_box_quantity', '2');
}
for (const input of await page.locator('.fee-row [data-field="feeAmount"] input').all())
if (!(await input.inputValue())) await input.fill('20');
await fill(form, 'discount', '18');
await fill(form, 'note', '手镯内圈刻字「安」');
await fill(form, 'internal_note', '#老客户 周末到店自取');
await page.locator('body').click({ position: { x: 2, y: 2 } });
await page.waitForTimeout(300);
}
async function issue(page, label, expectedTotal) {
const total = (await page.locator('[data-testid="create-total"]').innerText()).trim();
if (total === expectedTotal) ok(`${label} 表单合计 ${total}`);
@@ -230,9 +273,30 @@ try {
const label = name === 'mobile' ? '手机' : '桌面对照';
const { ctx, page } = await context(browser, base, label, viewport, mobile);
await page.goto(base + '/next/');
await page.waitForSelector('.login-form');
await page.waitForTimeout(300);
await page.screenshot({ path: path.join(COMPARE, `login-${name}-new.png`), fullPage: true });
{
// 旧界面登录页(尚未登录,同一宽度)
const oldLogin = await ctx.newPage();
await oldLogin.goto(base + '/');
await oldLogin.waitForSelector('#login-form');
await oldLogin.waitForTimeout(300);
await oldLogin.screenshot({ path: path.join(COMPARE, `login-${name}-old.png`), fullPage: true });
await oldLogin.close();
}
await loginNext(page, '麦麦');
await page.waitForTimeout(400);
await page.screenshot({ path: path.join(COMPARE, `create-${name}-new.png`), fullPage: true });
await page.screenshot({ path: path.join(COMPARE, `create-${name}-new-viewport.png`) });
if (!mobile) {
await fillShowcase(page);
await page.locator('#order-form [data-line]').nth(1).scrollIntoViewIfNeeded();
await page.evaluate(() => window.scrollBy(0, 180));
await page.waitForTimeout(300);
await page.screenshot({ path: path.join(COMPARE, `create-${name}-new-filled.png`) });
await page.screenshot({ path: path.join(COMPARE, `create-${name}-new-filled-full.png`), fullPage: true });
}
if (mobile) {
await overflow(page, '新版开单页');
await page.screenshot({ path: path.join(SHOTS, '07-mobile-login-create.png'), fullPage: true });
@@ -241,6 +305,16 @@ try {
await page.screenshot({ path: path.join(SHOTS, '08-mobile-filled.png'), fullPage: true });
await issue(page, '手机', '¥2,460');
await page.screenshot({ path: path.join(SHOTS, '09-mobile-issued.png'), fullPage: true });
await page.locator('[data-action="new-order"]').click();
await page.waitForSelector('#order-form');
await fillShowcase(page);
await overflow(page, '新版开单页(两行示例单)');
// 等上一张单的成功提示消失,避免遮挡截图。
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`) });
await page.screenshot({ path: path.join(COMPARE, `create-${name}-new-filled-full.png`), fullPage: true });
}
await csp(page, label);
// 旧界面同一账号同一宽度的开单页
@@ -251,6 +325,7 @@ try {
ok(`${label}:新界面登录后旧界面共用同一会话`);
await old.waitForTimeout(400);
await old.screenshot({ path: path.join(COMPARE, `create-${name}-old.png`), fullPage: true });
await old.screenshot({ path: path.join(COMPARE, `create-${name}-old-viewport.png`) });
await ctx.close();
}
ok('新旧开单页对照截图已保存(桌面、手机)');