[FIX] web: properly unpatch session after each test
Before this commit, `getTZOffset` and `user_has_group` weren't correctly reset to their initial values after tests. As a consequence tests executed afterwards might behave unexpectedly. closes odoo/odoo#69497 X-original-commit: b7b83db88c61d7db87045d87b09d7348f3a8a9eb Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -174,11 +174,12 @@ async function _getMockedOwlEnv(params, mockServer) {
|
||||
function _mockGlobalObjects(params) {
|
||||
// store initial session state (for restoration)
|
||||
const initialSession = Object.assign({}, session);
|
||||
// patch session
|
||||
Object.assign(session, {
|
||||
const sessionPatch = Object.assign({
|
||||
getTZOffset() { return 0; },
|
||||
async user_has_group() { return false; },
|
||||
}, params.session);
|
||||
// patch session
|
||||
Object.assign(session, sessionPatch);
|
||||
|
||||
// patch config
|
||||
let initialConfig;
|
||||
@@ -203,10 +204,8 @@ function _mockGlobalObjects(params) {
|
||||
// build the cleanUp function to restore everything at the end of the test
|
||||
function cleanUp() {
|
||||
let key;
|
||||
if ('session' in params) {
|
||||
for (key in session) {
|
||||
delete session[key];
|
||||
}
|
||||
for (key in sessionPatch) {
|
||||
delete session[key];
|
||||
}
|
||||
Object.assign(session, initialSession);
|
||||
if ('config' in params) {
|
||||
|
||||
Reference in New Issue
Block a user