@@ -184,19 +184,15 @@ describe( 'getLeftHalfOfUnblockTemplate( wikitext, appealReason )', () => {
184184 const wikitext = `{{unblock|reason={{u|331dot}} I am requesting a reconsideration of this block.}}` ;
185185 // The appeal reason as extracted from HTML - should be the full visible text
186186 const appealReason = `331dot I am requesting a reconsideration of this block.` ;
187- // When the pattern matches in wikitext, it will match starting at the {{u| since that's
188- // where "331dot" appears in the wikitext. So the left half includes that.
189- const expected = `{{unblock|reason={{u|` ;
187+ const expected = `{{unblock|reason=` ;
190188 expect ( unblockReview . getLeftHalfOfUnblockTemplate ( wikitext , appealReason ) ) . toBe ( expected ) ;
191189 } ) ;
192190
193191 test ( 'Multiple template syntax variations with wiki markup' , ( ) => {
194192 // Test with different parameter styles
195193 const wikitext = `{{unblock|{{u|TestUser}} Please reconsider this block.}}` ;
196194 const appealReason = `TestUser Please reconsider this block.` ;
197- // The pattern matches starting at "TestUser" (position 14), which is inside the {{u|...}} template
198- // So the left half includes everything from {{unblock| up to the start of the match
199- const expected = `{{unblock|{{u|` ;
195+ const expected = `{{unblock|` ;
200196 expect ( unblockReview . getLeftHalfOfUnblockTemplate ( wikitext , appealReason ) ) . toBe ( expected ) ;
201197 } ) ;
202198
@@ -210,8 +206,7 @@ describe( 'getLeftHalfOfUnblockTemplate( wikitext, appealReason )', () => {
210206 test ( 'Reason with multiple wikilinks and templates' , ( ) => {
211207 const wikitext = `{{unblock|reason={{u|Admin}} and [[User:Mod|moderator]] agree my block was a mistake.}}` ;
212208 const appealReason = `Admin and moderator agree my block was a mistake.` ;
213- // Pattern matches starting at {{u|Admin}}, so the expected left half includes that
214- const expected = `{{unblock|reason={{u|` ;
209+ const expected = `{{unblock|reason=` ;
215210 expect ( unblockReview . getLeftHalfOfUnblockTemplate ( wikitext , appealReason ) ) . toBe ( expected ) ;
216211 } ) ;
217212} ) ;
@@ -590,6 +585,15 @@ I was blocked a few days ago for... [[User:Test]]}}`;
590585 expect ( unblockReview . processAcceptOrDecline ( wikitext , paramsAndReason , acceptDeclineReason , DEFAULT_DECLINE_REASON , acceptOrDecline ) ) . toBe ( expected ) ;
591586 } ) ;
592587
588+ test ( 'Preserve a user template in the middle of an appeal reason' , ( ) => {
589+ const wikitext = `{{unblock|reason=Please {{u|331dot}} reconsider.}}` ;
590+ const paramsAndReason = `Please 331dot reconsider.` ;
591+ const acceptDeclineReason = `Insufficient.` ;
592+ const acceptOrDecline = `decline` ;
593+ const expected = `{{unblock reviewed|decline=Insufficient. ~~~~|1=Please {{u|331dot}} reconsider.}}` ;
594+ expect ( unblockReview . processAcceptOrDecline ( wikitext , paramsAndReason , acceptDeclineReason , DEFAULT_DECLINE_REASON , acceptOrDecline ) ) . toBe ( expected ) ;
595+ } ) ;
596+
593597 test ( 'Does not assume another template renders its argument as a user link' , ( ) => {
594598 const wikitext = `{{unblock|reason={{other|331dot}} I am requesting reconsideration.}}` ;
595599 const paramsAndReason = `331dot I am requesting reconsideration.` ;
0 commit comments