|
| 1 | +import {animationFrame, click, expect, runAllTimers, test} from "@odoo/hoot"; |
| 2 | +import { |
| 3 | + defineModels, |
| 4 | + fields, |
| 5 | + models, |
| 6 | + mountView, |
| 7 | + onRpc, |
| 8 | + toggleActionMenu, |
| 9 | +} from "@web/../tests/web_test_helpers"; |
| 10 | +import {defineMailModels} from "@mail/../tests/mail_test_helpers"; |
| 11 | + |
| 12 | +class Partner extends models.Model { |
| 13 | + display_name = fields.Char(); |
| 14 | + properties = fields.Properties({ |
| 15 | + string: "Properties", |
| 16 | + searchable: false, |
| 17 | + definition_record: "company_id", |
| 18 | + definition_record_field: "definitions", |
| 19 | + }); |
| 20 | + company_id = fields.Many2one({ |
| 21 | + string: "Company", |
| 22 | + relation: "properties.definition.model", |
| 23 | + }); |
| 24 | + _records = [ |
| 25 | + { |
| 26 | + id: 1, |
| 27 | + display_name: "first partner", |
| 28 | + properties: { |
| 29 | + property_1: "char value", |
| 30 | + property_2: "b", |
| 31 | + }, |
| 32 | + company_id: 37, |
| 33 | + }, |
| 34 | + ]; |
| 35 | +} |
| 36 | + |
| 37 | +class PropertiesDefinitionModel extends models.Model { |
| 38 | + _name = "properties.definition.model"; |
| 39 | + name = fields.Char({string: "Name"}); |
| 40 | + definitions = fields.PropertiesDefinition(); |
| 41 | + _records = [ |
| 42 | + { |
| 43 | + id: 37, |
| 44 | + name: "Company 1", |
| 45 | + definitions: [], |
| 46 | + }, |
| 47 | + ]; |
| 48 | +} |
| 49 | + |
| 50 | +defineModels([Partner, PropertiesDefinitionModel]); |
| 51 | +defineMailModels(); |
| 52 | +test("Portal Properties: check field", async () => { |
| 53 | + onRpc("has_access", () => true); |
| 54 | + await mountView({ |
| 55 | + type: "form", |
| 56 | + resModel: "partner", |
| 57 | + resId: 1, |
| 58 | + arch: ` |
| 59 | + <form> |
| 60 | + <sheet> |
| 61 | + <group> |
| 62 | + <field name="company_id"/> |
| 63 | + <field name="properties" widget="portal_properties"/> |
| 64 | + </group> |
| 65 | + </sheet> |
| 66 | + </form>`, |
| 67 | + actionMenus: {}, |
| 68 | + }); |
| 69 | + expect(".o_field_properties").toHaveCount(1); |
| 70 | + await toggleActionMenu(); |
| 71 | + await animationFrame(); |
| 72 | + expect(".o-dropdown--menu span:contains(Add Properties)").toHaveCount(1, { |
| 73 | + message: "The add button must be in the cog menu", |
| 74 | + }); |
| 75 | + await click(".o-dropdown--menu span .fa-cogs"); |
| 76 | + await runAllTimers(); |
| 77 | + await animationFrame(); |
| 78 | + expect(".o_property_field_popover").toHaveCount(1, { |
| 79 | + message: "Should have opened the definition popover", |
| 80 | + }); |
| 81 | + expect(".o_property_field_popover .o_property_display_in_portal").toHaveCount(1, { |
| 82 | + message: "The display in portal checkbox should be visible", |
| 83 | + }); |
| 84 | +}); |
0 commit comments