[FIX] web: notification: properly use className option

Before this commit, opening a notification with the className
option would result in a notification being displayed without the
given className. That className was overriden by the transition
className. This commit ensures we keep all classNames.

Part-of: odoo/odoo#92475
This commit is contained in:
Aaron Bohy
2022-06-30 09:29:40 +02:00
parent 35c2f217b0
commit 442d855c2e
2 changed files with 14 additions and 1 deletions
@@ -15,7 +15,7 @@ NotificationContainer.template = xml`
<div class="o_notification_manager">
<t t-foreach="notifications" t-as="notification" t-key="notification">
<Transition leaveDuration="0" name="'o_notification_fade'" t-slot-scope="transition">
<Notification t-props="notification_value.props" className="transition.className"/>
<Notification t-props="notification_value.props" className="(notification_value.props.className || '') + ' ' + transition.className"/>
</Transition>
</t>
</div>`;
@@ -38,6 +38,19 @@ QUnit.test("can display a basic notification", async (assert) => {
assert.hasClass(notif, "border-warning");
});
QUnit.test("can display a notification with a className", async (assert) => {
const env = await makeTestEnv({ serviceRegistry });
const { Component: NotificationContainer, props } = registry
.category("main_components")
.get("NotificationContainer");
const notifService = env.services.notification;
await mount(NotificationContainer, target, { env, props });
notifService.add("I'm a basic notification", { className: "abc" });
await nextTick();
assert.containsOnce(target, ".o_notification.abc");
});
QUnit.test("title and message are escaped by default", async (assert) => {
const env = await makeTestEnv({ serviceRegistry });
const { Component: NotificationContainer, props } = registry