From 82b3073ba55b1aa2c041cd15e8a34231aed291f0 Mon Sep 17 00:00:00 2001 From: creatixchu Date: Fri, 25 Sep 2026 18:31:34 +0800 Subject: [PATCH] test(cua): align preparation fixtures and component status queries --- .../ui-plugin-manager/tests/components.client.spec.tsx | 2 +- .../computer-use/cua/tests/provider-lifecycle.spec.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx index fa0be51e38..57cc37bc76 100644 --- a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx +++ b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx @@ -853,7 +853,7 @@ describe('PluginManagerPage', () => { fireEvent.click(toggle('row-2')) expect(actions.setRowEnabled).toHaveBeenCalledTimes(1) expect(toggle('include:row-5')).toHaveProperty('disabled', true) - expect(within(detail).getByText(en.rowPhaseFailed)).toBeTruthy() + expect(within(detail.querySelector('[data-plugin-row="include:row-3"]')!).getByText(en.rowPhaseFailed)).toBeTruthy() expect(within(detail).getByText(en.rowPhaseLoading)).toBeTruthy() expect(within(detail).getByText(en.rowPhaseUnloading)).toBeTruthy() expect(document.querySelector('[data-plugin-row="include:row-3"]')?.getAttribute('data-state')).toBe('failed') diff --git a/packages/computer-use/cua/tests/provider-lifecycle.spec.ts b/packages/computer-use/cua/tests/provider-lifecycle.spec.ts index e57bd0aa3d..91bc33d3f0 100644 --- a/packages/computer-use/cua/tests/provider-lifecycle.spec.ts +++ b/packages/computer-use/cua/tests/provider-lifecycle.spec.ts @@ -39,6 +39,8 @@ const config = { graceMs: 10, textEventIntervalMs: 8, maxElements: 64, maxDepth: 8, dragDurationMs: 200, dragSteps: 10, } satisfies NativeProvider.Config +const { helperPath: _helperPath, ...automaticConfig } = config + class ImageAdapter extends LlmAdapter { override resolveModel(provider: string, model: string): Promise { return Promise.resolve({ provider, id: model, name: model, inputModalities: ['text', 'image'] }) @@ -345,7 +347,7 @@ it('prepares the selected native component before registering CUA and creates no const f = await setup() await f.provider.dispose() native.prepare.mockReset().mockResolvedValue(resolve('prepared-helper')) - await NativeProvider.apply(f.ctx, { ...config, helperPath: undefined }) + await NativeProvider.apply(f.ctx, automaticConfig) expect(native.prepare).toHaveBeenCalledTimes(1) expect(native.instances).toHaveLength(0) await f.execute() @@ -359,7 +361,7 @@ it('does not register operations after native preparation fails', async () => { const f = await setup() await f.provider.dispose() native.prepare.mockReset().mockRejectedValue(new Error('compiler unavailable')) - await expect(NativeProvider.apply(f.ctx, { ...config, helperPath: undefined })).rejects.toThrow('compiler unavailable') + await expect(NativeProvider.apply(f.ctx, automaticConfig)).rejects.toThrow('compiler unavailable') expect(f.ctx.tools.schemas().some(tool => tool.name === 'cua')).toBe(false) expect(native.instances).toHaveLength(0) }) @@ -370,7 +372,7 @@ it('waits for canceled preparation and never publishes its late success', async const ready = Promise.withResolvers() onTestFinished(() => { ready.resolve(resolve('late-helper')) }) native.prepare.mockReset().mockReturnValue(ready.promise) - const starting = Promise.resolve(NativeProvider.apply(f.ctx, { ...config, helperPath: undefined })) + const starting = Promise.resolve(NativeProvider.apply(f.ctx, automaticConfig)) const failed = expect(starting).rejects.toThrow() const signal = native.prepare.mock.calls[0]![0].signal const aborted = new Promise(resolve => signal.addEventListener('abort', () => resolve(), { once: true })) @@ -391,6 +393,6 @@ it('rejects an unsupported native host before starting preparation', async () => await f.provider.dispose() native.architecture.mockImplementationOnce(() => { throw new Error('unsupported host') }) native.prepare.mockReset() - expect(() => NativeProvider.apply(f.ctx, { ...config, helperPath: undefined })).toThrow('unsupported host') + expect(() => NativeProvider.apply(f.ctx, automaticConfig)).toThrow('unsupported host') expect(native.prepare).not.toHaveBeenCalled() })