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.

52 lines
2.4 KiB

  1. # Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  3. import odoo.tests
  4. from odoo.api import Environment
  5. @odoo.tests.common.at_install(True)
  6. @odoo.tests.common.post_install(True)
  7. class TestUi(odoo.tests.HttpCase):
  8. def test_create_new_partner_and_move_message(self):
  9. env = Environment(self.registry.test_cr, self.uid, {})
  10. # needed because tests are run before the module is marked as
  11. # installed. In js web will only load qweb coming from modules
  12. # that are returned by the backend in module_boot. Without
  13. # this you end up with js, css but no qweb.
  14. env['ir.module.module'].search([('name', '=', 'mail_move_message')], limit=1).state = 'installed'
  15. self.registry.cursor().release()
  16. # updating models, to be able relocate messages to a partner at_install
  17. config_parameters = self.env["ir.config_parameter"].sudo()
  18. config_parameters.set_param("mail_relocation_models", "crm.lead,project.task,res.partner")
  19. code = """
  20. var delayed_button_click = function(delay, button){
  21. setTimeout(function(){
  22. if (button.length) {
  23. return button.click();
  24. }
  25. return console.log('error', 'There is no element with the next selector: ' + button.selector);
  26. }, delay);
  27. };
  28. var delay = 1000;
  29. var message = $('.o_thread_message_core:contains("virginie")');
  30. var relocate = message.find('.o_thread_icons .fa-exchange');
  31. delayed_button_click(delay, relocate);
  32. // form is opened
  33. var create_partner_button = $('button[special="quick_create"]');
  34. delayed_button_click(delay, create_partner_button);
  35. // partner creation wizard is opened
  36. var save_button = $('.modal-content .btn-primary:contains("Save")');
  37. delayed_button_click(delay, save_button);
  38. var move_button = $('.btn-sm.oe_highlight:contains("Move")');
  39. delayed_button_click(delay, move_button);
  40. console.log('ok')
  41. """
  42. self.phantom_js('/web', code, login="admin", ready="$('.o_thread_icons').length")