odoo.define("web/static/tests/views/search_panel_tests.js", function (require) { "use strict"; const FormView = require('web.FormView'); const KanbanView = require('web.KanbanView'); const ListView = require('web.ListView'); const testUtils = require('web.test_utils'); const SearchPanel = require("web.searchPanel"); const legacyViewRegistry = require('web.view_registry'); const createView = testUtils.createView; const { makeFakeUserService } = require("@web/../tests/helpers/mock_services"); const { createWebClient, doAction } = require('@web/../tests/webclient/helpers'); const { getFixture, legacyExtraNextTick } = require("@web/../tests/helpers/utils"); const { registry } = require("@web/core/registry"); const { PivotView } = require("@web/views/pivot/pivot_view"); const { switchView, toggleFilterMenu, toggleMenuItem, } = require("@web/../tests/search/helpers"); /** * Return the list of counters displayed in the search panel (if any). * @param {Widget} view, view controller * @returns {number[]} */ function getCounters(view) { return [...view.el.querySelectorAll('.o_search_panel_counter')].map( counter => Number(counter.innerText.trim()) ); } /** * Fold/unfold the category value (with children) * @param {Widget} widget * @param {string} text * @returns {Promise} */ function toggleFold(widget, text) { const headers = [...widget.el.querySelectorAll(".o_search_panel_category_value header")]; const target = headers.find( (header) => header.innerText.trim().startsWith(text) ); return testUtils.dom.click(target); } let serverData; let target; QUnit.module('Views', { beforeEach: function () { registry.category("views").remove("list"); // remove new list from registry registry.category("views").remove("kanban"); // remove new kanban from registry registry.category("views").remove("form"); // remove new form from registry legacyViewRegistry.add("list", ListView); // add legacy list -> will be wrapped and added to new registry legacyViewRegistry.add("kanban", KanbanView); // add legacy kanban -> will be wrapped and added to new registry legacyViewRegistry.add("form", FormView); // add legacy form -> will be wrapped and added to new registry this.data = { partner: { fields: { foo: {string: "Foo", type: 'char'}, bar: {string: "Bar", type: 'boolean'}, int_field: {string: "Int Field", type: 'integer', group_operator: 'sum'}, company_id: {string: "company", type: 'many2one', relation: 'company'}, company_ids: { string: "Companies", type: 'many2many', relation: 'company' }, category_id: { string: "category", type: 'many2one', relation: 'category' }, state: { string: "State", type: 'selection', selection: [['abc', "ABC"], ['def', "DEF"], ['ghi', "GHI"]]}, }, records: [ {id: 1, bar: true, foo: "yop", int_field: 1, company_ids: [3], company_id: 3, state: 'abc', category_id: 6}, {id: 2, bar: true, foo: "blip", int_field: 2, company_ids: [3], company_id: 5, state: 'def', category_id: 7}, {id: 3, bar: true, foo: "gnap", int_field: 4, company_ids: [], company_id: 3, state: 'ghi', category_id: 7}, {id: 4, bar: false, foo: "blip", int_field: 8, company_ids: [5], company_id: 5, state: 'ghi', category_id: 7}, ] }, company: { fields: { name: {string: "Display Name", type: 'char'}, parent_id: {string: 'Parent company', type: 'many2one', relation: 'company'}, category_id: {string: 'Category', type: 'many2one', relation: 'category'}, }, records: [ {id: 3, name: "asustek", category_id: 6}, {id: 5, name: "agrolait", category_id: 7}, ], }, category: { fields: { name: {string: "Category Name", type: 'char'}, }, records: [ {id: 6, name: "gold"}, {id: 7, name: "silver"}, ] }, }; this.actions = [{ id: 1, name: 'Partners', res_model: 'partner', type: 'ir.actions.act_window', views: [[false, 'kanban'], [false, 'list'], [false, 'pivot'], [false, 'form']], }, { id: 2, name: 'Partners', res_model: 'partner', type: 'ir.actions.act_window', views: [[false, 'form']], }]; this.archs = { 'partner,false,list': '', 'partner,false,kanban': `
`, 'partner,false,form': `