/** @odoo-module */ // web import { status } from "@odoo/owl"; import { getFixture, makeDeferred, nextTick, patchWithCleanup } from "@web/../tests/helpers/utils"; import { makeView, setupViewRegistries } from "@web/../tests/views/helpers"; import { getOrigin } from "@web/core/utils/urls"; // web_editor import { HtmlField } from "@web_editor/js/backend/html_field"; import { unformat } from "@web_editor/js/editor/odoo-editor/test/utils"; import { parseHTML } from "@web_editor/js/editor/odoo-editor/src/utils/utils"; // knowledge import { decodeDataBehaviorProps, getPropNameNodes, } from "@knowledge/js/knowledge_utils"; //------------------------------------------------------------------------------ // Upgrade utils //------------------------------------------------------------------------------ /** * Assert that the desired attributes are set with the correct value on an * anchor element. * * @param {Object} attributes {name: value} to check for * @param {Element} anchor * @param {Object} assert assert object from QUnit */ function assertAttributes(attributes, anchor, assert) { for (const attr in attributes) { assert.equal(anchor.getAttribute(attr), attributes[attr], `The value of attribute: ${attr} was not as expected.`); } } /** * Assert that the behavior props registered in `data-behavior-props` attribute * of anchor are correct. * * This function also validates that every prop currently registered on the * anchor has been tested. * * @param {Object} props {name: value} to check for * @param {Element} anchor * @param {Object} assert assert object from QUnit */ function assertBehaviorProps(props, anchor, assert) { const behaviorProps = decodeDataBehaviorProps(anchor.dataset.behaviorProps); for (const prop in props) { assert.deepEqual(behaviorProps[prop], props[prop], `The value of prop: ${prop} in data-behavior-props was not as expected.`); } assert.deepEqual(new Set(Object.keys(behaviorProps)), new Set(Object.keys(props)), "data-behavior-props should only contain valid props from Behavior props schema"); } //------------------------------------------------------------------------------ // QUnit setup //------------------------------------------------------------------------------ let fixture; let serverData; let arch; let record; let htmlFieldPromise; function beforeEach() { htmlFieldPromise = makeDeferred(); patchWithCleanup(HtmlField.prototype, { async startWysiwyg() { await super.startWysiwyg(...arguments); await nextTick(); htmlFieldPromise.resolve(this); } }); fixture = getFixture(); record = { id: 1, name: "Upgrade Article", body: "