rename web into demo

This commit is contained in:
Géry Debongnie
2019-03-14 11:02:14 +01:00
parent 75218b65e7
commit 2ffb0fd64c
1731 changed files with 8 additions and 12 deletions
@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can be rendered 1`] = `
"<div class=\\"o_home_menu\\">
<div class=\\"o_apps\\">
<a href=\\"#menu_id=96&amp;action_id=131\\" class=\\"o_app\\" data-menu=\\"96\\">
<i class=\\"fa fa-comment o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
Discuss
</div>
</a><a href=\\"#menu_id=205&amp;action_id=250\\" class=\\"o_app\\" data-menu=\\"205\\">
<i class=\\"fa fa-pen o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
Notes
</div>
</a><a href=\\"#menu_id=409&amp;action_id=597\\" class=\\"o_app\\" data-menu=\\"409\\">
<i class=\\"fa fa-handshake o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
CRM
</div>
</a>
</div>
</div>"
`;
@@ -0,0 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can be rendered (in home menu, no app) 1`] = `
"<div class=\\"o_navbar o_in_home\\">
</div>"
`;
exports[`can be rendered (in home menu, one active app) 1`] = `
"<div class=\\"o_navbar o_in_home\\">
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-chevron-left\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
</div>"
`;
exports[`can render one menu item 1`] = `
"<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\\">
Discuss
</a>
<ul class=\\"o_menu_sections\\">
</ul>
</div>"
`;
exports[`mobile mode: navbar is different 1`] = `
"<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\\">
<li>MOBILEMODE</li>
</ul>
</div>"
`;
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can be rendered (type = warning) 1`] = `
"<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 title\\" title=\\"Notification title\\"></span>
title
</div>
<div class=\\"o_notification_content\\">
message
</div>
</div>"
`;
exports[`can be rendered 1`] = `
"<div class=\\"o_notification\\">
<div class=\\"o_notification_title\\">
<span class=\\"o_icon fa fa-3x fa-lightbulb\\" role=\\"img\\" aria-label=\\"Notification title\\" title=\\"Notification title\\"></span>
title
</div>
<div class=\\"o_notification_content\\">
message
</div>
</div>"
`;
@@ -0,0 +1,257 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can be rendered (in home menu) 1`] = `
"<div class=\\"o_web_client\\">
<div class=\\"o_navbar o_in_home\\">
</div>
<div class=\\"o_home_menu\\">
<div class=\\"o_apps\\">
<a href=\\"#menu_id=96&amp;action_id=131\\" class=\\"o_app\\" data-menu=\\"96\\">
<i class=\\"fa fa-comment o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
Discuss
</div>
</a><a href=\\"#menu_id=205&amp;action_id=250\\" class=\\"o_app\\" data-menu=\\"205\\">
<i class=\\"fa fa-pen o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
Notes
</div>
</a><a href=\\"#menu_id=409&amp;action_id=597\\" class=\\"o_app\\" data-menu=\\"409\\">
<i class=\\"fa fa-handshake o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
CRM
</div>
</a>
</div>
</div>
<div class=\\"o_content o_hidden\\"></div>
<div class=\\"o_notification_container\\">
</div>
<div class=\\"o_loading d-none\\">Loading</div>
</div>"
`;
exports[`clicks on client action with invalid key => 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\\">
Discuss
</a>
<ul class=\\"o_menu_sections\\">
</ul>
</div>
<div class=\\"o_content\\"><div class=\\"o_action_controller\\"></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 Client Action\\" title=\\"Notification Invalid Client Action\\"></span>
Invalid Client Action
</div>
<div class=\\"o_notification_content\\">
Cannot find widget 'mail.discuss' in the action registry
</div>
</div>
</div>
<div class=\\"o_loading d-none\\">Loading</div>
</div>"
`;
exports[`if url has action_id, will render action and navigate to proper menu_id 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\\">
Discuss
</a>
<ul class=\\"o_menu_sections\\">
</ul>
</div>
<div class=\\"o_content\\"><div class=\\"o_discuss o_action_controller\\">
<div class=\\"o_control_panel\\">
<ol class=\\"breadcrumb\\" role=\\"navigation\\">
<li class=\\"breadcrumb-item active\\">
Discuss
</li>
</ol>
<div class=\\"o_cp_searchview\\" role=\\"search\\">
<div class=\\"o_searchview\\" role=\\"search\\" aria-autocomplete=\\"list\\">
<span class=\\"o_searchview_more fa\\" title=\\"Advanced Search...\\" role=\\"img\\" aria-label=\\"Advanced Search...\\"></span>
</div>
</div>
<div class=\\"o_cp_left\\">
<div class=\\"o_cp_buttons\\" role=\\"toolbar\\" aria-label=\\"Control panel toolbar\\"></div>
<aside class=\\"o_cp_sidebar\\"></aside>
</div>
<div class=\\"o_cp_right\\">
<div class=\\"btn-group o_search_options\\" role=\\"search\\"></div>
<nav class=\\"o_cp_pager\\" role=\\"search\\" aria-label=\\"Pager\\"></nav>
<nav class=\\"btn-group o_cp_switch_buttons\\" role=\\"toolbar\\" aria-label=\\"View switcher\\"></nav>
</div>
</div>
<div class=\\"o_content\\">
<div class=\\"o_discuss_sidebar\\">
<span>DISCUSS!!</span>
</div>
<div class=\\"o_discuss_content\\">
<button>Reset first counter</button>
<button>Reset counter 2 in 3s</button>
<button>Toggle Clock/counters</button>
<button>Toggle Color</button>
<button>Rerender this widget</button>
<input>
<div>
<button>-</button>
<span style=\\"font-weight:bold\\">Value: 4</span>
<button>+</button>
</div>
<div>
<button>-</button>
<span style=\\"font-weight:bold\\">Value: 400</span>
<button>+</button>
</div>
<div>
<span>Current Color: </span>
red
</div>
<button>Add notif</button>
<button>Add sticky notif</button>
<button>Add warning</button>
</div>
</div>
</div></div>
<div class=\\"o_notification_container\\">
</div>
<div class=\\"o_loading d-none\\">Loading</div>
</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 class=\\"o_action_controller\\"></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\\">
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<a class=\\"o_menu_brand\\" href=\\"\\" role=\\"button\\">
Discuss
</a>
<ul class=\\"o_menu_sections\\">
</ul>
</div>
<div class=\\"o_content\\"><div class=\\"o_discuss o_action_controller\\">
<div class=\\"o_control_panel\\">
<ol class=\\"breadcrumb\\" role=\\"navigation\\">
<li class=\\"breadcrumb-item active\\">
Discuss
</li>
</ol>
<div class=\\"o_cp_searchview\\" role=\\"search\\">
<div class=\\"o_searchview\\" role=\\"search\\" aria-autocomplete=\\"list\\">
<span class=\\"o_searchview_more fa\\" title=\\"Advanced Search...\\" role=\\"img\\" aria-label=\\"Advanced Search...\\"></span>
</div>
</div>
<div class=\\"o_cp_left\\">
<div class=\\"o_cp_buttons\\" role=\\"toolbar\\" aria-label=\\"Control panel toolbar\\"></div>
<aside class=\\"o_cp_sidebar\\"></aside>
</div>
<div class=\\"o_cp_right\\">
<div class=\\"btn-group o_search_options\\" role=\\"search\\"></div>
<nav class=\\"o_cp_pager\\" role=\\"search\\" aria-label=\\"Pager\\"></nav>
<nav class=\\"btn-group o_cp_switch_buttons\\" role=\\"toolbar\\" aria-label=\\"View switcher\\"></nav>
</div>
</div>
<div class=\\"o_content\\">
<div class=\\"o_discuss_sidebar\\">
<span>DISCUSS!!</span>
</div>
<div class=\\"o_discuss_content\\">
<button>Reset first counter</button>
<button>Reset counter 2 in 3s</button>
<button>Toggle Clock/counters</button>
<button>Toggle Color</button>
<button>Rerender this widget</button>
<input>
<div>
<button>-</button>
<span style=\\"font-weight:bold\\">Value: 4</span>
<button>+</button>
</div>
<div>
<button>-</button>
<span style=\\"font-weight:bold\\">Value: 400</span>
<button>+</button>
</div>
<div>
<span>Current Color: </span>
red
</div>
<button>Add notif</button>
<button>Add sticky notif</button>
<button>Add warning</button>
</div>
</div>
</div></div>
<div class=\\"o_notification_container\\">
</div>
<div class=\\"o_loading d-none\\">Loading</div>
</div>"
`;
+28
View File
@@ -0,0 +1,28 @@
import { HomeMenu } from "../../src/ts/ui/home_menu";
import { makeTestEnv, makeTestFixture } from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
beforeEach(() => {
fixture = makeTestFixture();
});
afterEach(() => {
fixture.remove();
});
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("can be rendered", async () => {
const testEnv = makeTestEnv();
const props = { menuInfo: testEnv.store.menuInfo };
const homeMenu = new HomeMenu(testEnv, props);
await homeMenu.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
+66
View File
@@ -0,0 +1,66 @@
import { MenuInfo } from "../../src/ts/store/store";
import { Navbar, Props } from "../../src/ts/ui/navbar";
import * as helpers from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
let env: helpers.TestEnv;
let props: Props;
let menuInfo: MenuInfo;
beforeEach(() => {
fixture = helpers.makeTestFixture();
env = helpers.makeTestEnv();
props = { inHome: false, app: null };
menuInfo = env.store.menuInfo;
});
afterEach(() => {
fixture.remove();
});
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("can be rendered (in home menu, no app)", async () => {
props.inHome = true;
const navbar = new Navbar(env, props);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("can be rendered (in home menu, one active app)", async () => {
props = { inHome: true, app: menuInfo.menus[96]! };
const navbar = new Navbar(env, props);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("can render one menu item", async () => {
props.app = menuInfo.menus[96]!;
const navbar = new Navbar(env, props);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("mobile mode: navbar is different", async () => {
props.app = menuInfo.menus[205]!;
env.isMobile = true;
const navbar = new Navbar(env, props);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("clicking on left icon toggle home menu ", async () => {
props.app = menuInfo.menus[96]!;
env.store.state.inHome = false;
const navbar = new Navbar(env, props);
await navbar.mount(fixture);
expect(env.store.state.inHome).toBe(false);
(<any>fixture).getElementsByClassName("o_title")[0].click();
expect(env.store.state.inHome).toBe(true);
});
+66
View File
@@ -0,0 +1,66 @@
import { Notification as INotification } from "../../src/ts/store/store";
import { Notification } from "../../src/ts/ui/notification";
import * as helpers from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
let env: helpers.TestEnv;
beforeEach(async () => {
fixture = helpers.makeTestFixture();
env = helpers.makeTestEnv();
});
afterEach(() => {
fixture.remove();
});
function makeNotification(notif: Partial<INotification> = {}): INotification {
const defaultNotif = {
id: 1,
title: "title",
message: "message",
type: "notification",
sticky: false
};
return Object.assign(defaultNotif, notif);
}
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("can be rendered", async () => {
const notif = makeNotification({ title: "title", message: "message" });
const navbar = new Notification(env, notif);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("can be rendered (type = warning)", async () => {
const notif = makeNotification({
title: "title",
message: "message",
type: "warning"
});
const navbar = new Notification(env, notif);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("can be closed by clicking on it (if sticky)", async () => {
env.addNotification({
title: "title",
message: "message",
sticky: true
});
const navbar = new Notification(env, env.store.state.notifications[0]);
await navbar.mount(fixture);
expect(env.store.state.notifications.length).toBe(1);
(<any>fixture.getElementsByClassName("o_close")[0]).click();
expect(env.store.state.notifications.length).toBe(0);
});
+85
View File
@@ -0,0 +1,85 @@
import { Registry } from "../../src/ts/core/registry";
import { Root } from "../../src/ts/ui/root";
import * as helpers from "../helpers";
import { makeTestEnv } from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
beforeEach(() => {
fixture = helpers.makeTestFixture();
});
afterEach(() => {
fixture.remove();
});
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("can be rendered (in home menu)", async () => {
const testEnv = makeTestEnv();
const root = new Root(testEnv, testEnv.store);
await root.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("if url has action_id, will render action and navigate to proper menu_id", async () => {
const router = new helpers.MockRouter({ action_id: "131" });
const testEnv = makeTestEnv({ services: <any>{ router } });
await helpers.nextTick();
const root = new Root(testEnv, testEnv.store);
await root.mount(fixture);
await helpers.nextTick();
expect(router.getQuery()).toEqual({
action_id: "131",
menu_id: "96"
});
expect(fixture.innerHTML).toMatchSnapshot();
});
test("start with no action => clicks on client action => discuss is rendered", async () => {
const testEnv = makeTestEnv();
const root = new Root(testEnv, testEnv.store);
await root.mount(fixture);
expect(testEnv.services.router.getQuery()).toEqual({ home: true });
// discuss menu item
await (<any>document.querySelector('[data-menu="96"]')).click();
await helpers.nextTick();
expect(fixture.innerHTML).toMatchSnapshot();
expect(testEnv.services.router.getQuery()).toEqual({
action_id: "131",
menu_id: "96"
});
});
test("clicks on client action with invalid key => empty widget is rendered + warning", async () => {
const testEnv = makeTestEnv({ actionRegistry: new Registry() });
const root = new Root(testEnv, testEnv.store);
await root.mount(fixture);
// discuss menu item
await (<any>document.querySelector('[data-menu="96"]')).click();
await helpers.nextTick();
expect(fixture.innerHTML).toMatchSnapshot();
});
test("open act window action with invalid viewtype => empty widget is rendered + warning", async () => {
const testEnv = makeTestEnv({ viewRegistry: new Registry() });
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();
});