@@ -5,6 +5,11 @@ import {
55 clearRuntimeAuthProfileStoreSnapshots ,
66 saveAuthProfileStore ,
77} from "openclaw/plugin-sdk/agent-runtime" ;
8+ import {
9+ capturePluginRegistration ,
10+ createRuntimeEnv ,
11+ resolveProviderPluginChoice ,
12+ } from "openclaw/plugin-sdk/plugin-test-runtime" ;
813import {
914 getProviderHttpMocks ,
1015 installProviderHttpMockCleanup ,
@@ -55,6 +60,49 @@ function clearAlibabaAuthEnvironment(): void {
5560const requireRecord = createRequireRecord ( "record" , "expected-label-record" ) ;
5661
5762describe ( "alibaba video generation provider" , ( ) => {
63+ it ( "registers media-only API-key onboarding alongside video generation" , async ( ) => {
64+ const { default : plugin } = await import ( "./index.js" ) ;
65+ const captured = capturePluginRegistration ( plugin ) ;
66+
67+ expect ( captured . videoGenerationProviders . map ( ( provider ) => provider . id ) ) . toEqual ( [ "alibaba" ] ) ;
68+ expect ( captured . modelCatalogProviders ) . toEqual ( [ ] ) ;
69+ expect ( captured . providers ) . toHaveLength ( 1 ) ;
70+ expect ( captured . providers [ 0 ] ) . toMatchObject ( {
71+ id : "alibaba" ,
72+ docsPath : "/providers/alibaba" ,
73+ envVars : [ "MODELSTUDIO_API_KEY" , "DASHSCOPE_API_KEY" , "QWEN_API_KEY" ] ,
74+ } ) ;
75+
76+ const choice = resolveProviderPluginChoice ( {
77+ providers : captured . providers ,
78+ choice : "alibaba-model-studio-api-key" ,
79+ } ) ;
80+ expect ( choice ?. method . id ) . toBe ( "api-key" ) ;
81+ expect ( choice ?. method . starterModel ) . toBeUndefined ( ) ;
82+ expect ( choice ?. wizard ?. onboardingScopes ) . toEqual ( [ "image-generation" ] ) ;
83+ if ( ! choice ?. method . validateNonInteractive ) {
84+ throw new Error ( "expected Alibaba non-interactive API-key validation" ) ;
85+ }
86+
87+ const resolveApiKey = vi . fn ( async ( ) => ( { key : "alibaba-test-key" , source : "flag" as const } ) ) ;
88+ expect (
89+ await choice . method . validateNonInteractive ( {
90+ authChoice : "alibaba-model-studio-api-key" ,
91+ config : { } ,
92+ baseConfig : { } ,
93+ opts : { alibabaModelStudioApiKey : "alibaba-test-key" } ,
94+ runtime : createRuntimeEnv ( ) ,
95+ resolveApiKey,
96+ } ) ,
97+ ) . toBe ( true ) ;
98+ expect ( resolveApiKey ) . toHaveBeenCalledWith ( {
99+ provider : "alibaba" ,
100+ flagValue : "alibaba-test-key" ,
101+ flagName : "--alibaba-model-studio-api-key" ,
102+ envVar : "MODELSTUDIO_API_KEY" ,
103+ } ) ;
104+ } ) ;
105+
58106 it ( "declares explicit mode capabilities" , ( ) => {
59107 expectExplicitVideoGenerationCapabilities ( alibabaVideoGenerationProvider ) ;
60108 expect ( alibabaVideoGenerationProvider ) . toMatchObject ( {
0 commit comments