summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/message/message_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/components/message/message_tests.js')
-rw-r--r--addons/mail/static/src/components/message/message_tests.js189
1 files changed, 189 insertions, 0 deletions
diff --git a/addons/mail/static/src/components/message/message_tests.js b/addons/mail/static/src/components/message/message_tests.js
index 1737d7ec291..bf27d71fdb5 100644
--- a/addons/mail/static/src/components/message/message_tests.js
+++ b/addons/mail/static/src/components/message/message_tests.js
@@ -984,6 +984,195 @@ QUnit.test('open chat with author on avatar click should be disabled when curren
);
});
+QUnit.test('basic rendering of tracking value (float type)', async function (assert) {
+ assert.expect(8);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Total",
+ field_type: "float",
+ id: 6,
+ new_value: 45.67,
+ old_value: 12.3,
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.containsOnce(
+ document.body,
+ '.o_Message_trackingValue',
+ "should display a tracking value"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_trackingValueFieldName',
+ "should display the name of the tracked field"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValueFieldName').textContent,
+ "Total:",
+ "should display the correct tracked field name (Total)",
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_trackingValueOldValue',
+ "should display the old value"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValueOldValue').textContent,
+ "12.3",
+ "should display the correct old value (12.3)",
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_trackingValueSeparator',
+ "should display the separator"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_trackingValueNewValue',
+ "should display the new value"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValueNewValue').textContent,
+ "45.67",
+ "should display the correct new value (45.67)",
+ );
+});
+
+QUnit.test('rendering of tracked field with change of value from non-0 to 0', async function (assert) {
+ assert.expect(1);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Total",
+ field_type: "float",
+ id: 6,
+ new_value: 0,
+ old_value: 1,
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValue').textContent,
+ "Total:10",
+ "should display the correct content of tracked field with change of value from non-0 to 0 (Total: 1 -> 0)"
+ );
+});
+
+QUnit.test('rendering of tracked field with change of value from 0 to non-0', async function (assert) {
+ assert.expect(1);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Total",
+ field_type: "float",
+ id: 6,
+ new_value: 1,
+ old_value: 0,
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValue').textContent,
+ "Total:01",
+ "should display the correct content of tracked field with change of value from 0 to non-0 (Total: 0 -> 1)"
+ );
+});
+
+QUnit.test('rendering of tracked field with change of value from true to false', async function (assert) {
+ assert.expect(1);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Is Ready",
+ field_type: "boolean",
+ id: 6,
+ new_value: false,
+ old_value: true,
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValue').textContent,
+ "Is Ready:truefalse",
+ "should display the correct content of tracked field with change of value from true to false (Is Ready: true -> false)"
+ );
+});
+
+QUnit.test('rendering of tracked field with change of value from false to true', async function (assert) {
+ assert.expect(1);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Is Ready",
+ field_type: "boolean",
+ id: 6,
+ new_value: true,
+ old_value: false,
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValue').textContent,
+ "Is Ready:falsetrue",
+ "should display the correct content of tracked field with change of value from false to true (Is Ready: false -> true)"
+ );
+});
+
+QUnit.test('rendering of tracked field with change of value from string to empty', async function (assert) {
+ assert.expect(1);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Name",
+ field_type: "char",
+ id: 6,
+ new_value: "",
+ old_value: "Marc",
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValue').textContent,
+ "Name:Marc",
+ "should display the correct content of tracked field with change of value from string to empty (Total: Marc ->)"
+ );
+});
+
+QUnit.test('rendering of tracked field with change of value from empty to string', async function (assert) {
+ assert.expect(1);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ id: 11,
+ tracking_value_ids: [{
+ changed_field: "Name",
+ field_type: "char",
+ id: 6,
+ new_value: "Marc",
+ old_value: "",
+ }],
+ });
+ await this.createMessageComponent(message);
+ assert.strictEqual(
+ document.querySelector('.o_Message_trackingValue').textContent,
+ "Name:Marc",
+ "should display the correct content of tracked field with change of value from empty to string (Total: -> Marc)"
+ );
+});
+
});
});
});