+2








318cdcc0b8
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>
76 lines
2.6 KiB
JavaScript
76 lines
2.6 KiB
JavaScript
/** @odoo-module */
|
|
|
|
import * as legacyRegistry from "web.Registry";
|
|
import * as BusService from "bus.BusService";
|
|
import * as RamStorage from "web.RamStorage";
|
|
import * as AbstractStorageService from "web.AbstractStorageService";
|
|
|
|
import { createWebClient } from "@web/../tests/webclient/helpers";
|
|
import { assetsWatchdogService } from "@bus/js/services/assets_watchdog_service";
|
|
import { click, getFixture, nextTick, patchWithCleanup } from "@web/../tests/helpers/utils";
|
|
import { browser } from "@web/core/browser/browser";
|
|
import { registry } from "@web/core/registry";
|
|
|
|
const LocalStorageService = AbstractStorageService.extend({
|
|
storage: new RamStorage(),
|
|
});
|
|
const serviceRegistry = registry.category("services");
|
|
|
|
QUnit.module("Bus Assets WatchDog", (hooks) => {
|
|
let legacyServicesRegistry;
|
|
let target;
|
|
hooks.beforeEach((assert) => {
|
|
legacyServicesRegistry = new legacyRegistry();
|
|
legacyServicesRegistry.add("bus_service", BusService);
|
|
legacyServicesRegistry.add("local_storage", LocalStorageService);
|
|
|
|
serviceRegistry.add("assetsWatchdog", assetsWatchdogService);
|
|
patchWithCleanup(browser, {
|
|
setTimeout: (fn) => fn(),
|
|
clearTimeout: () => {},
|
|
location: {
|
|
reload: () => assert.step("reloadPage"),
|
|
},
|
|
});
|
|
|
|
target = getFixture();
|
|
});
|
|
|
|
QUnit.test("can listen on bus and displays notifications in DOM", async (assert) => {
|
|
assert.expect(4);
|
|
|
|
let pollNumber = 0;
|
|
const mockRPC = async (route, args) => {
|
|
if (route === "/longpolling/poll") {
|
|
if (pollNumber > 0) {
|
|
return new Promise(() => {}); // let it hang to avoid further calls
|
|
}
|
|
pollNumber++;
|
|
return [{
|
|
message: {
|
|
type: 'bundle_changed',
|
|
payload: { server_version: "NEW_MAJOR_VERSION" },
|
|
},
|
|
}];
|
|
}
|
|
};
|
|
|
|
await createWebClient({
|
|
legacyParams: { serviceRegistry: legacyServicesRegistry },
|
|
mockRPC,
|
|
});
|
|
|
|
await nextTick();
|
|
|
|
assert.containsOnce(target, ".o_notification_body");
|
|
assert.strictEqual(
|
|
target.querySelector(".o_notification_body .o_notification_content").textContent,
|
|
"The page appears to be out of date."
|
|
);
|
|
|
|
// reload by clicking on the reload button
|
|
await click(target, ".o_notification_buttons .btn-primary");
|
|
assert.verifySteps(["reloadPage"]);
|
|
});
|
|
});
|