Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ea4f57
commit f6d2337
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import test_developer_mode_menu_elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
import odoo.tests | ||
from odoo.api import Environment | ||
|
||
|
||
@odoo.tests.common.at_install(True) | ||
@odoo.tests.common.post_install(True) | ||
class TestUi(odoo.tests.HttpCase): | ||
|
||
def test_01_remove_developer_mode_menu_elements(self): | ||
env = Environment(self.registry.test_cr, self.uid, {}) | ||
# needed because tests are run before the module is marked as | ||
# installed. In js web will only load qweb coming from modules | ||
# that are returned by the backend in module_boot. Without | ||
# this you end up with js, css but no qweb. | ||
env['ir.module.module'].search([('name', '=', 'web_debranding')], limit=1).state = 'installed' | ||
self.registry.cursor().release() | ||
|
||
url = '/web' | ||
code = """ | ||
$(document).ready( function() { | ||
setInterval(function(){ | ||
if (!$('.navbar-collapse.collapse .oe_user_menu_placeholder .dropdown-menu').length) { | ||
console.log('page is loading'); | ||
return; | ||
} | ||
if ($('li a[data-menu="debug"]').length > 0 || $('li a[data-menu="debugassets"]').length > 0) { | ||
console.log('error', 'Developer mode menu elements are displayed for not admin user'); | ||
} else { | ||
console.log('ok'); | ||
} | ||
}, 1000); | ||
}) | ||
""" | ||
self.phantom_js(url, code, login="demo") | ||
|
||
def test_02_remove_developer_mode_menu_elements(self): | ||
env = Environment(self.registry.test_cr, self.uid, {}) | ||
# needed because tests are run before the module is marked as | ||
# installed. In js web will only load qweb coming from modules | ||
# that are returned by the backend in module_boot. Without | ||
# this you end up with js, css but no qweb. | ||
env['ir.module.module'].search([('name', '=', 'web_debranding')], limit=1).state = 'installed' | ||
self.registry.cursor().release() | ||
|
||
url = '/web' | ||
code = """ | ||
$(document).ready( function() { | ||
setInterval(function(){ | ||
if (!$('.navbar-collapse.collapse .oe_user_menu_placeholder .dropdown-menu').length) { | ||
console.log('page is loading'); | ||
return; | ||
} | ||
if ($('li a[data-menu="debug"]').length > 0 && $('li a[data-menu="debugassets"]').length > 0) { | ||
console.log('ok'); | ||
} else { | ||
console.log('error', 'Developer mode menu elements are not displayed for admin'); | ||
} | ||
}, 1000); | ||
}) | ||
""" | ||
self.phantom_js(url, code, login="admin") |