import { describe, expect, test } from "@odoo/hoot"; import { drag, queryAll, queryAllTexts, queryFirst, scroll } from "@odoo/hoot-dom"; import { Deferred, animationFrame } from "@odoo/hoot-mock"; import { Component, onWillUpdateProps, xml } from "@odoo/owl"; import { contains, defineActions, defineModels, defineParams, fields, getService, models, mountWithCleanup, mountWithSearch, onRpc, toggleMenuItem, toggleSearchBarMenu, } from "@web/../tests/web_test_helpers"; import { SearchBarMenu } from "@web/search/search_bar_menu/search_bar_menu"; import { SearchPanel } from "@web/search/search_panel/search_panel"; import { WebClient } from "@web/webclient/webclient"; function parseContent(text) { const [value, counter] = text.split(/\s+/); return counter ? `${value}: ${counter}` : value; } function parseCounter(text) { const [, counter] = text.split(/\s+/); return isNaN(counter) ? null : Number(counter); } function getCategoriesContent() { return queryAllTexts`.o_search_panel_category_value header`.map(parseContent).filter(Boolean); } function getCategoriesCounter() { return queryAllTexts`.o_search_panel_category_value header`.map(parseCounter).filter(Boolean); } function getFiltersContent() { return queryAllTexts`.o_search_panel_filter_value`.map(parseContent).filter(Boolean); } function getFiltersCounter() { return queryAllTexts`.o_search_panel_filter_value`.map(parseCounter).filter(Boolean); } class TestComponent extends Component { static components = { SearchBarMenu, SearchPanel }; static template = xml`
`; static props = ["*"]; setup() { this.domain = this.props.domain; onWillUpdateProps((np) => this.willUpdateProps(np)); } async willUpdateProps(np) { this.domain = np.domain; } } class Partner extends models.Model { name = fields.Char(); foo = fields.Char(); bar = fields.Boolean(); int_field = fields.Integer({ string: "Int Field", aggregator: "sum" }); company_id = fields.Many2one({ string: "res.company", relation: "res.company" }); company_ids = fields.Many2many({ string: "Companies", relation: "res.company" }); category_id = fields.Many2one({ string: "category", relation: "category" }); state = fields.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, }, ]; _views = { toy: /* xml */ ``, list: /* xml */ ``, kanban: /* xml */ `
`, form: /* xml */ `