Skip to content

Commit 1fdcade

Browse files
committed
One more attempt to fix qunit tests
fix AIAssistantIntegrationController initialization fix type error fix tests after rebase fix after rebase
1 parent c8f094f commit 1fdcade

9 files changed

Lines changed: 66 additions & 41 deletions

File tree

packages/devextreme/js/__internal/grids/data_grid/ai_assistant/ai_assistant_controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { AIAssistantController } from '@ts/grids/grid_core/ai_assistant/ai_assistant_controller';
22
import type { GridCommand } from '@ts/grids/grid_core/ai_assistant/types';
33

4-
import type { DataGridAIAssistantIntegrationController } from './ai_assistant_integration_controller';
4+
import { DataGridAIAssistantIntegrationController } from './ai_assistant_integration_controller';
55
import { dataGridCommands } from './commands/index';
66

77
export class DataGridAIAssistantController extends AIAssistantController {
88
protected aiAssistantIntegrationController?: DataGridAIAssistantIntegrationController;
99

10+
protected getAiAssistantIntegrationController(): DataGridAIAssistantIntegrationController {
11+
return new DataGridAIAssistantIntegrationController(this.component);
12+
}
13+
1014
protected getGridCommandList(): GridCommand[] {
1115
const coreCommands = super.getGridCommandList();
1216

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/__tests__/ai_assistant_controller.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ describe('AIAssistantController', () => {
193193
{ status: 'aborted', message: 'filter aborted' },
194194
]),
195195
abort: jest.fn(),
196+
buildResponseSchema: jest.fn().mockReturnValue({ type: 'object' }),
197+
isExecuting: jest.fn().mockReturnValue(false),
196198
}),
197199
);
198200

199-
const controller = createController({
200-
'aiAssistant.aiIntegration': mockAIIntegration,
201-
});
201+
const controller = createController();
202202

