@@ -65,21 +65,18 @@ const textOf = (testId: string): string => screen.getByTestId(testId).textConten
6565const click = ( testId : string ) : void => { fireEvent . click ( screen . getByTestId ( testId ) ) ; } ;
6666
6767/**
68- * 弹层按 **DOM 边界**切段(顺序 = 标题 · message · 逐条 impact · 取消 · 确认),供 `toEqual` **逐段恰等**
69- * —— 这就是 I-1 的牙:段数、顺序、每段字面量全恰等,「改一个字 / 追加一句」必红。⚠️ 原语侧装饰(关闭钮 +
70- * 印章)**不入段**(不属 T11 迁的文案),但由**总长守卫**单独记账 ⇒ 任何未记账字符同样必红。
68+ * 弹层按 **DOM 边界**切段,供 `toEqual` **逐段恰等**(段数 · 顺序 · 字面量三者全恰等)—— 这就是 I-1 的牙。
69+ * 段 = 标题 · message · 逐条 impact · 取消 · 确认,由**一条按 DOM 序的选择器**取齐(不是按名字拼数组 ——
70+ * 拼数组会静默吞掉"段被挪了位置")。⚠️ 原语侧装饰(关闭钮 + 印章)**不入段**(不属 T11 迁的文案),
71+ * 但由**总长守卫**单独记账 ⇒ 面板内任何未记账的字符(多写的说明 / 游离文本)同样必红。
7172 */
7273function segmentsOf ( testId : string ) : string [ ] {
7374 const panel = screen . getByTestId ( testId ) ;
74- const q = ( sel : string ) : Element | null => panel . querySelector ( sel ) ;
75- const body = q ( ".ed-confirm" ) ;
76- const seal = q ( ".ed-confirm-seal" ) ;
77- const ul = q ( "ul.ed-confirm-impacts" ) ;
78- const kids = body === null ? [ ] : Array . from ( body . children ) . filter ( ( c ) => c !== seal && c !== ul ) ;
79- const lis = ul === null ? [ ] : Array . from ( ul . querySelectorAll ( "li" ) ) ;
80- const chrome = `${ q ( ".ed-modal-head > button" ) ?. textContent ?? "" } ${ seal ?. textContent ?? "" } ` ;
81- const segs = [ q ( ".ed-modal-head > div" ) , ...kids , ...lis ,
82- screen . getByTestId ( `${ testId } -cancel` ) , screen . getByTestId ( `${ testId } -confirm` ) ] . map ( ( n ) => n ?. textContent ?? "" ) ;
75+ const seal = panel . querySelector ( ".ed-confirm-seal" ) ;
76+ const segs = Array . from ( panel . querySelectorAll (
77+ ".ed-modal-head > div, .ed-confirm > *:not(.ed-confirm-seal):not(ul), ul.ed-confirm-impacts > li, .ed-modal-foot button" ,
78+ ) ) . map ( ( n ) => n . textContent ?? "" ) ;
79+ const chrome = `${ panel . querySelector ( ".ed-modal-head > button" ) ?. textContent ?? "" } ${ seal ?. textContent ?? "" } ` ;
8380 expect ( panel . textContent ?. length , `弹层里有未记账的字符:${ panel . textContent } ` ) . toBe ( segs . join ( "" ) . length + chrome . length ) ;
8481 return segs ;
8582}
0 commit comments