diff --git a/helpdesk_mgmt/tests/test_helpdesk_portal.py b/helpdesk_mgmt/tests/test_helpdesk_portal.py
index 0d8d94198a..ddc21376c0 100644
--- a/helpdesk_mgmt/tests/test_helpdesk_portal.py
+++ b/helpdesk_mgmt/tests/test_helpdesk_portal.py
@@ -59,7 +59,7 @@ def _create_ticket(self, partner, ticket_title):
}
)
- def _submit_ticket(self):
+ def _submit_ticket(self, files=None):
resp = self.url_open(
"/submitted/ticket",
data={
@@ -68,6 +68,7 @@ def _submit_ticket(self):
"subject": self.new_ticket_title,
"description": "\n".join(self.new_ticket_desc_lines),
},
+ files=files,
)
self.assertEqual(resp.status_code, 200)
@@ -92,3 +93,34 @@ def test_submit_ticket_02(self):
"
" + "
".join(self.new_ticket_desc_lines) + "
",
tickets.mapped("description"),
)
+
+ def test_submit_ticket_with_attachments(self):
+ self.authenticate("test-user", "test-user")
+ self._submit_ticket(
+ files=[
+ (
+ "attachment",
+ ("test.txt", b"test", "plain/text"),
+ ),
+ (
+ "attachment",
+ ("test.svg", b"", "image/svg+xml"),
+ ),
+ ]
+ )
+ ticket_id = self.get_new_tickets(self.basic_user)
+ self.assertEqual(len(ticket_id), 1)
+ # check that both files have been linked to the newly created ticket
+ attachment_ids = self.env["ir.attachment"].search(
+ [
+ ("res_model", "=", "helpdesk.ticket"),
+ ("res_id", "=", ticket_id.id),
+ ]
+ )
+ self.assertEqual(len(attachment_ids), 2)
+ # check that both files have kept their names
+ self.assertIn("test.txt", attachment_ids.mapped("name"))
+ self.assertIn("test.svg", attachment_ids.mapped("name"))
+ # check that both files are public (access_token is set)
+ self.assertTrue(attachment_ids[0].access_token)
+ self.assertTrue(attachment_ids[1].access_token)