mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
display notifications in a declarative way
This commit is contained in:
@@ -27,7 +27,9 @@ exports[`can be rendered (in home menu) 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div class=\\"o_content o_hidden\\"></div>
|
||||
<div class=\\"o_notification_container\\"></div>
|
||||
<div class=\\"o_notification_container\\">
|
||||
|
||||
</div>
|
||||
<div class=\\"o_loading d-none\\">Loading</div>
|
||||
</div>"
|
||||
`;
|
||||
@@ -74,7 +76,9 @@ exports[`if url has action_id, will render action and navigate to proper menu_id
|
||||
<button>Add notif</button>
|
||||
<button>Add sticky notif</button>
|
||||
</div></div>
|
||||
<div class=\\"o_notification_container\\"></div>
|
||||
<div class=\\"o_notification_container\\">
|
||||
|
||||
</div>
|
||||
<div class=\\"o_loading d-none\\">Loading</div>
|
||||
</div>"
|
||||
`;
|
||||
@@ -121,7 +125,9 @@ exports[`start with no action => clicks on client action => discuss is rendered
|
||||
<button>Add notif</button>
|
||||
<button>Add sticky notif</button>
|
||||
</div></div>
|
||||
<div class=\\"o_notification_container\\"></div>
|
||||
<div class=\\"o_notification_container\\">
|
||||
|
||||
</div>
|
||||
<div class=\\"o_loading d-none\\">Loading</div>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { INotification, Store } from "../../src/ts/store/store";
|
||||
import { Notification as INotification, Store } from "../../src/ts/store/store";
|
||||
import { Notification } from "../../src/ts/ui/notification";
|
||||
import * as helpers from "../helpers";
|
||||
|
||||
@@ -50,23 +50,15 @@ test("can be rendered", async () => {
|
||||
});
|
||||
|
||||
test("can be closed by clicking on it (if sticky)", async () => {
|
||||
let n = 0;
|
||||
let notif;
|
||||
store.on("notification_added", null, _notif => {
|
||||
n++;
|
||||
notif = _notif;
|
||||
});
|
||||
store.on("notification_closed", null, () => n--);
|
||||
|
||||
env.addNotification({
|
||||
title: "title",
|
||||
message: "message",
|
||||
sticky: true
|
||||
});
|
||||
|
||||
const navbar = new Notification(env, notif);
|
||||
const navbar = new Notification(env, store.state.notifications[0]);
|
||||
await navbar.mount(fixture);
|
||||
expect(n).toBe(1);
|
||||
expect(store.state.notifications.length).toBe(1);
|
||||
(<any>fixture.getElementsByClassName("o_close")[0]).click();
|
||||
expect(n).toBe(0);
|
||||
expect(store.state.notifications.length).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user