diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/sale_product_configurator/static/tests | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/sale_product_configurator/static/tests')
7 files changed, 986 insertions, 0 deletions
diff --git a/addons/sale_product_configurator/static/tests/product_configurator.test.js b/addons/sale_product_configurator/static/tests/product_configurator.test.js new file mode 100644 index 00000000..2d737820 --- /dev/null +++ b/addons/sale_product_configurator/static/tests/product_configurator.test.js @@ -0,0 +1,309 @@ +odoo.define('sale.product.configurator.tests', function (require) { +"use strict"; + +var FormView = require('web.FormView'); +var ProductConfiguratorFormView = require('sale_product_configurator.ProductConfiguratorFormView'); +var testUtils = require('web.test_utils'); +var createView = testUtils.createView; + +var getArch = function (){ + return '<form>' + + '<sheet>' + + '<field name="pricelist_id" widget="selection" />' + + '<field name="sale_order_line" widget="section_and_note_one2many">' + + '<tree editable="top"><control>' + + '<create string="Add a product"/>' + + '<create string="Add a section" context="{\'default_display_type\': \'line_section\'}"/>' + + '<create string="Add a note" context="{\'default_display_type\': \'line_note\'}"/>' + + '</control>' + + '<field name="product_id" invisible="1"/>' + + '<field name="product_template_id" widget="product_configurator"/>' + + '<field name="product_uom_qty"/>' + + '<field name="product_custom_attribute_value_ids" invisible="1"/>' + + '</tree>' + + '</field>' + + '</sheet>' + + '</form>'; +}; + +QUnit.module('Product Configurator', { + beforeEach: function () { + this.data = { + product_template: { + fields: { + id: {type: 'integer'} + }, + records: [{ + id: 42, + display_name: "Customizable Desk" + }] + }, + product: { + fields: { + id: {type: 'integer'} + }, + records: [{ + id: 1, + display_name: "Customizable Desk (1)" + }, { + id: 2, + display_name: "Customizable Desk (2)" + }] + }, + sale_order: { + fields: { + id: {type: 'integer'}, + pricelist_id: { + string: 'Pricelist', + type: 'one2many', + relation: 'pricelist' + }, + sale_order_line: { + string: 'lines', + type: 'one2many', + relation: 'sale_order_line' + }, + } + }, + sale_order_line: { + fields: { + product_template_id: { + string: 'product template', + type: 'many2one', + relation: 'product_template' + }, + product_id: { + string: 'product', + type: 'many2one', + relation: 'product' + }, + product_custom_attribute_value_ids: { + string: 'product_custom_attribute_values', + type: 'one2many', + relation: 'product_custom_attribute_value' + }, + product_uom_qty: {type: 'integer'}, + sequence: {type: 'integer'}, + } + }, + product_custom_attribute_value: { + fields: { + id: {type: 'integer'}, + sale_order_line_id: { + string: 'sale order line', + type: 'many2one', + relation: 'sale_order_line' + } + } + }, + sale_product_configurator: { + fields: { + product_template_id: { + string: 'product', + type: 'many2one', + relation: 'product_template' + }, + product_template_attribute_value_ids: { + type: 'many2many', + relation: 'product_template_attribute_value' + }, + product_no_variant_attribute_value_ids: { + type: 'many2many', + relation: 'product_template_attribute_value' + }, + product_custom_attribute_value_ids: { + type: 'many2many', + relation: 'product_attribute_custom_value' + } + }, + records: [{ + product_template_id: 42 + }] + }, + product_template_attribute_value: { + fields: { + id: {type: 'integer'} + } + }, + product_attribute_custom_value: { + fields: { + id: {type: 'integer'} + } + }, + pricelist: { + fields: { + id: {type: 'integer'} + } + } + }; + } +}, function () { + QUnit.test('Select a non configurable product template and verify that the product_id is correctly set', async function (assert) { + assert.expect(2); + + var form = await createView({ + View: FormView, + model: 'sale_order', + data: this.data, + arch: getArch(), + mockRPC: function (route, params) { + if (params.method === 'get_single_product_variant') { + assert.ok(true); + return Promise.resolve({product_id: 2}); + } + // FIXME awa: this shouldn't be here since the read is done in 'event_sale' + // But at the moment there is no easy way to solve such cross module 'include' issues + if (params.method === 'read') { + return Promise.resolve(false); + } + return this._super.apply(this, arguments); + }, + intercepts: { + do_action: function (ev) { + if (ev.data.action === 'sale_product_configurator.sale_product_configurator_action') { + assert.ok(false, "Should not execute the configure action"); + } + }, + } + }); + + await testUtils.dom.click(form.$("a:contains('Add a product')")); + await testUtils.fields.many2one.searchAndClickItem("product_template_id", {item: 'Customizable Desk'}); + // check that product_id is correctly set to 2 + assert.strictEqual(form.renderer.state.data.sale_order_line.data[0].data.product_id.data.id, 2); + form.destroy(); + }); + + QUnit.test('Select a configurable product template and verify that the product configurator is opened', async function (assert) { + assert.expect(2); + + var form = await createView({ + View: FormView, + model: 'sale_order', + data: this.data, + arch: getArch(), + mockRPC: function (route, params) { + if (params.method === 'get_single_product_variant') { + assert.ok(true); + return Promise.resolve(false); + } + return this._super.apply(this, arguments); + }, + intercepts: { + do_action: function (ev) { + if (ev.data.action === 'sale_product_configurator.sale_product_configurator_action') { + assert.ok(true); + } + }, + } + }); + + await testUtils.dom.click(form.$("a:contains('Add a product')")); + await testUtils.fields.many2one.searchAndClickItem("product_template_id", {item: 'Customizable Desk'}); + form.destroy(); + }); + + QUnit.test('trigger_up the "add_record" event and checks that rows are correctly added to the list', async function (assert) { + assert.expect(1); + + var form = await createView({ + View: FormView, + model: 'sale_order', + data: this.data, + arch: getArch() + }); + + var list = form.renderer.allFieldWidgets[form.handle][1]; + + list.trigger_up('add_record', { + context: [{default_product_id: 1, default_product_uom_qty: 2}, {default_product_id: 2, default_product_uom_qty: 3}], + forceEditable: "bottom" , + allowWarning: true + }); + await testUtils.nextTick(); + + assert.containsN(list, "tr.o_data_row", 2); + form.destroy(); + }); + + QUnit.test('Select a product in the list and check for template loading', async function (assert) { + assert.expect(1); + + var product_configurator_form = await createView({ + View: ProductConfiguratorFormView, + model: 'sale_product_configurator', + data: this.data, + arch: + '<form js_class="product_configurator_form">' + + '<group>' + + '<field name="product_template_id" class="oe_product_configurator_product_template_id" />' + + '<field name="product_template_attribute_value_ids" invisible="1" />' + + '<field name="product_no_variant_attribute_value_ids" invisible="1" />' + + '<field name="product_custom_attribute_value_ids" invisible="1" />' + + '</group>' + + '<footer>' + + '<button string="Add" class="btn-primary o_sale_product_configurator_add disabled"/>' + + '<button string="Cancel" class="btn-secondary" special="cancel"/>' + + '</footer>' + + '</form>', + mockRPC: function (route) { + if (route === '/sale_product_configurator/configure') { + assert.ok(true); + return Promise.resolve('<div>plop</div>'); + } + return this._super.apply(this, arguments); + } + }); + await testUtils.dom.click(product_configurator_form.$('.o_input')); + await testUtils.dom.click($("ul.ui-autocomplete li a:contains('Customizable Desk')").mouseenter()); + product_configurator_form.destroy(); + }); + + QUnit.test('drag and drop rows containing product_configurator many2one', async function (assert) { + assert.expect(4); + + this.data.sale_order.records = [ + { id: 1, sale_order_line: [1, 2] } + ]; + this.data.sale_order_line.records = [ + { id: 1, sequence: 5, product_id: 1 }, + { id: 2, sequence: 15, product_id: 2 }, + ]; + + const form = await createView({ + View: FormView, + model: 'sale_order', + data: this.data, + arch: ` + <form> + <field name="sale_order_line"/> + </form>`, + archs: { + 'sale_order_line,false,list': ` + <tree editable="bottom"> + <field name="sequence" widget="handle"/> + <field name="product_id" widget="product_configurator"/> + </tree>`, + }, + res_id: 1, + viewOptions: { + mode: 'edit', + }, + }); + + assert.containsN(form, '.o_data_row', 2); + assert.strictEqual(form.$('.o_data_row').text(), 'Customizable Desk (1)Customizable Desk (2)'); + assert.containsN(form, '.o_data_row .o_row_handle', 2); + + // move first row below second + const $firstHandle = form.$('.o_data_row:nth(0) .o_row_handle'); + const $secondHandle = form.$('.o_data_row:nth(1) .o_row_handle'); + await testUtils.dom.dragAndDrop($firstHandle, $secondHandle); + + assert.strictEqual(form.$('.o_data_row').text(), 'Customizable Desk (2)Customizable Desk (1)'); + + form.destroy(); + }); +}); + +}); diff --git a/addons/sale_product_configurator/static/tests/tours/product_configurator_advanced_ui.js b/addons/sale_product_configurator/static/tests/tours/product_configurator_advanced_ui.js new file mode 100644 index 00000000..16251f56 --- /dev/null +++ b/addons/sale_product_configurator/static/tests/tours/product_configurator_advanced_ui.js @@ -0,0 +1,165 @@ +odoo.define('sale.sale_product_configurator_advanced_tour', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +var optionVariantImage; + +tour.register('sale_product_configurator_advanced_tour', { + url: "/web", + test: true, +}, [tour.stepUtils.showAppsMenuItem(), { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', // Note: The module sale_management is mandatory + edition: 'community' +}, { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'enterprise' +}, { + trigger: ".o_list_button_add", + extra_trigger: ".o_sale_order" +}, { + trigger: ".o_required_modifier[name=partner_id] input", + run: "text Tajine Saucisse", +}, { + trigger: ".ui-menu-item > a:contains('Tajine Saucisse')", + auto: true, +}, { + trigger: "a:contains('Add a product')", + extra_trigger: ".o_field_widget[name=partner_shipping_id] > .o_external_button", // Wait for onchange_partner_id +}, { + trigger: 'div[name="product_template_id"] input', + run: function (){ + var $input = $('div[name="product_template_id"] input'); + $input.click(); + $input.val('Custo'); + var keyDownEvent = jQuery.Event("keydown"); + keyDownEvent.which = 42; + $input.trigger(keyDownEvent); + } +}, { + trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")', + run: 'click' +}, { + trigger: 'span:contains("Custom")', + extra_trigger: '.o_product_configurator', + run: 'click' +}, { + trigger: '.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(1) .variant_custom_value', + extra_trigger: '.o_product_configurator', + run: 'text Custom 1' +}, { + trigger: '.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(3) span:contains("PAV9")', + extra_trigger: '.o_product_configurator', + run: 'click' +}, { + trigger: '.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(3) .variant_custom_value', + extra_trigger: '.o_product_configurator', + run: 'text Custom 2' +}, { + trigger: '.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(4) span:contains("PAV5")', + extra_trigger: '.o_product_configurator', + run: 'click' +}, { + trigger: '.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(6) select ', + extra_trigger: '.o_product_configurator', + run: function (){ + var inputValue = $('.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(6) option[data-value_name="PAV9"]').val(); + $('.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(6) select').val(inputValue); + $('.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(6) select').trigger('change'); + } +}, { + trigger: '.o_product_configurator ul.js_add_cart_variants li[data-attribute_id]:nth-child(6) .variant_custom_value', + extra_trigger: '.o_product_configurator', + run: 'text Custom 3' +}, { + trigger: ".o_sale_product_configurator_add", + run: 'click' +}, { + trigger: '.main_product strong:contains("Custom, White, PAV9, PAV5, PAV1")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.main_product div:contains("Custom: Custom 1")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.main_product div:contains("PAV9: Custom 2")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.main_product div:contains("PAV9: Custom 3")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.main_product div:contains("PA5: PAV1")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.main_product div:contains("PA7: PAV1")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.main_product div:contains("PA8: PAV1")', + extra_trigger: '.oe_optional_products_modal', + run: function () {} //check +}, { + trigger: '.oe_optional_products_modal .js_product:eq(1) div:contains("Conference Chair (TEST) (Steel)")', + run: function () { + optionVariantImage = $('.oe_optional_products_modal .js_product:eq(1) img.variant_image').attr('src'); + } +}, { + trigger: '.oe_optional_products_modal .js_product:eq(1) input[data-value_name="Aluminium"]', +}, { + trigger: '.oe_optional_products_modal .js_product:eq(1) div:contains("Conference Chair (TEST) (Aluminium)")', + run: function () { + var newVariantImage = $('.oe_optional_products_modal .js_product:eq(1) img.variant_image').attr('src'); + if (newVariantImage !== optionVariantImage) { + $('<p>').text('image variant option src changed').insertAfter('.oe_optional_products_modal .js_product:eq(1) .product-name'); + } + + } +}, { + extra_trigger: '.oe_optional_products_modal .js_product:eq(1) div:contains("image variant option src changed")', + trigger: '.oe_optional_products_modal .js_product:eq(1) input[data-value_name="Steel"]', +}, { + trigger: 'button span:contains(Confirm)', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + trigger: 'td.o_data_cell:contains("Customizable Desk (TEST) (Custom, White, PAV9, PAV5, PAV1)")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}, { + trigger: 'td.o_data_cell:contains("Legs: Custom: Custom 1")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}, { + trigger: 'td.o_data_cell:contains("PA1: PAV9: Custom 2")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}, { + trigger: 'td.o_data_cell:contains("PA4: PAV9: Custom 3")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}, { + trigger: 'td.o_data_cell:contains("PA5: PAV1")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}, { + trigger: 'td.o_data_cell:contains("PA7: PAV1")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}, { + trigger: 'td.o_data_cell:contains("PA8: PAV1")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} //check +}]); + +}); diff --git a/addons/sale_product_configurator/static/tests/tours/product_configurator_edition_ui.js b/addons/sale_product_configurator/static/tests/tours/product_configurator_edition_ui.js new file mode 100644 index 00000000..dc7663d6 --- /dev/null +++ b/addons/sale_product_configurator/static/tests/tours/product_configurator_edition_ui.js @@ -0,0 +1,160 @@ +odoo.define('sale.product_configurator_edition_tour', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +tour.register('sale_product_configurator_edition_tour', { + url: "/web", + test: true, +}, [tour.stepUtils.showAppsMenuItem(), { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'community' +}, { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'enterprise' +}, { + trigger: ".o_list_button_add", + extra_trigger: ".o_sale_order" +}, { + trigger: "a:contains('Add a product')" +}, { + trigger: 'div[name="product_template_id"] input', + run: function (){ + var $input = $('div[name="product_template_id"] input'); + $input.click(); + $input.val('Custo'); + var keyDownEvent = jQuery.Event("keydown"); + keyDownEvent.which = 42; + $input.trigger(keyDownEvent); + } +}, { + trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")', + run: 'click' +}, { + trigger: '.configurator_container span:contains("Steel")', + run: function () { + $('input.product_id').change(function () { + $('.o_sale_product_configurator_add').attr('request_count', 1); + }); + } +}, { + trigger: '.configurator_container span:contains("Aluminium")' +}, { + trigger: '.o_sale_product_configurator_add[request_count="1"]', + run: function (){} // used to sync with "get_combination_info" completion +}, { + trigger: '.o_sale_product_configurator_add:not(.disabled)' +}, { + trigger: 'button span:contains(Confirm)', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + trigger: 'td.o_data_cell:contains("Customizable Desk (TEST) (Aluminium, White)")', + extra_trigger: 'div[name="order_line"]', + run: function (){} // check added product +}, { + trigger: 'td.o_product_configurator_cell', +}, { + trigger: '.o_edit_product_configuration', +}, { + trigger: '.configurator_container li.js_attribute_value:has(span:contains("Aluminium")) input:checked', + run: function (){} // check updated legs +}, { + trigger: 'span.oe_currency_value:contains("800")', + run: function (){} // check updated price +}, { + trigger: '.configurator_container span:contains("Steel")', + run: function () { + $('input.product_id').change(function () { + if ($('.o_sale_product_configurator_edit').attr('request_count')) { + $('.o_sale_product_configurator_edit').attr('request_count', + parseInt($('.o_sale_product_configurator_edit').attr('request_count')) + 1); + } else { + $('.o_sale_product_configurator_edit').attr('request_count', 1); + } + }); + } +}, { + trigger: '.configurator_container span:contains("Custom")', + run: function () { + // FIXME awa: since jquery3 update it doesn't "click" + // on the element without this run (and 'run: "click"' + // doesn't work either) + $('.configurator_container span:contains("Custom")').click(); + } +}, { + trigger: '.configurator_container .variant_custom_value', + run: 'text nice custom value' +}, { + trigger: 'input[data-value_name="Black"]', + run: 'click' +}, { + trigger: '.o_sale_product_configurator_edit[request_count="2"]', + run: function (){} // used to sync with "get_combination_info" completion +}, { + trigger: '.o_sale_product_configurator_edit', +}, { + trigger: 'td.o_data_cell:contains("Customizable Desk (TEST) (Custom, Black)")', + extra_trigger: 'div[name="order_line"]', + run: function (){} // check updated product +}, { + trigger: 'td.o_data_cell:contains("Custom: nice custom value")', + extra_trigger: 'div[name="order_line"]', + run: function (){} // check custom value +}, { + trigger: 'td.o_product_configurator_cell', +}, { + trigger: '.o_edit_product_configuration', +}, { + trigger: '.configurator_container .variant_custom_value', + run: 'text another nice custom value' +}, { + trigger: '.o_sale_product_configurator_edit', +}, { + trigger: 'td.o_data_cell:contains("Custom: another nice custom value")', + extra_trigger: 'div[name="order_line"]', + run: function (){} // check custom value +}, { + trigger: 'td.o_product_configurator_cell', +}, { + trigger: '.o_edit_product_configuration', +}, { + trigger: '.configurator_container span:contains("Steel")', + run: function () { + $('input.product_id').change(function () { + $('.o_sale_product_configurator_edit').attr('request_count', 1); + }); + } +}, { + trigger: '.configurator_container span:contains("Steel")', + run: function () { + // FIXME awa: since jquery3 update it doesn't "click" + // on the element without this run (and 'run: "click"' + // doesn't work either) + $('.configurator_container span:contains("Steel")').click(); + } +}, { + trigger: '.o_sale_product_configurator_edit[request_count="1"]', + run: function (){} // used to sync with "get_combination_info" completion +}, { + trigger: '.configurator_container button.js_add_cart_json:has(.fa-plus)', +}, { + trigger: '.o_sale_product_configurator_edit', +}, { + trigger: 'td.o_data_cell:contains("2.00")', + run: function (){} // check quantity +}, { + trigger: 'td.o_product_configurator_cell', + run: function () { + // used to check that the description does not contain a custom value anymore + if ($('td.o_data_cell:contains("Custom: another nice custom value")').length === 0){ + $('td.o_data_cell:contains("Customizable Desk (TEST) (Steel, Black)")').html('tour success'); + } + } +}, { + trigger: 'td.o_data_cell:contains("tour success")', + extra_trigger: 'div[name="order_line"]', + run: function (){} +}]); + +}); diff --git a/addons/sale_product_configurator/static/tests/tours/product_configurator_optional_products_ui.js b/addons/sale_product_configurator/static/tests/tours/product_configurator_optional_products_ui.js new file mode 100644 index 00000000..c566ce5b --- /dev/null +++ b/addons/sale_product_configurator/static/tests/tours/product_configurator_optional_products_ui.js @@ -0,0 +1,79 @@ +odoo.define('sale.product_configurator_optional_products_tour', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +tour.register('sale_product_configurator_optional_products_tour', { + url: "/web", + test: true, +}, [tour.stepUtils.showAppsMenuItem(), { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'community' +}, { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'enterprise' +}, { + trigger: ".o_list_button_add", + extra_trigger: ".o_sale_order" +}, { + trigger: "a:contains('Add a product')" +}, { + trigger: 'div[name="product_template_id"] input', + run: function () { + var $input = $('div[name="product_template_id"] input'); + $input.click(); + $input.val('Customizable Desk'); + var keyDownEvent = jQuery.Event("keydown"); + keyDownEvent.which = 42; + $input.trigger(keyDownEvent); + } +}, { + trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")', + run: 'click' +}, { + trigger: '.o_sale_product_configurator_add' +}, { + trigger: 'tr:has(.td-product_name:contains("Office Chair Black")) .js_add', +}, { + trigger: 'tr:has(.td-product_name:contains("Customizable Desk")) .fa-plus' +}, { + trigger: 'tr:has(.td-product_name:contains("Chair floor protection")) .js_add', +}, { + content: 'Is below its parent 1', + trigger: 'tr:has(.td-product_name:contains("Office Chair Black")) + tr:has(.td-product_name:contains("Chair floor protection"))' +}, { + trigger: 'tr:has(.td-product_name:contains("Conference Chair")) .js_add', +}, { + trigger: 'tr:has(.td-product_name:contains("Conference Chair")) .fa-minus' +}, { + trigger: 'tr:has(.td-product_name:contains("Chair floor protection")) .js_add', +}, { + content: 'Is below its parent 2', + trigger: 'tr:has(.td-product_name:contains("Conference Chair")) + tr:has(.td-product_name:contains("Chair floor protection"))' +}, { + trigger: 'button span:contains(Confirm)', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + trigger: 'tr:has(td.o_data_cell:contains("Customizable Desk")) td.o_data_cell:contains("2.0")', + extra_trigger: 'div[name="order_line"]', + run: function () {}, // check added product +}, { + trigger: 'tr:has(td.o_data_cell:contains("Office Chair Black")) td.o_data_cell:contains("1.0")', + extra_trigger: 'div[name="order_line"]', + run: function () {}, // check added product +}, { + trigger: 'tr:has(td.o_data_cell:contains("Conference Chair")) td.o_data_cell:contains("1.0")', + extra_trigger: 'div[name="order_line"]', + run: function () {}, // check added product +}, { + trigger: 'tr:has(td.o_data_cell:contains("Chair floor protection")):nth(0) td.o_data_cell:contains("1.0")', + extra_trigger: 'div[name="order_line"]', + run: function () {}, // check added product +}, { + trigger: 'tr:has(td.o_data_cell:contains("Chair floor protection")):nth(1) td.o_data_cell:contains("1.0")', + extra_trigger: 'div[name="order_line"]', + run: function () {}, // check added product +}]); + +}); diff --git a/addons/sale_product_configurator/static/tests/tours/product_configurator_pricelist_ui.js b/addons/sale_product_configurator/static/tests/tours/product_configurator_pricelist_ui.js new file mode 100644 index 00000000..af97bf1f --- /dev/null +++ b/addons/sale_product_configurator/static/tests/tours/product_configurator_pricelist_ui.js @@ -0,0 +1,99 @@ +odoo.define('sale.product_configurator_pricelist_tour', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +tour.register('sale_product_configurator_pricelist_tour', { + url: "/web", + test: true, +}, +[ +tour.stepUtils.showAppsMenuItem(), +{ + content: "navigate to the sale app", + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'community' +}, { + content: "navigate to the sale app", + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'enterprise' +}, { + content: "create a new order", + trigger: '.o_list_button_add', + extra_trigger: ".o_sale_order" +}, { + content: "search the partner", + trigger: 'div[name="partner_id"] input', + run: 'text Azure' +}, { + content: "select the partner", + trigger: 'ul.ui-autocomplete > li > a:contains(Azure)', +}, { + content: "search the pricelist", + trigger: 'div[name="pricelist_id"] input', + run: 'text Custom pricelist (TEST)' +}, { + content: "select the pricelist", + trigger: 'ul.ui-autocomplete > li > a:contains(Custom pricelist (TEST))', +}, { + trigger: "a:contains('Add a product')" +}, { + trigger: 'div[name="product_template_id"] input', + run: function (){ + var $input = $('div[name="product_template_id"] input'); + $input.click(); + $input.val('Custo'); + var keyDownEvent = jQuery.Event("keydown"); + keyDownEvent.which = 42; + $input.trigger(keyDownEvent); + } +}, { + trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")', + run: 'click' +}, { + content: "check price is correct (USD)", + trigger: 'span.oe_currency_value:contains("750.00")', + run: function () {} // check price +}, { + content: "add one more", + trigger: 'button.js_add_cart_json:has(i.fa-plus)', +}, { + content: "check price for 2", + trigger: 'span.oe_currency_value:contains("600.00")', + run: function () {} // check price (pricelist has discount for 2) +}, { + content: "click add", + trigger: '.o_sale_product_configurator_add:not(.disabled)' +}, { + content: "check we are on the add modal", + trigger: '.td-product_name:contains("Customizable Desk (TEST) (Steel, White)")', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + content: "add conference chair", + trigger: '.js_product:has(strong:contains(Conference Chair)) .js_add', + extra_trigger: '.oe_optional_products_modal .js_product:has(strong:contains(Conference Chair))', + run: 'click' +}, { + content: "add chair floor protection", + trigger: '.js_product:has(strong:contains(Chair floor protection)) .js_add', + extra_trigger: '.oe_optional_products_modal .js_product:has(strong:contains(Chair floor protection))', + run: 'click' +}, { + content: "verify configurator final price", // tax excluded + trigger: '.o_total_row .oe_currency_value:contains("1,257.00")', +}, { + content: "add to SO", + trigger: 'button span:contains(Confirm)', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + content: "verify SO final price excluded", + trigger: 'span[name="amount_untaxed"]:contains("1,257.00")', +}, { + content: "verify SO final price included", + trigger: 'span[name="amount_total"]:contains("1,437.00")', +} +]); + +}); diff --git a/addons/sale_product_configurator/static/tests/tours/product_configurator_single_custom_attribute_ui.js b/addons/sale_product_configurator/static/tests/tours/product_configurator_single_custom_attribute_ui.js new file mode 100644 index 00000000..8b1db607 --- /dev/null +++ b/addons/sale_product_configurator/static/tests/tours/product_configurator_single_custom_attribute_ui.js @@ -0,0 +1,79 @@ +odoo.define('sale.product_configurator_single_custom_attribute_tour', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +tour.register('sale_product_configurator_single_custom_attribute_tour', { + url: "/web", + test: true, +}, [tour.stepUtils.showAppsMenuItem(), { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'community' +}, { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'enterprise' +}, { + trigger: ".o_list_button_add", + extra_trigger: ".o_sale_order" +}, { + trigger: "a:contains('Add a product')" +}, { + trigger: 'div[name="product_template_id"] input', + run: function (){ + var $input = $('div[name="product_template_id"] input'); + $input.click(); + $input.val('Custo'); + // fake keydown to trigger search + var keyDownEvent = jQuery.Event("keydown"); + keyDownEvent.which = 42; + $input.trigger(keyDownEvent); + } +}, { + trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")', + run: 'click' +}, { + trigger: '.configurator_container span:contains("Aluminium")', + run: function () { + // used to check that the radio is NOT rendered + if ($('.configurator_container ul[data-attribute_id].d-none input[data-value_name="single product attribute value"]').length === 1) { + $('.configurator_container').addClass('tour_success'); + } + } +}, { + trigger: '.configurator_container.tour_success', + run: function () { + //check + } +}, { + trigger: '.configurator_container .variant_custom_value', + run: 'text great single custom value' +}, { + trigger: '.o_sale_product_configurator_add', +}, { + trigger: 'button span:contains(Confirm)', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + trigger: 'td.o_data_cell:contains("single product attribute value: great single custom value")', + extra_trigger: 'div[name="order_line"]', + run: function (){} // check custom value +}, { + trigger: 'td.o_product_configurator_cell', +}, { + trigger: '.o_edit_product_configuration', +}, { + trigger: '.configurator_container .variant_custom_value', + run: function () { + // check custom value initialized + if ($('.configurator_container .variant_custom_value').val() === "great single custom value") { + $('.configurator_container').addClass('tour_success_2'); + } + } +}, { + trigger: '.configurator_container.tour_success_2', + run: function () { + //check + } +}]); + +}); diff --git a/addons/sale_product_configurator/static/tests/tours/product_configurator_ui.js b/addons/sale_product_configurator/static/tests/tours/product_configurator_ui.js new file mode 100644 index 00000000..fad1fbd3 --- /dev/null +++ b/addons/sale_product_configurator/static/tests/tours/product_configurator_ui.js @@ -0,0 +1,95 @@ +odoo.define('sale.product_configurator_tour', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +// Note: please keep this test without pricelist for maximum coverage. +// The pricelist is tested on the other tours. + +tour.register('sale_product_configurator_tour', { + url: "/web", + test: true, +}, [tour.stepUtils.showAppsMenuItem(), { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'community' +}, { + trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]', + edition: 'enterprise' +}, { + trigger: ".o_list_button_add", + extra_trigger: ".o_sale_order" +}, { + trigger: "a:contains('Add a product')", +}, { + trigger: 'div[name="product_template_id"] input', + run: function (){ + var $input = $('div[name="product_template_id"] input'); + $input.click(); + $input.val('Custo'); + // fake keydown to trigger search + var keyDownEvent = jQuery.Event("keydown"); + keyDownEvent.which = 42; + $input.trigger(keyDownEvent); + } +}, { + trigger: 'ul.ui-autocomplete a:contains("Customizable Desk (TEST)")', + run: 'click' +}, { + trigger: '.configurator_container span:contains("Steel")', + run: function () {}, +}, { + trigger: '.configurator_container span:contains("Aluminium")', + run: 'click' +}, { + trigger: 'span.oe_currency_value:contains("800.40")', + run: function (){} // check updated price +}, { + trigger: 'input[data-value_name="Black"]' +}, { + trigger: '.o_sale_product_configurator_add.disabled' +}, { + trigger: 'input[data-value_name="White"]' +}, { + trigger: '.o_sale_product_configurator_add:not(.disabled)' +}, { + trigger: 'span:contains("Aluminium")', + extra_trigger: '.oe_optional_products_modal', + run: 'click' +}, { + trigger: '.js_product:has(strong:contains(Conference Chair)) .js_add', + extra_trigger: '.oe_optional_products_modal .js_product:has(strong:contains(Conference Chair))', + run: 'click' +}, { + trigger: '.js_product:has(strong:contains(Chair floor protection)) .js_add', + extra_trigger: '.oe_optional_products_modal .js_product:has(strong:contains(Chair floor protection))', + run: 'click' +}, { + trigger: 'button span:contains(Confirm)', + extra_trigger: '.oe_optional_products_modal', + id: "quotation_product_selected", + run: 'click' +}, +// check that 3 products were added to the SO +{ + trigger: 'td.o_data_cell:contains("Customizable Desk (TEST) (Aluminium, White)")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} +}, { + trigger: 'td.o_data_cell:contains("Conference Chair (TEST) (Aluminium)")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} +}, { + trigger: 'td.o_data_cell:contains("Chair floor protection")', + extra_trigger: 'div[name="order_line"]', + in_modal: false, + run: function (){} +}, { + trigger: '.o_readonly_modifier[name=amount_total]:contains("0.00")', + in_modal: false, + run: function (){} +} +]); + +}); |
