@@ -82,18 +82,26 @@ describe('CustomPatternsEditor', () => {
8282 expect ( onChange ) . toHaveBeenCalledWith ( [ { name : 'X' , regex : 'b+' , replacement : '<X>' } ] )
8383 } )
8484
85- it ( 'preserves an existing row while rows are appended and truncated' , ( ) => {
85+ it ( 'preserves rows while they are appended, edited, and truncated' , ( ) => {
8686 const onChange = vi . fn ( )
8787 const firstPattern = row ( 'a+' )
8888 renderEditor ( [ firstPattern ] , onChange )
8989
9090 const firstRegexInput = container . querySelector ( 'input[value="a+"]' ) as HTMLInputElement
9191 firstRegexInput . focus ( )
9292
93- renderEditor ( [ firstPattern , row ( 'b+' ) ] , onChange )
93+ const secondPattern = row ( 'b+' )
94+ renderEditor ( [ firstPattern , secondPattern ] , onChange )
9495 expect ( container . querySelector ( 'input[value="a+"]' ) ) . toBe ( firstRegexInput )
9596 expect ( document . activeElement ) . toBe ( firstRegexInput )
9697
98+ const secondRegexInput = container . querySelector ( 'input[value="b+"]' ) as HTMLInputElement
99+ secondRegexInput . focus ( )
100+ renderEditor ( [ firstPattern , { ...secondPattern , regex : 'b*' } ] , onChange )
101+ expect ( container . querySelector ( 'input[value="b*"]' ) ) . toBe ( secondRegexInput )
102+ expect ( document . activeElement ) . toBe ( secondRegexInput )
103+
104+ firstRegexInput . focus ( )
97105 renderEditor ( [ firstPattern ] , onChange )
98106 expect ( container . querySelector ( 'input[value="a+"]' ) ) . toBe ( firstRegexInput )
99107 expect ( document . activeElement ) . toBe ( firstRegexInput )
0 commit comments