mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:20:44 +00:00
refactor: split plugin sdk test helpers
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
92af5bb106da8278417701c301bc0dcc346cb21886956ab44b2b857e37b581be plugin-sdk-api-baseline.json
|
||||
9139536904eea7239a0d0060562270b06eb43ab755c9e012a5c6687447bbcb48 plugin-sdk-api-baseline.jsonl
|
||||
26eb392e2b8bc103f0aba289344134392ebd55e99a0254cce16327cc7ca4cf93 plugin-sdk-api-baseline.json
|
||||
24f6b50b8c9a2b004491c335eab25786d9024869c710d1784e5748bae4bd0698 plugin-sdk-api-baseline.jsonl
|
||||
|
||||
@@ -26,7 +26,9 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)
|
||||
| `plugin-sdk/plugin-test-api` | Minimal `OpenClawPluginApi` mock builder for direct plugin registration unit tests |
|
||||
| `plugin-sdk/channel-test-helpers` | Channel account lifecycle, directory, send-config, runtime mock, and hook test helpers |
|
||||
| `plugin-sdk/plugin-test-contracts` | Plugin registration, package manifest, public artifact, runtime API, import side-effect, and direct import contract helpers |
|
||||
| `plugin-sdk/plugin-test-runtime` | Plugin runtime, registry, provider-registration, setup-wizard, and runtime task-flow fixtures for tests |
|
||||
| `plugin-sdk/provider-test-contracts` | Provider runtime, auth, discovery, onboard, catalog, web-search/fetch, and wizard contract helpers |
|
||||
| `plugin-sdk/test-env` | Test environment, fetch/network, live-test, temporary filesystem, and time-control fixtures |
|
||||
| `plugin-sdk/migration` | Migration provider item helpers such as `createMigrationItem`, reason constants, item status markers, redaction helpers, and `summarizeMigrationItems` |
|
||||
| `plugin-sdk/migration-runtime` | Runtime migration helpers such as `copyMigrationFileItem` and `writeMigrationReport` |
|
||||
|
||||
|
||||
@@ -29,8 +29,12 @@ plugins.
|
||||
|
||||
**Plugin contract import:** `openclaw/plugin-sdk/plugin-test-contracts`
|
||||
|
||||
**Plugin runtime test import:** `openclaw/plugin-sdk/plugin-test-runtime`
|
||||
|
||||
**Provider contract import:** `openclaw/plugin-sdk/provider-test-contracts`
|
||||
|
||||
**Environment/network test import:** `openclaw/plugin-sdk/test-env`
|
||||
|
||||
The testing subpath exports a narrow set of helpers for plugin authors:
|
||||
|
||||
```typescript
|
||||
@@ -43,7 +47,9 @@ import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
|
||||
import { expectChannelInboundContextContract } from "openclaw/plugin-sdk/channel-contract-testing";
|
||||
import { createStartAccountContext } from "openclaw/plugin-sdk/channel-test-helpers";
|
||||
import { describePluginRegistrationContract } from "openclaw/plugin-sdk/plugin-test-contracts";
|
||||
import { registerSingleProviderPlugin } from "openclaw/plugin-sdk/plugin-test-runtime";
|
||||
import { describeOpenAIProviderRuntimeContract } from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import { withEnv, withFetchPreconnect } from "openclaw/plugin-sdk/test-env";
|
||||
```
|
||||
|
||||
### Available exports
|
||||
@@ -55,6 +61,12 @@ import { describeOpenAIProviderRuntimeContract } from "openclaw/plugin-sdk/provi
|
||||
| `installChannelOutboundPayloadContractSuite` | Install channel outbound payload contract cases. Import from `plugin-sdk/channel-contract-testing` |
|
||||
| `createStartAccountContext` | Build channel account lifecycle contexts. Import from `plugin-sdk/channel-test-helpers` |
|
||||
| `describePluginRegistrationContract` | Install plugin registration contract checks. Import from `plugin-sdk/plugin-test-contracts` |
|
||||
| `registerSingleProviderPlugin` | Register one provider plugin in loader smoke tests. Import from `plugin-sdk/plugin-test-runtime` |
|
||||
| `registerProviderPlugin` | Capture all provider kinds from one plugin. Import from `plugin-sdk/plugin-test-runtime` |
|
||||
| `registerProviderPlugins` | Capture provider registrations across multiple plugins. Import from `plugin-sdk/plugin-test-runtime` |
|
||||
| `requireRegisteredProvider` | Assert that a provider collection contains an id. Import from `plugin-sdk/plugin-test-runtime` |
|
||||
| `createRuntimeEnv` | Build a mocked CLI/plugin runtime environment. Import from `plugin-sdk/plugin-test-runtime` |
|
||||
| `createPluginSetupWizardStatus` | Build setup status helpers for channel plugins. Import from `plugin-sdk/plugin-test-runtime` |
|
||||
| `describeOpenAIProviderRuntimeContract` | Install provider-family runtime contract checks. Import from `plugin-sdk/provider-test-contracts` |
|
||||
| `installCommonResolveTargetErrorCases` | Shared test cases for target resolution error handling |
|
||||
| `shouldAckReaction` | Check whether a channel should add an ack reaction |
|
||||
@@ -62,25 +74,19 @@ import { describeOpenAIProviderRuntimeContract } from "openclaw/plugin-sdk/provi
|
||||
| `createTestRegistry` | Build a channel plugin registry fixture |
|
||||
| `createEmptyPluginRegistry` | Build an empty plugin registry fixture |
|
||||
| `setActivePluginRegistry` | Install a registry fixture for plugin runtime tests |
|
||||
| `createRequestCaptureJsonFetch` | Capture JSON fetch requests in media helper tests |
|
||||
| `withFetchPreconnect` | Run fetch tests with preconnect hooks installed |
|
||||
| `withEnv` / `withEnvAsync` | Temporarily patch environment variables |
|
||||
| `createTempHomeEnv` / `withTempDir` | Create isolated filesystem test fixtures |
|
||||
| `createMockServerResponse` | Create a minimal HTTP server response mock |
|
||||
| `registerSingleProviderPlugin` | Register one provider plugin in loader smoke tests |
|
||||
| `registerProviderPlugin` | Capture all provider kinds from one plugin |
|
||||
| `registerProviderPlugins` | Capture provider registrations across multiple plugins |
|
||||
| `requireRegisteredProvider` | Assert that a provider collection contains an id |
|
||||
| `createRequestCaptureJsonFetch` | Capture JSON fetch requests in media helper tests. Import from `plugin-sdk/test-env` |
|
||||
| `withFetchPreconnect` | Run fetch tests with preconnect hooks installed. Import from `plugin-sdk/test-env` |
|
||||
| `withEnv` / `withEnvAsync` | Temporarily patch environment variables. Import from `plugin-sdk/test-env` |
|
||||
| `createTempHomeEnv` / `withTempDir` | Create isolated filesystem test fixtures. Import from `plugin-sdk/test-env` |
|
||||
| `createMockServerResponse` | Create a minimal HTTP server response mock. Import from `plugin-sdk/test-env` |
|
||||
| `runProviderCatalog` | Execute a provider catalog hook with test dependencies |
|
||||
| `resolveProviderWizardOptions` | Resolve provider setup wizard choices in contract tests |
|
||||
| `resolveProviderModelPickerEntries` | Resolve provider model-picker entries in contract tests |
|
||||
| `buildProviderPluginMethodChoice` | Build provider wizard choice ids for assertions |
|
||||
| `setProviderWizardProvidersResolverForTest` | Inject provider wizard providers for isolated tests |
|
||||
| `createProviderUsageFetch` | Build provider usage fetch fixtures |
|
||||
| `useFrozenTime` / `useRealTime` | Freeze and restore timers for time-sensitive tests |
|
||||
| `createRuntimeEnv` | Build a mocked CLI/plugin runtime environment |
|
||||
| `useFrozenTime` / `useRealTime` | Freeze and restore timers for time-sensitive tests. Import from `plugin-sdk/test-env` |
|
||||
| `createTestWizardPrompter` | Build a mocked setup wizard prompter |
|
||||
| `createPluginSetupWizardStatus` | Build setup status helpers for channel plugins |
|
||||
| `createRuntimeTaskFlow` | Create isolated runtime task-flow state |
|
||||
| `typedCases` | Preserve literal types for table-driven tests |
|
||||
|
||||
@@ -90,9 +96,9 @@ suites that depend on bundled OpenClaw inventory stay under `src/plugins/contrac
|
||||
Keep new extension tests on `openclaw/plugin-sdk/testing` or a narrower
|
||||
documented SDK subpath such as `plugin-sdk/plugin-test-api` or
|
||||
`plugin-sdk/channel-contract-testing`, `plugin-sdk/channel-test-helpers`,
|
||||
`plugin-sdk/plugin-test-contracts`, or `plugin-sdk/provider-test-contracts`
|
||||
rather than importing repo `src/**` files or repo `test/helpers/plugins/*`
|
||||
bridges directly.
|
||||
`plugin-sdk/plugin-test-contracts`, `plugin-sdk/plugin-test-runtime`,
|
||||
`plugin-sdk/provider-test-contracts`, or `plugin-sdk/test-env` rather than
|
||||
importing repo `src/**` files or repo `test/helpers/plugins/*` bridges directly.
|
||||
|
||||
### Types
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ title: "Tests"
|
||||
- Test wrapper runs end with a short `[test] passed|failed|skipped ... in ...` summary. Vitest's own duration line stays the per-shard detail.
|
||||
- Full, extension, and include-pattern shard runs update local timing data in `.artifacts/vitest-shard-timings.json`; later whole-config runs use those timings to balance slow and fast shards. Include-pattern CI shards append the shard name to the timing key, which keeps filtered shard timings visible without replacing whole-config timing data. Set `OPENCLAW_TEST_PROJECTS_TIMINGS=0` to ignore the local timing artifact.
|
||||
- Selected `plugin-sdk` and `commands` test files now route through dedicated light lanes that keep only `test/setup.ts`, leaving runtime-heavy cases on their existing lanes.
|
||||
- Source files with sibling tests map to that sibling before falling back to wider directory globs. Helper edits under `test/helpers/channels` and `test/helpers/plugins` use a local import graph to run importing tests instead of broad-running every shard when the dependency path is precise.
|
||||
- Source files with sibling tests map to that sibling before falling back to wider directory globs. Helper edits under `test/helpers/channels`, `src/plugin-sdk/test-helpers`, and `src/plugins/contracts` use a local import graph to run importing tests instead of broad-running every shard when the dependency path is precise.
|
||||
- `auto-reply` now also splits into three dedicated configs (`core`, `top-level`, `reply`) so the reply harness does not dominate the lighter top-level status/token/helper tests.
|
||||
- Base Vitest config now defaults to `pool: "threads"` and `isolate: false`, with the shared non-isolated runner enabled across the repo configs.
|
||||
- `pnpm test:channels` runs `vitest.channels.config.ts`.
|
||||
|
||||
Reference in New Issue
Block a user