[FIX] web: tests: patch form multiClickTime once for all

A lot of tests in different QUnit modules need this delay to be
patched to 0. Some of them (e.g. the 'ActionManager > Misc' module)
didn't patch it correctly. It worked before because a patch was
done in a previous test, and wasn't unpatch. The previous commit
ensures the patch is removed, so now we have at least 2 tests of
the above mentionned module that fail. This commit ensures that
the delay is patched in every tests, and allows to specify a
custom delay if necessary.
This commit is contained in:
Aaron Bohy
2021-03-31 09:30:07 +00:00
committed by Michael Mattiello (mcm)
parent a3937cfde5
commit c89cdcf11c
7 changed files with 8 additions and 44 deletions
@@ -151,13 +151,6 @@ QUnit.module('basic_fields', {
}]
},
};
testUtils.mock.patch(FormController, {
'multiClickTime': 0,
});
},
afterEach() {
testUtils.mock.unpatch(FormController);
},
}, function () {
@@ -152,13 +152,6 @@ QUnit.module('fields', {}, function () {
}]
},
};
testUtils.mock.patch(FormController, {
'multiClickTime': 0,
});
},
afterEach: function () {
testUtils.mock.unpatch(FormController);
},
}, function () {
QUnit.module('FieldMany2One');
@@ -164,13 +164,6 @@ QUnit.module('fields', {}, function () {
}]
},
};
testUtils.mock.patch(FormController, {
'multiClickTime': 0,
});
},
afterEach: function () {
testUtils.mock.unpatch(FormController);
},
}, function () {
QUnit.module('FieldOne2Many');
@@ -170,13 +170,6 @@ QUnit.module('relational_fields', {
onchanges: {},
},
};
testUtils.mock.patch(FormController, {
'multiClickTime': 0,
});
},
afterEach: function () {
testUtils.mock.unpatch(FormController);
},
}, function () {
@@ -17,6 +17,7 @@ const Bus = require('web.Bus');
const config = require('web.config');
const core = require('web.core');
const dom = require('web.dom');
const FormController = require('web.FormController');
const makeTestEnvironment = require('web.test_env');
const MockServer = require('web.MockServer');
const RamStorage = require('web.RamStorage');
@@ -366,6 +367,10 @@ async function addMockEnvironmentOwl(Component, params, mockServer) {
});
}
// remove the multi-click delay for the quick edit in form view
const initialQuickEditDelay = FormController.prototype.multiClickTime;
FormController.prototype.multiClickTime = params.formMultiClickTime || 0;
// make sure the debounce value for input fields is set to 0
const initialDebounceValue = DebouncedField.prototype.DEBOUNCE;
DebouncedField.prototype.DEBOUNCE = params.fieldDebounce || 0;
@@ -425,6 +430,8 @@ async function addMockEnvironmentOwl(Component, params, mockServer) {
}
});
FormController.prototype.multiClickTime = initialQuickEditDelay;
DebouncedField.prototype.DEBOUNCE = initialDebounceValue;
dom.DEBOUNCE = initialDOMDebounceValue;
_.debounce = initialDebounce;
+1 -12
View File
@@ -152,13 +152,6 @@ QUnit.module('Views', {
type: 'ir.actions.act_window',
views: [[false, 'kanban'], [false, 'form']],
}];
testUtils.mock.patch(FormController, {
'multiClickTime': 0,
});
},
afterEach: function () {
testUtils.mock.unpatch(FormController);
},
}, function () {
@@ -11112,10 +11105,6 @@ QUnit.module('Views', {
const MULTI_CLICK_TIME = 50;
testUtils.mock.patch(FormController, {
'multiClickTime': MULTI_CLICK_TIME,
});
const form = await createView({
View: FormView,
model: 'partner',
@@ -11126,6 +11115,7 @@ QUnit.module('Views', {
<field name="display_name"/>
</group>
</form>`,
formMultiClickTime: MULTI_CLICK_TIME,
res_id: 1,
});
@@ -11157,7 +11147,6 @@ QUnit.module('Views', {
await concurrency.delay(MULTI_CLICK_TIME);
assert.containsOnce(form, '.o_form_view.o_form_editable');
testUtils.mock.unpatch(FormController);
form.destroy();
});
@@ -121,13 +121,9 @@ QUnit.module('web_editor', {}, function () {
throw 'Wrong template';
},
});
testUtils.mock.patch(FormController, {
'multiClickTime': 0,
});
},
afterEach: function () {
testUtils.mock.unpatch(ajax);
testUtils.mock.unpatch(FormController);
},
}, function () {