Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
344 changes: 185 additions & 159 deletions addons/board/static/tests/dashboard_tests.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion addons/bus/static/tests/assets_watchdog_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,5 @@ QUnit.module("Bus Assets WatchDog", (hooks) => {
// reload by clicking on the reload button
await click(webClient.el, ".o_notification_buttons .btn-primary");
assert.verifySteps(["reloadPage"]);
webClient.destroy();
});
});
6 changes: 0 additions & 6 deletions addons/calendar/static/tests/calendar_notification_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ QUnit.module("Calendar Notification", (hooks) => {
await click(webClient.el.querySelector(".o_notification_buttons .btn"));
assert.verifySteps(["notifyAck"]);
assert.containsNone(webClient.el, ".o_notification");

webClient.destroy();
}
);

Expand Down Expand Up @@ -171,8 +169,6 @@ QUnit.module("Calendar Notification", (hooks) => {
await click(webClient.el.querySelectorAll(".o_notification_buttons .btn")[1]);
assert.verifySteps(["calendar.action_calendar_event_notify"]);
assert.containsNone(webClient.el, ".o_notification");

webClient.destroy();
}
);

Expand Down Expand Up @@ -232,8 +228,6 @@ QUnit.module("Calendar Notification", (hooks) => {
await click(webClient.el.querySelectorAll(".o_notification_buttons .btn")[2]);
assert.verifySteps([], "should only close the notification withtout calling a rpc");
assert.containsNone(webClient.el, ".o_notification");

webClient.destroy();
}
);
});
39 changes: 36 additions & 3 deletions addons/mail/static/src/utils/test_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ import AbstractStorageService from 'web.AbstractStorageService';
import NotificationService from 'web.NotificationService';
import RamStorage from 'web.RamStorage';
import {
createActionManager,
createView,
makeTestPromise,
mock,
} from 'web.test_utils';
import Widget from 'web.Widget';
import {
createWebClient,
getActionManagerTestConfig,
} from "@web/../tests/webclient/actions/helpers";
import { ComponentAdapter } from "web.OwlCompatibility";
import LegacyMockServer from "web.MockServer";

const {
addMockEnvironment,
Expand Down Expand Up @@ -546,8 +551,36 @@ async function start(param0 = {}) {
}
});
} else if (hasActionManager) {
throw new Error("This is deprecated, should be adapted");
widget = await createActionManager(kwargs);
let testConfig;
if (!kwargs.testConfig) {
testConfig = getActionManagerTestConfig();
} else {
testConfig = kwargs.testConfig;
delete kwargs.testConfig;
}

if (kwargs.actions) {
const actions = {};
kwargs.actions.forEach((act) => {
actions[act.xml_id || act.id] = act;
});
Object.assign(testConfig.serverData.actions, actions);
delete kwargs.actions;
}

Object.assign(testConfig.serverData.views, kwargs.archs);
delete kwargs.archs;

Object.assign(testConfig.serverData.models, kwargs.data);
delete kwargs.data;

const mockRPC = kwargs.mockRPC;
delete kwargs.mockRPC;

const legacyParams = kwargs;
legacyParams.withLegacyMockServer = true;
const widget = await createWebClient({ testConfig, mockRPC, legacyParams });

legacyPatch(widget, {
destroy() {
destroyCallbacks.forEach(callback => callback({ widget }));
Expand Down
202 changes: 110 additions & 92 deletions addons/mail/static/tests/activity_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

import ActivityView from '@mail/js/views/activity/activity_view';
import testUtils from 'web.test_utils';
import { createWebClient } from "@web/../tests/webclient/actions/helpers";

var createActionManager = testUtils.createActionManager;
import { legacyExtraNextTick } from "@web/../tests/helpers/utils";
import { doAction, getActionManagerTestConfig } from "@web/../tests/webclient/actions/helpers";
import { registry } from "@web/core/registry";
import { makeFakeUserService } from "@web/../tests/helpers/mock_services";

let testConfig;

var createView = testUtils.createView;

Expand Down Expand Up @@ -108,6 +114,8 @@ QUnit.module('activity view', {
],
},
};
testConfig = getActionManagerTestConfig();
Object.assign(testConfig.serverData.models, this.data);
}
});

