| 1 |
import { renderToMarkup } from "@web/core/utils/render"; |
| 2 |
import { useSetupAction } from "@web/search/action_hook"; |
| 3 |
import { listView } from "@web/views/list/list_view"; |
| 4 |
import { kanbanView } from "@web/views/kanban/kanban_view"; |
| 5 |
import { SelectCreateDialog } from "@web/views/view_dialogs/select_create_dialog"; |
| 6 |
import { WebClient } from "@web/webclient/webclient"; |
| 7 |
|
| 8 |
import { xml } from "@odoo/owl"; |
| 9 |
|
| 10 |
import { |
| 11 |
clickModalButton, |
| 12 |
clickSave, |
| 13 |
contains, |
| 14 |
defineModels, |
| 15 |
editFavoriteName, |
| 16 |
fields, |
| 17 |
getService, |
| 18 |
models, |
| 19 |
mockService, |
| 20 |
mountView, |
| 21 |
mountWithCleanup, |
| 22 |
onRpc, |
| 23 |
patchWithCleanup, |
| 24 |
removeFacet, |
| 25 |
saveFavorite, |
| 26 |
toggleMenuItem, |
| 27 |
toggleSaveFavorite, |
| 28 |
toggleSearchBarMenu, |
| 29 |
} from "@web/../tests/web_test_helpers"; |
| 30 |
|
| 31 |
import { beforeEach, expect, test } from "@odoo/hoot"; |
| 32 |
import { click, queryOne } from "@odoo/hoot-dom"; |
| 33 |
import { animationFrame, runAllTimers } from "@odoo/hoot-mock"; |
| 34 |
|
| 35 |
class Partner extends models.Model { |
| 36 |
name = fields.Char({ string: "Displayed name" }); |
| 37 |
foo = fields.Char({ string: "Foo" }); |
| 38 |
bar = fields.Boolean({ string: "Bar" }); |
| 39 |
instrument = fields.Many2one({ string: "Instrument", relation: "instrument" }); |
| 40 |
|
| 41 |
_records = [ |
| 42 |
{ id: 1, foo: "blip", name: "blipblip", bar: true }, |
| 43 |
{ id: 2, foo: "ta tata ta ta", name: "macgyver", bar: false }, |
| 44 |
{ id: 3, foo: "piou piou", name: "Jack O'Neill", bar: true }, |
| 45 |
]; |
| 46 |
} |
| 47 |
|
| 48 |
class Instrument extends models.Model { |
| 49 |
name = fields.Char({ string: "name" }); |
| 50 |
badassery = fields.Many2many({ |
| 51 |
string: "level", |
| 52 |
relation: "badassery", |
| 53 |
domain: [["level", "=", "Awsome"]], |
| 54 |
}); |
| 55 |
} |
| 56 |
|
| 57 |
class Badassery extends models.Model { |
| 58 |
level = fields.Char({ string: "level" }); |
| 59 |
|
| 60 |
_records = [{ id: 1, level: "Awsome" }]; |
| 61 |
} |
| 62 |
|
| 63 |
class Product extends models.Model { |
| 64 |
name = fields.Char({ string: "name" }); |
| 65 |
partner = fields.One2many({ string: "Doors", relation: "partner" }); |
| 66 |
|
| 67 |
_records = [{ id: 1, name: "The end" }]; |
| 68 |
} |
| 69 |
|
| 70 |
class SaleOrderLine extends models.Model { |
| 71 |
_name = "sale_order_line"; |
| 72 |
|
| 73 |
product_id = fields.Many2one({ string: "product_id", relation: "product" }); |
| 74 |
linked_sale_order_line = fields.Many2many({ |
| 75 |
string: "linked_sale_order_line", |
| 76 |
relation: "sale_order_line", |
| 77 |
}); |
| 78 |
} |
| 79 |
|
| 80 |
defineModels([Partner, Instrument, Badassery, Product, SaleOrderLine]); |
| 81 |
|
| 82 |
beforeEach(() => onRpc("has_group", () => true)); |
| 83 |
|
| 84 |
test.tags("desktop"); |
| 85 |
test("SelectCreateDialog use domain, group_by and search default on desktop", async () => { |
| 86 |
expect.assertions(4); |
| 87 |
Partner._views["list"] = /* xml */ ` |
| 88 |
<list string="Partner"> |
| 89 |
<field name="name"/> |
| 90 |
<field name="foo"/> |
| 91 |
</list> |
| 92 |
`; |
| 93 |
Partner._views["search"] = /* xml */ ` |
| 94 |
<search> |
| 95 |
<field name="foo" filter_domain="[('name','ilike',self), ('foo','ilike',self)]"/> |
| 96 |
<group expand="0" string="Group By"> |
| 97 |
<filter name="groupby_bar" context="{'group_by' : 'bar'}"/> |
| 98 |
</group> |
| 99 |
</search> |
| 100 |
`; |
| 101 |
let search = 0; |
| 102 |
onRpc("web_read_group", ({ kwargs }) => { |
| 103 |
expect(kwargs.domain).toEqual([ |
| 104 |
"&", |
| 105 |
["name", "like", "a"], |
| 106 |
"&", |
| 107 |
["name", "ilike", "piou"], |
| 108 |
["foo", "ilike", "piou"], |
| 109 |
]); |
| 110 |
expect(kwargs.groupby).toEqual(["bar"]); |
| 111 |
}); |
| 112 |
onRpc("web_search_read", ({ kwargs }) => { |
| 113 |
if (search === 0) { |
| 114 |
expect(kwargs).toMatchObject( |
| 115 |
{ |
| 116 |
domain: [ |
| 117 |
"&", |
| 118 |
["name", "like", "a"], |
| 119 |
"&", |
| 120 |
["name", "ilike", "piou"], |
| 121 |
["foo", "ilike", "piou"], |
| 122 |
], |
| 123 |
specification: { name: {}, foo: {} }, |
| 124 |
limit: 80, |
| 125 |
offset: 0, |
| 126 |
order: "", |
| 127 |
count_limit: 10001, |
| 128 |
}, |
| 129 |
{ |
| 130 |
message: "should search with the complete domain (domain + search)", |
| 131 |
} |
| 132 |
); |
| 133 |
} else if (search === 1) { |
| 134 |
expect(kwargs).toMatchObject( |
| 135 |
{ |
| 136 |
domain: [["name", "like", "a"]], |
| 137 |
specification: { name: {}, foo: {} }, |
| 138 |
limit: 80, |
| 139 |
offset: 0, |
| 140 |
order: "", |
| 141 |
count_limit: 10001, |
| 142 |
}, |
| 143 |
{ |
| 144 |
message: "should search with the domain", |
| 145 |
} |
| 146 |
); |
| 147 |
} |
| 148 |
search++; |
| 149 |
}); |
| 150 |
await mountWithCleanup(WebClient); |
| 151 |
getService("dialog").add(SelectCreateDialog, { |
| 152 |
noCreate: true, |
| 153 |
resModel: "partner", |
| 154 |
domain: [["name", "like", "a"]], |
| 155 |
context: { |
| 156 |
search_default_groupby_bar: true, |
| 157 |
search_default_foo: "piou", |
| 158 |
}, |
| 159 |
}); |
| 160 |
await animationFrame(); |
| 161 |
await removeFacet("Bar"); |
| 162 |
await removeFacet("Foo piou"); |
| 163 |
}); |
| 164 |
|
| 165 |
test.tags("mobile"); |
| 166 |
test("SelectCreateDialog use domain, group_by and search default on mobile", async () => { |
| 167 |
expect.assertions(4); |
| 168 |
Partner._views["search"] = /* xml */ ` |
| 169 |
<search> |
| 170 |
<field name="foo" filter_domain="[('name','ilike',self), ('foo','ilike',self)]"/> |
| 171 |
<group expand="0" string="Group By"> |
| 172 |
<filter name="groupby_bar" context="{'group_by' : 'bar'}"/> |
| 173 |
</group> |
| 174 |
</search> |
| 175 |
`; |
| 176 |
Partner._views[ |
| 177 |
"kanban" |
| 178 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="name"/><field name="foo"/></t></templates></kanban>`; |
| 179 |
let search = 0; |
| 180 |
onRpc("web_read_group", ({ kwargs }) => { |
| 181 |
expect(kwargs.domain).toEqual([ |
| 182 |
"&", |
| 183 |
["name", "like", "a"], |
| 184 |
"&", |
| 185 |
["name", "ilike", "piou"], |
| 186 |
["foo", "ilike", "piou"], |
| 187 |
]); |
| 188 |
expect(kwargs.groupby).toEqual(["bar"]); |
| 189 |
}); |
| 190 |
onRpc("web_search_read", ({ kwargs }) => { |
| 191 |
if (search === 0) { |
| 192 |
expect(kwargs).toMatchObject( |
| 193 |
{ |
| 194 |
domain: [ |
| 195 |
"&", |
| 196 |
["name", "like", "a"], |
| 197 |
"&", |
| 198 |
["name", "ilike", "piou"], |
| 199 |
["foo", "ilike", "piou"], |
| 200 |
], |
| 201 |
specification: { name: {}, foo: {} }, |
| 202 |
limit: 40, |
| 203 |
offset: 0, |
| 204 |
order: "", |
| 205 |
count_limit: 10001, |
| 206 |
}, |
| 207 |
{ message: "should search with the complete domain (domain + search)" } |
| 208 |
); |
| 209 |
} else if (search === 1) { |
| 210 |
expect(kwargs).toMatchObject( |
| 211 |
{ |
| 212 |
domain: [["name", "like", "a"]], |
| 213 |
specification: { name: {}, foo: {} }, |
| 214 |
limit: 40, |
| 215 |
offset: 0, |
| 216 |
order: "", |
| 217 |
count_limit: 10001, |
| 218 |
}, |
| 219 |
{ message: "should search with the domain" } |
| 220 |
); |
| 221 |
} |
| 222 |
search++; |
| 223 |
}); |
| 224 |
await mountWithCleanup(WebClient); |
| 225 |
getService("dialog").add(SelectCreateDialog, { |
| 226 |
noCreate: true, |
| 227 |
resModel: "partner", |
| 228 |
domain: [["name", "like", "a"]], |
| 229 |
context: { |
| 230 |
search_default_groupby_bar: true, |
| 231 |
search_default_foo: "piou", |
| 232 |
}, |
| 233 |
}); |
| 234 |
await animationFrame(); |
| 235 |
await removeFacet("Bar"); |
| 236 |
await removeFacet("Foo piou"); |
| 237 |
}); |
| 238 |
|
| 239 |
test("SelectCreateDialog correctly evaluates domains", async () => { |
| 240 |
expect.assertions(1); |
| 241 |
|
| 242 |
Partner._views["list"] = /* xml */ ` |
| 243 |
<list string="Partner"> |
| 244 |
<field name="name"/> |
| 245 |
<field name="foo"/> |
| 246 |
</list> |
| 247 |
`; |
| 248 |
Partner._views["search"] = /* xml */ `<search><field name="foo"/></search>`; |
| 249 |
Partner._views[ |
| 250 |
"kanban" |
| 251 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="name"/><field name="foo"/></t></templates></kanban>`; |
| 252 |
onRpc("web_search_read", ({ kwargs }) => { |
| 253 |
expect(kwargs.domain).toEqual([["id", "=", 2]], { |
| 254 |
message: "should have correctly evaluated the domain", |
| 255 |
}); |
| 256 |
}); |
| 257 |
await mountWithCleanup(WebClient); |
| 258 |
getService("dialog").add(SelectCreateDialog, { |
| 259 |
noCreate: true, |
| 260 |
resModel: "partner", |
| 261 |
domain: [["id", "=", 2]], |
| 262 |
}); |
| 263 |
await animationFrame(); |
| 264 |
}); |
| 265 |
|
| 266 |
test.tags("desktop"); |
| 267 |
test("SelectCreateDialog list view is readonly", async () => { |
| 268 |
Partner._fields.sequence = fields.Integer(); |
| 269 |
Partner._views["list"] = /* xml */ ` |
| 270 |
<list string="Partner" editable="bottom" multi_edit="1"> |
| 271 |
<field name="sequence" widget="handle"/> |
| 272 |
<field name="name"/> |
| 273 |
<field name="foo"/> |
| 274 |
</list> |
| 275 |
`; |
| 276 |
|
| 277 |
await mountWithCleanup(WebClient); |
| 278 |
|
| 279 |
getService("dialog").add(SelectCreateDialog, { |
| 280 |
resModel: "partner", |
| 281 |
}); |
| 282 |
await animationFrame(); |
| 283 |
// select first row |
| 284 |
await contains(".o_list_view tbody tr td:first").click(); |
| 285 |
expect(".o_data_row_selected").toHaveCount(1); |
| 286 |
// click on it to see if the list is editable |
| 287 |
await contains(".o_list_view tbody tr:first .o_list_char").click(); |
| 288 |
expect(".o_data_row_selected").toHaveCount(0); |
| 289 |
expect(".o_selected_row").toHaveCount(0); |
| 290 |
|
| 291 |
expect(".o_list_view tbody tr td .o_field_char input").toHaveCount(0, { |
| 292 |
message: "list view should not be editable in a SelectCreateDialog", |
| 293 |
}); |
| 294 |
expect(".o_handle_cell").toHaveCount(4); |
| 295 |
expect(".o_row_handle.o_disabled").toHaveCount(3, { |
| 296 |
message: "handles should be disabled in readonly", |
| 297 |
}); |
| 298 |
}); |
| 299 |
|
| 300 |
test.tags("desktop"); |
| 301 |
test("SelectCreateDialog list view is readonly (grouped by m2o)", async () => { |
| 302 |
Partner._views.search = /* xml */ ` |
| 303 |
<search> |
| 304 |
<group expand="0" string="Group By"> |
| 305 |
<filter name="groupby_instrument" context="{'group_by' : 'instrument'}"/> |
| 306 |
</group> |
| 307 |
</search> |
| 308 |
`; |
| 309 |
Partner._views.list = /* xml */ ` |
| 310 |
<list string="Partner"> |
| 311 |
<field name="name"/> |
| 312 |
<field name="foo"/> |
| 313 |
</list> |
| 314 |
`; |
| 315 |
|
| 316 |
await mountWithCleanup(WebClient); |
| 317 |
|
| 318 |
getService("dialog").add(SelectCreateDialog, { |
| 319 |
resModel: "partner", |
| 320 |
context: { |
| 321 |
search_default_groupby_instrument: true, |
| 322 |
}, |
| 323 |
}); |
| 324 |
await animationFrame(); |
| 325 |
expect(".o_group_header").toHaveCount(1); |
| 326 |
expect(".o_list_footer .o_list_group_add").toHaveCount(0); |
| 327 |
}); |
| 328 |
|
| 329 |
test.tags("desktop"); |
| 330 |
test("SelectCreateDialog cascade x2many in create mode on desktop", async () => { |
| 331 |
expect.assertions(5); |
| 332 |
|
| 333 |
Partner._views["form"] = /* xml */ ` |
| 334 |
<form> |
| 335 |
<field name="name"/> |
| 336 |
<field name="instrument" widget="one2many" mode="list"/> |
| 337 |
</form> |
| 338 |
`; |
| 339 |
Instrument._views["form"] = /* xml */ ` |
| 340 |
<form> |
| 341 |
<field name="name"/> |
| 342 |
<field name="badassery"> |
| 343 |
<list> |
| 344 |
<field name="level"/> |
| 345 |
</list> |
| 346 |
</field> |
| 347 |
</form> |
| 348 |
`; |
| 349 |
Badassery._views["list"] = /* xml */ `<list><field name="level"/></list>`; |
| 350 |
Badassery._views["search"] = /* xml */ `<search><field name="level"/></search>`; |
| 351 |
|
| 352 |
onRpc(["partner", "instrument"], "get_formview_id", () => false); |
| 353 |
onRpc("instrument", "web_save", ({ args }) => { |
| 354 |
expect(args[1]).toEqual( |
| 355 |
{ badassery: [[4, 1]], name: "ABC" }, |
| 356 |
{ |
| 357 |
message: "The method create should have been called with the right arguments", |
| 358 |
} |
| 359 |
); |
| 360 |
return [{ id: 90 }]; |
| 361 |
}); |
| 362 |
|
| 363 |
await mountView({ |
| 364 |
type: "form", |
| 365 |
resModel: "product", |
| 366 |
resId: 1, |
| 367 |
arch: /* xml */ ` |
| 368 |
<form> |
| 369 |
<field name="name"/> |
| 370 |
<field name="partner" widget="one2many" > |
| 371 |
<list editable="top"> |
| 372 |
<field name="name"/> |
| 373 |
<field name="instrument"/> |
| 374 |
</list> |
| 375 |
</field> |
| 376 |
</form> |
| 377 |
`, |
| 378 |
}); |
| 379 |
|
| 380 |
await contains(".o_field_x2many_list_row_add a").click(); |
| 381 |
await contains(".o_field_widget[name=instrument] input").edit("ABC", { confirm: false }); |
| 382 |
await runAllTimers(); |
| 383 |
await contains( |
| 384 |
`[name="instrument"] .dropdown .dropdown-menu li:contains("Create and edit...")` |
| 385 |
).click(); |
| 386 |
|
| 387 |
expect(".modal .modal-lg").toHaveCount(1); |
| 388 |
|
| 389 |
await contains(".modal .o_field_x2many_list_row_add a").click(); |
| 390 |
|
| 391 |
expect(".modal .modal-lg").toHaveCount(2); |
| 392 |
|
| 393 |
await contains(".modal .o_data_row input[type=checkbox]").check(); |
| 394 |
await clickModalButton({ text: "Select" }); |
| 395 |
|
| 396 |
expect(".modal .modal-lg").toHaveCount(1); |
| 397 |
expect(".modal .o_data_cell").toHaveText("Awsome"); |
| 398 |
|
| 399 |
// click on modal save button |
| 400 |
await clickSave({ index: 1 }); |
| 401 |
}); |
| 402 |
|
| 403 |
test.tags("mobile"); |
| 404 |
test("SelectCreateDialog cascade x2many in create mode on mobile", async () => { |
| 405 |
expect.assertions(5); |
| 406 |
|
| 407 |
Partner._views["form"] = /* xml */ ` |
| 408 |
<form> |
| 409 |
<field name="name"/> |
| 410 |
<field name="instrument" widget="one2many" mode="list"/> |
| 411 |
</form> |
| 412 |
`; |
| 413 |
Instrument._views["form"] = /* xml */ ` |
| 414 |
<form> |
| 415 |
<field name="name"/> |
| 416 |
<field name="badassery"> |
| 417 |
<list> |
| 418 |
<field name="level"/> |
| 419 |
</list> |
| 420 |
</field> |
| 421 |
</form> |
| 422 |
`; |
| 423 |
Instrument._views["search"] = /* xml */ `<search/>`; |
| 424 |
Instrument._views[ |
| 425 |
"kanban" |
| 426 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="name"/></t></templates></kanban>`; |
| 427 |
Badassery._views["search"] = /* xml */ `<search/>`; |
| 428 |
Badassery._views[ |
| 429 |
"kanban" |
| 430 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="level"/></t></templates></kanban>`; |
| 431 |
|
| 432 |
onRpc(["partner", "instrument"], "get_formview_id", () => false); |
| 433 |
onRpc("instrument", "web_save", ({ args }) => { |
| 434 |
expect(args[1]).toEqual( |
| 435 |
{ badassery: [[4, 1]], name: "ABC" }, |
| 436 |
{ message: "The method create should have been called with the right arguments" } |
| 437 |
); |
| 438 |
return [{ id: 90 }]; |
| 439 |
}); |
| 440 |
await mountView({ |
| 441 |
type: "form", |
| 442 |
resModel: "product", |
| 443 |
resId: 1, |
| 444 |
arch: /* xml */ ` |
| 445 |
<form> |
| 446 |
<field name="name"/> |
| 447 |
<field name="partner" widget="one2many" > |
| 448 |
<list editable="top"> |
| 449 |
<field name="name"/> |
| 450 |
<field name="instrument"/> |
| 451 |
</list> |
| 452 |
</field> |
| 453 |
</form> |
| 454 |
`, |
| 455 |
}); |
| 456 |
|
| 457 |
await contains(".o_field_x2many_list_row_add a").click(); |
| 458 |
|
| 459 |
click(".o_field_widget[name=instrument] input"); |
| 460 |
await animationFrame(); |
| 461 |
|
| 462 |
await contains(`.modal .o_create_button`).click(); |
| 463 |
|
| 464 |
expect(".modal .modal-lg").toHaveCount(2); |
| 465 |
|
| 466 |
await contains(".modal .o_field_char[name=name] input").edit("ABC"); |
| 467 |
await contains(".modal .o_field_x2many_list_row_add a").click(); |
| 468 |
|
| 469 |
expect(".modal .modal-lg").toHaveCount(3); |
| 470 |
await contains( |
| 471 |
".modal .o_data_row input[type=checkbox], .o_kanban_record:contains(Awsome)" |
| 472 |
).click(); |
| 473 |
|
| 474 |
expect(".modal .modal-lg").toHaveCount(2); |
| 475 |
expect(".modal .o_data_cell").toHaveText("Awsome"); |
| 476 |
|
| 477 |
// click on modal save button |
| 478 |
await clickSave({ index: 1 }); |
| 479 |
}); |
| 480 |
|
| 481 |
test.tags("desktop"); |
| 482 |
test("SelectCreateDialog: save current search on desktop", async () => { |
| 483 |
expect.assertions(5); |
| 484 |
Partner._views["list"] = /* xml */ `<list><field name="name"/> </list>`; |
| 485 |
Partner._views[ |
| 486 |
"search" |
| 487 |
] = /* xml */ `<search><filter name="bar" help="Bar" domain="[('bar', '=', True)]"/></search>`; |
| 488 |
|
| 489 |
patchWithCleanup(listView.Controller.prototype, { |
| 490 |
setup() { |
| 491 |
super.setup(...arguments); |
| 492 |
useSetupAction({ |
| 493 |
getContext: () => ({ shouldBeInFilterContext: true }), |
| 494 |
}); |
| 495 |
}, |
| 496 |
}); |
| 497 |
|
| 498 |
onRpc("get_views", ({ kwargs }) => { |
| 499 |
expect(kwargs.options.load_filters).toBe(true, { message: "Missing load_filters option" }); |
| 500 |
}); |
| 501 |
onRpc("create_filter", ({ model, args }) => { |
| 502 |
if (model === "ir.filters") { |
| 503 |
const irFilter = args[0]; |
| 504 |
expect(irFilter.domain).toBe(`[("bar", "=", True)]`, { |
| 505 |
message: "should save the correct domain", |
| 506 |
}); |
| 507 |
const expectedContext = { |
| 508 |
group_by: [], // default groupby is an empty list |
| 509 |
shouldBeInFilterContext: true, |
| 510 |
}; |
| 511 |
expect(irFilter.context).toEqual(expectedContext, { |
| 512 |
message: "should save the correct context", |
| 513 |
}); |
| 514 |
return [7]; // fake serverSideId |
| 515 |
} |
| 516 |
}); |
| 517 |
|
| 518 |
await mountWithCleanup(WebClient); |
| 519 |
|
| 520 |
getService("dialog").add(SelectCreateDialog, { |
| 521 |
context: { shouldNotBeInFilterContext: false }, |
| 522 |
resModel: "partner", |
| 523 |
}); |
| 524 |
await animationFrame(); |
| 525 |
|
| 526 |
expect(".o_data_row").toHaveCount(3, { message: "should contain 3 records" }); |
| 527 |
|
| 528 |
// filter on bar |
| 529 |
await toggleSearchBarMenu(); |
| 530 |
await toggleMenuItem("Bar"); |
| 531 |
|
| 532 |
expect(".o_data_row").toHaveCount(2, { message: "should contain 2 records" }); |
| 533 |
|
| 534 |
// save filter |
| 535 |
await toggleSaveFavorite(); |
| 536 |
await editFavoriteName("some name"); |
| 537 |
await saveFavorite(); |
| 538 |
}); |
| 539 |
|
| 540 |
test.tags("mobile"); |
| 541 |
test("SelectCreateDialog: save current search on mobile", async () => { |
| 542 |
expect.assertions(5); |
| 543 |
Partner._views[ |
| 544 |
"kanban" |
| 545 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="name"/></t></templates></kanban>`; |
| 546 |
Partner._views[ |
| 547 |
"search" |
| 548 |
] = /* xml */ `<search><filter name="bar" help="Bar" domain="[('bar', '=', True)]"/></search>`; |
| 549 |
|
| 550 |
patchWithCleanup(kanbanView.Controller.prototype, { |
| 551 |
setup() { |
| 552 |
super.setup(...arguments); |
| 553 |
useSetupAction({ |
| 554 |
getContext: () => ({ shouldBeInFilterContext: true }), |
| 555 |
}); |
| 556 |
}, |
| 557 |
}); |
| 558 |
|
| 559 |
onRpc("get_views", ({ kwargs }) => { |
| 560 |
expect(kwargs.options.load_filters).toBe(true, { message: "Missing load_filters option" }); |
| 561 |
}); |
| 562 |
onRpc("create_filter", ({ model, args }) => { |
| 563 |
if (model === "ir.filters") { |
| 564 |
const irFilter = args[0]; |
| 565 |
expect(irFilter.domain).toBe(`[("bar", "=", True)]`, { |
| 566 |
message: "should save the correct domain", |
| 567 |
}); |
| 568 |
const expectedContext = { |
| 569 |
group_by: [], // default groupby is an empty list |
| 570 |
shouldBeInFilterContext: true, |
| 571 |
}; |
| 572 |
expect(irFilter.context).toEqual(expectedContext, { |
| 573 |
message: "should save the correct context", |
| 574 |
}); |
| 575 |
return 7; // fake serverSideId |
| 576 |
} |
| 577 |
}); |
| 578 |
|
| 579 |
await mountWithCleanup(WebClient); |
| 580 |
|
| 581 |
getService("dialog").add(SelectCreateDialog, { |
| 582 |
context: { shouldNotBeInFilterContext: false }, |
| 583 |
resModel: "partner", |
| 584 |
}); |
| 585 |
await animationFrame(); |
| 586 |
|
| 587 |
expect(".o_kanban_record[data-id]").toHaveCount(3, { message: "should contain 3 records" }); |
| 588 |
|
| 589 |
// filter on bar |
| 590 |
await toggleSearchBarMenu(); |
| 591 |
await toggleMenuItem("Bar"); |
| 592 |
|
| 593 |
expect(".o_kanban_record[data-id]").toHaveCount(2, { message: "should contain 2 records" }); |
| 594 |
|
| 595 |
// save filter |
| 596 |
await toggleSaveFavorite(); |
| 597 |
await editFavoriteName("some name"); |
| 598 |
await saveFavorite(); |
| 599 |
}); |
| 600 |
|
| 601 |
test.tags("desktop"); |
| 602 |
test("SelectCreateDialog calls on_selected with every record matching the domain", async () => { |
| 603 |
expect.assertions(1); |
| 604 |
|
| 605 |
Partner._views["list"] = /* xml */ ` |
| 606 |
<list limit="2" string="Partner"> |
| 607 |
<field name="name"/> |
| 608 |
<field name="foo"/> |
| 609 |
</list> |
| 610 |
`; |
| 611 |
Partner._views["search"] = /* xml */ `<search><field name="foo"/></search>`; |
| 612 |
|
| 613 |
await mountWithCleanup(WebClient); |
| 614 |
getService("dialog").add(SelectCreateDialog, { |
| 615 |
resModel: "partner", |
| 616 |
onSelected: (records) => expect(records.join(",")).toBe("1,2,3"), |
| 617 |
}); |
| 618 |
await animationFrame(); |
| 619 |
|
| 620 |
await contains("thead .o_list_record_selector input").click(); |
| 621 |
await contains(".o_selection_box .o_select_domain").click(); |
| 622 |
await clickModalButton({ text: "Select" }); |
| 623 |
}); |
| 624 |
|
| 625 |
test.tags("desktop"); |
| 626 |
test("SelectCreateDialog calls on_selected with every record matching without selecting a domain", async () => { |
| 627 |
expect.assertions(1); |
| 628 |
Partner._views["list"] = /* xml */ ` |
| 629 |
<list limit="2" string="Partner"> |
| 630 |
<field name="name"/> |
| 631 |
<field name="foo"/> |
| 632 |
</list> |
| 633 |
`; |
| 634 |
Partner._views["search"] = /* xml */ `<search><field name="foo"/></search>`; |
| 635 |
|
| 636 |
await mountWithCleanup(WebClient); |
| 637 |
|
| 638 |
getService("dialog").add(SelectCreateDialog, { |
| 639 |
resModel: "partner", |
| 640 |
onSelected: (records) => expect(records.join(",")).toBe("1,2"), |
| 641 |
}); |
| 642 |
await animationFrame(); |
| 643 |
|
| 644 |
await contains("thead .o_list_record_selector input").click(); |
| 645 |
await contains(".o_selection_box").click(); |
| 646 |
await clickModalButton({ text: "Select", index: 1 }); |
| 647 |
}); |
| 648 |
|
| 649 |
test.tags("desktop"); |
| 650 |
test("SelectCreateDialog: multiple clicks on record", async () => { |
| 651 |
Partner._views["list"] = /* xml */ `<list><field name="name"/></list>`; |
| 652 |
Partner._views["search"] = /* xml */ `<search><field name="foo"/></search>`; |
| 653 |
|
| 654 |
await mountWithCleanup(WebClient); |
| 655 |
getService("dialog").add(SelectCreateDialog, { |
| 656 |
resModel: "partner", |
| 657 |
onSelected: async function (records) { |
| 658 |
expect.step(`select record ${records[0]}`); |
| 659 |
}, |
| 660 |
}); |
| 661 |
await animationFrame(); |
| 662 |
await click(".modal .o_data_row .o_data_cell"); |
| 663 |
await click(".modal .o_data_row .o_data_cell"); |
| 664 |
await click(".modal .o_data_row .o_data_cell"); |
| 665 |
await animationFrame(); |
| 666 |
// should have called onSelected only once |
| 667 |
expect.verifySteps(["select record 1"]); |
| 668 |
}); |
| 669 |
|
| 670 |
test.tags("desktop"); |
| 671 |
test("SelectCreateDialog: default props, create a record on desktop", async () => { |
| 672 |
Partner._views["list"] = /* xml */ `<list><field name="name"/></list>`; |
| 673 |
Partner._views["search"] = /* xml */ ` |
| 674 |
<search> |
| 675 |
<filter name="bar" help="Bar" domain="[('bar', '=', True)]"/> |
| 676 |
</search> |
| 677 |
`; |
| 678 |
Partner._views["form"] = /* xml */ `<form><field name="name"/></form>`; |
| 679 |
await mountWithCleanup(WebClient); |
| 680 |
|
| 681 |
getService("dialog").add(SelectCreateDialog, { |
| 682 |
onSelected: (resIds) => expect.step(`onSelected ${resIds}`), |
| 683 |
resModel: "partner", |
| 684 |
}); |
| 685 |
await animationFrame(); |
| 686 |
|
| 687 |
expect(".o_dialog").toHaveCount(1); |
| 688 |
expect(".o_dialog .o_list_view .o_data_row").toHaveCount(3); |
| 689 |
expect(".o_dialog footer button").toHaveCount(3); |
| 690 |
expect(".o_dialog footer button.o_select_button").toHaveCount(1); |
| 691 |
expect(".o_dialog footer button.o_create_button").toHaveCount(1); |
| 692 |
expect(".o_dialog footer button.o_form_button_cancel").toHaveCount(1); |
| 693 |
expect(".o_dialog .o_control_panel_main_buttons .o_list_button_add").toHaveCount(0); |
| 694 |
|
| 695 |
await contains(".o_dialog footer button.o_create_button").click(); |
| 696 |
|
| 697 |
expect(".o_dialog").toHaveCount(2); |
| 698 |
expect(".o_dialog .o_form_view").toHaveCount(1); |
| 699 |
|
| 700 |
await contains(".o_dialog .o_form_view .o_field_widget input").edit("hello"); |
| 701 |
await clickSave(); |
| 702 |
|
| 703 |
expect(".o_dialog").toHaveCount(0); |
| 704 |
expect.verifySteps(["onSelected 4"]); |
| 705 |
}); |
| 706 |
|
| 707 |
test.tags("desktop"); |
| 708 |
test("SelectCreateDialog: click on row once in selection", async () => { |
| 709 |
Partner._views["list"] = `<list multi_edit="1"><field name="name"/></list>`; |
| 710 |
Partner._views["search"] = ` |
| 711 |
<search> |
| 712 |
<filter name="bar" help="Bar" domain="[('bar', '=', True)]"/> |
| 713 |
</search>`; |
| 714 |
await mountWithCleanup(WebClient); |
| 715 |
|
| 716 |
getService("dialog").add(SelectCreateDialog, { |
| 717 |
onSelected: (resIds) => expect.step(`onSelected ${resIds}`), |
| 718 |
resModel: "partner", |
| 719 |
}); |
| 720 |
await animationFrame(); |
| 721 |
|
| 722 |
expect(".o_dialog").toHaveCount(1); |
| 723 |
expect(".o_dialog .o_list_view .o_data_row").toHaveCount(3); |
| 724 |
expect(".o_dialog .o_selection_box").toHaveCount(0); |
| 725 |
|
| 726 |
await contains(".o_data_row .o_list_record_selector").click(); |
| 727 |
expect(".o_dialog .o_data_row_selected").toHaveCount(1); |
| 728 |
|
| 729 |
await contains(".o_data_row:eq(1) .o_data_cell").click(); |
| 730 |
expect(".o_dialog .o_data_row_selected").toHaveCount(2); |
| 731 |
await contains(".o_data_row:eq(1) .o_data_cell").click(); |
| 732 |
expect(".o_dialog .o_data_row_selected").toHaveCount(1); |
| 733 |
await contains(".o_data_row:eq(1) .o_data_cell").click(); |
| 734 |
expect(".o_dialog .o_data_row_selected").toHaveCount(2); |
| 735 |
|
| 736 |
await contains(".o_dialog footer .btn-primary").click(); |
| 737 |
expect(".o_dialog").toHaveCount(0); |
| 738 |
expect.verifySteps(["onSelected 1,2"]); |
| 739 |
}); |
| 740 |
|
| 741 |
test.tags("mobile"); |
| 742 |
test("SelectCreateDialog: default props, create a record on mobile", async () => { |
| 743 |
Partner._views["search"] = /* xml */ ` |
| 744 |
<search> |
| 745 |
<filter name="bar" help="Bar" domain="[('bar', '=', True)]"/> |
| 746 |
</search> |
| 747 |
`; |
| 748 |
Partner._views["kanban"] = /* xml */ ` |
| 749 |
<kanban><templates><t t-name="card"><field name="name"/></t></templates></kanban>`; |
| 750 |
Partner._views["form"] = /* xml */ `<form><field name="name"/></form>`; |
| 751 |
await mountWithCleanup(WebClient); |
| 752 |
|
| 753 |
getService("dialog").add(SelectCreateDialog, { |
| 754 |
onSelected: (resIds) => expect.step(`onSelected ${resIds}`), |
| 755 |
resModel: "partner", |
| 756 |
}); |
| 757 |
await animationFrame(); |
| 758 |
|
| 759 |
expect(".o_dialog").toHaveCount(1); |
| 760 |
expect(".o_dialog .o_kanban_record[data-id]").toHaveCount(3); |
| 761 |
expect(".o_dialog footer button").toHaveCount(3); |
| 762 |
expect(".o_dialog footer button.o_select_button").toHaveCount(1); |
| 763 |
expect(".o_dialog footer button.o_create_button").toHaveCount(1); |
| 764 |
expect(".o_dialog footer button.o_form_button_cancel").toHaveCount(1); |
| 765 |
expect(".o_dialog .o_control_panel_main_buttons .o_list_button_add").toHaveCount(0); |
| 766 |
|
| 767 |
await contains(".o_dialog footer button.o_create_button").click(); |
| 768 |
|
| 769 |
expect(".o_dialog").toHaveCount(2); |
| 770 |
expect(".o_dialog .o_form_view").toHaveCount(1); |
| 771 |
|
| 772 |
await contains(".o_dialog .o_form_view .o_field_widget input").edit("hello"); |
| 773 |
await clickSave(); |
| 774 |
|
| 775 |
expect(".o_dialog").toHaveCount(0); |
| 776 |
expect.verifySteps(["onSelected 4"]); |
| 777 |
}); |
| 778 |
|
| 779 |
test.tags("desktop"); |
| 780 |
test("SelectCreateDialog empty list, default no content helper", async () => { |
| 781 |
Partner._records = []; |
| 782 |
Partner._views["list"] = /* xml */ ` |
| 783 |
<list> |
| 784 |
<field name="name"/> |
| 785 |
<field name="foo"/> |
| 786 |
</list> |
| 787 |
`; |
| 788 |
await mountWithCleanup(WebClient); |
| 789 |
getService("dialog").add(SelectCreateDialog, { resModel: "partner" }); |
| 790 |
await animationFrame(); |
| 791 |
expect(".o_dialog .o_list_view").toHaveCount(1); |
| 792 |
expect(".o_dialog .o_list_view .o_data_row").toHaveCount(0); |
| 793 |
expect(".o_dialog .o_list_view .o_view_nocontent").toHaveCount(1); |
| 794 |
expect(queryOne(".o_dialog .o_list_view .o_view_nocontent")).toHaveInnerHTML( |
| 795 |
`<div class="o_nocontent_help"> |
| 796 |
<p>No record found</p> |
| 797 |
<p>Adjust your filters or create a new record.</p> |
| 798 |
</div>` |
| 799 |
); |
| 800 |
}); |
| 801 |
test.tags("mobile"); |
| 802 |
test("SelectCreateDialog empty kanban, default no content helper", async () => { |
| 803 |
Partner._records = []; |
| 804 |
Partner._views[ |
| 805 |
"kanban" |
| 806 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="name"/></t></templates></kanban>`; |
| 807 |
Partner._views["search"] = /* xml */ `<search/>`; |
| 808 |
await mountWithCleanup(WebClient); |
| 809 |
getService("dialog").add(SelectCreateDialog, { resModel: "partner" }); |
| 810 |
await animationFrame(); |
| 811 |
expect(".o_dialog .o_kanban_view").toHaveCount(1); |
| 812 |
expect(".o_dialog .o_kanban_view .o_kanban_record[data-id]").toHaveCount(0); |
| 813 |
expect(".o_dialog .o_kanban_view .o_view_nocontent").toHaveCount(1); |
| 814 |
expect(queryOne(".o_dialog .o_kanban_view .o_view_nocontent")).toHaveInnerHTML( |
| 815 |
`<div class="o_nocontent_help"> |
| 816 |
<p>No record found</p> |
| 817 |
<p>Adjust your filters or create a new record.</p> |
| 818 |
</div>` |
| 819 |
); |
| 820 |
}); |
| 821 |
|
| 822 |
test.tags("desktop"); |
| 823 |
test("SelectCreateDialog empty list, noContentHelp props", async () => { |
| 824 |
Partner._records = []; |
| 825 |
Partner._views["list"] = /* xml */ ` |
| 826 |
<list> |
| 827 |
<field name="name"/> |
| 828 |
<field name="foo"/> |
| 829 |
</list> |
| 830 |
`; |
| 831 |
|
| 832 |
await mountWithCleanup(WebClient); |
| 833 |
const template = xml` |
| 834 |
<p class="custom_classname">Hello</p> |
| 835 |
<p>I'm an helper</p> |
| 836 |
`; |
| 837 |
getService("dialog").add(SelectCreateDialog, { |
| 838 |
resModel: "partner", |
| 839 |
noContentHelp: renderToMarkup(template), |
| 840 |
}); |
| 841 |
await animationFrame(); |
| 842 |
|
| 843 |
expect(".o_dialog .o_list_view").toHaveCount(1); |
| 844 |
expect(".o_dialog .o_list_view .o_data_row").toHaveCount(0); |
| 845 |
expect(".o_dialog .o_list_view .o_view_nocontent").toHaveCount(1); |
| 846 |
expect(queryOne(".o_dialog .o_list_view .o_view_nocontent")).toHaveInnerHTML( |
| 847 |
`<div class="o_nocontent_help"> |
| 848 |
<p class="custom_classname">Hello</p> |
| 849 |
<p>I'm an helper</p> |
| 850 |
</div>` |
| 851 |
); |
| 852 |
}); |
| 853 |
|
| 854 |
test.tags("desktop"); |
| 855 |
test("SelectCreateDialog with open action", async () => { |
| 856 |
Instrument._records = []; |
| 857 |
for (let i = 0; i < 25; i++) { |
| 858 |
Instrument._records.push({ |
| 859 |
id: i + 1, |
| 860 |
name: "Instrument " + i, |
| 861 |
}); |
| 862 |
} |
| 863 |
mockService("action", { |
| 864 |
doActionButton(params) { |
| 865 |
const { name } = params; |
| 866 |
expect.step(`execute_action: ${name}`, params); |
| 867 |
}, |
| 868 |
}); |
| 869 |
Instrument._views["list"] = /* xml */ ` |
| 870 |
<list action="test_action" type="object"> |
| 871 |
<field name="name"/> |
| 872 |
</list> |
| 873 |
`; |
| 874 |
await mountView({ |
| 875 |
type: "form", |
| 876 |
resModel: "partner", |
| 877 |
resId: 1, |
| 878 |
arch: /* xml */ ` |
| 879 |
<form> |
| 880 |
<field name="instrument"/> |
| 881 |
</form> |
| 882 |
`, |
| 883 |
}); |
| 884 |
await contains(`.o_field_widget[name="instrument"] .dropdown input`).click(); |
| 885 |
await contains(`.o_field_widget[name="instrument"] .o_m2o_dropdown_option_search_more`).click(); |
| 886 |
await contains( |
| 887 |
`.o_list_renderer .o_data_row .o_field_cell.o_list_char[data-tooltip="Instrument 10"]` |
| 888 |
).click(); |
| 889 |
expect("input").toHaveValue("Instrument 10"); |
| 890 |
expect.verifySteps([]); |
| 891 |
}); |
| 892 |
|
| 893 |
test.tags("mobile"); |
| 894 |
test("SelectCreateDialog empty kanban, noContentHelp props", async () => { |
| 895 |
Partner._records = []; |
| 896 |
Partner._views[ |
| 897 |
"kanban" |
| 898 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="name"/></t></templates></kanban>`; |
| 899 |
Partner._views["search"] = /* xml */ `<search/>`; |
| 900 |
|
| 901 |
await mountWithCleanup(WebClient); |
| 902 |
const template = xml` |
| 903 |
<p class="custom_classname">Hello</p> |
| 904 |
<p>I'm an helper</p> |
| 905 |
`; |
| 906 |
getService("dialog").add(SelectCreateDialog, { |
| 907 |
resModel: "partner", |
| 908 |
noContentHelp: renderToMarkup(template), |
| 909 |
}); |
| 910 |
await animationFrame(); |
| 911 |
|
| 912 |
expect(".o_dialog .o_kanban_view").toHaveCount(1); |
| 913 |
expect(".o_dialog .o_kanban_view .o_kanban_record[data-id]").toHaveCount(0); |
| 914 |
expect(".o_dialog .o_kanban_view .o_view_nocontent").toHaveCount(1); |
| 915 |
expect(queryOne(".o_dialog .o_kanban_view .o_view_nocontent")).toHaveInnerHTML( |
| 916 |
`<div class="o_nocontent_help"><p class="custom_classname">Hello</p><p>I'm an helper</p></div>` |
| 917 |
); |
| 918 |
}); |
| 919 |
|
| 920 |
test.tags("mobile"); |
| 921 |
test("SelectCreateDialog: clear selection on mobile", async () => { |
| 922 |
expect.assertions(3); |
| 923 |
SaleOrderLine._views[ |
| 924 |
"kanban" |
| 925 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="id"/></t></templates></kanban>`; |
| 926 |
Product._views[ |
| 927 |
"kanban" |
| 928 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="id"/><field name="name"/></t></templates></kanban>`; |
| 929 |
Product._views["search"] = /* xml */ `<search/>`; |
| 930 |
|
| 931 |
onRpc("web_save", ({ model, args }) => { |
| 932 |
if (model === "sale_order_line") { |
| 933 |
expect(args[1].product_id).toBe(false, { |
| 934 |
message: `there should be no product selected`, |
| 935 |
}); |
| 936 |
} |
| 937 |
}); |
| 938 |
|
| 939 |
await mountView({ |
| 940 |
type: "form", |
| 941 |
resModel: "sale_order_line", |
| 942 |
arch: ` |
| 943 |
<form> |
| 944 |
<field name="product_id"/> |
| 945 |
<field name="linked_sale_order_line" widget="many2many_tags"/> |
| 946 |
</form>`, |
| 947 |
}); |
| 948 |
|
| 949 |
await contains('.o_field_widget[name="linked_sale_order_line"] input').click(); |
| 950 |
expect(".modal-dialog.modal-lg:eq(0) .btn.o_clear_button").toHaveCount(0, { |
| 951 |
message: "there shouldn't be a Clear button", |
| 952 |
}); |
| 953 |
await contains(".modal-dialog.modal-lg:eq(0) .o_form_button_cancel").click(); |
| 954 |
|
| 955 |
// Select a product |
| 956 |
await contains('.o_field_widget[name="product_id"] input').click(); |
| 957 |
await contains(".modal-dialog.modal-lg:eq(0) .o_kanban_record:nth-child(1)").click(); |
| 958 |
|
| 959 |
// Remove the product |
| 960 |
await contains('.o_field_widget[name="product_id"] input').click(); |
| 961 |
expect(".modal-dialog.modal-lg:eq(0) .btn.o_clear_button").toHaveCount(1, { |
| 962 |
message: "there should be a Clear button", |
| 963 |
}); |
| 964 |
await contains(".btn.o_clear_button").click(); |
| 965 |
|
| 966 |
await clickSave(); |
| 967 |
}); |
| 968 |
|
| 969 |
test.tags("mobile"); |
| 970 |
test("SelectCreateDialog: selection_mode should be true", async () => { |
| 971 |
expect.assertions(3); |
| 972 |
Product._views["kanban"] = /* xml */ ` |
| 973 |
<kanban> |
| 974 |
<templates> |
| 975 |
<t t-name="card"> |
| 976 |
<div class="o_primary" t-if="!selection_mode"> |
| 977 |
<a type="object" name="some_action"> |
| 978 |
<field name="name"/> |
| 979 |
</a> |
| 980 |
</div> |
| 981 |
<div class="o_primary" t-if="selection_mode"> |
| 982 |
<field name="name"/> |
| 983 |
</div> |
| 984 |
</t> |
| 985 |
</templates> |
| 986 |
</kanban>`; |
| 987 |
Product._views["search"] = /* xml */ `<search/>`; |
| 988 |
|
| 989 |
onRpc("web_save", ({ model, args }) => { |
| 990 |
if (model === "sale_order_line") { |
| 991 |
expect(args[1].product_id).toBe(1, { |
| 992 |
message: `the product should be selected`, |
| 993 |
}); |
| 994 |
} |
| 995 |
}); |
| 996 |
await mountView({ |
| 997 |
type: "form", |
| 998 |
resModel: "sale_order_line", |
| 999 |
arch: ` |
| 1000 |
<form> |
| 1001 |
<field name="product_id"/> |
| 1002 |
<field name="linked_sale_order_line" widget="many2many_tags"/> |
| 1003 |
</form>`, |
| 1004 |
}); |
| 1005 |
|
| 1006 |
await contains('.o_field_widget[name="product_id"] input').click(); |
| 1007 |
await contains(".modal-dialog.modal-lg .o_kanban_record:nth-child(1) .o_primary span").click(); |
| 1008 |
expect(".modal-dialog.modal-lg").toHaveCount(0); |
| 1009 |
await clickSave(); |
| 1010 |
expect.verifySteps([]); |
| 1011 |
}); |
| 1012 |
|
| 1013 |
test.tags("mobile"); |
| 1014 |
test("SelectCreateDialog: default props, create a record", async () => { |
| 1015 |
Product._views["form"] = /* xml */ `<form><field name="name"/></form>`; |
| 1016 |
Product._views[ |
| 1017 |
"kanban" |
| 1018 |
] = /* xml */ `<kanban><templates><t t-name="card"><field name="id"/><field name="name"/></t></templates></kanban>`; |
| 1019 |
Product._views["search"] = /* xml */ `<search/>`; |
| 1020 |
|
| 1021 |
await mountView({ |
| 1022 |
type: "form", |
| 1023 |
resModel: "sale_order_line", |
| 1024 |
arch: ` |
| 1025 |
<form> |
| 1026 |
<field name="product_id"/> |
| 1027 |
<field name="linked_sale_order_line" widget="many2many_tags"/> |
| 1028 |
</form>`, |
| 1029 |
}); |
| 1030 |
|
| 1031 |
await contains('.o_field_widget[name="product_id"] input').click(); |
| 1032 |
expect(".o_dialog").toHaveCount(1); |
| 1033 |
expect(".o_dialog .o_kanban_view .o_kanban_record:not(.o_kanban_ghost)").toHaveCount(1); |
| 1034 |
expect(".o_dialog footer button").toHaveCount(2); |
| 1035 |
expect(".o_dialog footer button.o_create_button").toHaveCount(1); |
| 1036 |
expect(".o_dialog footer button.o_form_button_cancel").toHaveCount(1); |
| 1037 |
expect(".o_dialog .o_control_panel_main_buttons .o-kanban-button-new").toHaveCount(0); |
| 1038 |
|
| 1039 |
await contains(".o_dialog footer button.o_create_button:eq(0)").click(); |
| 1040 |
|
| 1041 |
expect(".o_dialog").toHaveCount(2); |
| 1042 |
expect(".o_dialog .o_form_view").toHaveCount(1); |
| 1043 |
|
| 1044 |
await contains(".o_dialog .o_form_view .o_field_widget input").edit("hello"); |
| 1045 |
await contains(".o_dialog .o_form_button_save:eq(0)").click(); |
| 1046 |
|
| 1047 |
expect(".o_dialog").toHaveCount(0); |
| 1048 |
}); |