Repository navigation
Expand file tree
/
Copy pathplugin.test.ts
More file actions
42 lines (40 loc) · 1.6 KB
/
Copy pathplugin.test.ts
File metadata and controls
42 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { expect, test } from 'vitest';
import { createPluginHost } from '@agent-device/plugins/host';
import { resolveProviderPlugins, startProviderRegistry } from '@agent-device/plugins/registry';
import replayPlugin from './plugin.ts';
test('the first-party factory uses the managed registry and preserves native script syntax', async () => {
const registry = await startProviderRegistry(
await resolveProviderPlugins([{ source: 'embedder', load: replayPlugin }]),
{},
{
adaptWebDriver: async () => {
throw new Error('Replay cannot create providers');
},
},
);
try {
const execution = await registry.resolveReplayExecution();
const manifest = execution.inspectAdReplay(
'open com.example.app\nfill "id=password" "${PASSWORD}"\nclose',
);
expect(manifest.actions.map((action) => action.command)).toEqual(['open', 'fill', 'close']);
expect(manifest.actions[1]?.positionals).toContain('${PASSWORD}');
const suite = await execution.runReplayTestSuite({
request: { inputs: [], sessionName: 'unused' },
} as never);
expect(suite).toEqual({
status: 'failed',
error: { code: 'INVALID_ARGS', message: 'test requires at least one path or glob' },
});
} finally {
await registry.close();
}
});
test('the package refuses a core outside its declared release family', async () => {
const host = { ...createPluginHost({}, undefined), clientVersion: '0.23.0' };
expect(() => replayPlugin().setup(host)).toThrow(
expect.objectContaining({
details: expect.objectContaining({ reason: 'incompatible_plugin' }),
}),
);
});