@@ -6,6 +6,7 @@ import type { ParsedNode } from "@subboost/core/types/node";
66const mocks = vi . hoisted ( ( ) => ( {
77 buttons : [ ] as Array < Record < string , any > > ,
88 dialog : null as Record < string , any > | null ,
9+ formField : null as Record < string , any > | null ,
910 switchField : null as Record < string , any > | null ,
1011 textarea : null as Record < string , any > | null ,
1112} ) ) ;
@@ -28,15 +29,23 @@ vi.mock("@subboost/ui/components/ui/dialog", () => ({
2829 DialogTitle : ( props : any ) => React . createElement ( "h2" , null , props . children ) ,
2930} ) ) ;
3031vi . mock ( "@subboost/ui/components/ui/form-field" , ( ) => ( {
31- FormField : ( props : any ) =>
32- React . createElement (
32+ FormField : ( props : any ) => {
33+ mocks . formField = props ;
34+ const label = React . createElement ( "label" , null , props . label ) ;
35+ const description = props . description
36+ ? React . createElement ( "p" , null , props . description )
37+ : null ;
38+ return React . createElement (
3339 "div" ,
3440 null ,
35- React . createElement ( "label" , null , props . label ) ,
41+ props . descriptionPlacement === "before-control"
42+ ? React . createElement ( "div" , null , label , description )
43+ : label ,
3644 props . children ,
37- props . description ? React . createElement ( "p" , null , props . description ) : null ,
45+ props . descriptionPlacement === "before-control" ? null : description ,
3846 props . error ? React . createElement ( "p" , { role : "alert" } , props . error ) : null
39- ) ,
47+ ) ;
48+ } ,
4049} ) ) ;
4150vi . mock ( "@subboost/ui/components/ui/switch-field" , ( ) => ( {
4251 SwitchField : ( props : any ) => {
@@ -111,6 +120,7 @@ describe("NodeManagementAutoProcessingDialog", () => {
111120 beforeEach ( ( ) => {
112121 mocks . buttons = [ ] ;
113122 mocks . dialog = null ;
123+ mocks . formField = null ;
114124 mocks . switchField = null ;
115125 mocks . textarea = null ;
116126 } ) ;
@@ -121,12 +131,25 @@ describe("NodeManagementAutoProcessingDialog", () => {
121131 expect ( html ) . toContain ( "自动处理" ) ;
122132 expect ( html ) . toContain ( "启用" ) ;
123133 expect ( html ) . toContain ( "排除正则" ) ;
124- expect ( html ) . toContain ( "每行一条,匹配导入名称 。" ) ;
134+ expect ( html ) . toContain ( "每行一条,匹配到的节点会被全局排除,关闭后恢复 。" ) ;
125135 expect ( html ) . toContain ( "剩余流量|套餐到期|注意事项" ) ;
136+ expect ( html . indexOf ( "排除正则" ) ) . toBeLessThan (
137+ html . indexOf ( "每行一条,匹配到的节点会被全局排除,关闭后恢复。" )
138+ ) ;
139+ expect (
140+ html . indexOf ( "每行一条,匹配到的节点会被全局排除,关闭后恢复。" )
141+ ) . toBeLessThan ( html . indexOf ( "剩余流量|套餐到期|注意事项" ) ) ;
126142 expect ( html ) . toContain ( "导入 2 · 排除 1 · 保留 1" ) ;
127143 expect ( html ) . toContain ( "[HK] Alpha" ) ;
128144 expect ( html ) . toContain ( "原名:Alpha" ) ;
129145 expect ( html ) . not . toContain ( "原名:Beta" ) ;
146+ expect ( mocks . formField ) . toEqual (
147+ expect . objectContaining ( {
148+ description : "每行一条,匹配到的节点会被全局排除,关闭后恢复。" ,
149+ descriptionPlacement : "before-control" ,
150+ label : "排除正则" ,
151+ } )
152+ ) ;
130153 expect ( mocks . switchField ) . toEqual (
131154 expect . objectContaining ( { checked : true , label : "启用" } )
132155 ) ;
0 commit comments