summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/core/domain_tests.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2020-02-05 10:34:51 +0000
committerXavier Morel <xmo@odoo.com>2020-02-12 09:32:17 +0000
commite95ccf0908c263f6cf23c91c477a8e252e936ff1 (patch)
treef5e7b10ebf7726a9f17598f0407d0a8cb14298c3 /addons/web/static/tests/core/domain_tests.js
parent968638aa1a158d24789ba6f0374436c74f807f2e (diff)
[FIX] *: domains should not have as many binary operator as there are terms
* modify client-side domain normalisation to error if the domain is invalid (not enough terms / segments for the number of operators) * add better error reporting to attrs / modifiers parsing * add a few layered error augmentation to provide clearer context e.g. "error: invalid domain <thing>" is helpful but "error while parsing modifiers for field foo: modifier invisible: invalid domain <thing>" is much more helpful * rework _evalModifiers to deduplicate it in order to more easily implement this contextual augmentation * test that improper domains are properly found improper * fix a bunch of incorrect attrs domains * also removed an apparently undefined (& unused) "options" argument to a _applyModifiers call closes odoo/odoo#44642 Related: odoo/enterprise#8175 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/web/static/tests/core/domain_tests.js')
-rw-r--r--addons/web/static/tests/core/domain_tests.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/addons/web/static/tests/core/domain_tests.js b/addons/web/static/tests/core/domain_tests.js
index a9c7ac48ece..e9ee5f80cf6 100644
--- a/addons/web/static/tests/core/domain_tests.js
+++ b/addons/web/static/tests/core/domain_tests.js
@@ -7,6 +7,11 @@ QUnit.module('core', {}, function () {
QUnit.module('domain');
+ QUnit.test("empty", function (assert) {
+ assert.expect(1);
+ assert.ok(new Domain([]).compute({}));
+ });
+
QUnit.test("basic", function (assert) {
assert.expect(3);
@@ -59,6 +64,22 @@ QUnit.module('core', {}, function () {
assert.notOk(new Domain(0).compute({}));
});
+ QUnit.test("invalid domains should not succeed", function (assert) {
+ assert.expect(3);
+ assert.throws(
+ () => new Domain(['|', ['hr_presence_state', '=', 'absent']]),
+ /invalid domain .* \(missing 1 segment/
+ );
+ assert.throws(
+ () => new Domain(['|', '|', ['hr_presence_state', '=', 'absent'], ['attendance_state', '=', 'checked_in']]),
+ /invalid domain .* \(missing 1 segment/
+ );
+ assert.throws(
+ () => new Domain(['&', ['composition_mode', '!=', 'mass_post']]),
+ /invalid domain .* \(missing 1 segment/
+ );
+ });
+
QUnit.test("domain <=> condition", function (assert) {
assert.expect(3);