合并企业版代码(未测试,先提交到测试分支)
This commit is contained in:
1344
web_gantt/static/tests/gantt_dependency_tests.js
Normal file
1344
web_gantt/static/tests/gantt_dependency_tests.js
Normal file
File diff suppressed because it is too large
Load Diff
92
web_gantt/static/tests/gantt_mobile_tests.js
Normal file
92
web_gantt/static/tests/gantt_mobile_tests.js
Normal file
@@ -0,0 +1,92 @@
|
||||
odoo.define('web_gantt.gantt_mobile_tests', function (require) {
|
||||
"use strict";
|
||||
|
||||
const GanttView = require('web_gantt.GanttView');
|
||||
const testUtils = require('web.test_utils');
|
||||
|
||||
const createView = testUtils.createView;
|
||||
|
||||
let initialDate = new Date(2018, 11, 20, 8, 0, 0);
|
||||
initialDate = new Date(initialDate.getTime() - initialDate.getTimezoneOffset() * 60 * 1000);
|
||||
|
||||
QUnit.module('LegacyViews', {
|
||||
beforeEach: function () {
|
||||
this.data = {
|
||||
tasks: {
|
||||
fields: {
|
||||
id: {string: 'ID', type: 'integer'},
|
||||
start: {string: 'Start Date', type: 'datetime'},
|
||||
stop: {string: 'Stop Date', type: 'datetime'},
|
||||
user_id: {string: 'Assign To', type: 'many2one', relation: 'users'},
|
||||
},
|
||||
records: [
|
||||
{ id: 1, start: '2018-11-30 18:30:00', stop: '2018-12-31 18:29:59', user_id: 1},
|
||||
{ id: 2, start: '2018-12-17 11:30:00', stop: '2018-12-22 06:29:59', user_id: 2},
|
||||
{ id: 3, start: '2018-12-27 06:30:00', stop: '2019-01-03 06:29:59', user_id: 2},
|
||||
{ id: 4, start: '2018-12-19 22:30:00', stop: '2018-12-20 06:29:59', user_id: 1},
|
||||
{ id: 5, start: '2018-11-08 01:53:10', stop: '2018-12-04 01:34:34', user_id: 1},
|
||||
],
|
||||
},
|
||||
users: {
|
||||
fields: {
|
||||
id: {string: 'ID', type: 'integer'},
|
||||
name: {string: 'Name', type: 'char'},
|
||||
},
|
||||
records: [
|
||||
{id: 1, name: 'User 1'},
|
||||
{id: 2, name: 'User 2'},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
}, function () {
|
||||
QUnit.module('GanttView (legacy) - Mobile');
|
||||
|
||||
QUnit.test('Progressbar: check the progressbar percentage visibility.', async function (assert) {
|
||||
assert.expect(11);
|
||||
|
||||
const gantt = await createView({
|
||||
View: GanttView,
|
||||
model: 'tasks',
|
||||
data: this.data,
|
||||
arch: `<gantt date_start="start" date_stop="stop"
|
||||
default_scale="week" scales="week"
|
||||
default_group_by="user_id"
|
||||
progress_bar="user_id">
|
||||
<field name="user_id"/>
|
||||
</gantt>`,
|
||||
viewOptions: {
|
||||
initialDate: initialDate,
|
||||
},
|
||||
config: {device: {isMobile: true}},
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'gantt_progress_bar') {
|
||||
assert.strictEqual(args.model, "tasks");
|
||||
assert.deepEqual(args.args[0], ['user_id']);
|
||||
assert.deepEqual(args.args[1], {user_id: [1, 2]});
|
||||
return Promise.resolve({
|
||||
user_id: {
|
||||
1: {value: 50, max_value: 100},
|
||||
2: {value: 25, max_value: 200},
|
||||
}
|
||||
});
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
const progressbar = gantt.el.querySelectorAll('.o_gantt_row_sidebar .o_gantt_progressbar');
|
||||
assert.strictEqual(progressbar.length, 2, "Gantt should include two progressbars");
|
||||
assert.strictEqual(progressbar[0].style.width, "50%");
|
||||
assert.strictEqual(progressbar[1].style.width, "12.5%");
|
||||
assert.hasClass(progressbar[0], 'o_gantt_group_success', "Progress bar should have the success class");
|
||||
assert.hasClass(progressbar[1], 'o_gantt_group_success', "Progress bar should have the success class");
|
||||
const progressbarText = gantt.el.querySelectorAll('.o_gantt_row_sidebar .o_gantt_text_mobile');
|
||||
assert.hasClass(progressbarText[0], 'o_gantt_text_mobile', "Progress bar should be visible.");
|
||||
assert.hasClass(progressbarText[1], 'o_gantt_text_mobile', "Progress bar should be visible.");
|
||||
assert.isVisible(gantt.el.querySelector('.o_gantt_row_sidebar .o_gantt_group_hours'), "Progressbar Title should be visible.");
|
||||
|
||||
gantt.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
5054
web_gantt/static/tests/gantt_tests.js
Normal file
5054
web_gantt/static/tests/gantt_tests.js
Normal file
File diff suppressed because it is too large
Load Diff
51
web_gantt/static/tests/test_remove_domain.js
Normal file
51
web_gantt/static/tests/test_remove_domain.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { Domain } from '@web/core/domain';
|
||||
import { removeDomainLeaf } from '@web_gantt/js/gantt_controller';
|
||||
|
||||
QUnit.module('WebGantt > RemoveDomainLeaf');
|
||||
|
||||
QUnit.test('Remove leaf in domain.', function (assert) {
|
||||
let domain = [
|
||||
['start_datetime', '!=', false], ['end_datetime', '!=', false],
|
||||
['sale_line_id', '!=', false],
|
||||
];
|
||||
const keysToRemove = ['start_datetime', 'end_datetime'];
|
||||
let newDomain = removeDomainLeaf(domain, keysToRemove);
|
||||
let expectedDomain = new Domain([
|
||||
'&', ...Domain.TRUE.toList({}), ...Domain.TRUE.toList({}),
|
||||
['sale_line_id', '!=', false],
|
||||
]);
|
||||
assert.deepEqual(
|
||||
newDomain.toList({}),
|
||||
expectedDomain.toList({}),
|
||||
);
|
||||
domain = [
|
||||
'|', ['role_id', '=', false],
|
||||
'&', ['resource_id', '!=', false], ['start_datetime', '=', false],
|
||||
['sale_line_id', '!=', false],
|
||||
];
|
||||
newDomain = removeDomainLeaf(domain, keysToRemove);
|
||||
expectedDomain = new Domain([
|
||||
'|', ['role_id', '=', false],
|
||||
'&', ['resource_id', '!=', false], ...Domain.TRUE.toList({}),
|
||||
['sale_line_id', '!=', false],
|
||||
]);
|
||||
assert.deepEqual(
|
||||
newDomain.toList({}),
|
||||
expectedDomain.toList({}),
|
||||
);
|
||||
domain = [
|
||||
'|', ['start_datetime', '=', false], ['end_datetime', '=', false],
|
||||
['sale_line_id', '!=', false],
|
||||
];
|
||||
newDomain = removeDomainLeaf(domain, keysToRemove);
|
||||
expectedDomain = new Domain([
|
||||
...Domain.TRUE.toList({}),
|
||||
['sale_line_id', '!=', false],
|
||||
]);
|
||||
assert.deepEqual(
|
||||
newDomain.toList({}),
|
||||
expectedDomain.toList({}),
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user