[IMP] sale: add testcase for fix 7bee068a0
The bug has been fixed meanwhile, but this one adds a testcase, so it's worth merging it. Task #1871444
This commit is contained in:
@@ -39,6 +39,8 @@ KanbanRecord.include({
|
||||
.done(function() {
|
||||
self.trigger_up('kanban_record_update', {id: self.id});
|
||||
});
|
||||
// TODO: previous lines can be refactored as follows (in master)
|
||||
// self.trigger_up('kanban_record_update', {invoiced_target: value});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
model: 'crm.team',
|
||||
data: this.data,
|
||||
arch: '<kanban>' +
|
||||
'<templates>' +
|
||||
'<t t-name="kanban-box">' +
|
||||
'<div class="container o_kanban_card_content">' +
|
||||
'<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");
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
assert.strictEqual(kanban.$('.o_kanban_view .sales_team_target_definition').length, 1,
|
||||
"should have classname 'sales_team_target_definition'");
|
||||
assert.strictEqual(kanban.$('.o_kanban_primary_bottom').length, 2,
|
||||
"should have two divs with classname 'o_kanban_primary_bottom'");
|
||||
|
||||
kanban.$('a.sales_team_target_definition').click();
|
||||
assert.strictEqual(kanban.$('.o_kanban_primary_bottom:last input').length, 1,
|
||||
"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').blur();
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -11,4 +11,10 @@
|
||||
<link rel='stylesheet' href='/sale/static/src/less/sale_portal.less'/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="qunit_suite" name="sales_team_dashboard_tests" inherit_id="web.qunit_suite">
|
||||
<xpath expr="//t[@t-set='head']" position="inside">
|
||||
<script type="text/javascript" src="/sale/static/tests/sales_team_dashboard_tests.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user