@@ -1138,6 +1138,47 @@ test("an authored duplicate leading mention survives draft restoration", async (
11381138 . toBe ( "@Morgarita authored duplicate" ) ;
11391139} ) ;
11401140
1141+ test ( "typed deletion preserves an identical authored mention in drafts" , async ( {
1142+ page,
1143+ } ) => {
1144+ await installAudienceFixtures ( page ) ;
1145+ await openGeneral ( page ) ;
1146+ const composer = channelComposer ( page ) ;
1147+ const input = composer . getByTestId ( "message-input" ) ;
1148+ await automaticallyMention ( composer , "Morgarita" ) ;
1149+
1150+ const selectAllShortcut = await page . evaluate ( ( ) =>
1151+ / m a c | i p h o n e | i p a d | i p o d / i. test ( navigator . platform ) ? "Meta+A" : "Control+A" ,
1152+ ) ;
1153+ await input . press ( selectAllShortcut ) ;
1154+ await input . press ( "Backspace" ) ;
1155+ await expect ( input ) . toHaveText ( "" ) ;
1156+ await expect (
1157+ composer . getByTestId ( `composer-address-lock-${ AGENT_A } ` ) ,
1158+ ) . toHaveCount ( 0 ) ;
1159+
1160+ await input . pressSequentially ( "@Morgarita manual after typed deletion" ) ;
1161+ await page . goto ( `/#/channels/${ RANDOM_CHANNEL_ID } ` , {
1162+ waitUntil : "domcontentloaded" ,
1163+ } ) ;
1164+ await expect
1165+ . poll ( ( ) =>
1166+ page . evaluate ( ( channelId ) => {
1167+ for ( const storageKey of Object . keys ( window . localStorage ) ) {
1168+ if ( ! storageKey . startsWith ( "buzz-drafts.v2:" ) ) continue ;
1169+ const draft = (
1170+ JSON . parse (
1171+ window . localStorage . getItem ( storageKey ) ?? "{}" ,
1172+ ) as Record < string , { content ?: string } >
1173+ ) [ channelId ] ;
1174+ if ( draft ) return draft . content ?? "" ;
1175+ }
1176+ return "" ;
1177+ } , CHANNEL_ID ) ,
1178+ )
1179+ . toBe ( "@Morgarita manual after typed deletion" ) ;
1180+ } ) ;
1181+
11411182test ( "removing an automatic mention preserves an identical authored mention in drafts" , async ( {
11421183 page,
11431184} ) => {
0 commit comments