11import { describe , expect , it } from "vitest" ;
2- import { validatePluginConfig } from "./loader-shared.js" ;
2+ import type { PluginCandidate } from "./discovery.js" ;
3+ import { createManifestPluginRecord , validatePluginConfig } from "./loader-shared.js" ;
4+ import type { PluginManifestRecord } from "./manifest-registry.js" ;
35
46const emptyObjectSchema = {
57 type : "object" ,
@@ -11,6 +13,50 @@ function withSchemaKeyword(key: "if" | "then" | "else", value: unknown) {
1113 return { [ key ] : value } ;
1214}
1315
16+ const manifestRecord = {
17+ id : "example" ,
18+ channels : [ ] ,
19+ providers : [ ] ,
20+ cliBackends : [ ] ,
21+ skills : [ ] ,
22+ hooks : [ ] ,
23+ origin : "global" ,
24+ rootDir : "/plugins/example" ,
25+ source : "/plugins/example/index.js" ,
26+ manifestPath : "/plugins/example/openclaw.plugin.json" ,
27+ } satisfies PluginManifestRecord ;
28+
29+ function createRecordWithBuildVersion ( openclawVersion : unknown ) {
30+ const candidate = {
31+ idHint : "example" ,
32+ source : manifestRecord . source ,
33+ rootDir : manifestRecord . rootDir ,
34+ origin : manifestRecord . origin ,
35+ packageManifest : {
36+ build : { openclawVersion } ,
37+ } as unknown as NonNullable < PluginCandidate [ "packageManifest" ] > ,
38+ } satisfies PluginCandidate ;
39+
40+ return createManifestPluginRecord ( {
41+ candidate,
42+ manifestRecord,
43+ enabled : true ,
44+ activationState : {
45+ enabled : true ,
46+ activated : true ,
47+ explicitlyEnabled : true ,
48+ source : "explicit" ,
49+ } ,
50+ } ) ;
51+ }
52+
53+ describe ( "createManifestPluginRecord" , ( ) => {
54+ it ( "ignores malformed package build version metadata" , ( ) => {
55+ expect ( createRecordWithBuildVersion ( " 2026.7.2 " ) . builtWithOpenClawVersion ) . toBe ( "2026.7.2" ) ;
56+ expect ( createRecordWithBuildVersion ( 42 ) . builtWithOpenClawVersion ) . toBeUndefined ( ) ;
57+ } ) ;
58+ } ) ;
59+
1460describe ( "validatePluginConfig empty schema classification" , ( ) => {
1561 it ( "validates pattern properties instead of requiring empty config" , ( ) => {
1662 const schema = {
0 commit comments