2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
import re
|
2018-01-16 11:34:37 +01:00
|
|
|
import flectra.tests
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
RE_ONLY = re.compile('QUnit\.only\(')
|
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
class WebSuite(flectra.tests.HttpCase):
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
post_install = True
|
|
|
|
at_install = False
|
|
|
|
|
|
|
|
def test_01_js(self):
|
|
|
|
# webclient desktop test suite
|
2018-01-15 15:21:30 +01:00
|
|
|
self.phantom_js('/web/tests?mod=web', "", "", login='admin', timeout=360)
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
def test_02_js(self):
|
|
|
|
# webclient mobile test suite
|
|
|
|
self.phantom_js('/web/tests/mobile?mod=web', "", "", login='admin', timeout=300)
|
|
|
|
|
|
|
|
def test_check_suite(self):
|
|
|
|
# verify no js test is using `QUnit.only` as it forbid any other test to be executed
|
|
|
|
self._check_only_call('web.qunit_suite')
|
|
|
|
self._check_only_call('web.qunit_mobile_suite')
|
|
|
|
|
|
|
|
def _check_only_call(self, suite):
|
|
|
|
# As we currently aren't in a request context, we can't render `web.layout`.
|
|
|
|
# redefinied it as a minimal proxy template.
|
|
|
|
self.env.ref('web.layout').write({'arch_db': '<t t-name="web.layout"><t t-raw="head"/></t>'})
|
|
|
|
|
|
|
|
for asset in self.env['ir.qweb']._get_asset_content(suite, options={})[0]:
|
|
|
|
filename = asset['filename']
|
|
|
|
if not filename or asset['atype'] != 'text/javascript':
|
|
|
|
continue
|
|
|
|
with open(filename, 'r') as fp:
|
|
|
|
if RE_ONLY.search(fp.read()):
|
|
|
|
self.fail("`QUnit.only()` used in file %r" % asset['url'])
|