|
2 | 2 |
|
3 | 3 | import ActivityView from '@mail/js/views/activity/activity_view'; |
4 | 4 | import testUtils from 'web.test_utils'; |
| 5 | +import { createWebClient } from "@web/../tests/webclient/actions/helpers"; |
5 | 6 |
|
6 | | -var createActionManager = testUtils.createActionManager; |
| 7 | +import { legacyExtraNextTick } from "@web/../tests/helpers/utils"; |
| 8 | +import { doAction, getActionManagerTestConfig } from "@web/../tests/webclient/actions/helpers"; |
| 9 | +import { registry } from "@web/core/registry"; |
| 10 | +import { makeFakeUserService } from "@web/../tests/helpers/mock_services"; |
| 11 | + |
| 12 | +let testConfig; |
7 | 13 |
|
8 | 14 | var createView = testUtils.createView; |
9 | 15 |
|
@@ -108,6 +114,8 @@ QUnit.module('activity view', { |
108 | 114 | ], |
109 | 115 | }, |
110 | 116 | }; |
| 117 | + testConfig = getActionManagerTestConfig(); |
| 118 | + Object.assign(testConfig.serverData.models, this.data); |
111 | 119 | } |
112 | 120 | }); |
113 | 121 |
|
@@ -350,49 +358,68 @@ QUnit.test('activity view: activity widget', async function (assert) { |
350 | 358 |
|
351 | 359 | activity.destroy(); |
352 | 360 | }); |
353 | | -QUnit.skip('activity view: no group_by_menu and no comparison_menu', async function (assert) { |
| 361 | + |
| 362 | +QUnit.test("activity view: no group_by_menu and no comparison_menu", async function (assert) { |
354 | 363 | assert.expect(4); |
355 | 364 |
|
356 | | - var actionManager = await createActionManager({ |
357 | | - actions: [{ |
358 | | - id: 1, |
359 | | - name: 'Task Action', |
360 | | - res_model: 'task', |
361 | | - type: 'ir.actions.act_window', |
362 | | - views: [[false, 'activity']], |
363 | | - }], |
364 | | - archs: { |
365 | | - 'task,false,activity': '<activity string="Task">' + |
366 | | - '<templates>' + |
367 | | - '<div t-name="activity-box">' + |
368 | | - '<field name="foo"/>' + |
369 | | - '</div>' + |
370 | | - '</templates>' + |
371 | | - '</activity>', |
372 | | - 'task,false,search': '<search></search>', |
373 | | - }, |
374 | | - data: this.data, |
375 | | - session: { |
376 | | - user_context: {lang: 'zz_ZZ'}, |
377 | | - }, |
378 | | - mockRPC: function(route, args) { |
379 | | - if (args.method === 'get_activity_data') { |
380 | | - assert.deepEqual(args.kwargs.context, {lang: 'zz_ZZ'}, |
381 | | - 'The context should have been passed'); |
382 | | - } |
383 | | - return this._super.apply(this, arguments); |
384 | | - }, |
385 | | - }); |
| 365 | + testConfig.serverData.actions[1] = { |
| 366 | + id: 1, |
| 367 | + name: "Task Action", |
| 368 | + res_model: "task", |
| 369 | + type: "ir.actions.act_window", |
| 370 | + views: [[false, "activity"]], |
| 371 | + }; |
386 | 372 |
|
387 | | - await actionManager.doAction(1); |
| 373 | + testConfig.serverData.views = { |
| 374 | + "task,false,activity": |
| 375 | + '<activity string="Task">' + |
| 376 | + "<templates>" + |
| 377 | + '<div t-name="activity-box">' + |
| 378 | + '<field name="foo"/>' + |
| 379 | + "</div>" + |
| 380 | + "</templates>" + |
| 381 | + "</activity>", |
| 382 | + "task,false,search": "<search></search>", |
| 383 | + }; |
| 384 | + |
| 385 | + const mockRPC = (route, args) => { |
| 386 | + if (args.method === "get_activity_data") { |
| 387 | + assert.strictEqual( |
| 388 | + args.kwargs.context.lang, |
| 389 | + "zz_ZZ", |
| 390 | + "The context should have been passed" |
| 391 | + ); |
| 392 | + } |
| 393 | + }; |
388 | 394 |
|
389 | | - assert.containsN(actionManager, '.o_search_options .o_dropdown button:visible', 2, |
390 | | - "only two elements should be available in view search"); |
391 | | - assert.isVisible(actionManager.$('.o_search_options .o_dropdown.o_filter_menu > button'), |
392 | | - "filter should be available in view search"); |
393 | | - assert.isVisible(actionManager.$('.o_search_options .o_dropdown.o_favorite_menu > button'), |
394 | | - "favorites should be available in view search"); |
395 | | - actionManager.destroy(); |
| 395 | + registry.category("services").add( |
| 396 | + "user", |
| 397 | + makeFakeUserService({ |
| 398 | + session_info: { |
| 399 | + user_context: { lang: "zz_ZZ" }, |
| 400 | + }, |
| 401 | + }), |
| 402 | + { force: true } |
| 403 | + ); |
| 404 | + |
| 405 | + const webClient = await createWebClient({ testConfig, mockRPC , legacyParams: {withLegacyMockServer: true}}); |
| 406 | + |
| 407 | + await doAction(webClient, 1); |
| 408 | + |
| 409 | + assert.containsN( |
| 410 | + webClient, |
| 411 | + ".o_search_options .o_dropdown button:visible", |
| 412 | + 2, |
| 413 | + "only two elements should be available in view search" |
| 414 | + ); |
| 415 | + assert.isVisible( |
| 416 | + $(webClient.el).find(".o_search_options .o_dropdown.o_filter_menu > button"), |
| 417 | + "filter should be available in view search" |
| 418 | + ); |
| 419 | + assert.isVisible( |
| 420 | + $(webClient.el).find(".o_search_options .o_dropdown.o_favorite_menu > button"), |
| 421 | + "favorites should be available in view search" |
| 422 | + ); |
396 | 423 | }); |
397 | 424 |
|
398 | 425 | QUnit.test('activity view: search more to schedule an activity for a record of a respecting model', async function (assert) { |
@@ -458,63 +485,54 @@ QUnit.test('activity view: search more to schedule an activity for a record of a |
458 | 485 | activity.destroy(); |
459 | 486 | }); |
460 | 487 |
|
461 | | -QUnit.skip('Activity view: discard an activity creation dialog', async function (assert) { |
| 488 | +QUnit.test("Activity view: discard an activity creation dialog", async function (assert) { |
462 | 489 | assert.expect(2); |
463 | 490 |
|
464 | | - var actionManager = await createActionManager({ |
465 | | - actions: [{ |
466 | | - id: 1, |
467 | | - name: 'Task Action', |
468 | | - res_model: 'task', |
469 | | - type: 'ir.actions.act_window', |
470 | | - views: [[false, 'activity']], |
471 | | - }], |
472 | | - archs: { |
473 | | - 'task,false,activity': ` |
474 | | - <activity string="Task"> |
475 | | - <templates> |
476 | | - <div t-name="activity-box"> |
477 | | - <field name="foo"/> |
478 | | - </div> |
479 | | - </templates> |
480 | | - </activity>`, |
481 | | - 'task,false,search': '<search></search>', |
482 | | - 'mail.activity,false,form': ` |
483 | | - <form> |
484 | | - <field name="display_name"/> |
485 | | - <footer> |
486 | | - <button string="Discard" class="btn-secondary" special="cancel"/> |
487 | | - </footer> |
488 | | - </form>` |
489 | | - }, |
490 | | - data: this.data, |
491 | | - intercepts: { |
492 | | - do_action(ev) { |
493 | | - actionManager.doAction(ev.data.action, ev.data.options); |
494 | | - } |
495 | | - }, |
496 | | - async mockRPC(route, args) { |
497 | | - if (args.method === 'check_access_rights') { |
498 | | - return true; |
499 | | - } |
500 | | - return this._super(...arguments); |
501 | | - }, |
502 | | - }); |
503 | | - await actionManager.doAction(1); |
| 491 | + testConfig.serverData.actions[1] = { |
| 492 | + id: 1, |
| 493 | + name: "Task Action", |
| 494 | + res_model: "task", |
| 495 | + type: "ir.actions.act_window", |
| 496 | + views: [[false, "activity"]], |
| 497 | + }; |
| 498 | + |
| 499 | + testConfig.serverData.views = { |
| 500 | + "task,false,activity": ` |
| 501 | + <activity string="Task"> |
| 502 | + <templates> |
| 503 | + <div t-name="activity-box"> |
| 504 | + <field name="foo"/> |
| 505 | + </div> |
| 506 | + </templates> |
| 507 | + </activity>`, |
| 508 | + "task,false,search": "<search></search>", |
| 509 | + "mail.activity,false,form": ` |
| 510 | + <form> |
| 511 | + <field name="display_name"/> |
| 512 | + <footer> |
| 513 | + <button string="Discard" class="btn-secondary" special="cancel"/> |
| 514 | + </footer> |
| 515 | + </form>`, |
| 516 | + }; |
| 517 | + |
| 518 | + const mockRPC = (route, args) => { |
| 519 | + if (args.method === "check_access_rights") { |
| 520 | + return true; |
| 521 | + } |
| 522 | + }; |
504 | 523 |
|
505 | | - await testUtils.dom.click(actionManager.$('.o_activity_view .o_data_row .o_activity_empty_cell')[0]); |
506 | | - assert.containsOnce( |
507 | | - $, |
508 | | - '.modal.o_technical_modal.show', |
509 | | - "Activity Modal should be opened"); |
| 524 | + const webClient = await createWebClient({ testConfig, mockRPC, legacyParams: {withLegacyMockServer: true} }); |
| 525 | + await doAction(webClient, 1); |
510 | 526 |
|
511 | | - await testUtils.dom.click($('.modal.o_technical_modal.show button[special="cancel"]')); |
512 | | - assert.containsNone( |
513 | | - $, |
514 | | - '.modal.o_technical_modal.show', |
515 | | - "Activity Modal should be closed"); |
| 527 | + await testUtils.dom.click( |
| 528 | + $(webClient.el).find(".o_activity_view .o_data_row .o_activity_empty_cell")[0] |
| 529 | + ); |
| 530 | + await legacyExtraNextTick(); |
| 531 | + assert.containsOnce($, ".modal.o_technical_modal", "Activity Modal should be opened"); |
516 | 532 |
|
517 | | - actionManager.destroy(); |
| 533 | + await testUtils.dom.click($('.modal.o_technical_modal button[special="cancel"]')); |
| 534 | + await legacyExtraNextTick(); |
| 535 | + assert.containsNone($, ".modal.o_technical_modal", "Activity Modal should be closed"); |
518 | 536 | }); |
519 | 537 |
|
520 | 538 | }); |
0 commit comments