mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
add different view types
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { readFile } from "fs";
|
||||
import { BaseMenuItem, getMenuInfo } from "../../src/ts/loaders";
|
||||
import { actionRegistry } from "../../src/ts/registries";
|
||||
import { actionRegistry, viewRegistry } from "../../src/ts/registries";
|
||||
import { ActionDescription } from "../../src/ts/store/action_manager_mixin";
|
||||
import { MenuInfo } from "../../src/ts/store/store";
|
||||
import { Registry } from "../../src/ts/core/registry";
|
||||
@@ -9,6 +9,7 @@ export interface TestData {
|
||||
menuInfo: MenuInfo;
|
||||
actions: ActionDescription[];
|
||||
actionRegistry: typeof actionRegistry;
|
||||
viewRegistry: typeof viewRegistry;
|
||||
templates: string;
|
||||
}
|
||||
|
||||
@@ -18,13 +19,16 @@ export async function makeTestData(): Promise<TestData> {
|
||||
if (!templates) {
|
||||
templates = await loadTemplates();
|
||||
}
|
||||
const registry: typeof actionRegistry = new Registry();
|
||||
(<any>registry).map = Object.assign({}, (<any>actionRegistry).map);
|
||||
const _actionRegistry: typeof actionRegistry = new Registry();
|
||||
(<any>_actionRegistry).map = Object.assign({}, (<any>actionRegistry).map);
|
||||
const _viewRegistry: typeof actionRegistry = new Registry();
|
||||
(<any>_viewRegistry).map = Object.assign({}, (<any>actionRegistry).map);
|
||||
|
||||
return {
|
||||
menuInfo: makeMenuInfo(),
|
||||
actions: makeActionData(),
|
||||
actionRegistry: registry,
|
||||
actionRegistry: _actionRegistry,
|
||||
viewRegistry: _viewRegistry,
|
||||
templates
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,12 +41,14 @@ export function makeTestEnv(info: TestInfo = {}): TestEnv {
|
||||
roots: []
|
||||
};
|
||||
const actionRegistry = info.actionRegistry || new Registry();
|
||||
const viewRegistry = info.viewRegistry || new Registry();
|
||||
const actions = info.actions || [];
|
||||
|
||||
const data: TestData = {
|
||||
menuInfo,
|
||||
actions,
|
||||
actionRegistry,
|
||||
viewRegistry,
|
||||
templates
|
||||
};
|
||||
|
||||
@@ -63,7 +65,7 @@ export function makeTestEnv(info: TestInfo = {}): TestEnv {
|
||||
router: info.router || new MockRouter()
|
||||
};
|
||||
|
||||
const store = new Store(services, menuInfo, actionRegistry);
|
||||
const store = new Store(services, menuInfo, actionRegistry, viewRegistry);
|
||||
const env = makeEnv(store, templates);
|
||||
const testEnv = Object.assign({ store }, env);
|
||||
return testEnv;
|
||||
|
||||
@@ -38,3 +38,15 @@ test("display a warning if client action is not in registry", async () => {
|
||||
expect(notifs.length).toBe(1);
|
||||
expect(notifs[0].type).toBe("warning");
|
||||
});
|
||||
|
||||
test("display a warning if view is not in registry", async () => {
|
||||
const data = await makeTestData();
|
||||
data.viewRegistry = new Registry();
|
||||
const testEnv = makeTestEnv(data);
|
||||
|
||||
await testEnv.store.doAction(250);
|
||||
|
||||
const notifs = testEnv.store.state.notifications;
|
||||
expect(notifs.length).toBe(1);
|
||||
expect(notifs[0].type).toBe("warning");
|
||||
});
|
||||
|
||||
@@ -118,6 +118,40 @@ exports[`if url has action_id, will render action and navigate to proper menu_id
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`open act window action with invalid viewtype => empty widget is rendered + warning 1`] = `
|
||||
"<div class=\\"o_web_client\\">
|
||||
<div class=\\"o_navbar\\">
|
||||
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
|
||||
|
||||
<a class=\\"o_menu_brand\\" href=\\"\\" role=\\"button\\">
|
||||
Notes
|
||||
</a>
|
||||
<ul class=\\"o_menu_sections\\">
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class=\\"o_content\\"><div></div></div>
|
||||
<div class=\\"o_notification_container\\">
|
||||
|
||||
<div class=\\"o_notification o_error\\">
|
||||
|
||||
<div class=\\"o_notification_title\\">
|
||||
<span class=\\"o_icon fa fa-3x fa-exclamation\\" role=\\"img\\" aria-label=\\"Notification Invalid View type\\" title=\\"Notification Invalid View type\\"></span>
|
||||
Invalid View type
|
||||
</div>
|
||||
<div class=\\"o_notification_content\\">
|
||||
Cannot find view of type 'kanban' in the view registry
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class=\\"o_loading d-none\\">Loading</div>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`start with no action => clicks on client action => discuss is rendered 1`] = `
|
||||
"<div class=\\"o_web_client\\">
|
||||
<div class=\\"o_navbar\\">
|
||||
|
||||
@@ -76,3 +76,17 @@ test("clicks on client action with invalid key => empty widget is rendered + war
|
||||
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("open act window action with invalid viewtype => empty widget is rendered + warning", async () => {
|
||||
const data = await makeTestData();
|
||||
data.viewRegistry = new Registry();
|
||||
const testEnv = makeTestEnv(data);
|
||||
const root = new Root(testEnv, testEnv.store);
|
||||
await root.mount(fixture);
|
||||
|
||||
// note menu item
|
||||
await (<any>document.querySelector('[data-menu="205"]')).click();
|
||||
await helpers.nextTick();
|
||||
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user