/addons/sale_product_configurator/static/tests/tours/product_configurator_edition_ui.js

https://gitlab.com/odoo-manage/odoo-manage · JavaScript · 162 lines · 152 code · 3 blank · 7 comment · 3 complexity · c3ffd3630ce101fdb5d73956341755c6 MD5 · raw file

  1. odoo.define('sale.product_configurator_edition_tour', function (require) {
  2. "use strict";
  3. var tour = require('web_tour.tour');
  4. tour.register('sale_product_configurator_edition_tour', {
  5. url: "/web",
  6. test: true,
  7. }, [tour.stepUtils.showAppsMenuItem(), {
  8. trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]',
  9. edition: 'community'
  10. }, {
  11. trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]',
  12. edition: 'enterprise'
  13. }, {
  14. trigger: ".o_list_button_add",
  15. extra_trigger: ".o_sale_order"
  16. }, {
  17. trigger: "a:contains('Add a product')"
  18. }, {
  19. trigger: 'div[name="product_template_id"] input',
  20. run: function (){
  21. var $input = $('div[name="product_template_id"] input');
  22. $input.click();
  23. $input.val('Custo');
  24. var keyDownEvent = jQuery.Event("keydown");
  25. keyDownEvent.which = 42;
  26. $input.trigger(keyDownEvent);
  27. }
  28. }, {
  29. trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")',
  30. run: 'click'
  31. }, {
  32. trigger: '.main_product span:contains("Steel")',
  33. run: function () {
  34. $('input.product_id').change(function () {
  35. $('.show .modal-footer .btn-primary').attr('request_count', 1);
  36. });
  37. }
  38. }, {
  39. trigger: '.main_product span:contains("Aluminium")'
  40. }, {
  41. trigger: '.btn-primary[request_count="1"]',
  42. extra_trigger: '.show .modal-footer',
  43. run: function (){} // used to sync with "get_combination_info" completion
  44. }, {
  45. trigger: '.btn-primary:not(.disabled)',
  46. extra_trigger: '.show .modal-footer',
  47. }, {
  48. trigger: 'button span:contains(Confirm)',
  49. extra_trigger: '.oe_advanced_configurator_modal',
  50. run: 'click'
  51. }, {
  52. trigger: 'td.o_data_cell:contains("Customizable Desk (TEST) (Aluminium, White)")',
  53. extra_trigger: 'div[name="order_line"]',
  54. run: function (){} // check added product
  55. }, {
  56. trigger: 'td.o_product_configurator_cell',
  57. }, {
  58. trigger: '.o_edit_product_configuration',
  59. }, {
  60. trigger: '.configurator_container li.js_attribute_value:has(span:contains("Aluminium")) input:checked',
  61. run: function (){} // check updated legs
  62. }, {
  63. trigger: 'span.oe_currency_value:contains("800")',
  64. run: function (){} // check updated price
  65. }, {
  66. trigger: '.configurator_container span:contains("Steel")',
  67. run: function () {
  68. $('input.product_id').change(function () {
  69. if ($('.o_sale_product_configurator_edit').attr('request_count')) {
  70. $('.o_sale_product_configurator_edit').attr('request_count',
  71. parseInt($('.o_sale_product_configurator_edit').attr('request_count')) + 1);
  72. } else {
  73. $('.o_sale_product_configurator_edit').attr('request_count', 1);
  74. }
  75. });
  76. }
  77. }, {
  78. trigger: '.configurator_container span:contains("Custom")',
  79. run: function () {
  80. // FIXME awa: since jquery3 update it doesn't "click"
  81. // on the element without this run (and 'run: "click"'
  82. // doesn't work either)
  83. $('.configurator_container span:contains("Custom")').click();
  84. }
  85. }, {
  86. trigger: '.configurator_container .variant_custom_value',
  87. run: 'text nice custom value'
  88. }, {
  89. trigger: 'input[data-value_name="Black"]',
  90. run: 'click'
  91. }, {
  92. trigger: '.o_sale_product_configurator_edit[request_count="2"]',
  93. run: function (){} // used to sync with "get_combination_info" completion
  94. }, {
  95. trigger: '.o_sale_product_configurator_edit',
  96. }, {
  97. trigger: 'td.o_data_cell:contains("Customizable Desk (TEST) (Custom, Black)")',
  98. extra_trigger: 'div[name="order_line"]',
  99. run: function (){} // check updated product
  100. }, {
  101. trigger: 'td.o_data_cell:contains("Custom: nice custom value")',
  102. extra_trigger: 'div[name="order_line"]',
  103. run: function (){} // check custom value
  104. }, {
  105. trigger: 'td.o_product_configurator_cell',
  106. }, {
  107. trigger: '.o_edit_product_configuration',
  108. }, {
  109. trigger: '.configurator_container .variant_custom_value',
  110. run: 'text another nice custom value'
  111. }, {
  112. trigger: '.o_sale_product_configurator_edit',
  113. }, {
  114. trigger: 'td.o_data_cell:contains("Custom: another nice custom value")',
  115. extra_trigger: 'div[name="order_line"]',
  116. run: function (){} // check custom value
  117. }, {
  118. trigger: 'td.o_product_configurator_cell',
  119. }, {
  120. trigger: '.o_edit_product_configuration',
  121. }, {
  122. trigger: '.configurator_container span:contains("Steel")',
  123. run: function () {
  124. $('input.product_id').change(function () {
  125. $('.o_sale_product_configurator_edit').attr('request_count', 1);
  126. });
  127. }
  128. }, {
  129. trigger: '.configurator_container span:contains("Steel")',
  130. run: function () {
  131. // FIXME awa: since jquery3 update it doesn't "click"
  132. // on the element without this run (and 'run: "click"'
  133. // doesn't work either)
  134. $('.configurator_container span:contains("Steel")').click();
  135. }
  136. }, {
  137. trigger: '.o_sale_product_configurator_edit[request_count="1"]',
  138. run: function (){} // used to sync with "get_combination_info" completion
  139. }, {
  140. trigger: '.configurator_container button.js_add_cart_json:has(.fa-plus)',
  141. }, {
  142. trigger: '.o_sale_product_configurator_edit',
  143. }, {
  144. trigger: 'td.o_data_cell:contains("2.00")',
  145. run: function (){} // check quantity
  146. }, {
  147. trigger: 'td.o_product_configurator_cell',
  148. run: function () {
  149. // used to check that the description does not contain a custom value anymore
  150. if ($('td.o_data_cell:contains("Custom: another nice custom value")').length === 0){
  151. $('td.o_data_cell:contains("Customizable Desk (TEST) (Steel, Black)")').html('tour success');
  152. }
  153. }
  154. }, {
  155. trigger: 'td.o_data_cell:contains("tour success")',
  156. extra_trigger: 'div[name="order_line"]',
  157. run: function (){}
  158. }]);
  159. });