feat(inout): 발주 메일 미리보기에서 본문 바로 고치기
미리보기 창을 눌러 글·표를 고치면 고친 본문 그대로 발송(안 고치면 서버 본문). 서버가 허용 태그·인라인 서식만 남기고 글 버전도 다시 만든다. [원래 본문으로]·닫을 때 확인. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -393,3 +393,37 @@ class OrderNoticeMailTests(OrderMailCcTests):
|
||||
self.assertIn("입고 담당이 옵션에 없어", r.json()["message"])
|
||||
|
||||
test_preview_cc_default_and_setting = test_save_option_admin_only = None
|
||||
|
||||
|
||||
class OrderMailEditTests(OrderNoticeMailTests):
|
||||
"""미리보기 창에서 고친 발주 메일 본문을 그대로 보낸다(2026-10-27) — 입고 담당 알림은 원래 내용 그대로."""
|
||||
|
||||
def _post(self, body):
|
||||
def fake_send(refresh, raw):
|
||||
self.sent.append(email.message_from_bytes(raw, policy=policy.default))
|
||||
return "g"
|
||||
|
||||
with patch.object(gmail, "decrypt_token", lambda e, enc: "refresh"), patch.object(gmail, "send", fake_send):
|
||||
return self.c.post("/inout/orders/7/mail", json={"to": "f@x.com", **body})
|
||||
|
||||
def test_edited_body_sent_cleaned(self):
|
||||
r = self._post({"html": '<p style="color:red" onclick="x()">납기 당겨 주세요<script>alert(1)</script></p>'
|
||||
'<table><tr><td style="background:#ffd8a8">MW-0320</td><td>5,500</td></tr></table>'})
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
factory, notice = self.sent
|
||||
h = factory.get_body(("html",)).get_content()
|
||||
self.assertIn('<p style="color:red">납기 당겨 주세요</p>', h)
|
||||
self.assertIn('<td style="background:#ffd8a8">MW-0320</td>', h)
|
||||
for absent in ("onclick", "script", "alert"):
|
||||
self.assertNotIn(absent, h)
|
||||
self.assertIn("MW-0320 | 5,500", factory.get_body(("plain",)).get_content()) # 글 버전도 고친 본문에서
|
||||
self.assertIn("PO-261019-01", notice.get_body(("html",)).get_content()) # 알림은 서버가 만든 내용
|
||||
|
||||
def test_empty_edited_body_rejected(self):
|
||||
r = self._post({"html": "<p> <br></p>"})
|
||||
self.assertEqual(r.status_code, 400)
|
||||
self.assertIn("비어 있습니다", r.json()["detail"])
|
||||
self.assertEqual(self.sent, [])
|
||||
|
||||
test_preview_shows_notice_recipients = test_notice_sent_separately_same_subject_minimal_body = None
|
||||
test_no_receivers_or_notice_failure_does_not_block = None
|
||||
|
||||
Reference in New Issue
Block a user