mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
update test helpers and improve widget tests
This commit is contained in:
@@ -8,19 +8,23 @@ import { ActionManager } from "./services/action_manager";
|
||||
import { MenuInfo, MenuItem } from "./widgets/root";
|
||||
import { Env } from "./widgets/widget";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
interface InitializedData {
|
||||
env: Env;
|
||||
menuInfo: MenuInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* makeEnvironment returns the main environment for the application.
|
||||
* init returns the main environment for the application.
|
||||
*
|
||||
* Note that it does not make much sense (except for tests) to have more than
|
||||
* one environment. For example, with two environment, the router code in one
|
||||
* environment will probably interfere with the code from the other environment.
|
||||
*
|
||||
* For this reason, the result of makeEnvironment is memoized: every call to
|
||||
* For this reason, the result of init is memoized: every call to
|
||||
* this function will actually return the same environment.
|
||||
*/
|
||||
export const init = memoize(async function(): Promise<InitializedData> {
|
||||
@@ -61,13 +65,9 @@ export const init = memoize(async function(): Promise<InitializedData> {
|
||||
// Adapters
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function loadMenus(): MenuInfo {
|
||||
const menuItems: BaseMenuItem[] = (<any>window).odoo.menus;
|
||||
const menuInfo = getMenuInfo(menuItems);
|
||||
delete (<any>window).odoo.menus; // overkill?
|
||||
return menuInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load xml templates as a string.
|
||||
*/
|
||||
async function loadTemplates(): Promise<string> {
|
||||
const result = await fetch("templates.xml");
|
||||
if (!result.ok) {
|
||||
@@ -76,6 +76,16 @@ async function loadTemplates(): Promise<string> {
|
||||
return result.text();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all menu items
|
||||
*/
|
||||
function loadMenus(): MenuInfo {
|
||||
const menuItems: BaseMenuItem[] = (<any>window).odoo.menus;
|
||||
const menuInfo = getMenuInfo(menuItems);
|
||||
delete (<any>window).odoo.menus; // overkill?
|
||||
return menuInfo;
|
||||
}
|
||||
|
||||
interface BaseMenuItem {
|
||||
id: number;
|
||||
name: string;
|
||||
|
||||
@@ -106,7 +106,6 @@ export class Root extends Widget<Props, State> {
|
||||
if (app) {
|
||||
this.updateState({ currentApp: app });
|
||||
}
|
||||
debugger;
|
||||
this.env.router.navigate(query);
|
||||
this.env.actionManager.doAction(actionId);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user