| 1 |
import { expect, test } from "@odoo/hoot"; |
| 2 |
import { mockPermission } from "@odoo/hoot-mock"; |
| 3 |
import { defineModels, models, mountView } from "@web/../tests/web_test_helpers"; |
| 4 |
|
| 5 |
class Partner extends models.Model { |
| 6 |
_records = [{ id: 1 }]; |
| 7 |
} |
| 8 |
|
| 9 |
defineModels([Partner]); |
| 10 |
|
| 11 |
const viewData = { |
| 12 |
type: "form", |
| 13 |
resModel: "partner", |
| 14 |
resId: 1, |
| 15 |
arch: /* xml */ `<form><widget name="notification_alert"/></form>`, |
| 16 |
}; |
| 17 |
|
| 18 |
test("notification alert should be displayed when notification denied", async () => { |
| 19 |
mockPermission("notifications", "denied"); |
| 20 |
await mountView(viewData); |
| 21 |
expect(".o_widget_notification_alert .alert").toHaveCount(1, { |
| 22 |
message: "notification alert should be displayed when notification denied", |
| 23 |
}); |
| 24 |
}); |
| 25 |
|
| 26 |
test("notification alert should not be displayed when notification granted", async () => { |
| 27 |
mockPermission("notifications", "granted"); |
| 28 |
await mountView(viewData); |
| 29 |
expect(".o_widget_notification_alert .alert").toHaveCount(0, { |
| 30 |
message: "notification alert should not be displayed when notification granted", |
| 31 |
}); |
| 32 |
}); |
| 33 |
|
| 34 |
test("notification alert should not be displayed when notification default", async () => { |
| 35 |
mockPermission("notifications", "default"); |
| 36 |
await mountView(viewData); |
| 37 |
expect(".o_widget_notification_alert .alert").toHaveCount(0, { |
| 38 |
message: "notification alert should not be displayed when notification default", |
| 39 |
}); |
| 40 |
}); |