11import { describe , expect , it } from 'vitest' ;
22
3- import { convertEnvToSettings } from '../utils' ;
3+ import { convertEnvToSettings , mergeExternalPluginPresets } from '../utils' ;
44
55describe ( 'convertEnvToSettings' , ( ) => {
66 it ( 'should convert flat env into structured settings object' , ( ) => {
@@ -22,3 +22,32 @@ describe('convertEnvToSettings', () => {
2222 expect ( result . env . INIT_APP_LANG ) . toBe ( 'zh-CN' ) ;
2323 } ) ;
2424} ) ;
25+
26+ describe ( 'mergeExternalPluginPresets' , ( ) => {
27+ it ( 'should append plugins added by a newer default preset' , ( ) => {
28+ const defaults = [
29+ { name : 'existing' , enabledByDefault : true } ,
30+ { name : 'new-plugin' , enabledByDefault : false } ,
31+ ] ;
32+ const runtime = [ { name : 'existing' , enabledByDefault : true } ] ;
33+
34+ expect ( mergeExternalPluginPresets ( defaults , runtime ) ) . toEqual ( defaults ) ;
35+ } ) ;
36+
37+ it ( 'should preserve runtime overrides for existing plugins' , ( ) => {
38+ const defaults = [ { name : 'existing' , enabledByDefault : true } ] ;
39+ const runtime = [ { name : 'existing' , enabledByDefault : false } ] ;
40+
41+ expect ( mergeExternalPluginPresets ( defaults , runtime ) ) . toEqual ( runtime ) ;
42+ } ) ;
43+
44+ it ( 'should preserve runtime-only plugins without creating duplicates' , ( ) => {
45+ const defaults = [ { name : 'existing' , enabledByDefault : true } ] ;
46+ const runtime = [
47+ { name : 'existing' , enabledByDefault : false } ,
48+ { name : 'private-plugin' , enabledByDefault : false } ,
49+ ] ;
50+
51+ expect ( mergeExternalPluginPresets ( defaults , runtime ) ) . toEqual ( runtime ) ;
52+ } ) ;
53+ } ) ;
0 commit comments