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/static/tests | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/sale/static/tests')
| -rw-r--r-- | addons/sale/static/tests/product_configurator_tests.js | 100 | ||||
| -rw-r--r-- | addons/sale/static/tests/sales_team_dashboard_tests.js | 122 | ||||
| -rw-r--r-- | addons/sale/static/tests/tours/sale_signature.js | 51 |
3 files changed, 273 insertions, 0 deletions
diff --git a/addons/sale/static/tests/product_configurator_tests.js b/addons/sale/static/tests/product_configurator_tests.js new file mode 100644 index 00000000..eaed8488 --- /dev/null +++ b/addons/sale/static/tests/product_configurator_tests.js @@ -0,0 +1,100 @@ +odoo.define('sale.product_configurator_tests', function (require) { + "use strict"; + + const FormView = require('web.FormView'); + const testUtils = require('web.test_utils'); + + const createView = testUtils.createView; + + QUnit.module('product_configurator', { + beforeEach: function () { + this.data = { + order: { + fields: { + line_ids: { + string: "Lines", + type: 'one2many', + relation: 'line', + relation_field: 'order_id' + }, + }, + records: [ + {id: 1, line_ids: [1, 2]}, + ], + }, + line: { + fields: { + product_id: { + string: "Product", + type: 'many2one', + relation: 'product', + }, + order_id: { + string: "Order", + type: 'many2one', + relation: 'order' + }, + sequence: { + string: "Sequence", + type: 'number', + }, + }, + records: [ + {id: 1, sequence: 4, product_id: 3, order_id: 1}, + {id: 2, sequence: 14, product_id: 4, order_id: 1}, + ] + }, + product: { + fields: { + name: { + string: "Name", + type: 'char', + }, + }, + records: [ + {id: 3, name: "Chair"}, + {id: 4, name: "Table"}, + ], + }, + }; + }, + }, function () { + QUnit.test('drag and drop rows containing product_configurator many2one', async function (assert) { + assert.expect(4); + + const form = await createView({ + View: FormView, + model: 'order', + data: this.data, + arch: ` + <form> + <field name="line_ids"/> + </form>`, + archs: { + '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(), 'ChairTable'); + 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(), 'TableChair'); + + form.destroy(); + }); + }); +}); diff --git a/addons/sale/static/tests/sales_team_dashboard_tests.js b/addons/sale/static/tests/sales_team_dashboard_tests.js new file mode 100644 index 00000000..a9ab7604 --- /dev/null +++ b/addons/sale/static/tests/sales_team_dashboard_tests.js @@ -0,0 +1,122 @@ +odoo.define('sale.dashboard_tests', function (require) { +"use strict"; + +var KanbanView = require('web.KanbanView'); +var testUtils = require('web.test_utils'); + +var createView = testUtils.createView; + +QUnit.module('Sales Team Dashboard', { + beforeEach: function () { + this.data = { + 'crm.team': { + fields: { + foo: {string: "Foo", type: 'char'}, + invoiced_target: {string: "Invoiced_target", type: 'integer'}, + }, + records: [ + {id: 1, foo: "yop"}, + ], + }, + }; + } +}); + +QUnit.test('edit target with several o_kanban_primary_bottom divs [REQUIRE FOCUS]', async function (assert) { + assert.expect(6); + + var kanban = await createView({ + View: KanbanView, + model: 'crm.team', + data: this.data, + arch: '<kanban>' + + '<templates>' + + '<t t-name="kanban-box">' + + '<div class="container o_kanban_card_content">' + + '<field name="invoiced_target" />' + + '<a href="#" class="sales_team_target_definition o_inline_link">' + + 'Click to define a target</a>' + + '<div class="col-12 o_kanban_primary_bottom"/>' + + '<div class="col-12 o_kanban_primary_bottom bottom_block"/>' + + '</div>' + + '</t>' + + '</templates>' + + '</kanban>', + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.strictEqual(args.args[1].invoiced_target, 123, + "new value is correctly saved"); + } + if (args.method === 'read') { // Read happens after the write + assert.deepEqual(args.args[1], ['invoiced_target', 'display_name'], + 'the read (after write) should ask for invoiced_target'); + } + return this._super.apply(this, arguments); + }, + }); + + assert.containsOnce(kanban, '.o_kanban_view .sales_team_target_definition', + "should have classname 'sales_team_target_definition'"); + assert.containsN(kanban, '.o_kanban_primary_bottom', 2, + "should have two divs with classname 'o_kanban_primary_bottom'"); + + await testUtils.dom.click(kanban.$('a.sales_team_target_definition')); + assert.containsOnce(kanban, '.o_kanban_primary_bottom:last input', + "should have rendered an input in the last o_kanban_primary_bottom div"); + + kanban.$('.o_kanban_primary_bottom:last input').focus(); + kanban.$('.o_kanban_primary_bottom:last input').val('123'); + kanban.$('.o_kanban_primary_bottom:last input').trigger('blur'); + await testUtils.nextTick(); + assert.strictEqual(kanban.$('.o_kanban_record').text(), "123Click to define a target", + 'The kanban record should display the updated target value'); + + kanban.destroy(); +}); + +QUnit.test('edit target supports push Enter', async function (assert) { + assert.expect(3); + + var kanban = await createView({ + View: KanbanView, + model: 'crm.team', + data: this.data, + arch: '<kanban>' + + '<templates>' + + '<t t-name="kanban-box">' + + '<div class="container o_kanban_card_content">' + + '<field name="invoiced_target" />' + + '<a href="#" class="sales_team_target_definition o_inline_link">' + + 'Click to define a target</a>' + + '<div class="col-12 o_kanban_primary_bottom"/>' + + '<div class="col-12 o_kanban_primary_bottom bottom_block"/>' + + '</div>' + + '</t>' + + '</templates>' + + '</kanban>', + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.strictEqual(args.args[1].invoiced_target, 123, + "new value is correctly saved"); + } + if (args.method === 'read') { // Read happens after the write + assert.deepEqual(args.args[1], ['invoiced_target', 'display_name'], + 'the read (after write) should ask for invoiced_target'); + } + return this._super.apply(this, arguments); + }, + }); + + await testUtils.dom.click(kanban.$('a.sales_team_target_definition')); + + kanban.$('.o_kanban_primary_bottom:last input').focus(); + kanban.$('.o_kanban_primary_bottom:last input').val('123'); + kanban.$('.o_kanban_primary_bottom:last input').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER, keyCode: $.ui.keyCode.ENTER})); + await testUtils.nextTick(); + assert.strictEqual(kanban.$('.o_kanban_record').text(), "123Click to define a target", + 'The kanban record should display the updated target value'); + + kanban.destroy(); +}); + +}); diff --git a/addons/sale/static/tests/tours/sale_signature.js b/addons/sale/static/tests/tours/sale_signature.js new file mode 100644 index 00000000..185d4457 --- /dev/null +++ b/addons/sale/static/tests/tours/sale_signature.js @@ -0,0 +1,51 @@ +odoo.define('sale.tour_sale_signature', function (require) { +'use strict'; + +var tour = require('web_tour.tour'); + +// This tour relies on data created on the Python test. +tour.register('sale_signature', { + test: true, + url: '/my/quotes', +}, +[ + { + content: "open the test SO", + trigger: 'a:containsExact("test SO")', + }, + { + content: "click sign", + trigger: 'a:contains("Sign")', + }, + { + content: "check submit is disabled", + trigger: '.o_portal_sign_submit:disabled', + run: function () {}, + }, + { + content: "click Auto", + trigger: '.o_web_sign_auto_button', + }, + { + content: "check submit is enabled", + trigger: '.o_portal_sign_submit:enabled', + run: function () {}, + }, + { + content: "click select style", + trigger: '.o_web_sign_auto_select_style a', + }, + { + content: "click style 4", + trigger: '.o_web_sign_auto_font_selection a:eq(3)', + }, + { + content: "click submit", + trigger: '.o_portal_sign_submit:enabled', + }, + { + content: "check it's confirmed", + trigger: '#quote_content:contains("Thank You")', + }, +]); +}); |
