Files
odoo_source/addons/website/static/tests/dashboard_tests.js
T
+2 56cc3dfab1 [REF] website, website_*: adapt code to owl 2
Owl 2 changelog: https://github.com/odoo/owl/blob/a9f29c4caad4f32d06be1ec4780572825781cd9b/CHANGELOG.md

Part-of: odoo/odoo#80156
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Simon Genin (ges) <ges@odoo.com>
Co-authored-by: Francois (fge) <fge@odoo.com>
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: luvi <luvi@odoo.com>
Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
2022-02-10 07:46:12 +00:00

67 lines
2.1 KiB
JavaScript

odoo.define('website/static/tests/dashboard_tests', function (require) {
"use strict";
const ControlPanel = require('web.ControlPanel');
const Dashboard = require('website.backend.dashboard');
const testUtils = require("web.test_utils");
const { patch, unpatch } = require('web.utils');
const { createParent, nextTick, prepareTarget } = testUtils;
QUnit.module('Website Backend Dashboard', {
}, function () {
QUnit.test("mounted is called once for the dashboard's ControlPanel", async function (assert) {
// This test can be removed as soon as we don't mix legacy and owl layers anymore.
assert.expect(5);
patch(ControlPanel.prototype, 'test.ControlPanel', {
setup() {
this._super();
owl.onMounted(() => {
assert.step('mounted');
});
owl.onWillUnmount(() => {
assert.step('willUnmount');
})
},
});
const params = {
mockRPC: (route) => {
if (route === '/website/fetch_dashboard_data') {
return Promise.resolve({
dashboards: {
visits: {},
sales: { summary: {} },
},
groups: { system: true, website_designer: true },
websites: [
{id: 1, name: "My Website", domain: "", selected: true},
],
});
}
return this._super(...arguments);
},
};
const parent = await createParent(params);
const dashboard = new Dashboard(parent, {});
await dashboard.appendTo(document.createDocumentFragment());
assert.verifySteps([]);
dashboard.$el.appendTo(prepareTarget());
dashboard.on_attach_callback();
await nextTick();
assert.verifySteps(['mounted']);
dashboard.destroy();
assert.verifySteps(['willUnmount']);
unpatch(ControlPanel.prototype, 'test.ControlPanel');
});
});
});