/* @odoo-module */ import { startServer } from "@bus/../tests/helpers/mock_python_environment"; import { start } from "@mail/../tests/helpers/test_utils"; import { Command } from "@mail/../tests/helpers/command"; QUnit.module("im_status"); QUnit.test("on leave & online", async (assert) => { const pyEnv = await startServer(); const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "leave_online" }); const channelId = pyEnv["discuss.channel"].create({ channel_member_ids: [ Command.create({ partner_id: pyEnv.currentPartnerId }), Command.create({ partner_id: partnerId }), ], channel_type: "chat", }); const { openDiscuss } = await start(); await openDiscuss(channelId); assert.containsOnce($, ".o-mail-ImStatus i.fa-plane[title='Online']"); }); QUnit.test("on leave & away", async (assert) => { const pyEnv = await startServer(); const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "leave_away" }); const channelId = pyEnv["discuss.channel"].create({ channel_member_ids: [ Command.create({ partner_id: pyEnv.currentPartnerId }), Command.create({ partner_id: partnerId }), ], channel_type: "chat", }); const { openDiscuss } = await start(); await openDiscuss(channelId); assert.containsOnce($, ".o-mail-ImStatus i.fa-plane[title='Idle']"); }); QUnit.test("on leave & offline", async (assert) => { const pyEnv = await startServer(); const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "leave_offline" }); const channelId = pyEnv["discuss.channel"].create({ channel_member_ids: [ Command.create({ partner_id: pyEnv.currentPartnerId }), Command.create({ partner_id: partnerId }), ], channel_type: "chat", }); const { openDiscuss } = await start(); await openDiscuss(channelId); assert.containsOnce($, ".o-mail-ImStatus i.fa-plane[title='Out of office']"); });