| 1 |
import { expect, test } from "@odoo/hoot"; |
| 2 |
import { click } from "@odoo/hoot-dom"; |
| 3 |
import { animationFrame } from "@odoo/hoot-mock"; |
| 4 |
import { defineModels, fields, models, mountView } from "@web/../tests/web_test_helpers"; |
| 5 |
|
| 6 |
class Partner extends models.Model { |
| 7 |
bar = fields.Boolean({ string: "Bar field" }); |
| 8 |
foo = fields.Boolean(); |
| 9 |
|
| 10 |
_records = [{ id: 1, bar: true, foo: false }]; |
| 11 |
} |
| 12 |
|
| 13 |
defineModels([Partner]); |
| 14 |
|
| 15 |
test("BooleanIcon field in form view", async () => { |
| 16 |
await mountView({ |
| 17 |
resModel: "partner", |
| 18 |
resId: 1, |
| 19 |
type: "form", |
| 20 |
arch: ` |
| 21 |
<form> |
| 22 |
<field name="bar" widget="boolean_icon" options="{'icon': 'fa-recycle'}" /> |
| 23 |
<field name="foo" widget="boolean_icon" options="{'icon': 'fa-trash'}" /> |
| 24 |
</form>`, |
| 25 |
}); |
| 26 |
expect(".o_field_boolean_icon button").toHaveCount(2); |
| 27 |
expect("[name='bar'] button").toHaveAttribute("data-tooltip", "Bar field"); |
| 28 |
expect("[name='bar'] button").toHaveClass("btn-primary fa-recycle"); |
| 29 |
expect("[name='foo'] button").toHaveClass("btn-outline-secondary fa-trash"); |
| 30 |
|
| 31 |
await click("[name='bar'] button"); |
| 32 |
await animationFrame(); |
| 33 |
expect("[name='bar'] button").toHaveClass("btn-outline-secondary fa-recycle"); |
| 34 |
}); |