51 lines
4.3 KiB
Plaintext
51 lines
4.3 KiB
Plaintext
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { chromium } from 'playwright';
|
|
const root = path.resolve('.qa/reliability-1.25.2/formal-web'), origin = 'http://127.0.0.1:4318';
|
|
assert.equal(fs.existsSync(root), false); fs.mkdirSync(root);
|
|
const bootstrap = await (await fetch(origin + '/api/bootstrap')).json();
|
|
assert.equal(bootstrap.version, '1.25.2');
|
|
const projects = bootstrap.projects.filter(row => row.root.replaceAll('\\', '/').endsWith('/releases/Agent-Workbench-0.1.0-win-x64/examples/starter-project'));
|
|
assert.equal(projects.length, 1); const project = projects[0];
|
|
const sessions = bootstrap.sessions.filter(row => row.projectId === project.id && row.title.startsWith('创建一个HTML'));
|
|
assert.equal(sessions.length, 1); const session = sessions[0]; assert.equal(session.status, 'completed');
|
|
const browser = await chromium.launch({ channel: 'msedge', headless: true }), context = await browser.newContext({ viewport: { width: 1440, height: 1080 } });
|
|
const rejectedWrites = [], errors = [], checks = [], views = []; let result;
|
|
await context.route('**/*', async route => {
|
|
const request = route.request();
|
|
if (request.url().startsWith(origin + '/api/') && !['GET', 'HEAD'].includes(request.method())) {
|
|
rejectedWrites.push({ method: request.method(), url: request.url() }); await route.abort();
|
|
} else await route.continue();
|
|
});
|
|
const page = await context.newPage(); page.on('pageerror', error => errors.push(error.message));
|
|
try {
|
|
await page.goto(origin + '/?release=1.25.2'); await page.locator('.connection.connected').waitFor();
|
|
await page.getByLabel('当前项目', { exact: true }).selectOption(project.id);
|
|
await page.locator('.session-list button').filter({ hasText: session.title }).click();
|
|
await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
|
|
const panel = page.getByLabel('要求与证据', { exact: true }); await panel.waitFor();
|
|
await panel.getByText('尚未逐项记录要求。模型的完成答复保留在原会话中。', { exact: true }).waitFor();
|
|
checks.push('Original completed Task opens its unconfigured requirement view without backfilling acceptance or shadow receipts');
|
|
for (const [label, width, height] of [['desktop', 1440, 1080], ['narrow', 390, 844]]) {
|
|
await page.setViewportSize({ width, height });
|
|
if (!await page.getByLabel('选择运行记录', { exact: true }).isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
|
|
await page.getByLabel('当前缺口与下一步', { exact: true }).getByText('当前文件已交付,按约定未测试', { exact: true }).waitFor();
|
|
await panel.scrollIntoViewIfNeeded();
|
|
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true);
|
|
assert.equal(await page.getByLabel('单轮观察', { exact: true }).count(), 0);
|
|
await page.screenshot({ path: path.join(root, label + '.png'), scale: 'css' });
|
|
fs.writeFileSync(path.join(root, label + '.txt'), await page.locator('body').innerText());
|
|
views.push({ label, width, height, requirementItems: await panel.locator('.requirement-list li').count(), legacyShadowPanels: 0 });
|
|
}
|
|
assert.deepEqual(errors, []); assert.deepEqual(rejectedWrites, []);
|
|
const health = await (await fetch(origin + '/api/health')).json(); assert.equal(health.pid, 36552); assert.equal(health.version, '1.25.2');
|
|
result = { success: true, version: health.version, pid: health.pid, projectId: project.id, sessionId: session.id, checks, views, errors, rejectedWrites,
|
|
realModelRequests: 0, scope: 'Read-only actual formal web UI after asynchronous follow-up has settled at both viewports; new requirement creation and new shadow runs are verified on isolated source/portable/installed fixtures.' };
|
|
} catch (error) {
|
|
await page.screenshot({ path: path.join(root, 'failure.png') }).catch(() => {});
|
|
fs.writeFileSync(path.join(root, 'failure.txt'), await page.locator('body').innerText().catch(() => 'Unavailable'));
|
|
result = { success: false, error: error.stack, checks, views, errors, rejectedWrites, realModelRequests: 0 }; process.exitCode = 1;
|
|
} finally { await browser.close(); }
|
|
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(result, null, 2) + '\n', { flag: 'wx' }); console.log(JSON.stringify(result));
|