odoo.define('base.settings_tests', function (require) { "use strict"; var testUtils = require('web.test_utils'); var view_registry = require('web.view_registry'); var createView = testUtils.createView; var BaseSettingsView = view_registry.get('base_settings'); var createActionManager = testUtils.createActionManager; QUnit.module('base_settings_tests', { beforeEach: function () { this.data = { project: { fields: { foo: {string: "Foo", type: "boolean"}, bar: {string: "Bar", type: "boolean"}, }, }, }; } }, function () { QUnit.module('BaseSetting'); QUnit.test('change setting on nav bar click in base settings', async function (assert) { assert.expect(5); var form = await createView({ View: BaseSettingsView, model: 'project', data: this.data, arch: '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
'+ '
' + '
No Record Found
' + '
' + '
'+ '
'+ '
' + ''+ '
'+ '
'+ '
' + '
'+ '
'+ '
' + ''+ '
'+ '
'+ 'Foo'+ '
'+ 'this is foo'+ '
'+ '
' + '
'+ '
' + '
' + '
' + '
' + '', }); assert.hasAttrValue(form.$('.selected'), 'data-key',"crm","crm setting selected"); assert.isVisible(form.$(".settings .app_settings_block"), "project settings show"); await testUtils.fields.editAndTrigger(form.$('.searchInput'), 'b', 'keyup'); assert.strictEqual(form.$('.highlighter').html(), "B", "b word highlighted"); await testUtils.fields.editAndTrigger(form.$('.searchInput'), 'bx', 'keyup'); assert.isVisible(form.$('.notFound'), "record not found message shown"); form.$('.searchInput').val('f').trigger('keyup'); assert.strictEqual(form.$('span.o_form_label .highlighter').html(), "F", "F word highlighted"); form.destroy(); }); QUnit.test('settings views does not read existing id when coming back in breadcrumbs', async function (assert) { assert.expect(8); var actions = [{ id: 1, name: 'Settings view', res_model: 'project', type: 'ir.actions.act_window', views: [[1, 'form']], }, { id: 4, name: 'Other action', res_model: 'project', type: 'ir.actions.act_window', views: [[2, 'list']], }]; var archs = { 'project,1,form': '
' + '
' + '
' + '
', 'project,2,list': '', 'project,false,search': '', }; var actionManager = await createActionManager({ actions: actions, archs: archs, data: this.data, mockRPC: function (route, args) { if (args.method) { assert.step(args.method); } return this._super.apply(this, arguments); }, }); await actionManager.doAction(1); await testUtils.nextTick(); await testUtils.dom.click(actionManager.$('button[name="4"]')); await testUtils.dom.click($('.o_control_panel .breadcrumb-item a')); assert.hasClass(actionManager.$('.o_form_view'), 'o_form_editable'); assert.verifySteps([ 'load_views', // initial setting action 'default_get', // this is a setting view => create new record 'create', // when we click on action button => save 'read', // with save, we have a reload... (not necessary actually) 'load_views', // for other action in breadcrumb, // with a searchread (not shown here since it is a route) 'default_get', // when we come back, we want to restart from scratch ]); actionManager.destroy(); }); QUnit.test('settings view does not display other settings after reload', async function (assert) { assert.expect(2); var form = await createView({ View: BaseSettingsView, model: 'project', data: this.data, arch: '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
'+ '
' + '
No Record Found
' + '
' + 'crm tab' + '
' + '
' + 'other app tab' + '
' + '
' + '
' + '', }); assert.strictEqual(form.$('.app_settings_block').text().replace(/\s/g,''), 'CRMcrmtab'); await form.reload(); assert.strictEqual(form.$('.app_settings_block').text().replace(/\s/g,''), 'CRMcrmtab'); form.destroy(); }); }); });