Skip to content

Commit

Permalink
🛡️ tests for developer mode icon
Browse files Browse the repository at this point in the history
  • Loading branch information
KolushovAlexandr committed Jul 17, 2018
1 parent 8ea4f57 commit f6d2337
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web_debranding/doc/changelog.rst
@@ -1,7 +1,7 @@
`1.0.26`
--------

- FIX: developer mode availability via dropdown menu for not admins
- FIX: developer mode was availabile via dropdown menu for non-admins

`1.0.25`
--------
Expand Down
3 changes: 3 additions & 0 deletions web_debranding/tests/__init__.py
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import test_developer_mode_menu_elements
64 changes: 64 additions & 0 deletions web_debranding/tests/test_developer_mode_menu_elements.py
@@ -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")

0 comments on commit f6d2337

Please sign in to comment.