feat: add task-bound real browser checks and verified page delivery
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { createHash } from 'node:crypto';
|
||||
|
||||
export function planBrowserBundle(appRoot) {
|
||||
const lock = JSON.parse(fs.readFileSync(path.join(appRoot, 'package-lock.json'), 'utf8'));
|
||||
const packages = ['playwright', 'playwright-core'].map(name => {
|
||||
const root = path.join(appRoot, 'node_modules', name), meta = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
||||
const declaration = lock.packages['node_modules/' + name];
|
||||
if (meta.version !== '1.64.1' || declaration.version !== meta.version || !declaration.integrity) throw new Error('Portable browser packages must match locked Playwright 1.64.1.');
|
||||
if (!fs.existsSync(path.join(root, 'LICENSE'))) throw new Error('The browser package requires its original LICENSE.');
|
||||
return { name, version: meta.version, root, integrity: declaration.integrity };
|
||||
});
|
||||
return { version: '1.64.1', packages };
|
||||
}
|
||||
export function copyBrowserBundle(runtimeDirectory, plan) {
|
||||
const runtime = path.resolve(runtimeDirectory), output = path.join(runtime, 'node_modules'), packages = [];
|
||||
const copy = (root, destination, relative = '') => {
|
||||
const records = [];
|
||||
for (const entry of fs.readdirSync(path.join(root, relative), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
||||
if (entry.isSymbolicLink()) throw new Error('Browser runtime input cannot be a link.');
|
||||
const file = path.join(relative, entry.name), target = path.resolve(destination, file);
|
||||
if (!target.startsWith(output + path.sep)) throw new Error('Browser bundle escaped the owned runtime.');
|
||||
if (entry.isDirectory()) { fs.mkdirSync(target, { recursive: true }); records.push(...copy(root, destination, file)); continue; }
|
||||
const bytes = fs.readFileSync(path.join(root, file)); fs.mkdirSync(path.dirname(target), { recursive: true }); fs.writeFileSync(target, bytes);
|
||||
records.push({ path: file.replaceAll('\\', '/'), bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') });
|
||||
}
|
||||
return records;
|
||||
};
|
||||
for (const pkg of plan.packages) packages.push({ name: pkg.name, version: pkg.version, integrity: pkg.integrity,
|
||||
files: copy(pkg.root, path.join(output, pkg.name)) });
|
||||
const result = { schemaVersion: 1, kind: 'workbench-browser-runtime', playwrightVersion: plan.version, browser: 'local Microsoft Edge',
|
||||
scope: 'win32-x64 static build checks; browser executable remains the locally installed Edge', packages };
|
||||
fs.writeFileSync(path.join(runtime, 'BROWSER-RUNTIME.json'), JSON.stringify(result, null, 2) + '\n'); return result;
|
||||
}
|
||||
@@ -3,11 +3,13 @@ import path from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { planReaBundle, copyReaBundle } from './bundle-rea.mjs';
|
||||
import { planBrowserBundle, copyBrowserBundle } from './bundle-browser.mjs';
|
||||
|
||||
const root = process.cwd();
|
||||
const meta = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||
const lock = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'));
|
||||
const reaPlan = planReaBundle(root);
|
||||
const browserPlan = planBrowserBundle(root);
|
||||
const releases = path.resolve(root, 'releases');
|
||||
fs.mkdirSync(releases, { recursive: true });
|
||||
const baseName = 'Agent-Workbench-' + meta.version;
|
||||
@@ -46,6 +48,8 @@ if (!fs.existsSync(path.join(npmRoot, 'bin', 'npm-cli.js'))) throw new Error('Th
|
||||
copyTree(npmRoot, path.join(portableRoot, 'runtime', 'node_modules', 'npm'));
|
||||
const reaRuntime = copyReaBundle(path.join(portableRoot, 'runtime'), reaPlan);
|
||||
copyReaBundle(path.join(sourceRoot, 'runtime'), reaPlan);
|
||||
const browserRuntime = copyBrowserBundle(path.join(portableRoot, 'runtime'), browserPlan);
|
||||
copyBrowserBundle(path.join(sourceRoot, 'runtime'), browserPlan);
|
||||
|
||||
const notices = ['Agent Workbench third-party notices', '',
|
||||
'Original product code is supplied for the project owner. Its redistribution terms are determined by the project owner.',
|
||||
@@ -113,5 +117,6 @@ function archive(directory) {
|
||||
return { path: destination, bytes: fs.statSync(destination).size, sha256: createHash('sha256').update(fs.readFileSync(destination)).digest('hex') };
|
||||
}
|
||||
const result = { portableRoot, sourceRoot, portable: archive(portableRoot), source: archive(sourceRoot), nodeVersion, reaRuntime, portableFiles: portableManifest.files.length, licenseTexts: licenseCount + 2 };
|
||||
result.browserRuntime = { playwrightVersion: browserRuntime.playwrightVersion, packages: browserRuntime.packages.map(pkg => ({ name: pkg.name, version: pkg.version, files: pkg.files.length })) };
|
||||
fs.writeFileSync(path.join(releases, 'latest.json'), JSON.stringify(result, null, 2));
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
|
||||
@@ -64,7 +64,7 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
|
||||
if (!fs.existsSync(originalScript) || !fs.existsSync(upgradeScript) || !fs.existsSync(path.join(next, 'dist-client', 'index.html'))) throw new Error('Upgrade bundles are incomplete.');
|
||||
if (!Number.isInteger(pid) || pid < 1 || pid === process.pid) throw new Error('Invalid target process.');
|
||||
const before = await readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read original Workbench');
|
||||
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
|
||||
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
|
||||
if (before.sessions.some(session => ['running', 'awaiting_approval', 'stopping'].includes(session.status))) throw new Error('Wait for existing tasks and approvals before upgrading.');
|
||||
let protocol, socket, enabledHere = false, paused = false;
|
||||
const breakpoints = [];
|
||||
|
||||
@@ -6,18 +6,19 @@ import { gitEnvironment } from '../src/core/git-process.mjs';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
|
||||
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0'].includes(version), 'Review evidence paths when introducing the next release.');
|
||||
const prefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context' : version === '1.6.2' ? 'working-retention' : version === '1.7.0' ? 'python-engine' : version === '1.9.0' ? 'external-engines' : 'rea-engine', resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
|
||||
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0'].includes(version), 'Review evidence paths when introducing the next release.');
|
||||
const prefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context' : version === '1.6.2' ? 'working-retention' : version === '1.7.0' ? 'python-engine' : version === '1.10.0' ? 'browser-engine' : version === '1.9.0' ? 'external-engines' : 'rea-engine', resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
|
||||
const cases = [
|
||||
...(version === '1.10.0' ? [['verify-browser-ui.mjs', 'docs/browser-engine-browser-ui-validation.json']] : []),
|
||||
['verify-ui.mjs', '.qa/ui-validation.json'], ['verify-diagnostics-ui.mjs', '.qa/diagnostics-ui-validation.json'],
|
||||
['verify-execution-ui.mjs', '.qa/execution-ui-validation.json'], ['verify-delivery-ui.mjs', '.qa/delivery-ui-validation.json'],
|
||||
['verify-index-ui.mjs', '.qa/index-ui-result.json'], ['verify-change-sets-ui.mjs', `docs/${prefix}-batch-ui-validation.json`],
|
||||
['verify-context-ui.mjs', `.qa/${version === '1.6.0' ? 'workspaces-context' : prefix}-ui-validation.json`],
|
||||
['verify-workspaces-ui.mjs', `docs/${prefix === 'workspaces' ? prefix : prefix + '-workspaces'}-ui-validation.json`],
|
||||
...(['1.7.0', '1.8.0', '1.9.0'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
|
||||
...(['1.7.0', '1.8.0', '1.9.0'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
|
||||
...(['1.8.0', '1.9.0'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
|
||||
...(version === '1.9.0' ? [['verify-engines-ui.mjs', 'docs/engines-ui-validation.json']] : []),
|
||||
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
|
||||
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
|
||||
...(['1.8.0', '1.9.0', '1.10.0'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
|
||||
...(['1.9.0', '1.10.0'].includes(version) ? [['verify-engines-ui.mjs', version === '1.10.0' ? 'docs/browser-engine-engines-ui-validation.json' : 'docs/engines-ui-validation.json']] : []),
|
||||
];
|
||||
fs.mkdirSync('.qa', { recursive: true });
|
||||
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { chromium, expect } from 'playwright/test';
|
||||
import { fixture, launchWorkbench } from '../tests/helpers.mjs';
|
||||
import { createBrowserProject } from '../tests/fixtures/browser-project.mjs';
|
||||
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-browser-ui.mjs — independent real Edge browser plans, review, results, images, mobile, stop, late response and restart'); process.exit(0); }
|
||||
const directory = path.resolve('.qa', 'browser-ui-' + randomUUID()); fs.mkdirSync(directory, { recursive: true });
|
||||
const disposers = [], t = { after: value => disposers.push(value) }, f = createBrowserProject(fixture(t));
|
||||
f.session.title = '工程实际页面验收';
|
||||
const indexFile = path.join(f.projectRoot, 'dist', 'index.html'); fs.writeFileSync(indexFile, fs.readFileSync(indexFile, 'utf8').replace('<h1>', '<p>' + '页面证据 '.repeat(1800) + '</p><h1>'));
|
||||
f.store.save(f.session); f.store.close(); let host = await launchWorkbench(t, f.data), route = '/sessions/' + f.session.id;
|
||||
assert.notEqual(new URL(host.url).port, '4318'); assert.equal(host.bootstrap.config.hasKey, false);
|
||||
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
const passed = [], pageErrors = [], requestFailures = [], screenshots = [], actualJobs = []; let result, deliberateNavigation = false;
|
||||
page.on('pageerror', error => pageErrors.push(error.message));
|
||||
page.on('requestfailed', request => { if (!deliberateNavigation) requestFailures.push(request.url() + ': ' + request.failure()?.errorText); });
|
||||
const panel = () => page.getByLabel('工程页面验收', { exact: true }), state = () => host.api(route);
|
||||
const mark = message => { passed.push(message); console.log('PASS ' + message); };
|
||||
const screenshot = async name => { const file = path.join(directory, name + '.png'); await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file); };
|
||||
const sha = value => createHash('sha256').update(value).digest('hex');
|
||||
async function selectTask() {
|
||||
await page.getByLabel('当前项目').selectOption(f.project.id);
|
||||
await page.locator('.session-list button').filter({ hasText: f.session.title }).click();
|
||||
await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
|
||||
await expect(panel().getByRole('button', { name: '封存页面计划', exact: true })).toBeEnabled();
|
||||
}
|
||||
async function seal() {
|
||||
const old = (await state()).execution.browserPlans.at(-1)?.id;
|
||||
await panel().getByRole('button', { name: '封存页面计划', exact: true }).click();
|
||||
await expect.poll(async () => (await state()).execution.browserPlans.at(-1)?.id).not.toBe(old);
|
||||
return (await state()).execution.browserPlans.at(-1);
|
||||
}
|
||||
async function start() {
|
||||
await panel().getByRole('button', { name: '运行这份计划', exact: true }).click();
|
||||
await page.getByRole('dialog', { name: '执行页面检查', exact: true }).getByRole('button', { name: '确认运行页面检查', exact: true }).click();
|
||||
}
|
||||
async function finished() {
|
||||
await expect.poll(async () => (await state()).execution.browserJobs.at(-1)?.finishedAt, { timeout: 20000 }).toBeTruthy();
|
||||
const job = (await state()).execution.browserJobs.at(-1); actualJobs.push(job); return job;
|
||||
}
|
||||
async function original(job) {
|
||||
let text = '', offset = 0, value;
|
||||
do { value = await host.api(route + '/browser-jobs/' + job.id + '/record?offset=' + offset + '&limit=8000'); text += value.content; offset += value.content.length; } while (value.truncated);
|
||||
assert.equal(sha(text), job.resultSha256); fs.writeFileSync(path.join(directory, 'original-' + job.id + '.json'), text); return JSON.parse(text);
|
||||
}
|
||||
try {
|
||||
await page.goto(host.url); await page.waitForLoadState('networkidle'); await selectTask();
|
||||
await expect(panel()).toContainText('Edge · 实际浏览器'); assert.equal((await state()).execution.browserJobs.length, 0);
|
||||
for (let index = 1; index <= 3; index++) await panel().getByRole('button', { name: '添加步骤', exact: true }).click();
|
||||
await panel().getByLabel('步骤 1 操作').selectOption('click'); await panel().getByLabel('步骤 1 元素').fill('#toggle');
|
||||
await panel().getByLabel('步骤 2 操作').selectOption('assert_text'); await panel().getByLabel('步骤 2 元素').fill('#state'); await panel().getByLabel('步骤 2 预期文字').fill('已完成');
|
||||
await panel().getByLabel('步骤 3 操作').selectOption('assert_count'); await panel().getByLabel('步骤 3 元素').fill('button'); await panel().getByLabel('步骤 3 预期数量').fill('1');
|
||||
const plan = await seal(); assert.equal(plan.steps.length, 3); assert.equal(plan.build.files, 2); assert.equal((await state()).execution.browserJobs.length, 0);
|
||||
mark('actual step editor seals the chosen build, viewport and three CSS interactions without opening the page');
|
||||
|
||||
await panel().getByRole('button', { name: '运行这份计划', exact: true }).click();
|
||||
const confirm = page.getByRole('dialog', { name: '执行页面检查', exact: true }); await expect(confirm).toContainText('1280×900'); await expect(confirm).toContainText('#state'); await expect(confirm).toContainText(plan.build.sha256);
|
||||
await confirm.getByRole('button', { name: '取消', exact: true }).click(); assert.equal((await state()).execution.browserJobs.length, 0);
|
||||
mark('review shows exact build identity and planned assertions; cancelling executes no browser work');
|
||||
|
||||
await start(); const success = await finished(); assert.equal(success.status, 'passed', success.summary); assert.equal(success.assertions.total, 2); assert.equal(success.cleanup.exited, true);
|
||||
await expect(panel()).toContainText('实际断言 2/2'); const succeeded = await original(success); assert.equal(succeeded.steps[2].actual, 1);
|
||||
assert.ok(succeeded.pages.at(-1).text.includes('已完成')); await screenshot('browser-desktop-results');
|
||||
mark('real inner Edge clicks the intended element and the two counted assertions display with original Task/Run/build identity');
|
||||
|
||||
await panel().getByRole('button', { name: '查看原执行记录', exact: true }).first().click();
|
||||
const record = () => page.getByRole('dialog', { name: '浏览器原执行记录', exact: true }); await expect(record()).toContainText(success.resultSha256);
|
||||
await expect(record().getByRole('button', { name: '下一段', exact: true })).toBeEnabled();
|
||||
const first = await record().locator('.artifact-preview').textContent(); await record().getByRole('button', { name: '下一段', exact: true }).click();
|
||||
await expect.poll(async () => await record().locator('.artifact-preview').textContent()).not.toBe(first); await expect(record()).toContainText('字符 8000');
|
||||
await record().getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
const downloading = page.waitForEvent('download'); await panel().getByRole('button', { name: '下载原结果', exact: true }).first().click();
|
||||
const download = await downloading, downloadPath = await download.path(); assert.equal(sha(fs.readFileSync(downloadPath)), success.resultSha256);
|
||||
mark('original large JSON is paged in the UI and downloads the complete hash-identical result');
|
||||
|
||||
await panel().getByRole('button', { name: '最终截图', exact: true }).first().click(); const image = () => page.getByRole('dialog', { name: '原始页面截图', exact: true });
|
||||
await expect.poll(async () => image().locator('img').evaluate(node => node.naturalWidth)).toBe(1280); await expect(image()).toContainText(success.screenshots.at(-1).sha256);
|
||||
const imageDownload = page.waitForEvent('download'); await image().getByRole('button', { name: '下载原始PNG', exact: true }).click();
|
||||
const png = await imageDownload, pngPath = await png.path(); assert.equal(sha(fs.readFileSync(pngPath)), success.screenshots.at(-1).sha256);
|
||||
await screenshot('browser-desktop-original-image'); await image().getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
mark('the original screenshot renders at its actual resolution and downloads identical PNG bytes');
|
||||
|
||||
await panel().getByLabel('步骤 3 预期数量').fill('2'); await seal(); await start(); const failure = await finished();
|
||||
assert.equal(failure.status, 'failed'); const failed = await original(failure); assert.equal(failed.steps[2].actual, 1); assert.equal(failed.assertions.failed, 1);
|
||||
await expect(panel()).toContainText('第3步失败'); await expect(panel().getByRole('button', { name: '运行这份计划', exact: true })).toBeDisabled();
|
||||
mark('a real failed assertion retains actual count one and requires a newly reviewed plan instead of replaying');
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 844 }); await expect(page.locator('.workbench')).toHaveClass(/sidebar-hidden/);
|
||||
await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
|
||||
await panel().getByLabel('浏览器视口').selectOption('mobile'); await panel().getByLabel('步骤 3 预期数量').fill('1'); await seal(); await start(); const mobile = await finished();
|
||||
assert.equal(mobile.status, 'passed', mobile.summary); assert.equal(mobile.screenshots.at(-1).width, 390);
|
||||
assert.ok(await page.locator('body').evaluate(node => node.scrollWidth <= 390)); await screenshot('browser-mobile-results');
|
||||
await panel().getByRole('button', { name: '最终截图', exact: true }).first().click(); await expect.poll(async () => image().locator('img').evaluate(node => node.naturalWidth)).toBe(390);
|
||||
await screenshot('browser-mobile-original-image'); await image().getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
mark('390px forms and result records remain usable and the inner browser captures its real 390px layout');
|
||||
|
||||
await panel().getByRole('button', { name: '添加步骤', exact: true }).click(); await panel().getByLabel('步骤 4 操作').selectOption('assert_count');
|
||||
await panel().getByLabel('步骤 4 元素').fill('.never-present'); await panel().getByLabel('步骤 4 预期数量').fill('1'); await seal(); await start();
|
||||
await expect.poll(async () => (await state()).execution.browserJobs.at(-1)?.steps.length, { timeout: 15000 }).toBe(3);
|
||||
await panel().getByRole('button', { name: '停止浏览器检查', exact: true }).click(); const stopped = await finished();
|
||||
assert.equal(stopped.status, 'interrupted'); assert.equal(stopped.cleanup.exited, true); assert.equal(stopped.steps[0].status, 'passed');
|
||||
assert.equal((await state()).execution.browserJobs.length, 4);
|
||||
mark('stopping an actual in-flight assertion closes its owned browser and preserves prior successful and failed jobs');
|
||||
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
if (await page.getByRole('button', { name: '展开项目栏', exact: true }).count()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
|
||||
let held, release; const delivered = new Promise(resolve => { release = resolve; });
|
||||
const matcher = '**/browser-jobs/' + mobile.id + '/record?*';
|
||||
await page.route(matcher, pending => { held = pending; return delivered; });
|
||||
// Locate by original sequence: interrupted job, mobile success, failed job, desktop success.
|
||||
await panel().locator('.browser-result').nth(1).getByRole('button', { name: '查看原执行记录', exact: true }).click();
|
||||
await expect.poll(() => !!held).toBeTruthy(); const originalSession = (await state()).id;
|
||||
await page.getByRole('button', { name: '新建任务', exact: true }).first().click();
|
||||
await expect.poll(async () => (await host.api('/sessions?project=' + f.project.id)).length).toBe(2);
|
||||
await expect.poll(async () => page.evaluate(() => localStorage.getItem('awb-session'))).not.toBe(originalSession);
|
||||
await held.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ error: '原任务迟到错误' }) }); release(); await page.unroute(matcher);
|
||||
await expect(page.getByText('原任务迟到错误', { exact: false })).toHaveCount(0); assert.equal((await state()).id, originalSession);
|
||||
mark('a delayed original-record failure stays with its source and does not appear in a newly selected task');
|
||||
|
||||
const before = (await state()).execution.browserJobs; deliberateNavigation = true; await host.close(); host = await launchWorkbench(t, f.data);
|
||||
await page.goto(host.url); await page.waitForLoadState('networkidle'); deliberateNavigation = false; await selectTask();
|
||||
assert.deepEqual((await state()).execution.browserJobs, before); assert.equal((await state()).execution.task.usage.requests, 0);
|
||||
await panel().getByRole('button', { name: '最终截图', exact: true }).first().click(); await expect.poll(async () => image().locator('img').evaluate(node => node.naturalWidth)).toBe(390);
|
||||
await image().getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
mark('actual host restart preserves the four original browser jobs and PNGs without model requests or execution replay');
|
||||
assert.deepEqual(pageErrors, []); assert.deepEqual(requestFailures, []);
|
||||
result = { success: true, version: host.bootstrap.version, testedAt: new Date().toISOString(), directory, passed, pageErrors, requestFailures,
|
||||
screenshots, taskId: actualJobs[0].taskId, sessionId: f.session.id, jobs: actualJobs.map(job => ({ id: job.id, status: job.status, planId: job.planId,
|
||||
assertions: job.assertions, resultSha256: job.resultSha256, cleanup: job.cleanup, screenshots: job.screenshots })),
|
||||
scope: 'Actual independent Workbench UI plus real Edge static-build executions. The configured production Provider, other projects and keys are not accessed.' };
|
||||
} catch (error) {
|
||||
await screenshot('browser-ui-failure').catch(() => {}); fs.writeFileSync(path.join(directory, 'failure-dom.html'), await page.content().catch(() => ''));
|
||||
result = { success: false, version: host.bootstrap.version, testedAt: new Date().toISOString(), directory, passed, pageErrors, requestFailures, screenshots, error: error.stack }; process.exitCode = 1;
|
||||
} finally { deliberateNavigation = true; await browser.close(); for (const dispose of disposers.reverse()) await dispose(); }
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n');
|
||||
fs.writeFileSync('docs/browser-engine-browser-ui-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
console.log(JSON.stringify({ success: result.success, version: result.version, groups: passed.length, directory, error: result.error }));
|
||||
@@ -0,0 +1,109 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const sha = value => createHash('sha256').update(value).digest('hex');
|
||||
async function until(predicate, timeout = 20000) {
|
||||
const deadline = Date.now() + timeout;
|
||||
while (!await predicate()) {
|
||||
if (Date.now() >= deadline) throw new Error('Owned browser verification timed out.');
|
||||
await new Promise(resolve => setTimeout(resolve, 30));
|
||||
}
|
||||
}
|
||||
|
||||
export async function verifyBrowserApi({ api, url, token, directory, appRoot, contained = false }) {
|
||||
const projectRoot = path.join(directory, 'browser-project'); fs.mkdirSync(path.join(projectRoot, 'dist'), { recursive: true });
|
||||
fs.writeFileSync(path.join(projectRoot, 'README.md'), '# Owned portable browser acceptance\n');
|
||||
fs.writeFileSync(path.join(projectRoot, 'dist', 'index.html'), '<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>随包页面验收</title>'
|
||||
+ '<style>body{font:16px sans-serif;margin:20px}input,select,button{display:block;max-width:100%;margin:12px 0}</style><h1>实际随包浏览器</h1>'
|
||||
+ '<input id="query" aria-label="搜索"><select id="filter"><option value="all">全部</option><option value="pending">待办</option></select>'
|
||||
+ '<button id="toggle">切换</button><p id="state">待办</p><script src="/app.js"></script></html>');
|
||||
fs.writeFileSync(path.join(projectRoot, 'dist', 'app.js'), 'document.querySelector("#toggle").addEventListener("click",()=>document.querySelector("#state").textContent="已完成");');
|
||||
const project = await api('/projects', { root: projectRoot }), session = await api('/sessions', { projectId: project.id }), route = '/sessions/' + session.id;
|
||||
await api(route + '/messages', { content: '为自有静态工程创建独立验收任务。' }); let current;
|
||||
await until(async () => { current = await api(route); return current.status === 'awaiting_approval'; });
|
||||
const approval = current.approvals.find(value => value.status === 'pending'); assert.equal(approval.command, 'node --version');
|
||||
await api(route + '/approvals/' + approval.id, { allow: true });
|
||||
await until(async () => { current = await api(route); return current.status === 'needs_review'; });
|
||||
for (const change of current.changes.filter(value => value.status === 'pending')) await api(route + '/changes/' + change.id + '/reject', {});
|
||||
const taskId = (await api(route)).execution.task.id, availability = (await api(route + '/browser')).availability;
|
||||
assert.equal(availability.status, 'available', availability.message); assert.equal(availability.playwrightVersion, '1.64.1');
|
||||
const steps = [{ action: 'fill', selector: '#query', value: '本地页面验收' }, { action: 'select', selector: '#filter', value: 'pending' },
|
||||
{ action: 'assert_count', selector: 'button', count: 1 }, { action: 'assert_text', selector: '#state', text: '待办' },
|
||||
{ action: 'click', selector: '#toggle' }, { action: 'assert_text', selector: '#state', text: '已完成' }];
|
||||
const results = [];
|
||||
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
||||
const planned = await api(route + '/browser-plans', { steps, viewport }), plan = planned.execution.browserPlans.at(-1);
|
||||
const contract = await api('/artifacts/' + plan.contractArtifactId + '?session=' + session.id + '&limit=16000');
|
||||
assert.equal(contract.truncated, false); assert.equal(sha(contract.content), contract.sha256);
|
||||
const sealed = JSON.parse(contract.content); assert.equal(sealed.id, plan.id); assert.equal(sealed.taskId, taskId);
|
||||
assert.equal(sealed.installation.playwrightVersion, '1.64.1');
|
||||
if (contained) assert.ok(sealed.installation.modulePath.startsWith(fs.realpathSync.native(path.join(appRoot, 'runtime', 'node_modules')) + path.sep));
|
||||
await api(route + '/browser-jobs', { planId: plan.id }); let job;
|
||||
await until(async () => { job = (await api(route)).execution.browserJobs.at(-1); return !!job?.finishedAt; }, 25000);
|
||||
assert.equal(job.status, 'passed', job.summary); assert.equal(job.taskId, taskId); assert.equal(job.assertions.passed, 3);
|
||||
assert.equal(job.cleanup.exited, true); assert.equal(job.cleanup.previewClosed, true); assert.equal(job.cleanup.snapshotDisposed, true);
|
||||
let text = '', offset = 0, originalPage;
|
||||
do { originalPage = await api(route + '/browser-jobs/' + job.id + '/record?offset=' + offset + '&limit=4000'); text += originalPage.content; offset += originalPage.content.length; } while (originalPage.truncated);
|
||||
assert.equal(sha(text), job.resultSha256); const original = JSON.parse(text), actualPage = original.pages.at(-1);
|
||||
assert.equal(original.steps[0].actual, '本地页面验收'); assert.deepEqual(original.steps[1].actual, ['pending']);
|
||||
assert.deepEqual(original.pageErrors, []); assert.deepEqual(original.blockedRequests, []); assert.equal(actualPage.viewport.width, viewport.width);
|
||||
assert.ok(actualPage.text.includes('已完成')); if (viewport.width === 390) assert.ok(actualPage.viewport.scrollWidth <= 390);
|
||||
fs.writeFileSync(path.join(directory, 'browser-original-' + viewport.width + '.json'), text);
|
||||
const image = job.screenshots.at(-1), response = await fetch(url + '/api' + route + '/browser-jobs/' + job.id + '/images/' + image.artifactId,
|
||||
{ headers: { 'X-Workbench-Token': token, Connection: 'close' }, signal: AbortSignal.timeout(15000) });
|
||||
assert.equal(response.status, 200); assert.equal(response.headers.get('content-type'), 'image/png'); const bytes = Buffer.from(await response.arrayBuffer());
|
||||
assert.equal(sha(bytes), image.sha256); assert.equal(bytes.length, image.bytes); assert.equal(bytes.readUInt32BE(16), viewport.width); assert.equal(bytes.readUInt32BE(20), viewport.height);
|
||||
fs.writeFileSync(path.join(directory, 'browser-original-' + viewport.width + '.png'), bytes);
|
||||
const reused = await api(route + '/browser-jobs', { planId: plan.id }); assert.equal(reused.execution.browserJobs.at(-1).id, job.id);
|
||||
assert.equal(reused.execution.browserJobs.length, results.length + 1);
|
||||
results.push({ jobId: job.id, taskId, viewport, status: job.status, assertions: job.assertions, resultSha256: job.resultSha256,
|
||||
buildSha256: job.buildSha256, screenshotSha256: image.sha256, browserExited: job.cleanup.exited, reusedOriginalJob: true });
|
||||
}
|
||||
return { success: true, installation: availability, results, modelRequests: 0,
|
||||
scope: 'Actual API, locked browser runtime, two isolated Edge processes, CSS interactions, original DOM and PNG bytes. The task is created through the offline demonstration; no remote model is used.' };
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-browser.mjs [--app-root <source-or-portable-directory>] [--contained]'); return; }
|
||||
const index = process.argv.indexOf('--app-root'); if (index >= 0 && !process.argv[index + 1]) throw new Error('--app-root needs an absolute or relative directory.');
|
||||
const appRoot = fs.realpathSync.native(path.resolve(index >= 0 ? process.argv[index + 1] : '.'));
|
||||
const directory = path.resolve('.qa', 'browser-native-' + randomUUID()), data = path.join(directory, 'data'); fs.mkdirSync(data, { recursive: true });
|
||||
const allowed = /^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all)$/i;
|
||||
const env = { ...Object.fromEntries(Object.entries(process.env).filter(([name]) => allowed.test(name))),
|
||||
AGENT_WORKBENCH_APP_DIR: appRoot, AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: '0' };
|
||||
const runtime = path.join(appRoot, 'runtime', 'node.exe');
|
||||
const child = spawn(fs.existsSync(runtime) ? runtime : process.execPath, [path.join(appRoot, 'dist-server', 'server.mjs')],
|
||||
{ cwd: appRoot, env, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
let url = '', stdout = '', stderr = '', api, result;
|
||||
child.stdout.on('data', bytes => { stdout += bytes.toString('utf8'); for (const line of stdout.split('\n')) { try { const value = JSON.parse(line); if (value.ready) url = value.url; } catch {} } });
|
||||
child.stderr.on('data', bytes => { stderr += bytes.toString('utf8'); });
|
||||
try {
|
||||
await until(() => url || child.exitCode !== null, 10000); assert.ok(url, 'Owned host failed: ' + stderr); assert.notEqual(new URL(url).port, '4318');
|
||||
const bootstrap = await (await fetch(url + '/api/bootstrap')).json(); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const health = await (await fetch(url + '/api/health')).json(); assert.equal(health.pid, child.pid);
|
||||
api = async (route, input) => {
|
||||
const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' },
|
||||
...(input === undefined ? {} : { body: JSON.stringify(input) }), signal: AbortSignal.timeout(20000) });
|
||||
const value = await response.json(); assert.ok(response.ok, value.error); return value;
|
||||
};
|
||||
result = { ...await verifyBrowserApi({ api, url, token: bootstrap.token, directory, appRoot, contained: process.argv.includes('--contained') }),
|
||||
version: bootstrap.version, directory, appRoot, testedAt: new Date().toISOString(), ownedHostPid: child.pid };
|
||||
} catch (error) { result = { success: false, directory, appRoot, error: error.stack }; process.exitCode = 1; }
|
||||
finally {
|
||||
if (api && child.exitCode === null) {
|
||||
try { await api('/shutdown', {}); await until(() => child.exitCode !== null || child.signalCode !== null, 10000); }
|
||||
catch (error) { result.success = false; result.shutdownError = error.message; process.exitCode = 1; }
|
||||
}
|
||||
if (child.exitCode === null && child.signalCode === null) child.kill();
|
||||
await until(() => child.exitCode !== null || child.signalCode !== null, 5000); result.rootExited = true;
|
||||
fs.writeFileSync(path.join(directory, 'host.log'), stdout + '\n' + stderr);
|
||||
}
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n');
|
||||
fs.writeFileSync('.qa/browser-native-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
console.log(JSON.stringify({ success: result.success, version: result.version, directory, results: result.results, modelRequests: 0, rootExited: result.rootExited, error: result.error, shutdownError: result.shutdownError }));
|
||||
}
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main();
|
||||
@@ -33,8 +33,8 @@ child.stdout.on('data', value => { output += value; for (const line of output.sp
|
||||
child.stderr.on('data', value => { errors += value; });
|
||||
const wait = async predicate => { const deadline = Date.now() + 15000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('UI fixture timed out: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
|
||||
await wait(() => url); const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
|
||||
assert.ok(['1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const proofPrefix = bootstrap.version === '1.4.0' ? 'm2-batch' : bootstrap.version === '1.5.0' ? 'context-batch' : bootstrap.version === '1.5.1' ? 'context-fix-batch' : bootstrap.version === '1.6.0' ? 'workspaces-batch' : bootstrap.version === '1.6.1' ? 'working-context-batch' : bootstrap.version === '1.6.2' ? 'working-retention-batch' : bootstrap.version === '1.7.0' ? 'python-engine-batch' : bootstrap.version === '1.9.0' ? 'external-engines-batch' : 'rea-engine-batch';
|
||||
assert.ok(['1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const proofPrefix = bootstrap.version === '1.4.0' ? 'm2-batch' : bootstrap.version === '1.5.0' ? 'context-batch' : bootstrap.version === '1.5.1' ? 'context-fix-batch' : bootstrap.version === '1.6.0' ? 'workspaces-batch' : bootstrap.version === '1.6.1' ? 'working-context-batch' : bootstrap.version === '1.6.2' ? 'working-retention-batch' : bootstrap.version === '1.7.0' ? 'python-engine-batch' : bootstrap.version === '1.10.0' ? 'browser-engine-batch' : bootstrap.version === '1.9.0' ? 'external-engines-batch' : 'rea-engine-batch';
|
||||
const screenshotPrefix = bootstrap.version === '1.4.0' ? '1.4-batch' : proofPrefix;
|
||||
const api = async (route, input) => { const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' },
|
||||
...(input === undefined ? {} : { body: JSON.stringify(input) }) }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
|
||||
|
||||
@@ -76,9 +76,9 @@ child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
|
||||
const until = async predicate => { const deadline = Date.now() + 20000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('Context UI fixture timeout: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
|
||||
await until(() => url || child.exitCode !== null); assert.ok(url, errors);
|
||||
const bootstrap = await (await fetch(url + '/api/bootstrap', { headers: { Connection: 'close' } })).json();
|
||||
assert.ok(['1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
assert.ok(['1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const api = async route => { const response = await fetch(url + '/api' + route, { headers: { 'X-Workbench-Token': bootstrap.token, Connection: 'close' } }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
|
||||
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : bootstrap.version === '1.5.1' ? 'context-fix' : bootstrap.version === '1.6.0' ? 'workspaces-context' : bootstrap.version === '1.6.1' ? 'working-context' : bootstrap.version === '1.6.2' ? 'working-retention' : bootstrap.version === '1.7.0' ? 'python-engine' : bootstrap.version === '1.9.0' ? 'external-engines' : 'rea-engine';
|
||||
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : bootstrap.version === '1.5.1' ? 'context-fix' : bootstrap.version === '1.6.0' ? 'workspaces-context' : bootstrap.version === '1.6.1' ? 'working-context' : bootstrap.version === '1.6.2' ? 'working-retention' : bootstrap.version === '1.7.0' ? 'python-engine' : bootstrap.version === '1.10.0' ? 'browser-engine' : bootstrap.version === '1.9.0' ? 'external-engines' : 'rea-engine';
|
||||
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
const passed = [], pageErrors = [], requestFailures = [], screenshots = [];
|
||||
page.on('pageerror', error => pageErrors.push(error.message));
|
||||
|
||||
@@ -137,5 +137,5 @@ try {
|
||||
result = { success: false, version: host.bootstrap.version, testedAt: new Date().toISOString(), root, passed, pageErrors, requestFailures, expectedRequestFailures, screenshots, error: error.stack }; process.exitCode = 1;
|
||||
} finally { deliberateNavigation = true; await browser.close(); for (const dispose of disposers.reverse()) await dispose(); }
|
||||
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(result, null, 2) + '\n');
|
||||
fs.writeFileSync('docs/engines-ui-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
fs.writeFileSync(result.version === '1.10.0' ? 'docs/browser-engine-engines-ui-validation.json' : 'docs/engines-ui-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
console.log(JSON.stringify({ success: result.success, version: result.version, groups: passed.length, root, pageErrors, requestFailures, error: result.error }));
|
||||
|
||||
@@ -12,7 +12,7 @@ const protectedFiles = createPythonDeliveryProject(f), source = captureWorkspace
|
||||
f.session.title = 'Python工程检查与交付'; f.store.core.task.get(f.session.taskId).goal = '修复三个Python模块,保护测试与声明,核对实际检查并交付本地Git报告。';
|
||||
f.store.save(f.session); f.store.close();
|
||||
const host = await launchWorkbench(t, f.data, process.env.AGENT_WORKBENCH_TEST_PYTHON ? { AGENT_WORKBENCH_PYTHON_PATH: process.env.AGENT_WORKBENCH_TEST_PYTHON } : {});
|
||||
const proofPrefix = host.bootstrap.version === '1.8.0' ? 'rea-engine' : host.bootstrap.version === '1.9.0' ? 'external-engines' : 'python-engine';
|
||||
const proofPrefix = host.bootstrap.version === '1.8.0' ? 'rea-engine' : host.bootstrap.version === '1.10.0' ? 'browser-engine' : host.bootstrap.version === '1.9.0' ? 'external-engines' : 'python-engine';
|
||||
assert.notEqual(new URL(host.url).port, '4318'); assert.equal(host.bootstrap.config.hasKey, false);
|
||||
fs.mkdirSync('.qa/screenshots', { recursive: true });
|
||||
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
|
||||
@@ -117,7 +117,7 @@ try {
|
||||
checks: actual.results.map(result => ({ name: result.name, status: result.status, exitCode: result.exitCode, tests: result.tests })),
|
||||
commit: job.commit, changes: job.paths, protectedFiles: Object.fromEntries(Object.entries(protectedBytes).map(([relative, bytes]) => [relative, sha(bytes)])),
|
||||
scope: 'Owned frozen React TypeScript project with offline-installed fixed dependencies, real npm/typecheck/build/browser and Workbench review/Git/report. API fixtures supply repairs; configured-model success is separate.' };
|
||||
fs.writeFileSync(host.bootstrap.version === '1.8.0' ? 'docs/rea-engine-react-delivery-validation.json' : host.bootstrap.version === '1.9.0' ? 'docs/external-engines-react-delivery-validation.json' : 'docs/react-engine-delivery-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
|
||||
fs.writeFileSync(host.bootstrap.version === '1.8.0' ? 'docs/rea-engine-react-delivery-validation.json' : host.bootstrap.version === '1.10.0' ? 'docs/browser-engine-react-delivery-validation.json' : host.bootstrap.version === '1.9.0' ? 'docs/external-engines-react-delivery-validation.json' : 'docs/react-engine-delivery-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
|
||||
} catch (error) {
|
||||
await snapshot('failure').catch(() => {});
|
||||
fs.writeFileSync('.qa/react-engine-delivery-failure.json', JSON.stringify({ error: error.message, passed, pageErrors, requestFailures, session }, null, 2)); throw error;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { randomUUID, createHash } from 'node:crypto';
|
||||
import { spawn } from 'node:child_process';
|
||||
import net from 'node:net';
|
||||
import { createResearchSamples } from './research-fixtures.mjs';
|
||||
import { verifyBrowserApi } from './verify-browser.mjs';
|
||||
|
||||
const release = JSON.parse(fs.readFileSync('releases/latest.json', 'utf8'));
|
||||
const appRoot = release.portableRoot;
|
||||
@@ -91,7 +92,7 @@ try {
|
||||
const checkLog = await api('/artifacts/' + checked.results[0].logArtifactId + '?session=' + session.id); assert.match(checkLog.content, /tests 4/);
|
||||
assert.ok(fs.existsSync(path.join(appRoot, 'runtime/node_modules/npm/bin/npm-cli.js')));
|
||||
const actualRea = [];
|
||||
if (['1.8.0', '1.9.0'].includes(manifest.version)) {
|
||||
if (['1.8.0', '1.9.0', '1.10.0'].includes(manifest.version)) {
|
||||
const installation = await api('/research/availability'); assert.equal(installation.status, 'available'); assert.equal(installation.version, '6.8.0');
|
||||
assert.equal(fs.realpathSync.native(installation.packageRoot), fs.realpathSync.native(path.join(appRoot, 'runtime/node_modules/rea-agents')));
|
||||
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
|
||||
@@ -123,7 +124,7 @@ try {
|
||||
console.log('PASS actual contained REA: ASAR, PE imports and PE resources; zero target execution/model requests');
|
||||
}
|
||||
let actualEngine = null;
|
||||
if (manifest.version === '1.9.0' && process.argv.includes('--native-engines')) {
|
||||
if (['1.9.0', '1.10.0'].includes(manifest.version) && process.argv.includes('--native-engines')) {
|
||||
const installation = await api('/engines/deepseek/availability'); assert.equal(installation.status, 'available', installation.message);
|
||||
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
|
||||
const engineRoot = path.join(data, 'engine-project'); fs.mkdirSync(engineRoot); fs.writeFileSync(path.join(engineRoot, 'README.md'), '# Owned portable engine connection\n');
|
||||
@@ -143,10 +144,11 @@ try {
|
||||
assert.equal((await api('/research')).length, 4);
|
||||
const page = await fetch(url); assert.equal(page.status, 200);
|
||||
assert.match(await page.text(), /Agent Workbench/);
|
||||
const actualBrowser = manifest.version === '1.10.0' ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
|
||||
console.log((await stop()).trim()); started = false;
|
||||
await until(async () => { try { await fetch(url + '/api/health'); return false; } catch { return true; } });
|
||||
const result = { success: true, date: new Date().toISOString(), appRoot, version: manifest.version, nodeVersion: manifest.nodeVersion,
|
||||
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine,
|
||||
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine, actualBrowser,
|
||||
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop'], realModel: false };
|
||||
fs.writeFileSync('.qa/release-validation.json', JSON.stringify(result, null, 2));
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Store } from '../src/server/store.mjs';
|
||||
import { launchWorkbench } from '../tests/helpers.mjs';
|
||||
import { createResearchSamples, ownedAsar } from './research-fixtures.mjs';
|
||||
|
||||
const proofPrefix = JSON.parse(fs.readFileSync('package.json', 'utf8')).version === '1.9.0' ? 'external-engines' : 'rea-engine';
|
||||
const proofPrefix = JSON.parse(fs.readFileSync('package.json', 'utf8')).version === '1.10.0' ? 'browser-engine' : JSON.parse(fs.readFileSync('package.json', 'utf8')).version === '1.9.0' ? 'external-engines' : 'rea-engine';
|
||||
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-research-ui.mjs — independent owned projects, real REA static operations and a declared stdio stop fixture'); process.exit(0); }
|
||||
const root = path.resolve('.qa', 'research-ui-' + randomUUID()), data = path.join(root, 'data'), projectRoot = path.join(root, 'project');
|
||||
|
||||
@@ -42,7 +42,7 @@ try {
|
||||
assert.deepEqual(actualFiles.slice().sort(), Object.keys(expected).sort());
|
||||
for (const [relative, sha256] of Object.entries(expected)) assert.equal(digest(path.join(sourceRoot, relative)), sha256, relative);
|
||||
let actualRea = null;
|
||||
if (['1.8.0', '1.9.0'].includes(evidence.version)) {
|
||||
if (['1.8.0', '1.9.0', '1.10.0'].includes(evidence.version)) {
|
||||
stage = 'contained REA';
|
||||
const reaOutput = await run(['scripts/verify-rea.mjs', '--app-root', sourceRoot, '--contained'], 'rea.log');
|
||||
actualRea = JSON.parse(reaOutput.trim().split('\n').at(-1));
|
||||
@@ -50,19 +50,29 @@ try {
|
||||
assert.ok(actualRea.results.every(item => item.rootExited === true));
|
||||
}
|
||||
let actualEngine = null;
|
||||
if (evidence.version === '1.9.0' && process.argv.includes('--native-engines')) {
|
||||
if (['1.9.0', '1.10.0'].includes(evidence.version) && process.argv.includes('--native-engines')) {
|
||||
stage = 'native DeepSeek SDK';
|
||||
const output = await run(['scripts/verify-engines.mjs'], 'engines.log');
|
||||
actualEngine = JSON.parse(output.trim().split('\n').at(-1));
|
||||
assert.equal(actualEngine.success, true); assert.equal(actualEngine.version, evidence.version);
|
||||
assert.equal(actualEngine.modelRequests, 0); assert.equal(actualEngine.rootExited, true); assert.equal(actualEngine.nativeMethods.length, 6);
|
||||
}
|
||||
let actualBrowser = null;
|
||||
if (evidence.version === '1.10.0') {
|
||||
stage = 'contained browser runtime';
|
||||
const output = await run(['scripts/verify-browser.mjs', '--app-root', sourceRoot, '--contained'], 'browser.log');
|
||||
actualBrowser = JSON.parse(output.trim().split('\n').at(-1));
|
||||
assert.equal(actualBrowser.success, true); assert.equal(actualBrowser.version, evidence.version);
|
||||
assert.equal(actualBrowser.rootExited, true); assert.equal(actualBrowser.results.length, 2);
|
||||
assert.ok(actualBrowser.results.every(value => value.status === 'passed' && value.browserExited));
|
||||
assert.equal(actualBrowser.modelRequests, 0);
|
||||
}
|
||||
stage = 'tests';
|
||||
const output = await run(['--test', '--test-concurrency=2', '--test-reporter=tap', ...files(path.join(sourceRoot, 'tests')).filter(file => !file.includes(path.sep) && file.endsWith('.test.mjs')).map(file => path.join('tests', file))], 'tests.tap');
|
||||
const stats = Object.fromEntries([...output.matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(match => [match[1], Number(match[2])]));
|
||||
assert.ok(stats.tests > 0); assert.equal(stats.pass, stats.tests); for (const key of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(stats[key], 0);
|
||||
const result = { success: true, version: evidence.version, testedAt: new Date().toISOString(), sourceRoot, offlineInstall: true,
|
||||
buildMatchedFiles: Object.keys(expected).length, tests: stats, actualRea, actualEngine, credentialsHandling: 'Only build/runtime environment paths are inherited; no model configuration or credentials are used.' };
|
||||
buildMatchedFiles: Object.keys(expected).length, tests: stats, actualRea, actualEngine, actualBrowser, credentialsHandling: 'Only build/runtime environment paths are inherited; no model configuration or credentials are used.' };
|
||||
fs.writeFileSync(resultFile, JSON.stringify(result, null, 2)); console.log(JSON.stringify(result, null, 2));
|
||||
} catch (error) {
|
||||
fs.writeFileSync(resultFile, JSON.stringify({ success: false, version: evidence.version, stage, error: error.message, sourceRoot }, null, 2));
|
||||
|
||||
@@ -44,4 +44,5 @@ try {
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n'); fs.writeFileSync('.qa/tests-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
if (version === '1.8.0') fs.writeFileSync('docs/rea-engine-tests-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
if (version === '1.9.0') fs.writeFileSync('docs/external-engines-tests-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
if (version === '1.10.0') fs.writeFileSync('docs/browser-engine-tests-validation.json', JSON.stringify(result, null, 2) + '\n');
|
||||
console.log(JSON.stringify({ success: result.success, version, tests: result.tests, inputFiles: result.inputFiles, directory, error: result.error, tail: result.tail }, null, 2));
|
||||
|
||||
@@ -12,7 +12,7 @@ import { captureWorkspaceSource, assertWorkspaceSource } from '../tests/fixtures
|
||||
// Every host/project is synthetic and independently owned. Never uses 4318.
|
||||
const root = path.resolve('.qa', 'workspace-ui-' + randomUUID()), data = path.join(root, 'data');
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
|
||||
const proofPrefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context-workspaces' : version === '1.6.2' ? 'working-retention-workspaces' : version === '1.7.0' ? 'python-engine-workspaces' : version === '1.9.0' ? 'external-engines-workspaces' : 'rea-engine-workspaces';
|
||||
const proofPrefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context-workspaces' : version === '1.6.2' ? 'working-retention-workspaces' : version === '1.7.0' ? 'python-engine-workspaces' : version === '1.10.0' ? 'browser-engine-workspaces' : version === '1.9.0' ? 'external-engines-workspaces' : 'rea-engine-workspaces';
|
||||
fs.mkdirSync(root, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true });
|
||||
const store = new Store(data), cases = {}, passed = [], pageErrors = [], requestFailures = [], screenshots = [], createPosts = [];
|
||||
for (const name of ['normal', 'mobile', 'recovery', 'late-success', 'late-failure']) {
|
||||
|
||||
Reference in New Issue
Block a user