203203
// eslint-disable-next-line @typescript-eslint/no-floating-promises
204204
controller.sendRequestToAI({

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_controller.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class AIAssistantController extends Controller {
3535
private processing = false;
3636

3737
private getCustomizedResponseTitle(
38-
status: MessageStatus.Success | MessageStatus.Failure,
38+
status: MessageStatus,
3939
commandNames: string[],
4040
): string {
4141
// TODO: remove type description, it should be got from d.ts
@@ -232,10 +232,14 @@ export class AIAssistantController extends Controller {
232232
return [...coreCommands];
233233
}
234234

235+
protected getAiAssistantIntegrationController(): AIAssistantIntegrationController {
236+
return new AIAssistantIntegrationController(this.component);
237+
}
238+
235239
public init(): void {
236240
this.gridCommands = new GridCommands(this.component, this.getGridCommandList());
237241
this.messageStore = new ArrayStore<Message, string>({ key: 'id' });
238-
this.aiAssistantIntegrationController = new AIAssistantIntegrationController(this.component);
242+
this.aiAssistantIntegrationController = this.getAiAssistantIntegrationController();
239243
this.aiAssistantIntegrationController.init();
240244
}
241245

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type CustomizeResponseText = (
6262

6363
// TODO: move to d.ts
6464
export type CustomizeResponseTitle = (
65-
status: MessageStatus.Success | MessageStatus.Failure,
65+
status: MessageStatus,
6666
commandNames: string[],
6767
) => string;
6868

packages/devextreme/js/__internal/grids/grid_core/ai_chat/ai_chat.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ describe('AIChat', () => {
548548

549549
const chatConfig = getChatConfig();
550550
const container = document.createElement('div');
551-
const commands: CommandResults = [
551+
const commands: CommandResult[] = [
552552
{ status: 'success', message: 'Sorted Name.' },
553553
{ status: 'aborted', message: 'Filter was aborted.' },
554554
];
@@ -572,7 +572,7 @@ describe('AIChat', () => {
572572

573573
const chatConfig = getChatConfig();
574574
const container = document.createElement('div');
575-
const commands: CommandResults = [
575+
const commands: CommandResult[] = [
576576
{ status: 'aborted', message: 'Filter was aborted.' },
577577
];
578578

packages/devextreme/js/__internal/grids/grid_core/ai_chat/utils.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {
2-
describe, expect, it,
3-
} from '@jest/globals';
1+
import { describe, expect, it } from '@jest/globals';
42
import type { Message } from '@js/ui/chat';
3+
import { MessageStatus } from '@ts/grids/grid_core/ai_assistant/const';
54

6-
import { MessageStatus } from '../ai_assistant/const';
75
import {
86
ABORTED_ITEM_EMOJI, CLASSES, ERROR_ITEM_EMOJI, SUCCESS_ITEM_EMOJI,
97
} from './const';

packages/devextreme/js/__internal/grids/grid_core/ai_chat/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Message } from '@js/ui/chat';
2+
import { MessageStatus } from '@ts/grids/grid_core/ai_assistant/const';
3+
import type { CommandStatus } from '@ts/grids/grid_core/ai_assistant/types';
24

3-
import { MessageStatus } from '../ai_assistant/const';
4-
import type { CommandStatus } from '../ai_assistant/types';
55
import {
66
ABORTED_ITEM_EMOJI, CLASSES, ERROR_ITEM_EMOJI, SUCCESS_ITEM_EMOJI,
77
} from './const';
Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
/**
22
* Minimal zod stub for QUnit / SystemJS tests.
33
*
4-
* Wrapped in AMD define() so SystemJS CSP-production mode can load it.
4+
* Uses System.register format which works with both regular SystemJS
5+
* and CSP-production mode (no eval required).
56
*/
67

7-
define((require, exports) => {
8-
const z = {};
8+
System.register([], (exports) => ({
9+
execute() {
10+
const z = {
11+
// top-level constructors
12+
object: () => z,
13+
string: () => z,
14+
boolean: () => z,
15+
number: () => z,
16+
null: () => z,
17+
enum: () => z,
18+
union: () => z,
19+
array: () => z,
20+
tuple: () => z,
21+
literal: () => z,
22+
record: () => z,
23+
lazy: () => z,
24+
// chain modifiers
25+
optional: () => z,
26+
nullable: () => z,
27+
strict: () => z,
28+
int: () => z,
29+
// eslint-disable-next-line spellcheck/spell-checker
30+
nonnegative: () => z,
31+
min: () => z,
32+
max: () => z,
33+
// validation
34+
safeParse: () => ({ success: true, data: {} }),
35+
};
936

10-
[
11-
// top-level constructors
12-
'object', 'string', 'boolean', 'number', 'null',
13-
'enum', 'union', 'array', 'tuple', 'literal', 'record', 'lazy',
14-
// chain modifiers
15-
'optional', 'nullable', 'strict',
16-
'int', 'nonnegative',
17-
'min', 'max',
18-
// validation
19-
'safeParse',
20-
].forEach((name) => { z[name] = () => z; });
21-
22-
Object.defineProperty(exports, '__esModule', { value: true });
23-
exports.z = z;
24-
exports.default = z;
25-
});
37+
exports('z', z);
38+
exports('default', z);
39+
exports('__esModule', true);
40+
},
41+
}));
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/**
22
* Minimal zod-to-json-schema stub for QUnit / SystemJS tests.
33
*
4-
* Wrapped in AMD define() so SystemJS CSP-production mode can load it.
4+
* Uses System.register format which works with both regular SystemJS
5+
* and CSP-production mode (no eval required).
56
*/
67

7-
define((require, exports) => {
8-
const zodToJsonSchema = () => ({ type: 'object' });
8+
System.register([], (exports) => ({
9+
execute() {
10+
const zodToJsonSchema = () => ({ type: 'object' });
911

10-
Object.defineProperty(exports, '__esModule', { value: true });
11-
exports.zodToJsonSchema = zodToJsonSchema;
12-
exports.default = zodToJsonSchema;
13-
});
12+
exports('zodToJsonSchema', zodToJsonSchema);
13+
exports('default', zodToJsonSchema);
14+
exports('__esModule', true);
15+
},
16+
}));

0 commit comments

Comments
 (0)