Expand Down Expand Up @@ -350,49 +358,68 @@ QUnit.test('activity view: activity widget', async function (assert) {

activity.destroy();
});
QUnit.skip('activity view: no group_by_menu and no comparison_menu', async function (assert) {

QUnit.test("activity view: no group_by_menu and no comparison_menu", async function (assert) {
assert.expect(4);

var actionManager = await createActionManager({
actions: [{
id: 1,
name: 'Task Action',
res_model: 'task',
type: 'ir.actions.act_window',
views: [[false, 'activity']],
}],
archs: {
'task,false,activity': '<activity string="Task">' +
'<templates>' +
'<div t-name="activity-box">' +
'<field name="foo"/>' +
'</div>' +
'</templates>' +
'</activity>',
'task,false,search': '<search></search>',
},
data: this.data,
session: {
user_context: {lang: 'zz_ZZ'},
},
mockRPC: function(route, args) {
if (args.method === 'get_activity_data') {
assert.deepEqual(args.kwargs.context, {lang: 'zz_ZZ'},
'The context should have been passed');
}
return this._super.apply(this, arguments);
},
});
testConfig.serverData.actions[1] = {
id: 1,
name: "Task Action",
res_model: "task",
type: "ir.actions.act_window",
views: [[false, "activity"]],
};

await actionManager.doAction(1);
testConfig.serverData.views = {
"task,false,activity":
'<activity string="Task">' +
"<templates>" +
'<div t-name="activity-box">' +
'<field name="foo"/>' +
"</div>" +
"</templates>" +
"</activity>",
"task,false,search": "<search></search>",
};

const mockRPC = (route, args) => {
if (args.method === "get_activity_data") {
assert.strictEqual(
args.kwargs.context.lang,
"zz_ZZ",
"The context should have been passed"
);
}
};

assert.containsN(actionManager, '.o_search_options .o_dropdown button:visible', 2,
"only two elements should be available in view search");
assert.isVisible(actionManager.$('.o_search_options .o_dropdown.o_filter_menu > button'),
"filter should be available in view search");
assert.isVisible(actionManager.$('.o_search_options .o_dropdown.o_favorite_menu > button'),
"favorites should be available in view search");
actionManager.destroy();
registry.category("services").add(
"user",
makeFakeUserService({
session_info: {
user_context: { lang: "zz_ZZ" },
},
}),
{ force: true }
);

const webClient = await createWebClient({ testConfig, mockRPC , legacyParams: {withLegacyMockServer: true}});

await doAction(webClient, 1);

assert.containsN(
webClient,
".o_search_options .o_dropdown button:visible",
2,
"only two elements should be available in view search"
);
assert.isVisible(
$(webClient.el).find(".o_search_options .o_dropdown.o_filter_menu > button"),
"filter should be available in view search"
);
assert.isVisible(
$(webClient.el).find(".o_search_options .o_dropdown.o_favorite_menu > button"),
"favorites should be available in view search"
);
});

QUnit.test('activity view: search more to schedule an activity for a record of a respecting model', async function (assert) {
Expand Down Expand Up @@ -458,63 +485,54 @@ QUnit.test('activity view: search more to schedule an activity for a record of a
activity.destroy();
});

QUnit.skip('Activity view: discard an activity creation dialog', async function (assert) {
QUnit.test("Activity view: discard an activity creation dialog", async function (assert) {
assert.expect(2);

var actionManager = await createActionManager({
actions: [{
id: 1,
name: 'Task Action',
res_model: 'task',
type: 'ir.actions.act_window',
views: [[false, 'activity']],
}],
archs: {
'task,false,activity': `
<activity string="Task">
<templates>
<div t-name="activity-box">
<field name="foo"/>
</div>
</templates>
</activity>`,
'task,false,search': '<search></search>',
'mail.activity,false,form': `
<form>
<field name="display_name"/>
<footer>
<button string="Discard" class="btn-secondary" special="cancel"/>
</footer>
</form>`
},
data: this.data,
intercepts: {
do_action(ev) {
actionManager.doAction(ev.data.action, ev.data.options);
}
},
async mockRPC(route, args) {
if (args.method === 'check_access_rights') {
return true;
}
return this._super(...arguments);
},
});
await actionManager.doAction(1);
testConfig.serverData.actions[1] = {
id: 1,
name: "Task Action",
res_model: "task",
type: "ir.actions.act_window",
views: [[false, "activity"]],
};

testConfig.serverData.views = {
"task,false,activity": `
<activity string="Task">
<templates>
<div t-name="activity-box">
<field name="foo"/>
</div>
</templates>
</activity>`,
"task,false,search": "<search></search>",
"mail.activity,false,form": `
<form>
<field name="display_name"/>
<footer>
<button string="Discard" class="btn-secondary" special="cancel"/>
</footer>
</form>`,
};

const mockRPC = (route, args) => {
if (args.method === "check_access_rights") {
return true;
}
};

await testUtils.dom.click(actionManager.$('.o_activity_view .o_data_row .o_activity_empty_cell')[0]);
assert.containsOnce(
$,
'.modal.o_technical_modal.show',
"Activity Modal should be opened");
const webClient = await createWebClient({ testConfig, mockRPC, legacyParams: {withLegacyMockServer: true} });
await doAction(webClient, 1);

await testUtils.dom.click($('.modal.o_technical_modal.show button[special="cancel"]'));
assert.containsNone(
$,
'.modal.o_technical_modal.show',
"Activity Modal should be closed");
await testUtils.dom.click(
$(webClient.el).find(".o_activity_view .o_data_row .o_activity_empty_cell")[0]
);
await legacyExtraNextTick();
assert.containsOnce($, ".modal.o_technical_modal", "Activity Modal should be opened");

actionManager.destroy();
await testUtils.dom.click($('.modal.o_technical_modal button[special="cancel"]'));
await legacyExtraNextTick();
assert.containsNone($, ".modal.o_technical_modal", "Activity Modal should be closed");
});

});
Loading