You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.8 KiB

  1. from werkzeug import url_encode
  2. import odoo.tests
  3. @odoo.tests.common.at_install(True)
  4. @odoo.tests.common.post_install(True)
  5. class TestUi(odoo.tests.HttpCase):
  6. def test_01_mail_to(self):
  7. # checks the presence of an element with a link to the recipient
  8. env = self.env
  9. # needed because tests are run before the module is marked as
  10. # installed. In js web will only load qweb coming from modules
  11. # that are returned by the backend in module_boot. Without
  12. # this you end up with js, css but no qweb.
  13. env["ir.module.module"].search(
  14. [("name", "=", "mail_to")], limit=1
  15. ).state = "installed"
  16. # Handle messages in Odoo
  17. res_users_ids = env["res.users"].search([])
  18. res_users_ids.write({"notification_type": "inbox"})
  19. # demo messages
  20. partner_ids = env["res.partner"].search([])
  21. msg = env["mail.message"].create(
  22. {
  23. "subject": "_Test",
  24. "body": self._testMethodName,
  25. "subtype_id": self.ref("mail.mt_comment"),
  26. "model": "mail.channel",
  27. "partner_ids": [(6, 0, [i.id for i in partner_ids])],
  28. }
  29. )
  30. # notifications for everyone
  31. for p in partner_ids.ids:
  32. env["mail.notification"].create(
  33. {"res_partner_id": p, "mail_message_id": msg.id, "is_read": False,}
  34. )
  35. code = """
  36. setTimeout(function () {
  37. console.log($('a.recipient_link').length && 'ok' || 'error');
  38. }, 3000);
  39. """
  40. link = "/web#%s" % url_encode({"action": "mail.action_discuss"})
  41. self.phantom_js(
  42. link,
  43. code,
  44. "odoo.__DEBUG__.services['web_tour.tour'].tours.mail_tour.ready",
  45. login="admin",
  46. )