在 Makelore 构建并预检静态发布产物

This commit is contained in:
2026-08-12 21:19:39 +08:00
parent 3a80625fe2
commit 5b44864265
26 changed files with 1275 additions and 217 deletions

View File

@@ -16,6 +16,7 @@ import {
agentBrowserPartition,
} from '@electron/agent-browser/module';
import { AgentBrowserPayloadStore } from '@electron/agent-browser/payload-store';
import { createStaticArtifactSnapshot } from '@electron/services/static-release-server';
class FakeDebugger implements AgentBrowserDebuggerPort {
readonly events = new EventEmitter();
@@ -252,6 +253,32 @@ async function openBrowser(adapter = new FakeAdapter()) {
}
describe('AgentBrowserModule', () => {
it('preflights a Main-owned static artifact without requiring or mutating a browser record', async () => {
const artifact = createStaticArtifactSnapshot([{ path: 'index.html', bytes: Buffer.from('<main>ok</main>') }]);
const adapter = new FakeAdapter();
const module = new AgentBrowserModule(adapter);
try {
await expect(module.preflightStaticArtifact(artifact)).resolves.toEqual({ ok: true });
expect(await module.getSnapshot()).toMatchObject({ state: 'closed', browserId: null });
expect(adapter.views.map((view) => view.bounds)).toEqual([
{ x: 0, y: 0, width: 1280, height: 720 },
{ x: 0, y: 0, width: 390, height: 844 },
]);
expect(adapter.destroyed).toBe(2);
expect(adapter.resetPartitions).toEqual(adapter.partitions);
} finally {
await module.dispose();
}
});
it('reports forged artifact snapshots as infrastructure unavailable', async () => {
const module = new AgentBrowserModule(new FakeAdapter());
await expect(module.preflightStaticArtifact({} as never)).rejects.toMatchObject({
code: 'PUBLISH_PREFLIGHT_UNAVAILABLE',
message: '暂时无法启动作品检查,请稍后重试。',
});
});
it('preflights desktop and mobile viewports in temporary non-persistent profiles', async () => {
const adapter = new FakeAdapter();
adapter.onCreate = (view) => {