Skip to content

Commit 89c3074

Browse files
committed
Pressing Clear button clears the cache
1 parent b235160 commit 89c3074

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,6 +3231,54 @@ describe('DropDownButton', () => {
32313231

32323232
expect(instance.columnOption('myColumn', 'ai.prompt')).toBe('');
32333233
});
3234+
3235+
it('should clear cached data', async () => {
3236+
const aiIntegration = new AIIntegration({
3237+
sendRequest(prompt): RequestResult {
3238+
return {
3239+
promise: new Promise<string>((resolve) => {
3240+
const result = {};
3241+
Object.entries(prompt.data?.data).forEach(([key, value]) => {
3242+
result[key] = `Response ${(value as any).name}`;
3243+
});
3244+
resolve(JSON.stringify(result));
3245+
}),
3246+
abort: (): void => {},
3247+
};
3248+
},
3249+
});
3250+
const { component, instance } = await createDataGrid({
3251+
dataSource: [
3252+
{ id: 1, name: 'Name 1', value: 10 },
3253+
],
3254+
keyExpr: 'id',
3255+
columns: [
3256+
{ dataField: 'id', caption: 'ID' },
3257+
{ dataField: 'name', caption: 'Name' },
3258+
{ dataField: 'value', caption: 'Value' },
3259+
{
3260+
type: 'ai',
3261+
caption: 'AI Column',
3262+
name: 'myColumn',
3263+
ai: {
3264+
prompt: 'Initial prompt',
3265+
aiIntegration,
3266+
},
3267+
},
3268+
],
3269+
});
3270+
3271+
jest.runAllTimers();
3272+
await Promise.resolve();
3273+
expect(instance.getAIColumnText('myColumn', 1)).toBe('Response Name 1');
3274+
3275+
const dropDownButton = component.getAIHeaderCell(3).getDropDownButton();
3276+
dropDownButton?.getButtonElement()?.click();
3277+
expect(dropDownButton.isOpened()).toBe(true);
3278+
3279+
dropDownButton.getList()?.getItem(2)?.getElement()?.click();
3280+
expect(instance.getAIColumnText('myColumn', 1)).toBeUndefined();
3281+
});
32343282
});
32353283
});
32363284

0 commit comments

Comments
 (0)