From 67d8ebe1fecd16062b0d6a03d292962c7743f2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Fri, 27 Mar 2026 11:43:13 +0100 Subject: [PATCH 1/2] Chat: Move init of errors into component level --- .../ui/chat/message_box/chat_text_area.ts | 11 +++-- .../chatParts/chatTextArea.tests.js | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/packages/devextreme/js/__internal/ui/chat/message_box/chat_text_area.ts b/packages/devextreme/js/__internal/ui/chat/message_box/chat_text_area.ts index 48f492ed30a8..699b23d6ac97 100644 --- a/packages/devextreme/js/__internal/ui/chat/message_box/chat_text_area.ts +++ b/packages/devextreme/js/__internal/ui/chat/message_box/chat_text_area.ts @@ -78,9 +78,8 @@ export const CHAT_TEXT_AREA_TOOLBAR = 'dx-chat-textarea-toolbar'; const MAX_ATTACHMENTS_COUNT = 10; const INFORMER_DELAY = 10000; -const ERRORS = { - // @ts-expect-error format params should be extended - fileLimit: messageLocalization.format('dxChat-fileLimitReachedWarning', MAX_ATTACHMENTS_COUNT), +const ERROR_MESSAGE_NAME = { + fileLimit: 'dxChat-fileLimitReachedWarning', }; export const STT_INITIAL_STATE: ButtonState = { @@ -532,7 +531,11 @@ class ChatTextArea extends TextArea { }; _fileUploaderFileLimitReached(): void { - this._showInformer(ERRORS.fileLimit); + this._showInformer(messageLocalization.format( + ERROR_MESSAGE_NAME.fileLimit, + // @ts-expect-error format params should be extended + MAX_ATTACHMENTS_COUNT, + )); this._updateInputHeight(); } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js index 943bd28c0b36..c53632db6310 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js @@ -2,6 +2,7 @@ import $ from 'jquery'; import keyboardMock from '../../../helpers/keyboardMock.js'; import { isRenderer } from 'core/utils/type'; import config from 'core/config'; +import messageLocalization from 'common/core/localization/message'; import ChatTextArea, { CHAT_TEXT_AREA_ATTACH_BUTTON, @@ -845,6 +846,50 @@ QUnit.module('ChatTextArea', moduleConfig, () => { assert.strictEqual(this.sendButton.option('disabled'), true, 'send button is disabled after file removal'); }); + + QUnit.module('Localization', { + beforeEach: function() { + this.defaultMessage = messageLocalization.format('dxChat-fileLimitReachedWarning', 10); + this.customMessage = 'Custom file limit message'; + }, + afterEach: function() { + messageLocalization.load({ en: { 'dxChat-fileLimitReachedWarning': this.defaultMessage } }); + } + }, () => { + QUnit.test('informer should show custom localization message loaded before component initialization', function(assert) { + messageLocalization.load({ en: { 'dxChat-fileLimitReachedWarning': this.customMessage } }); + + this.reinit({ + fileUploaderOptions: { + uploadFile: () => {}, + } + }); + + const fileUploader = this.getFileUploader(); + fileUploader.option('onFileLimitReached')(); + + const $informerText = this.$element.find(`.${INFORMER_TEXT_CLASS}`); + + assert.strictEqual($informerText.text(), this.customMessage, 'custom localization message is shown'); + }); + + QUnit.test('informer should show custom localization message loaded after component initialization', function(assert) { + this.reinit({ + fileUploaderOptions: { + uploadFile: () => {}, + } + }); + + messageLocalization.load({ en: { 'dxChat-fileLimitReachedWarning': this.customMessage } }); + + const fileUploader = this.getFileUploader(); + fileUploader.option('onFileLimitReached')(); + + const $informerText = this.$element.find(`.${INFORMER_TEXT_CLASS}`); + + assert.strictEqual($informerText.text(), this.customMessage, 'custom localization message is shown after runtime load'); + }); + }); }); QUnit.module('Integration with text option', () => { From 4c6602b59631f541a2b087e4851d8c2483cfa4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Fri, 27 Mar 2026 11:57:27 +0100 Subject: [PATCH 2/2] fix(minor) --- .../tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js index c53632db6310..a9e078412105 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chatTextArea.tests.js @@ -849,7 +849,7 @@ QUnit.module('ChatTextArea', moduleConfig, () => { QUnit.module('Localization', { beforeEach: function() { - this.defaultMessage = messageLocalization.format('dxChat-fileLimitReachedWarning', 10); + this.defaultMessage = messageLocalization.format('dxChat-fileLimitReachedWarning'); this.customMessage = 'Custom file limit message'; }, afterEach: function() {