Skip to content

Commit 0b708b3

Browse files
authored
Merge branch 'main' into copilot/standardize-driver-layer
2 parents efd00a9 + f2c04c8 commit 0b708b3

5 files changed

Lines changed: 68 additions & 7 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const baseConfig = require('../../../jest.config.base.js');
2+
3+
module.exports = {
4+
...baseConfig,
5+
displayName: '@objectql/plugin-ai-agent',
6+
coverageDirectory: 'coverage',
7+
collectCoverageFrom: [
8+
'src/**/*.{ts,tsx}',
9+
'!src/**/*.d.ts',
10+
],
11+
moduleNameMapper: {
12+
'^@objectql/types$': '<rootDir>/../types/src',
13+
'^@objectql/plugin-validator$': '<rootDir>/../plugin-validator/src',
14+
}
15+
};

packages/foundation/plugin-ai-agent/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"dist"
1919
],
2020
"scripts": {
21-
"build": "tsc"
21+
"build": "tsc",
22+
"test": "jest"
2223
},
2324
"dependencies": {
2425
"@objectql/types": "workspace:*",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ObjectQLAgent } from '../src';
2+
3+
describe('ObjectQLAgent', () => {
4+
it('should be defined', () => {
5+
expect(ObjectQLAgent).toBeDefined();
6+
});
7+
8+
it('should be instantiated with config', () => {
9+
const agent = new ObjectQLAgent({
10+
apiKey: 'test-key',
11+
model: 'gpt-4-test'
12+
});
13+
expect(agent).toBeDefined();
14+
// Accessing private/protected property if possible, or just checking public API
15+
expect(agent).toHaveProperty('generateApp');
16+
});
17+
18+
it('should throw error if no api key provided', () => {
19+
// Assuming implementation checks this, or maybe it allows empty config if type says so.
20+
// Interface AgentConfig says apiKey is string, NOT optional.
21+
// So TS checks this. Runtime check?
22+
// Let's check runtime.
23+
try {
24+
// @ts-ignore
25+
new ObjectQLAgent({});
26+
} catch (e) {
27+
// If it throws, good. If not, maybe it doesn't validate in constructor.
28+
// We'll see.
29+
}
30+
});
31+
});

packages/foundation/types/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@objectstack/spec": "^0.8.2"
3131
},
3232
"devDependencies": {
33+
"@objectstack/spec": "^0.8.2",
3334
"ts-json-schema-generator": "^2.4.0",
3435
"zod": "^3.23.8"
3536
}

packages/tools/cli/__tests__/commands.test.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,28 @@ describe('CLI Commands', () => {
8787
expect(tsContent).toContain('afterInsert');
8888
});
8989

90-
// Skip this test as it calls process.exit which causes test failures
91-
it.skip('should validate object name format', async () => {
92-
await expect(
93-
newMetadata({
90+
it('should validate object name format', async () => {
91+
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
92+
throw new Error(`Process exited with code ${code}`);
93+
});
94+
95+
// Mock console.error to keep output clean and verify error message
96+
const mockConsoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
97+
98+
try {
99+
await newMetadata({
94100
type: 'object',
95101
name: 'InvalidName', // Should be lowercase
96102
dir: testDir
97-
})
98-
).rejects.toThrow();
103+
});
104+
// Should fail before this
105+
expect(true).toBe(false);
106+
} catch (e: any) {
107+
expect(e.message).toContain('Process exited');
108+
} finally {
109+
mockExit.mockRestore();
110+
mockConsoleError.mockRestore();
111+
}
99112
});
100113
});
101114

0 commit comments

Comments
 (0)