@@ -71,6 +71,49 @@ def test_unquoted_reply(self):
7171 wizard = (
7272 self .env [action ["res_model" ]].with_context (** action ["context" ]).create ({})
7373 )
74+ wizard = wizard .with_context (
75+ default_subject = "Some subject for testing purposes" ,
76+ )
77+ self .assertTrue (wizard .partner_ids )
78+ self .assertEqual (message .email_from , wizard .partner_ids .email_formatted )
79+ # the onchange in the composer isn't triggered in tests, so we check for the
80+ # correct quote in the context
81+ email_quote = re .search ("<p>.*?</p>" , wizard .env .context ["quote_body" ]).group ()
82+ self .assertEqual ("<p>demo message</p>" , email_quote )
83+ wizard .action_send_mail ()
84+ new_message = partner .message_ids .filtered (
85+ lambda r : r .message_type != "notification" and r != message
86+ )
87+ self .assertTrue (new_message )
88+ self .assertEqual (1 , len (new_message ))
89+
90+ def test_reply_with_existing_body (self ):
91+ partner = self .env ["res.partner" ].create ({"name" : "demo partner" })
92+ self .assertFalse (
93+ partner .message_ids .filtered (lambda r : r .message_type != "notification" )
94+ )
95+ # pylint: disable=C8107
96+ message = partner .message_post (
97+ body = "demo message" ,
98+ message_type = "email" ,
99+ partner_ids = self .env .ref ("base.partner_admin" ).ids ,
100+ )
101+ partner .invalidate_recordset ()
102+ self .assertIn (
103+ message ,
104+ partner .message_ids .filtered (lambda r : r .message_type != "notification" ),
105+ )
106+ self .assertFalse (
107+ partner .message_ids .filtered (
108+ lambda r : r .message_type != "notification" and r != message
109+ )
110+ )
111+ action = message .reply_message ()
112+ action ["context" ]["is_quoted_reply" ] = False
113+ wizard = (
114+ self .env [action ["res_model" ]].with_context (** action ["context" ]).create ({})
115+ )
116+ wizard .body = "Some body for testing purposes"
74117 self .assertTrue (wizard .partner_ids )
75118 self .assertEqual (message .email_from , wizard .partner_ids .email_formatted )
76119 # the onchange in the composer isn't triggered in tests, so we check for the
0 commit comments