import { defineResourceModels } from "@resource/../tests/resource_test_helpers"; import { beforeEach, describe, expect, test } from "@odoo/hoot"; import { queryFirst } from "@odoo/hoot-dom"; import { click, contains, openFormView, openKanbanView, start, startServer, } from "@mail/../tests/mail_test_helpers"; describe.current.tags("desktop"); const data = {}; defineResourceModels(); beforeEach(async () => { /* 1. Create data 3 type of records tested: - Task linked to a material resource (resourceComputer) - fa-wrench should be used instead of avatar - clicking the icon should not open any popover - Task linked to a human resource not linked to a user (resourceMarie) (- avatar of the resource should not be displayed) (Currently not implemented, todo when m2o fields will support relatedFields option) - a card popover should open - No possibility to send a message to this resource as no user exists for it - Task linked to a human resource linked to a user (resourcePierre) - avatar of the user should be displayed - a card popover should open - A button to send a message to this user should be on the card */ const pyEnv = await startServer(); // User data.partnerPierreId = pyEnv["res.partner"].create({ name: "Pierre", email: "Pierre@odoo.test", phone: "+32487898933", }); data.userPierreId = pyEnv["res.users"].create({ name: "Pierre", partner_id: data.partnerPierreId, }); // Resources [data.resourceComputerId, data.resourceMarieId, data.resourcePierreId] = pyEnv[ "resource.resource" ].create([ { name: "Continuity testing computer", resource_type: "material", }, { name: "Marie", resource_type: "user", }, { name: "Pierre", resource_type: "user", user_id: data.userPierreId, im_status: "online", }, ]); // Tasks linked to those resources [data.taskComputerId, data.taskMarieId, data.taskPierreId] = pyEnv["resource.task"].create([ { display_name: "Task testing computer", resource_id: data.resourceComputerId, resource_type: "material", }, { display_name: "Task Marie", resource_id: data.resourceMarieId, resource_type: "user", }, { display_name: "Task Pierre", resource_id: data.resourcePierreId, resource_type: "user", }, ]); }); test("many2one_avatar_resource widget in form view", async () => { await start(); await openFormView("resource.task", data.taskComputerId, { arch: `
`, }); expect(queryFirst(".o_material_resource")).toHaveClass("o_material_resource"); }); test("many2one_avatar_resource widget in kanban view", async () => { await start(); await openKanbanView("resource.task", { arch: `