From 65aaa844f588f2e28ea5dc56d7d5cc189feff969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Thu, 10 Oct 2024 12:09:48 +0200 Subject: [PATCH 1/2] Chat: Skip message rendering in onMessageSend --- packages/devextreme/js/__internal/ui/chat/chat.ts | 1 - .../tests/DevExpress.ui.widgets/chatParts/chat.tests.js | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/devextreme/js/__internal/ui/chat/chat.ts b/packages/devextreme/js/__internal/ui/chat/chat.ts index 25efed0b35df..4a214ff9b74e 100644 --- a/packages/devextreme/js/__internal/ui/chat/chat.ts +++ b/packages/devextreme/js/__internal/ui/chat/chat.ts @@ -166,7 +166,6 @@ class Chat extends Widget { text, }; - this.renderMessage(message); this._messageSendAction?.({ message, event }); } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js index dd4991c32456..0fd3daca147e 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js @@ -236,19 +236,20 @@ QUnit.module('Chat', moduleConfig, () => { assert.strictEqual(onMessageSend.callCount, 1); }); - QUnit.test('new message should be created after clicking the send button', function(assert) { + QUnit.test('new message should not be created after clicking the send button', function(assert) { const text = 'new text message'; keyboardMock(this.$input) .focus() .type(text); + const numberOfMessagesBefore = this.getBubbles().length; + this.$sendButton.trigger('dxclick'); - const $bubbles = this.getBubbles(); - const bubble = $bubbles[$bubbles.length - 1]; + const numberOfMessagesAfter = this.getBubbles().length; - assert.strictEqual($(bubble).text(), text); + assert.strictEqual(numberOfMessagesAfter, numberOfMessagesBefore); }); QUnit.test('New message should be correct after clicking the send button', function(assert) { From c0bb8efae72cec8cdd57df3a8a702e2e4b26baf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Thu, 10 Oct 2024 19:51:22 +0200 Subject: [PATCH 2/2] fix(chat): Add renderMessage into onMessageSend --- e2e/testcafe-devextreme/tests/chat/messageList.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/e2e/testcafe-devextreme/tests/chat/messageList.ts b/e2e/testcafe-devextreme/tests/chat/messageList.ts index 803355457dba..8859d6492f22 100644 --- a/e2e/testcafe-devextreme/tests/chat/messageList.ts +++ b/e2e/testcafe-devextreme/tests/chat/messageList.ts @@ -104,6 +104,11 @@ test('Messagelist appearance with scrollbar', async (t) => { user: userSecond, width: 400, height: 600, + onMessageSend: (e) => { + const { component, message } = e; + + component.renderMessage(message); + }, }); });