import { after, before, expect, test } from "@odoo/hoot"; import { clear, click, hover, manuallyDispatchProgrammaticEvent, middleClick, press, queryAllAttributes, queryAllTexts, queryFirst, waitFor, } from "@odoo/hoot-dom"; import { animationFrame, Deferred, mockTimeZone, mockTouch, runAllTimers, tick, } from "@odoo/hoot-mock"; import { Component, EventBus, onMounted, onPatched, onWillStart, onWillUpdateProps, useEffect, useRef, useState, xml, } from "@odoo/owl"; import { clickSave, contains, defineActions, defineMenus, defineModels, fields, findComponent, getPagerLimit, getPagerValue, getService, installLanguages, makeServerError, MockServer, mockService, models, mountView, mountViewInDialog, mountWithCleanup, onRpc, patchWithCleanup, serverState, stepAllNetworkCalls, toggleActionMenu, toggleMenuItem, toggleSearchBarMenu, } from "@web/../tests/web_test_helpers"; import { browser } from "@web/core/browser/browser"; import { makeErrorFromResponse } from "@web/core/network/rpc"; import { registry } from "@web/core/registry"; import { config as transitionConfig } from "@web/core/transition"; import { SIZES } from "@web/core/ui/ui_service"; import { useBus, useService } from "@web/core/utils/hooks"; import { redirect } from "@web/core/utils/urls"; import { CharField } from "@web/views/fields/char/char_field"; import { DateTimeField } from "@web/views/fields/datetime/datetime_field"; import { Field } from "@web/views/fields/field"; import { IntegerField } from "@web/views/fields/integer/integer_field"; import { useSpecialData } from "@web/views/fields/relational_utils"; import { standardFieldProps } from "@web/views/fields/standard_field_props"; import { X2ManyField, x2ManyField } from "@web/views/fields/x2many/x2many_field"; import { FormController } from "@web/views/form/form_controller"; import { AttachDocumentWidget } from "@web/views/widgets/attach_document/attach_document"; import { WebClient } from "@web/webclient/webclient"; const fieldsRegistry = registry.category("fields"); const widgetsRegistry = registry.category("view_widgets"); class Partner extends models.Model { name = fields.Char({ translate: true }); foo = fields.Char({ default: "My little Foo Value" }); bar = fields.Boolean(); int_field = fields.Integer(); float_field = fields.Float({ aggregator: "sum" }); child_ids = fields.One2many({ string: "one2many field", relation: "partner" }); parent_id = fields.Many2one({ relation: "partner" }); type_ids = fields.Many2many({ relation: "partner.type" }); product_id = fields.Many2one({ relation: "product" }); product_ids = fields.One2many({ relation: "product" }); state = fields.Selection({ selection: [ ["ab", "AB"], ["cd", "CD"], ["ef", "EF"], ], }); date = fields.Date(); datetime = fields.Datetime(); reference = fields.Reference({ selection: [ ["product", "Product"], ["partner_type", "Partner Type"], ["partner", "Partner"], ], }); user_id = fields.Many2one({ relation: "res.users" }); _records = [ { id: 1, name: "first record", product_id: 37, bar: true, foo: "yop", int_field: 10, float_field: 0.44, child_ids: [], type_ids: [], parent_id: 4, state: "ab", date: "2017-01-25", datetime: "2016-12-12 10:55:05", }, { id: 2, name: "second record", bar: true, foo: "blip", int_field: 9, float_field: 13, child_ids: [], type_ids: [], parent_id: 1, state: "cd", }, { id: 4, name: "aaa", state: "ef", }, { id: 5, name: "aaa", foo: "", bar: false, state: "ef", }, ]; } class PartnerType extends models.Model { _name = "partner.type"; name = fields.Char(); color = fields.Integer(); foo = fields.Char(); _records = [ { id: 12, name: "gold", color: 2 }, { id: 14, name: "silver", color: 5 }, ]; } class Product extends models.Model { name = fields.Char(); partner_type_id = fields.Many2one({ relation: "partner.type" }); _records = [ { id: 37, name: "xphone" }, { id: 41, name: "xpad" }, ]; } class ResUsers extends models.Model { _name = "res.users"; name = fields.Char(); partner_ids = fields.One2many({ relation: "partner", relation_field: "user_id" }); _records = [ { id: 17, name: "Aline", partner_ids: [1] }, { id: 19, name: "Christine" }, ]; } class ResCompany extends models.Model { _name = "res.company"; name = fields.Char(); } defineModels([Partner, PartnerType, Product, ResUsers, ResCompany]); onRpc("has_group", () => true); before(() => { patchWithCleanup(EventBus.prototype, { addEventListener(...args) { super.addEventListener(...args); after(() => { this.removeEventListener(...args); }); }, }); }); test(`simple form rendering`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
some htmlaa
`, resId: 2, }); expect(`div.test`).toHaveCount(1); expect(`div.test`).toHaveStyle({ opacity: "0.5" }); expect(`label:contains(Foo)`).toHaveCount(1); expect(`.o_field_char input`).toHaveCount(1); expect(`.o_field_char input`).toHaveValue("blip"); expect(`.o_group .o_inner_group:eq(0)`).toHaveStyle({ backgroundColor: "rgb(255, 0, 0)" }); expect(`.o_field_widget[name=foo]`).toHaveStyle({ color: "rgb(0, 0, 255)" }); expect(`label:contains(something_id)`).toHaveCount(0); expect(`label:contains(f3_description)`).toHaveCount(1); expect(`div.o_field_one2many table`).toHaveCount(1); expect(`div.o_cell:not(.o_list_record_selector) .o-checkbox input:checked`).toHaveCount(1); expect(`label.o_form_label_empty:contains(type_ids)`).toHaveCount(0); }); test(`form rendering with class and style attributes`, async () => { await mountView({ resModel: "partner", type: "form", arch: /* xml */ `
`, resId: 2, }); expect( `.o_view_controller[style*='border: 1px solid red;'], .o_view_controller [style*='border: 1px solid red;']` ).toHaveCount(0); expect(`.o_view_controller.o_form_view.myCustomClass`).toHaveCount(1); expect(`.myCustomClass`).toHaveCount(1); }); test(`generic tags are case insensitive`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
Hello
`, }); expect(`div.test`).toHaveCount(1); }); test(`form view with a group that contains an invisible group`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_form_view .o_group`).toHaveCount(1); }); test.tags("mobile"); test(`button box rendering on small screen`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o-form-buttonbox > button`).toHaveCount(0); expect(`.oe_stat_button .o_button_more`).toHaveCount(1); await contains(`div.oe_stat_button .o_button_more`).click(); expect(`.o-form-buttonbox-small button.oe_stat_button`).toHaveCount(4); expect(`.o-dropdown--menu #btn4`).toHaveCount(1); }); test.tags("desktop"); test(`button box rendering on big screen`, async () => { const bus = new EventBus(); mockService("ui", (env) => { Object.defineProperty(env, "isSmall", { value: false, }); return { bus, get size() { return SIZES.XXL; }, get isSmall() { return false; }, }; }); let btnString = ""; for (let i = 0; i < 9; i++) { btnString += ``; } await mountView({ resModel: "partner", type: "form", arch: `
${btnString}
`, resId: 2, }); expect(`.o-form-buttonbox > button`).toHaveCount(7); expect(`.o-form-buttonbox > .oe_stat_button .o-dropdown`).toHaveCount(1); const buttonBox = queryFirst(`.o-form-buttonbox`); const buttonBoxRect = buttonBox.getBoundingClientRect(); // we asserted that we have 7 buttons + 1 dropdown for (const btn of buttonBox.children) { expect(btn).toHaveRect({ top: buttonBoxRect.top }); } }); test(`button box rendering invisible`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_control_panel .o_control_panel_actions`).toHaveInnerHTML(""); }); test(`form view gets size class on small and big screens`, async () => { let uiSize = SIZES.MD; const bus = new EventBus(); mockService("ui", (env) => { Object.defineProperty(env, "isSmall", { value: false, }); return { bus, get size() { return uiSize; }, get isSmall() { return uiSize <= SIZES.SM; }, }; }); await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_xxl_form_view, .o_xxs_form_view`).toHaveCount(0); uiSize = SIZES.XXL; bus.trigger("resize"); await animationFrame(); expect(`.o_xxs_form_view`).toHaveCount(0); expect(`.o_xxl_form_view`).toHaveCount(1); uiSize = SIZES.XS; bus.trigger("resize"); await animationFrame(); expect(`.o_xxl_form_view`).toHaveCount(0); expect(`.o_xxs_form_view`).toHaveCount(1); }); test(`duplicate fields rendered properly`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, }); expect(`.o_field_widget[name=foo].foo_1`).toHaveCount(0); expect(`.o_field_widget[name=foo].foo_2`).toHaveCount(1); expect(`.o_field_widget[name=foo].foo_3`).toHaveCount(1); await contains(`.o_field_widget[name=foo].foo_3 input`).edit("hello"); expect(`.o_field_widget[name=foo].foo_2 input`).toHaveValue("hello"); expect(`.o_field_widget[name=int_field].int_field_1`).not.toHaveClass("o_readonly_modifier"); expect(`.o_field_widget[name=int_field].int_field_2`).toHaveClass("o_readonly_modifier"); expect(`.int_field_1 input`).toHaveCount(1); expect(`.int_field_2 span`).toHaveCount(1); await contains(`.o_field_widget[name=bar] input`).check(); expect(`.o_field_widget[name=int_field].int_field_1`).toHaveClass("o_readonly_modifier"); expect(`.o_field_widget[name=int_field].int_field_2`).not.toHaveClass("o_readonly_modifier"); expect(`.int_field_1 span`).toHaveCount(1); expect(`.int_field_2 input`).toHaveCount(1); }); test(`duplicate fields rendered properly (one2many)`, async () => { Partner._records.push({ id: 6, child_ids: [1] }); await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 6, }); expect(`.o_field_one2many`).toHaveCount(2); expect(`.o_field_one2many:eq(0)`).not.toHaveClass("o_readonly_modifier"); expect(`.o_field_one2many:eq(1)`).toHaveClass("o_readonly_modifier"); await contains(`.o_field_one2many:eq(0) .o_data_cell`).click(); expect(`.o_field_one2many`).toHaveCount(2); expect(`.o_field_one2many:eq(0) .o_selected_row .o_field_widget[name=foo] input`).toHaveValue( "yop" ); expect(`.o_field_one2many:eq(1) .o_data_row:eq(0) .o_data_cell[name=foo]`).toHaveText("yop"); await contains(`.o_field_one2many:eq(0) .o_selected_row .o_field_widget[name=foo] input`).edit( "hello", { confirm: false } ); await click(`.o_content`); // confirm change by focusing out the input. await animationFrame(); await animationFrame(); await animationFrame(); await animationFrame(); await animationFrame(); await animationFrame(); expect(`.o_field_one2many:eq(1) .o_data_row:eq(0) .o_data_cell[name=foo]`).toHaveText("hello"); await contains(`.o_field_one2many:eq(0) .o_field_x2many_list_row_add a`).click(); expect(`.o_field_one2many:eq(0) .o_selected_row .o_field_widget[name="foo"] input`).toHaveValue( "My little Foo Value" ); expect(`.o_field_one2many:eq(1) .o_data_row:eq(1) .o_data_cell[name=foo]`).toHaveText( "My little Foo Value" ); }); test(`attributes are transferred on async widgets`, async () => { const def = new Deferred(); class AsyncField extends CharField { willStart() { return def; } } fieldsRegistry.add("asyncwidget", { component: AsyncField }); const viewProm = mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); await animationFrame(); def.resolve(); await viewProm; expect(`.o_field_widget[name=foo]`).toHaveStyle({ color: "rgb(0, 0, 255)" }); }); test(`placeholder attribute on input`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`input[placeholder="chimay"]`).toHaveCount(1); }); test(`decoration works on widgets`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name="display_name"]`).not.toHaveClass("text-danger"); expect(`.o_field_widget[name="foo"]`).toHaveClass("text-danger"); }); test(`form with o2m having a many2many fields using the many2many_tags widget along the color_field option`, async () => { // In this scenario, the x2many form view isn't inline, so when we click on the record, // it does an independant getView, which doesn't return all fields of the model. In the // x2many list view, there's a field with a many2many_tags widget with the color option, // and the color field (color) in our case, isn't in the form view. // This test ensures that we can open the form view in this situation. Partner._records[0].type_ids = [12, 14]; Partner._views = { form: `
`, }; await mountView({ resModel: "res.users", type: "form", arch: `
`, resId: 17, }); expect(`.o_field_widget[name=type_ids] .o_field_tags`).toHaveCount(1); await contains(`.o_data_row .o_data_cell`).click(); expect(`.modal .o_form_view .o_field_widget[name=type_ids]`).toHaveCount(1); }); test(`form with o2m having a field with fieldDependencies`, async () => { // In this scenario, the x2many form view isn't inline, so when we click on the record, // it does an independant getView, which doesn't return all fields of the model. In the // x2many list view, there's a field with fieldDependencies, and the dependency field // (int_field) in our case, isn't in the form view. This test ensures that we can open // the form view in this situation. class MyField extends CharField {} fieldsRegistry.add("my_widget", { component: MyField, fieldDependencies: [{ name: "int_field", type: "integer" }], }); Partner._records[1].child_ids = [1]; await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name="child_ids"] .o_data_row`).toHaveCount(1); await contains(`.o_field_widget[name="child_ids"] .o_data_row .o_data_cell`).click(); expect(`.modal .o_form_view .o_field_widget[name="child_ids"]`).toHaveCount(1); }); test(`form with o2m having a selection field with fieldDependencies`, async () => { class MyField extends CharField {} fieldsRegistry.add("my_widget", { component: MyField, fieldDependencies: [{ name: "selection", type: "selection" }], }); Partner._fields.o2m = fields.One2many({ relation: "partner.type" }); Partner._records[1].o2m = [1]; PartnerType._fields.selection = fields.Selection({ selection: [ ["a", "A"], ["b", "B"], ], }); PartnerType._records = [ { id: 1, name: "first partner_type", selection: false, }, ]; PartnerType._views = { form: `
`, }; await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name=o2m] .o_data_row`).toHaveCount(1); await contains(`.o_field_widget[name=o2m] .o_field_x2many_list_row_add a`).click(); expect(`.modal .o_form_view .o_field_widget[name=display_name]`).toHaveCount(1); }); test(`form view: widget having a o2m field as fieldDependencies`, async () => { class MyWidget extends Component { static template = xml`My custom widget`; static props = ["*"]; } widgetsRegistry.add("my_widget", { component: MyWidget, fieldDependencies: [{ name: "child_ids", type: "one2many" }], }); await mountView({ resModel: "res.users", type: "form", arch: `
`, resId: 17, }); await contains(`.o_list_view .o_field_cell[name="name"]`).click(); expect(`.modal .o_form_view .o_widget_my_widget`).toHaveCount(1); }); test(`fieldDependencies are readonly by default`, async () => { class MyField extends CharField {} fieldsRegistry.add("my_widget", { component: MyField, fieldDependencies: [ { name: "int_field", type: "integer" }, { name: "bar", type: "boolean" }, { name: "float_field", type: "float", readonly: false }, ], }); onRpc("web_save", ({ args }) => { expect(args[1]).toEqual( { name: "plop", foo: "My little Foo Value", float_field: 0, }, { message: "'int_field' and 'bar' shouldn't be present" } ); expect.step("web_save"); }); await mountView({ resModel: "partner", type: "form", arch: `
`, }); await contains(`[name='name'] input`).edit("plop"); await contains(`.o_form_button_save`).click(); expect.verifySteps(["web_save"]); }); test(`decoration-bf works on fields`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name="display_name"]`).not.toHaveClass("fw-bold"); expect(`.o_field_widget[name="foo"]`).toHaveClass("fw-bold"); }); test(`decoration-it works on fields`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name="display_name"]`).not.toHaveClass("fst-italic"); expect(`.o_field_widget[name="foo"]`).toHaveClass("fst-italic"); }); test(`decoration on widgets are reevaluated if necessary`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name="display_name"]`).not.toHaveClass("text-danger"); await contains(`.o_field_widget[name=int_field] input`).edit("3"); expect(`.o_field_widget[name="display_name"]`).toHaveClass("text-danger"); }); test(`decoration on widgets works on same widget`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect(`.o_field_widget[name="int_field"]`).not.toHaveClass("text-danger"); await contains(`.o_field_widget[name=int_field] input`).edit("3"); expect(`.o_field_widget[name="int_field"]`).toHaveClass("text-danger"); }); test(`only necessary fields are fetched with correct context`, async () => { onRpc("web_read", ({ kwargs }) => { expect.step("web_read"); expect(kwargs.specification).toEqual( { foo: {}, display_name: {} }, { message: "should only fetch requested fields" } ); expect(kwargs.context.bin_size).toBe(true, { message: "bin_size should always be in the context", }); }); await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 1, }); expect.verifySteps(["web_read"]); }); test(`group rendering`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 1, }); expect(`div.o_inner_group`).toHaveCount(1); }); test(`group with formLabel`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 1, }); expect(`.o_field_widget[name=foo]`).toHaveClass(["o_field_char", "col-lg-6"]); expect(`.o_form_label[for=foo_0]`).toHaveClass(["plop", "plop2", "col-lg-6"]); }); test(`group containing both a field and a group`, async () => { // The purpose of this test is to check that classnames defined in a // field widget and those added by the form renderer are correctly // combined. For instance, the renderer adds className 'o_group_col_x' // on outer group's children (an outer group being a group that contains // at least a group). await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 1, }); expect(`.o_group .o_field_widget[name=foo]`).toHaveCount(1); expect(`.o_group .o_inner_group .o_field_widget[name=int_field]`).toHaveCount(1); expect(`.o_field_widget[name=foo]`).toHaveClass(["o_field_char", "col-lg-6"]); }); test(`field ids are unique (same field name in 2 form views)`, async () => { await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 1, }); expect(".o_field_widget input#foo_0").toHaveCount(1); await contains(".o_field_x2many_list_row_add a").click(); expect(".modal .o_form_view").toHaveCount(1); expect(".o_field_widget input#foo_0").toHaveCount(1); expect(".modal .o_field_widget input#foo_0").toHaveCount(1); expect(".modal .o_field_widget input#bar_0").toHaveCount(1); }); test(`Form and subview with _view_ref contexts`, async () => { Product._fields.type_ids = fields.One2many({ relation: "partner.type" }); Product._records = [{ id: 1, name: "Tromblon", type_ids: [12, 14] }]; Partner._records[0].product_id = 1; // This is an old test, written before "get_views" (formerly "load_views") automatically // inlines x2many subviews. As the purpose of this test is to assert that the js fetches // the correct sub view when it is not inline (which can still happen in nested form views), // we bypass the inline mecanism of "get_views" by setting widget="one2many" on the field. Partner._views = { form: `
`, }; PartnerType._views = { list: ``, kanban: ` `, }; Product._views = { form: `
`, }; onRpc("product", "get_views", ({ kwargs }) => { const { context } = kwargs; expect.step("product get_views"); expect(context.list_view_ref).toBe("some_tree_view"); // "The correct _view_ref should have been sent to the server, first time" }); onRpc("partner.type", "get_views", ({ kwargs }) => { const { context } = kwargs; expect.step("partner.type get_views"); expect(context.list_view_ref).toBe("some_other_tree_view"); // "The correct _view_ref should have been sent to the server for the subview" }); onRpc("get_formview_action", ({ model, kwargs }) => { expect.step("get_formview_action"); return { res_id: 1, type: "ir.actions.act_window", target: "current", res_model: model, context: kwargs.context, view_mode: "form", views: [[false, "form"]], }; }); await mountWithCleanup(WebClient); await getService("action").doAction({ res_id: 1, type: "ir.actions.act_window", target: "current", res_model: "partner", view_mode: "form", views: [[false, "form"]], }); await contains(`.o_field_widget[name="product_id"] .o_external_button`, { visible: false, }).click(); expect.verifySteps(["get_formview_action", "product get_views", "partner.type get_views"]); }); test(`Form and subsubview with only _view_ref contexts`, async () => { PartnerType._fields.company_ids = fields.One2many({ relation: "res.company" }); ResCompany._views = { list: ``, kanban: ` `, "form,2": `
`, }; PartnerType._views = { list: ``, kanban: ` `, "form,foo.partner_type_form_view": `
`, }; const userContext = { lang: "en", tz: "taht", uid: 7, allowed_company_ids: [1], }; const expectedContexts = new Map(); expectedContexts.set("view:partner", { ...userContext }); expectedContexts.set("onchange:partner", { ...userContext }); expectedContexts.set("view:partner.type", { ...userContext, form_view_ref: "foo.partner_type_form_view", }); expectedContexts.set("onchange:partner.type", { ...userContext, form_view_ref: "foo.partner_type_form_view", }); onRpc("get_views", ({ model, kwargs }) => { const { context } = kwargs; expect.step(`get_views (${model})`); expect(context).toEqual(expectedContexts.get(`view:${model}`)); }); onRpc("onchange", ({ model, kwargs }) => { const { context } = kwargs; expect.step(`onchange (${model})`); expect(context).toEqual(expectedContexts.get(`onchange:${model}`)); }); await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 2, }); expect.verifySteps(["get_views (partner)", "get_views (partner.type)"]); // Add a line in the x2many type_ids field expectedContexts.clear(); expectedContexts.set("view:partner.type", { ...userContext, form_view_ref: "foo.partner_type_form_view", }); expectedContexts.set("onchange:partner.type", { ...userContext, default_partner_id: 2, form_view_ref: "foo.partner_type_form_view", }); await contains( `[name=type_ids] .o_field_x2many_list_row_add a, [name=type_ids] .o-kanban-button-new` ).click(); expect.verifySteps(["get_views (partner.type)"]); // Create a new type_ids await contains(`.modal .o_create_button`).click(); expect.verifySteps(["get_views (partner.type)", "onchange (partner.type)"]); // Create a new company expectedContexts.clear(); expectedContexts.set("view:res.company", { ...userContext, form_view_ref: "bar.rescompany_form_view", }); expectedContexts.set("onchange:res.company", { ...userContext, default_color: 2, form_view_ref: "bar.rescompany_form_view", }); await contains(`.modal [name=company_ids] .o_field_x2many_list_row_add a`).click(); expect.verifySteps(["get_views (res.company)", "onchange (res.company)"]); }); test(`x2many form_view_ref with defined list`, async () => { Partner._records = [{ id: 1, type_ids: [1] }]; PartnerType._records = [{ id: 1, name: "Timmy 1" }]; PartnerType._views = { "form,foo.partner_type_form_view": `
`, }; const expectedContexts = new Map(); const userContext = { lang: "en", tz: "taht", uid: 7, allowed_company_ids: [1], }; expectedContexts.set("partner", { ...userContext }); expectedContexts.set("partner.type", { ...userContext, form_view_ref: "foo.partner_type_form_view", }); onRpc("get_views", ({ model, kwargs }) => { expect.step(`get_views (${model})`); expect(kwargs.context).toEqual(expectedContexts.get(model)); }); await mountView({ resModel: "partner", type: "form", arch: `
`, resId: 1, }); expect.verifySteps(["get_views (partner)"]); await contains(`.o_field_widget[name='type_ids'] .o_field_cell`).click(); expect.verifySteps(["get_views (partner.type)"]); }); test(`invisible fields are properly hidden`, async () => { await mountView({ resModel: "partner", type: "form", // the arch contains an x2many field without inline view: as it is always invisible, // the view should not be fetched. we don't specify any view in this test, so if it // ever tries to fetch it, it will crash, indicating that this is wrong. arch: `
`, resId: 1, }); expect(`label:contains(Foo)`).toHaveCount(0); expect(`.o_field_widget[name=foo]`).toHaveCount(0); expect(`.o_field_widget[name=float_field]`).toHaveCount(0); expect(`.o_field_widget[name="child_ids"]`).toHaveCount(0); }); test(`correctly copy attributes to compiled labels`, async () => { await mountView({ resModel: "partner", type: "form", arch: `