PURPOSE SMS are a powerful marketing tool. For instance it is perfect to announce a sale or to communicate a coupon code, to welcome a new customer in a fidelity program, ... Purpose of this task is to integrate SMS sending in batch in mass mailing. It will use same mailing objects but sending SMS instead of emails. Some metrics and flows will have to be slightly updated at the same time. SPECIFICATIONS Clean the use and options of sms composer after FP feedback : * see https://s.nimbusweb.me/share/3167586/ap1xpy95rz29a5cys576 as basis; * globally, do not display invalid recipients, only valid / invalid count as well as current selection / active domain counts; * consider logging a note as default behavior when using the composer; * simplify code: when doing a mass SMS, send SMS and attach a simple note to the document; Some other points * make name of sms templates translatable; * improve various wording, notably in sms widget; * display error code in sms list view; * update sms composer actions accordingly by correctly setting active id or ids; LINKS Task 1997464 PR #34424 Original SMS addition: Task1922163(4287481)
75 lines
3.4 KiB
JavaScript
75 lines
3.4 KiB
JavaScript
odoo.define('sms.sms_widget_tests', function (require) {
|
|
"use strict";
|
|
|
|
var FormView = require('web.FormView');
|
|
var testUtils = require('web.test_utils');
|
|
|
|
var createView = testUtils.createView;
|
|
|
|
QUnit.module('fields', {
|
|
beforeEach: function () {
|
|
this.data = {
|
|
partner: {
|
|
fields: {
|
|
message: {string: "message", type: "text"},
|
|
},
|
|
records: [{
|
|
id: 1,
|
|
message: "",
|
|
}]
|
|
},
|
|
};
|
|
}
|
|
}, function () {
|
|
|
|
QUnit.module('SmsWidget');
|
|
|
|
QUnit.test('Sms widgets are correctly rendered', async function (assert) {
|
|
assert.expect(9);
|
|
var form = await createView({
|
|
View: FormView,
|
|
model: 'partner',
|
|
data: this.data,
|
|
arch: '<form><sheet><field name="message" widget="sms_widget"/></sheet></form>',
|
|
});
|
|
assert.containsOnce(form, '.o_sms_count', "Should have a sms counter");
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '0 characters, fits in 0 SMS (GSM7) ',
|
|
'Should be "0 characters, fits in 0 SMS (GSM7) " by default');
|
|
// GSM-7
|
|
await testUtils.fields.editAndTrigger(form.$('.o_input'), "Hello from Odoo", 'input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '15 characters, fits in 1 SMS (GSM7) ',
|
|
'Should be "15 characters, fits in 1 SMS (GSM7) " for "Hello from Odoo"');
|
|
// GSM-7 with \n => this one count as 2 characters
|
|
form.$('.o_input').val("Hello from Odoo\n").trigger('input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '17 characters, fits in 1 SMS (GSM7) ',
|
|
'Should be "17 characters, fits in 1 SMS (GSM7) " for "Hello from Odoo\\n"');
|
|
// Unicode => ê
|
|
form.$('.o_input').val("Hêllo from Odoo").trigger('input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '15 characters, fits in 1 SMS (UNICODE) ',
|
|
'Should be "15 characters, fits in 1 SMS (UNICODE) " for "Hêllo from Odoo"');
|
|
// GSM-7 with 160c
|
|
var text = Array(161).join('a');
|
|
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '160 characters, fits in 1 SMS (GSM7) ',
|
|
'Should be "160 characters, fits in 1 SMS (GSM7) " for 160 x "a"');
|
|
// GSM-7 with 161c
|
|
text = Array(162).join('a');
|
|
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '161 characters, fits in 2 SMS (GSM7) ',
|
|
'Should be "161 characters, fits in 2 SMS (GSM7) " for 161 x "a"');
|
|
// Unicode with 70c
|
|
text = Array(71).join('ê');
|
|
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '70 characters, fits in 1 SMS (UNICODE) ',
|
|
'Should be "70 characters, fits in 1 SMS (UNICODE) " for 70 x "ê"');
|
|
// Unicode with 71c
|
|
text = Array(72).join('ê');
|
|
await testUtils.fields.editAndTrigger(form.$('.o_input'), text, 'input');
|
|
assert.strictEqual(form.$('.o_sms_count').text(), '71 characters, fits in 2 SMS (UNICODE) ',
|
|
'Should be "71 characters, fits in 2 SMS (UNICODE) " for 71 x "ê"');
|
|
|
|
form.destroy();
|
|
});
|
|
});
|
|
});
|