Skip to content

Commit fbb1a7f

Browse files
author
Alyar
committed
Fix resetting prompt via columnOption method
1 parent 774cb1e commit fbb1a7f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

packages/devextreme/js/__internal/grids/grid_core/ai_column/ai_column.integration.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,46 @@ describe('columnOption', () => {
827827
component.apiColumnOption('myColumn', 'type', 'ai');
828828
expect(component.apiColumnOption('myColumn').type).toBe('ai');
829829
});
830+
831+
describe('when prompt is reset', () => {
832+
it('should clear AI column values', async () => {
833+
const { component, instance } = await createDataGrid({
834+
keyExpr: 'id',
835+
dataSource: [
836+
{ id: 1, name: 'Name 1', value: 10 },
837+
],
838+
columns: [
839+
{ dataField: 'id', caption: 'ID' },
840+
{ dataField: 'name', caption: 'Name' },
841+
{ dataField: 'value', caption: 'Value' },
842+
{
843+
type: 'ai',
844+
caption: 'AI Column',
845+
name: 'myColumn',
846+
ai: {
847+
prompt: 'Initial Prompt',
848+
aiIntegration: new AIIntegration({
849+
sendRequest(): RequestResult {
850+
return {
851+
promise: new Promise<string>((resolve) => {
852+
resolve('{"1":"AI Value"}');
853+
}),
854+
abort: (): void => {},
855+
};
856+
},
857+
}),
858+
},
859+
},
860+
],
861+
});
862+
863+
expect(component.getDataCell(0, 3).getText()).toBe('AI Value');
864+
865+
instance.columnOption('myColumn', 'ai.prompt', '');
866+
867+
expect(component.getDataCell(0, 3).getText()).toBe(EMPTY_CELL_TEXT);
868+
});
869+
});
830870
});
831871

832872
describe('aiIntegration', () => {

packages/devextreme/js/__internal/grids/grid_core/ai_column/m_ai_column_controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ export class AIColumnController extends Controller {
188188

189189
if (isPromptOptionName && column.name) {
190190
this.aiColumnIntegrationController.clearAIColumn(column.name);
191+
192+
if (!column.ai?.prompt) {
193+
this.updateAICells();
194+
}
191195
}
192196
}
193197

0 commit comments

Comments
 (0)