@@ -9,7 +9,7 @@ import { createAgent, createDepartment } from '../../../data/livechat/rooms';
99import { removeTag , saveTags } from '../../../data/livechat/tags' ;
1010import { createMonitor , createUnit } from '../../../data/livechat/units' ;
1111import { updatePermission , updateSetting } from '../../../data/permissions.helper' ;
12- import { password } from '../../../data/user' ;
12+ import { password , adminUsername } from '../../../data/user' ;
1313import { createUser , login } from '../../../data/users.helper' ;
1414import { IS_EE } from '../../../e2e/config/constants' ;
1515
@@ -245,6 +245,33 @@ import { IS_EE } from '../../../e2e/config/constants';
245245 expect ( getResult ) . to . have . property ( 'success' , true ) ;
246246 expect ( getResult . cannedResponses ) . to . be . an ( 'array' ) . with . lengthOf ( 0 ) ;
247247 } ) ;
248+
249+ it ( 'should persist userId when updating a canned response' , async ( ) => {
250+ const response = await createCannedResponse ( ) ;
251+
252+ const {
253+ body : { cannedResponses } ,
254+ } = await request . get ( api ( 'canned-responses' ) ) . set ( credentials ) . query ( { } ) . expect ( 200 ) ;
255+
256+ const targetCannedResponse = cannedResponses . find (
257+ ( cannedResponse : IOmnichannelCannedResponse ) => cannedResponse . shortcut === response . shortcut ,
258+ ) ;
259+
260+ const { body } = await request
261+ . post ( api ( 'canned-responses' ) )
262+ . set ( credentials )
263+ . send ( { _id : targetCannedResponse . _id , shortcut : `${ targetCannedResponse . shortcut } -edited` , text : 'edited text' , scope : 'user' } )
264+ . expect ( 200 ) ;
265+ expect ( body ) . to . have . property ( 'success' , true ) ;
266+
267+ const { body : getResult } = await request
268+ . get ( api ( 'canned-responses' ) )
269+ . set ( credentials )
270+ . query ( { shortcut : `${ targetCannedResponse . shortcut } -edited` } )
271+ . expect ( 200 ) ;
272+ expect ( getResult ) . to . have . property ( 'success' , true ) ;
273+ expect ( getResult . cannedResponses [ 0 ] ) . to . have . property ( 'userId' , adminUsername ) ;
274+ } ) ;
248275 } ) ;
249276
250277 describe ( '[DELETE] canned-responses' , ( ) => {
0 commit comments