oca-ocb-web/odoo-bringout-oca-ocb-html_builder/html_builder/static/tests/img.test.js
Ernad Husremovic f866779561 replace stale web_editor with html_editor and html_builder for 19.0
web_editor was removed in Odoo 19.0 and replaced by html_editor
and html_builder. The old web_editor was incorrectly included in
the 19.0 vanilla import.

🤖 assisted by claude
2026-03-09 15:31:13 +01:00

46 lines
1.4 KiB
JavaScript

import { Img } from "@html_builder/core/img";
import { ImgGroup } from "@html_builder/core/img_group";
import { defineMailModels } from "@mail/../tests/mail_test_helpers";
import { expect, test, describe } from "@odoo/hoot";
import { animationFrame, Deferred } from "@odoo/hoot-dom";
import { Component, xml } from "@odoo/owl";
import { mountWithCleanup, patchWithCleanup } from "@web/../tests/web_test_helpers";
describe.current.tags("desktop");
defineMailModels(); // meh
test("ImgGroup's inner Img components should not be blocked before src load", async () => {
const defs = {
img1: new Deferred(),
img2: new Deferred(),
img3: new Deferred(),
};
patchWithCleanup(Img.prototype, {
loadImage() {
const def = defs[this.props.class];
return Promise.all([super.loadImage(), def]);
},
});
class Container extends Component {
static components = { ImgGroup, Img };
static template = xml`
<ImgGroup>
<t t-foreach="Object.keys(defs)" t-as="key" t-key="key">
<Img src="''" class="key"/>
</t>
</ImgGroup>`;
static props = {};
setup() {
this.defs = defs;
}
}
await mountWithCleanup(Container);
for (const key in defs) {
expect("img").toHaveCount(0);
defs[key].resolve();
await animationFrame();
}
expect("img").toHaveCount(3);
});