import { expect, test } from "@odoo/hoot"; import { queryOne } from "@odoo/hoot-dom"; import { defineModels, models, mountView } from "@web/../tests/web_test_helpers"; import { defineMailModels } from "@mail/../tests/mail_test_helpers"; class SocialPostTemplate extends models.ServerModel { _name = "social.post.template"; _records = [ { id: 1, message: "Hello @Odoo-Social, check this out: https://www.odoo.com #crazydeals #odoo", twitter_message: "Hello @Odoo-Social, check this out: https://www.odoo.com #crazydeals #odoo", is_split_per_media: false, has_twitter_account: true, twitter_preview: `
X Account @x ยท 11m
Hello @Odoo-Social, check this out: https://www.odoo.com #crazydeals #odoo
Post Image
www.odoo.com
`, }, ]; _views = { form: `
`, }; } defineMailModels(); defineModels([SocialPostTemplate]); test("SocialPostFormatterMixin on HtmlField is working as expected", async () => { await mountView({ type: "form", resId: 1, resModel: "social.post.template", }); const htmlValue = queryOne(".o_social_preview_message").innerHTML; expect(htmlValue).toEqual( [ `Hello`, `@Odoo-Social,`, `check this out:`, `https://www.odoo.com`, `#crazydeals`, `#odoo`, ].join(" ") ); });