feat: harden appointment flow and refresh handoff docs
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
async function main() {
|
||||
let chromium;
|
||||
try {
|
||||
({ chromium } = require('playwright'));
|
||||
} catch (error) {
|
||||
({ chromium } = require('@playwright/test'));
|
||||
}
|
||||
|
||||
const artifactDir = 'E:/yuminail/artifacts/full-regression';
|
||||
const runId = 'fd0608212248';
|
||||
const resultPath = path.join(artifactDir, `web_smoke_${runId}.json`);
|
||||
const loginShot = path.join(artifactDir, `web_admin_login_${runId}.png`);
|
||||
const dashboardShot = path.join(artifactDir, `web_admin_dashboard_${runId}.png`);
|
||||
const result = {
|
||||
runId,
|
||||
url: 'http://127.0.0.1:3000/admin/login',
|
||||
startedAt: new Date().toISOString(),
|
||||
status: 'BLOCKED',
|
||||
screenshots: [],
|
||||
checks: [],
|
||||
error: null
|
||||
};
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage({ viewport: { width: 1366, height: 768 } });
|
||||
try {
|
||||
await page.goto(result.url, { waitUntil: 'networkidle', timeout: 30000 });
|
||||
await page.screenshot({ path: loginShot, fullPage: true });
|
||||
result.screenshots.push(loginShot);
|
||||
const loginText = await page.locator('body').innerText({ timeout: 5000 }).catch(() => '');
|
||||
result.checks.push({
|
||||
name: 'login-page-text',
|
||||
pass: /登录|账号|密码|Fingertip Designer|后台/.test(loginText),
|
||||
detail: loginText.slice(0, 1000)
|
||||
});
|
||||
|
||||
const inputs = await page.locator('input').count();
|
||||
result.checks.push({ name: 'login-input-count', pass: inputs >= 2, detail: `inputs=${inputs}` });
|
||||
if (inputs >= 2) {
|
||||
await page.locator('input').nth(0).fill(`${runId}manager`);
|
||||
await page.locator('input').nth(1).fill('Aa888888!');
|
||||
await page.waitForTimeout(1200);
|
||||
}
|
||||
const buttons = await page.locator('button').count();
|
||||
result.checks.push({ name: 'login-button-count', pass: buttons >= 1, detail: `buttons=${buttons}` });
|
||||
if (buttons >= 1) {
|
||||
await page.locator('button').filter({ hasText: /登录|Sign/i }).first().click().catch(async () => {
|
||||
await page.locator('button').first().click();
|
||||
});
|
||||
}
|
||||
await page.waitForTimeout(3000);
|
||||
await page.screenshot({ path: dashboardShot, fullPage: true });
|
||||
result.screenshots.push(dashboardShot);
|
||||
const afterUrl = page.url();
|
||||
const dashboardText = await page.locator('body').innerText({ timeout: 5000 }).catch(() => '');
|
||||
result.checks.push({
|
||||
name: 'after-login-route',
|
||||
pass: /\/admin(\/|$)|\/dashboard/.test(afterUrl) && !/\/admin\/login$/.test(afterUrl),
|
||||
detail: afterUrl
|
||||
});
|
||||
result.checks.push({
|
||||
name: 'admin-page-content',
|
||||
pass: /店铺|订单|用户|作品|今日|后台|管理/.test(dashboardText),
|
||||
detail: dashboardText.slice(0, 1200)
|
||||
});
|
||||
result.status = result.checks.every(check => check.pass) ? 'PASS' : 'FAIL';
|
||||
} catch (error) {
|
||||
result.status = 'BLOCKED';
|
||||
result.error = error.stack || String(error);
|
||||
} finally {
|
||||
await browser.close();
|
||||
result.finishedAt = new Date().toISOString();
|
||||
fs.writeFileSync(resultPath, JSON.stringify(result, null, 2), 'utf8');
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user