mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
adapt tests
This commit is contained in:
@@ -100,10 +100,12 @@ exports[`if url has action_id, will render action and navigate to proper menu_id
|
||||
|
||||
</div>
|
||||
|
||||
<div class=\\"o_content\\"></div>
|
||||
<div class=\\"o_content\\"><div class=\\"o_crm\\">
|
||||
<span>CRM!!!!</span>
|
||||
</div></div>
|
||||
|
||||
<div class=\\"o_notification_container\\"></div>
|
||||
<div class=\\"o_loading\\">Loading</div>
|
||||
<div class=\\"o_loading d-none\\">Loading</div>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ActionStack } from "../../src/ts/store/action_manager";
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { ActionStack, Store } from "../../src/ts/store";
|
||||
import { ActionContainer, Props } from "../../src/ts/widgets/action_container";
|
||||
import { Widget } from "../../src/ts/widgets/widget";
|
||||
import * as helpers from "../helpers";
|
||||
@@ -8,7 +9,8 @@ import * as helpers from "../helpers";
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
let fixture: HTMLElement;
|
||||
let env: ReturnType<typeof helpers.makeTestEnv>;
|
||||
let store: Store;
|
||||
let env: Env;
|
||||
let props: Props;
|
||||
let templates: string;
|
||||
|
||||
@@ -18,8 +20,8 @@ beforeAll(async () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = helpers.makeTestFixture();
|
||||
env = helpers.makeTestEnv();
|
||||
env.qweb.loadTemplates(templates);
|
||||
store = helpers.makeTestStore();
|
||||
env = makeEnv(store, templates);
|
||||
props = { stack: [] };
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { Store } from "../../src/ts/store";
|
||||
import { HomeMenu, Props } from "../../src/ts/widgets/home_menu";
|
||||
import * as helpers from "../helpers";
|
||||
|
||||
@@ -6,7 +8,8 @@ import * as helpers from "../helpers";
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
let fixture: HTMLElement;
|
||||
let env: ReturnType<typeof helpers.makeTestEnv>;
|
||||
let store: Store;
|
||||
let env: Env;
|
||||
let props: Props;
|
||||
let templates: string;
|
||||
|
||||
@@ -16,8 +19,8 @@ beforeAll(async () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = helpers.makeTestFixture();
|
||||
env = helpers.makeTestEnv();
|
||||
env.qweb.loadTemplates(templates);
|
||||
store = helpers.makeTestStore();
|
||||
env = makeEnv(store, templates);
|
||||
props = { menuInfo: helpers.makeDemoMenuInfo() };
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { MenuInfo, Store } from "../../src/ts/store";
|
||||
import { Navbar, Props } from "../../src/ts/widgets/navbar";
|
||||
import * as helpers from "../helpers";
|
||||
import { MenuInfo } from "../../src/ts/loaders/menus";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Setup and helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
let fixture: HTMLElement;
|
||||
let env: ReturnType<typeof helpers.makeTestEnv>;
|
||||
let store: Store;
|
||||
let env: Env;
|
||||
let props: Props;
|
||||
let menuInfo: MenuInfo;
|
||||
let templates: string;
|
||||
@@ -18,8 +20,8 @@ beforeAll(async () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = helpers.makeTestFixture();
|
||||
env = helpers.makeTestEnv();
|
||||
env.qweb.loadTemplates(templates);
|
||||
store = helpers.makeTestStore();
|
||||
env = makeEnv(store, templates);
|
||||
props = { inHome: false, app: null };
|
||||
menuInfo = helpers.makeDemoMenuInfo();
|
||||
});
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import { INotification } from "../../src/ts/store/notifications";
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { INotification, Store } from "../../src/ts/store";
|
||||
import { Notification } from "../../src/ts/widgets/notification";
|
||||
import { makeTestEnv, makeTestFixture, loadTemplates } from "../helpers";
|
||||
import * as helpers from "../helpers";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Setup and helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
let fixture: HTMLElement;
|
||||
let env: ReturnType<typeof makeTestEnv>;
|
||||
let store: Store;
|
||||
let env: Env;
|
||||
let templates: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
templates = await loadTemplates();
|
||||
templates = await helpers.loadTemplates();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = makeTestFixture();
|
||||
env = makeTestEnv();
|
||||
env.qweb.loadTemplates(templates);
|
||||
fixture = helpers.makeTestFixture();
|
||||
fixture = helpers.makeTestFixture();
|
||||
store = helpers.makeTestStore();
|
||||
env = makeEnv(store, templates);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -49,13 +52,13 @@ test("can be rendered", async () => {
|
||||
test("can be closed by clicking on it (if sticky)", async () => {
|
||||
let n = 0;
|
||||
let notif;
|
||||
env.notifications.on("notification_added", null, _notif => {
|
||||
store.on("notification_added", null, _notif => {
|
||||
n++;
|
||||
notif = _notif;
|
||||
});
|
||||
env.notifications.on("notification_closed", null, () => n--);
|
||||
store.on("notification_closed", null, () => n--);
|
||||
|
||||
env.notifications.add({
|
||||
env.addNotification({
|
||||
title: "title",
|
||||
message: "message",
|
||||
sticky: true
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Root, Props } from "../../src/ts/widgets/root";
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { Store } from "../../src/ts/store";
|
||||
import { Root } from "../../src/ts/widgets/root";
|
||||
import * as helpers from "../helpers";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -6,8 +8,8 @@ import * as helpers from "../helpers";
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
let fixture: HTMLElement;
|
||||
let env: ReturnType<typeof helpers.makeTestEnv>;
|
||||
let props: Props;
|
||||
let store: Store;
|
||||
let env: Env;
|
||||
let templates: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -16,9 +18,9 @@ beforeAll(async () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = helpers.makeTestFixture();
|
||||
env = helpers.makeTestEnv();
|
||||
env.qweb.loadTemplates(templates);
|
||||
props = { menuInfo: helpers.makeDemoMenuInfo() };
|
||||
store = helpers.makeTestStore();
|
||||
env = makeEnv(store, templates);
|
||||
// props = { menuInfo: helpers.makeDemoMenuInfo() };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -30,29 +32,38 @@ afterEach(() => {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
test("can be rendered (in home menu)", async () => {
|
||||
const root = new Root(env, props);
|
||||
const root = new Root(env, 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 () => {
|
||||
env.router.setQuery({ action_id: "595" });
|
||||
const root = new Root(env, props);
|
||||
const router = new helpers.MockRouter({ action_id: "595" });
|
||||
store = helpers.makeTestStore({ router });
|
||||
env = makeEnv(store, templates);
|
||||
|
||||
const root = new Root(env, store);
|
||||
await root.mount(fixture);
|
||||
expect(env.services.router.getQuery()).toEqual({
|
||||
action_id: "595",
|
||||
menu_id: "409"
|
||||
});
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
// we check here that the url was changed to set app id as menu_id
|
||||
expect(env.router.currentQuery).toEqual({ action_id: "595", menu_id: "409" });
|
||||
});
|
||||
|
||||
test("start with no action => clicks on client action => discuss is rendered", async () => {
|
||||
const root = new Root(env, props);
|
||||
const root = new Root(env, store);
|
||||
await root.mount(fixture);
|
||||
|
||||
expect(env.router.currentQuery).toEqual({});
|
||||
expect(env.services.router.getQuery()).toEqual({});
|
||||
|
||||
// discuss menu item
|
||||
await (<any>document.querySelector('[data-menu="96"]')).click();
|
||||
await helpers.nextTick();
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
expect(env.router.currentQuery).toEqual({ action_id: "131", menu_id: "96" });
|
||||
expect(env.services.router.getQuery()).toEqual({
|
||||
action_id: "131",
|
||||
menu_id: "96"
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user