From 633f0b27d9526c63b1992e3ba1b1547bf9977ecb Mon Sep 17 00:00:00 2001 From: Eldar Iusupzhanov Date: Tue, 28 Jul 2026 13:16:35 +0600 Subject: [PATCH 1/2] fix --- .../common/aiColumn/adaptivity.functional.ts | 196 +----------------- .../grids/grid_core/adaptivity/utils.ts | 4 +- 2 files changed, 11 insertions(+), 189 deletions(-) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts b/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts index c373985f89d0..79aec27a619b 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts @@ -1,5 +1,4 @@ import DataGrid from 'devextreme-testcafe-models/dataGrid'; -import { ClientFunction } from 'testcafe'; import url from '../../../../helpers/getPageUrl'; import { createWidget } from '../../../../helpers/createWidget'; @@ -8,39 +7,26 @@ fixture`Ai Column.Adaptivity` const DATA_GRID_SELECTOR = '#container'; -const resolveAIRequest = ClientFunction((): void => { - const { aiResponseData } = (window as any); - const { aiResolve } = (window as any); - - if (aiResponseData && aiResolve) { - aiResolve(aiResponseData); - - (window as any).aiResponseData = null; - (window as any).aiResolve = null; - } -}); - -const deleteGlobalVariables = ClientFunction((): void => { - delete (window as any).aiResponseData; - delete (window as any).aiResolve; -}); - -test('The AI column should be hidden when columnHidingEnabled is true', async (t) => { +test('The AI column should not hidden when columnHidingEnabled is true', async (t) => { // arrange, act const dataGrid = new DataGrid(DATA_GRID_SELECTOR); await t.expect(dataGrid.isReady()).ok(); - const fourthHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(3); + const thirdHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(2); // assert: the AI column is hidden await t - .expect(fourthHeaderCell.element.textContent).eql('AI Column') - .expect(fourthHeaderCell.isHidden).ok(); + .expect(dataGrid.getHeaders().getHeaderRow(0).getDataHeaderCells().count) + .eql(3) + .expect(thirdHeaderCell.element.textContent) + .eql('AI Column') + .expect(thirdHeaderCell.isHidden) + .notOk(); // assert: the adaptive button is visible await t - .expect(dataGrid.getDataRow(0).getCommandCell(4).getAdaptiveButton().visible).ok(); + .expect(dataGrid.getDataRow(0).getCommandCell(3).getAdaptiveButton().visible).ok(); }).before(async () => createWidget('dxDataGrid', { dataSource: [ { id: 1, name: 'Name 1', value: 10 }, @@ -48,7 +34,7 @@ test('The AI column should be hidden when columnHidingEnabled is true', async (t { id: 3, name: 'Name 3', value: 30 }, ], keyExpr: 'id', - width: 350, + width: 390, columnWidth: 100, columnHidingEnabled: true, columns: [ @@ -61,165 +47,3 @@ test('The AI column should be hidden when columnHidingEnabled is true', async (t }, ], })); - -test('The AI column should be hidden when hidingPriority is set for it', async (t) => { - // arrange, act - const dataGrid = new DataGrid(DATA_GRID_SELECTOR); - - await t.expect(dataGrid.isReady()).ok(); - - const firstHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(0); - - // assert: the AI column is hidden - await t - .expect(firstHeaderCell.element.textContent).eql('AI Column') - .expect(firstHeaderCell.isHidden).ok(); - - // assert: the adaptive button is visible - await t - .expect(dataGrid.getDataRow(0).getCommandCell(4).getAdaptiveButton().visible).ok(); -}).before(async () => createWidget('dxDataGrid', { - dataSource: [ - { id: 1, name: 'Name 1', value: 10 }, - { id: 2, name: 'Name 2', value: 20 }, - { id: 3, name: 'Name 3', value: 30 }, - ], - keyExpr: 'id', - width: 350, - columnWidth: 100, - columns: [ - { - type: 'ai', - caption: 'AI Column', - hidingPriority: 0, - }, - { dataField: 'id', caption: 'ID' }, - { dataField: 'name', caption: 'Name' }, - { dataField: 'value', caption: 'Value' }, - ], -})); - -test('The AI column should not be hidden when there is a second AI column with a hidingPriority set', async (t) => { - // arrange, act - const dataGrid = new DataGrid(DATA_GRID_SELECTOR); - - await t.expect(dataGrid.isReady()).ok(); - - const firstHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(0); - const secondHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(1); - - // assert: the first AI column is hidden - await t - .expect(firstHeaderCell.element.textContent).eql('AI Column 1') - .expect(firstHeaderCell.isHidden).ok(); - - // assert: the second AI column is visible - await t - .expect(secondHeaderCell.element.textContent).eql('AI Column 2') - .expect(secondHeaderCell.isHidden).notOk(); - - // assert: the adaptive button is visible - await t - .expect(dataGrid.getDataRow(0).getCommandCell(5).getAdaptiveButton().visible).ok(); -}).before(async () => createWidget('dxDataGrid', { - dataSource: [ - { id: 1, name: 'Name 1', value: 10 }, - { id: 2, name: 'Name 2', value: 20 }, - { id: 3, name: 'Name 3', value: 30 }, - ], - keyExpr: 'id', - width: 350, - columnWidth: 100, - columns: [ - { - type: 'ai', - name: 'aiColumn1', - caption: 'AI Column 1', - hidingPriority: 0, - }, - { - type: 'ai', - name: 'aiColumn2', - caption: 'AI Column 2', - }, - { dataField: 'id', caption: 'ID' }, - { dataField: 'name', caption: 'Name' }, - { dataField: 'value', caption: 'Value' }, - ], -})); - -test('The AI column should have value in the adaptive detail row', async (t) => { - const dataGrid = new DataGrid(DATA_GRID_SELECTOR); - await t.expect(dataGrid.isReady()).ok(); - - // act - await resolveAIRequest(); - - // assert - - const adaptiveButton = dataGrid.getAdaptiveButton(); - - await t.expect(adaptiveButton.exists).ok(); - - await t.click(adaptiveButton); - - const adaptiveRow = dataGrid.getAdaptiveRow(0); - - await t.expect(adaptiveRow.element.exists).ok(); - - const aiFormItem = adaptiveRow.getAdaptiveCellByText('AI Column'); - - await t.expect(aiFormItem.element.exists).ok(); - - await t.expect(aiFormItem.getAdaptiveCellValue()).contains('Response 1'); -}).before(async () => createWidget('dxDataGrid', () => ({ - dataSource: [ - { id: 1, name: 'Name 1', value: 10 }, - { id: 2, name: 'Name 2', value: 20 }, - { id: 3, name: 'Name 3', value: 30 }, - ], - keyExpr: 'id', - width: 400, - columnHidingEnabled: true, - showBorders: true, - columns: [ - { - dataField: 'id', caption: 'ID', width: 150, hidingPriority: 3, - }, - { - dataField: 'name', caption: 'Name', width: 150, hidingPriority: 2, - }, - { - dataField: 'value', caption: 'Value', width: 100, hidingPriority: 1, - }, - { - name: 'AIcolumn', - caption: 'AI Column', - type: 'ai', - ai: { - prompt: 'Send me nothing', - // eslint-disable-next-line new-cap - aiIntegration: new (window as any).DevExpress.aiIntegration.AIIntegration({ - sendRequest({ data }) { - return { - promise: new Promise((resolve) => { - const obj = {}; - Object.entries(data?.data).forEach(([key, value]) => { - obj[key] = `Response ${(value as any).id}`; - }); - - (window as any).aiResponseData = JSON.stringify(obj); - (window as any).aiResolve = resolve; - }), - abort: (): void => {}, - }; - }, - }), - }, - width: 200, - hidingPriority: 0, - }, - ], -}))).after(async () => { - await deleteGlobalVariables(); -}); diff --git a/packages/devextreme/js/__internal/grids/grid_core/adaptivity/utils.ts b/packages/devextreme/js/__internal/grids/grid_core/adaptivity/utils.ts index a03d6024efb6..4bb55266036a 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/adaptivity/utils.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/adaptivity/utils.ts @@ -1,13 +1,11 @@ import { isDefined } from '@js/core/utils/type'; import type { Column } from '@ts/grids/grid_core/columns_controller/types'; -const HIDEABLE_COMMAND_COLUMNS = ['ai']; - function isHideableColumn(column: Column): boolean { const isGroup = (column?.groupIndex ?? -1) >= 0; return column.visible === true - && (!isDefined(column.type) || HIDEABLE_COMMAND_COLUMNS.includes(column.type)) + && !isDefined(column.type) && !column.fixed && !isGroup; } From ca0b415265fb83aeb6449f361ecae210ee45daef Mon Sep 17 00:00:00 2001 From: Eldar Iusupzhanov Date: Tue, 28 Jul 2026 15:56:09 +0600 Subject: [PATCH 2/2] fix test --- .../common/aiColumn/adaptivity.functional.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts b/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts index 79aec27a619b..b2abf05e9d12 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/adaptivity.functional.ts @@ -14,19 +14,21 @@ test('The AI column should not hidden when columnHidingEnabled is true', async ( await t.expect(dataGrid.isReady()).ok(); const thirdHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(2); + const fourthHeaderCell = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(3); // assert: the AI column is hidden await t - .expect(dataGrid.getHeaders().getHeaderRow(0).getDataHeaderCells().count) - .eql(3) - .expect(thirdHeaderCell.element.textContent) + .expect(fourthHeaderCell.element.textContent) .eql('AI Column') - .expect(thirdHeaderCell.isHidden) + .expect(fourthHeaderCell.isHidden) .notOk(); // assert: the adaptive button is visible await t - .expect(dataGrid.getDataRow(0).getCommandCell(3).getAdaptiveButton().visible).ok(); + .expect(thirdHeaderCell.isHidden) + .ok() + .expect(dataGrid.getDataRow(0).getCommandCell(4).getAdaptiveButton().visible) + .ok(); }).before(async () => createWidget('dxDataGrid', { dataSource: [ { id: 1, name: 'Name 1', value: 10 },