-
Notifications
You must be signed in to change notification settings - Fork 672
AI Assistant: error handling integration tests #33666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dmirgaev
merged 11 commits into
DevExpress:26_1
from
dmirgaev:26_1__ai_assistant_error_handling
May 22, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3ab2022
rename error message const
dmirgaev 703e845
first iteration
dmirgaev ca4cf28
add AIAssistantDataGridModel
dmirgaev 75c086d
simplify methods naming
dmirgaev b39c2cb
enrich POM with chat methods
dmirgaev 60a9a8d
enrich POM with chat methods
dmirgaev 2824ce6
enrich POM with methods
dmirgaev 80999f7
add AIChatModel
dmirgaev f90daeb
fix and rename a model method
dmirgaev ea24abb
use model method instead of controller one
dmirgaev 18dbc63
move tests and models to grid_core
dmirgaev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
packages/devextreme/js/__internal/grids/data_grid/__tests__/__mock__/model/data_grid.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/devextreme/js/__internal/grids/grid_core/__tests__/__mock__/model/ai_assistant.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import type { ArrayStore } from '@js/common/data'; | ||
| import type { Message } from '@js/ui/chat'; | ||
| import DataGrid from '@js/ui/data_grid'; | ||
| import type { DataGridInstance } from '@ts/grids/grid_core/__tests__/__mock__/helpers/utils'; | ||
| import { AIChatModel } from '@ts/grids/grid_core/__tests__/__mock__/model/ai_chat'; | ||
| import { DataGridBaseModel } from '@ts/grids/grid_core/__tests__/__mock__/model/data_grid_base'; | ||
| import type { AIAssistantController } from '@ts/grids/grid_core/ai_assistant/ai_assistant_controller'; | ||
| import type { AIAssistantViewController } from '@ts/grids/grid_core/ai_assistant/ai_assistant_view_controller'; | ||
| import type { AIMessage } from '@ts/grids/grid_core/ai_assistant/types'; | ||
|
|
||
| export class AIAssistantDataGridModel extends DataGridBaseModel<DataGrid> { | ||
| protected NAME = 'dxDataGrid'; | ||
|
|
||
| public getInstance(): DataGridInstance { | ||
| return DataGrid.getInstance(this.root) as DataGridInstance; | ||
| } | ||
|
|
||
| public getAiAssistantController(): AIAssistantController { | ||
| return this.getInstance().getController('aiAssistant'); | ||
| } | ||
|
|
||
| public getAiAssistantViewController(): AIAssistantViewController { | ||
| return this.getInstance().getController('aiAssistantViewController'); | ||
| } | ||
|
|
||
| public sendAiRequest(text: string): void { | ||
| const controller = this.getAiAssistantController(); | ||
|
|
||
| controller | ||
| .sendRequestToAI({ | ||
| author: { id: 'user', name: 'User' }, | ||
| text, | ||
| timestamp: new Date().toISOString(), | ||
| } as Message) | ||
| .catch(() => {}); | ||
| } | ||
|
|
||
| public sendAiRequestRaw(message: Message | AIMessage): Promise<void> { | ||
| return this.getAiAssistantController().sendRequestToAI(message); | ||
| } | ||
|
|
||
| public getMessageStore(): ArrayStore<Message, string> { | ||
| return this.getAiAssistantController().getMessageStore(); | ||
| } | ||
|
|
||
| public loadMessages(): Promise<Message[]> { | ||
| return this.getMessageStore().load() as Promise<Message[]>; | ||
| } | ||
|
|
||
| public getAiChatModel(): AIChatModel { | ||
| return new AIChatModel(); | ||
| } | ||
|
|
||
| public async togglePopup(): Promise<void> { | ||
| await this.getAiAssistantViewController().toggle(); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
packages/devextreme/js/__internal/grids/grid_core/__tests__/__mock__/model/ai_chat.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import type { dxElementWrapper } from '@js/core/renderer'; | ||
| import $ from '@js/core/renderer'; | ||
| import { MessageStatus } from '@ts/grids/grid_core/ai_assistant/const'; | ||
| import { CLASSES } from '@ts/grids/grid_core/ai_chat/const'; | ||
|
|
||
| export class AIChatModel { | ||
| protected readonly root: dxElementWrapper; | ||
|
|
||
| constructor() { | ||
| this.root = $(`.${CLASSES.aiChat}`); | ||
| } | ||
|
|
||
| public getMessages(): dxElementWrapper { | ||
| return this.root.find(`.${CLASSES.message}`); | ||
| } | ||
|
|
||
| public getMessage(messageIndex: number): dxElementWrapper { | ||
| return this.getMessages().eq(messageIndex); | ||
| } | ||
|
|
||
| public getMessageStatus(messageIndex: number): MessageStatus { | ||
| const $message = this.getMessage(messageIndex); | ||
| if ($message.hasClass(CLASSES.messagePending)) { | ||
| return MessageStatus.Pending; | ||
| } | ||
| if ($message.hasClass(CLASSES.messageSuccess)) { | ||
| return MessageStatus.Success; | ||
| } | ||
| if ($message.hasClass(CLASSES.messageError)) { | ||
| return MessageStatus.Failure; | ||
| } | ||
| return '' as never; | ||
| } | ||
|
|
||
| public getErrorMessage(messageIndex: number): dxElementWrapper { | ||
| return this.getMessage(messageIndex) | ||
| .find(`.${CLASSES.messageErrorText}`); | ||
| } | ||
|
|
||
| public getActionList(messageIndex: number): dxElementWrapper { | ||
| return this.getMessage(messageIndex) | ||
| .find(`.${CLASSES.actionListItemText}`); | ||
| } | ||
|
|
||
| public getRegenerateButton(messageIndex: number): HTMLElement { | ||
| return this.getMessage(messageIndex) | ||
| .find(`.${CLASSES.messageRegenerateButton}`) | ||
| .get(0) as HTMLElement; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.