-
Notifications
You must be signed in to change notification settings - Fork 672
DataGrid - AI Assistant: toolbar & popup e2e tests #33803
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
Open
Alyar666
wants to merge
8
commits into
DevExpress:26_1
Choose a base branch
from
Alyar666:ai_assistant_e2e_toolbar_popup_26_1
base: 26_1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+267
−13
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6ab27a
DataGrid - AI Assistant: toolbar & popup e2e tests
08a9b31
DataGrid - AI Assistant: await aiIntegration global before createWidget
0ec6e39
DataGrid - AI Assistant: extract createWidgetWithAIIntegration test h…
052201e
DataGrid - AI Assistant: Address Copilot review feedback on POM selec…
e851c5b
DataGrid - AI Assistant: refine toolbar & popup e2e tests, trim POM
d7ee52d
Fix copilot comment
3fc8f17
Fix tests
3f1ac37
Fix copilot comments
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
e2e/testcafe-devextreme/tests/dataGrid/common/aiAssistant/testHelpers.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,16 @@ | ||
| /* eslint-disable no-underscore-dangle */ | ||
| import { ClientFunction } from 'testcafe'; | ||
| import url from '../../../../helpers/getPageUrl'; | ||
|
|
||
| export const GRID_SELECTOR = '#container'; | ||
|
|
||
| export const AI_INTEGRATION_PAGE = url(__dirname, '../../../container-ai-integration.html'); | ||
|
|
||
| export const getRequestColumnNames = ClientFunction( | ||
| (index: number) => (window as any).__aiRequests[index].data.context.columns | ||
| .map((c: any) => c.dataField), | ||
| ); | ||
|
|
||
| export const formatMessage = ClientFunction( | ||
| (key: string) => (window as any).DevExpress.localization.formatMessage(key), | ||
| ); |
198 changes: 198 additions & 0 deletions
198
e2e/testcafe-devextreme/tests/dataGrid/common/aiAssistant/toolbarAndPopup.functional.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,198 @@ | ||
| import DataGrid from 'devextreme-testcafe-models/dataGrid'; | ||
| import { | ||
| AI_INTEGRATION_PAGE, | ||
| GRID_SELECTOR, | ||
| } from './testHelpers'; | ||
| import { createWidget } from '../../../../helpers/createWidget'; | ||
|
|
||
| // AI Assistant enabled with a request that never resolves — keeps the chat in the | ||
| // idle/empty state (no command runs) for visibility & open/close lifecycle tests. | ||
| const gridWithIdleAssistant = (): any => ({ | ||
| dataSource: [ | ||
| { id: 1, name: 'Alice', value: 30 }, | ||
| { id: 2, name: 'Bob', value: 20 }, | ||
| { id: 3, name: 'Charlie', value: 10 }, | ||
| ], | ||
| keyExpr: 'id', | ||
| columns: ['id', 'name', 'value'], | ||
| showBorders: true, | ||
| aiAssistant: { | ||
| enabled: true, | ||
| aiIntegration: new (window as any).DevExpress.aiIntegration.AIIntegration({ | ||
| sendRequest() { | ||
| return { promise: new Promise(() => {}), abort: (): void => {} }; | ||
| }, | ||
| }), | ||
| }, | ||
| }); | ||
|
|
||
| // Grid without the `aiAssistant` option — toolbar button must not be rendered. | ||
| const gridWithoutAssistant = (): any => ({ | ||
| dataSource: [ | ||
| { id: 1, name: 'Alice', value: 30 }, | ||
| { id: 2, name: 'Bob', value: 20 }, | ||
| { id: 3, name: 'Charlie', value: 10 }, | ||
| ], | ||
| keyExpr: 'id', | ||
| columns: ['id', 'name', 'value'], | ||
| showBorders: true, | ||
| }); | ||
|
|
||
| // AI Assistant whose mocked request resolves to a single `sorting` command, so a | ||
| // prompt actually mutates grid state (used to assert the command is applied). | ||
| const gridWithSortingAssistant = (): any => ({ | ||
| dataSource: [ | ||
| { id: 1, name: 'Alice', value: 30 }, | ||
| { id: 2, name: 'Bob', value: 20 }, | ||
| { id: 3, name: 'Charlie', value: 10 }, | ||
| ], | ||
| keyExpr: 'id', | ||
| columns: ['id', 'name', 'value'], | ||
| showBorders: true, | ||
| aiAssistant: { | ||
| enabled: true, | ||
| aiIntegration: new (window as any).DevExpress.aiIntegration.AIIntegration({ | ||
| sendRequest() { | ||
| return { | ||
| promise: Promise.resolve({ | ||
| actions: [{ name: 'sorting', args: { dataField: 'name', sortOrder: 'asc' } }], | ||
| }), | ||
| abort: (): void => {}, | ||
| }; | ||
| }, | ||
| }), | ||
| }, | ||
| }); | ||
|
|
||
| // AI Assistant with a custom popup title (request stays pending — title only). | ||
| const gridWithTitledAssistant = (): any => ({ | ||
| dataSource: [ | ||
| { id: 1, name: 'Alice', value: 30 }, | ||
| { id: 2, name: 'Bob', value: 20 }, | ||
| { id: 3, name: 'Charlie', value: 10 }, | ||
| ], | ||
| keyExpr: 'id', | ||
| columns: ['id', 'name', 'value'], | ||
| showBorders: true, | ||
| aiAssistant: { | ||
| enabled: true, | ||
| title: 'My Custom Assistant', | ||
| aiIntegration: new (window as any).DevExpress.aiIntegration.AIIntegration({ | ||
| sendRequest() { | ||
| return { promise: new Promise(() => {}), abort: (): void => {} }; | ||
| }, | ||
| }), | ||
| }, | ||
| }); | ||
|
|
||
| // === §1.1 Toolbar entry point & popup lifecycle === | ||
| fixture`AI Assistant - Toolbar` | ||
| .page(AI_INTEGRATION_PAGE); | ||
|
|
||
| // 1.1.1 | ||
| test('Toolbar button should be visible when aiAssistant.enabled is true', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| await t.expect(dataGrid.getAIAssistantButton().exists).ok(); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithIdleAssistant)); | ||
|
|
||
| // 1.1.2 | ||
| test('Toolbar button should be hidden when aiAssistant is not configured', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| await t.expect(dataGrid.getAIAssistantButton().exists).notOk(); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithoutAssistant)); | ||
|
|
||
| // 1.1.3 | ||
| test('Popup should open on toolbar button click without changing grid state', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| const initialState = await dataGrid.apiState(); | ||
|
|
||
| await t.click(dataGrid.getAIAssistantButton()); | ||
|
|
||
| const aiChat = dataGrid.getAIAssistantChat(); | ||
| const finalState = await dataGrid.apiState(); | ||
|
|
||
| await t.expect(finalState).eql(initialState); | ||
| await t.expect(aiChat.element.visible).ok(); | ||
| await t.expect(aiChat.getChat().element.exists).ok(); | ||
| await t.expect(aiChat.getInput().visible).ok(); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithIdleAssistant)); | ||
|
|
||
| // 1.1.4 | ||
| test('AI Assistant-applied sorting should persist after popup close', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| await t.click(dataGrid.getAIAssistantButton()); | ||
|
|
||
| const aiChat = dataGrid.getAIAssistantChat(); | ||
|
|
||
| await t | ||
| .typeText(aiChat.getInput(), 'Sort by name') | ||
| .pressKey('enter'); | ||
|
|
||
| await t.expect(aiChat.getSuccessMessages().count).eql(1); | ||
| await t.expect(aiChat.getActionItems(0).count).eql(1); | ||
|
|
||
| await t.click(aiChat.getCloseButton().element); | ||
|
|
||
| const sortOrder = await dataGrid.apiColumnOption('name', 'sortOrder'); | ||
|
|
||
| await t.expect(sortOrder).eql('asc'); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithSortingAssistant)); | ||
|
|
||
| // 1.1.6 | ||
| test('Custom title should be rendered in popup header', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| await t.click(dataGrid.getAIAssistantButton()); | ||
|
|
||
| const aiChat = dataGrid.getAIAssistantChat(); | ||
|
|
||
| await t.expect(aiChat.getTitle().textContent).contains('My Custom Assistant'); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithTitledAssistant)); | ||
|
|
||
| // === §1.10 A11y / KBN === | ||
| fixture`AI Assistant - A11y` | ||
| .page(AI_INTEGRATION_PAGE); | ||
|
|
||
| // 1.10.2 (Enter) — focus the toolbar button and activate it with Enter. | ||
| test('Toolbar button should activate via Enter key', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| await dataGrid.focusAIAssistantButton(); | ||
|
|
||
| await t.expect(dataGrid.getAIAssistantButton().focused).ok(); | ||
|
|
||
| await t.pressKey('enter'); | ||
|
|
||
| await t.expect(dataGrid.getAIAssistantChat().element.visible).ok(); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithIdleAssistant)); | ||
|
|
||
| // 1.10.2 (Space) — same scenario, activated with Space. | ||
| test('Toolbar button should activate via Space key', async (t) => { | ||
| const dataGrid = new DataGrid(GRID_SELECTOR); | ||
|
|
||
| await t.expect(dataGrid.isReady()).ok(); | ||
|
|
||
| await dataGrid.focusAIAssistantButton(); | ||
|
|
||
| await t.expect(dataGrid.getAIAssistantButton().focused).ok(); | ||
|
|
||
| await t.pressKey('space'); | ||
|
|
||
| await t.expect(dataGrid.getAIAssistantChat().element.visible).ok(); | ||
| }).before(async () => createWidget('dxDataGrid', gridWithIdleAssistant)); |
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
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
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
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 |
|---|---|---|
|
|
@@ -167,4 +167,4 @@ export default abstract class GridCore extends Widget { | |
| }, | ||
| )(); | ||
| } | ||
| } | ||
| } | ||
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.