Skip to content

Commit d16fbd5

Browse files
authored
Merge pull request #416 from objectstack-ai/copilot/fix-test-errors
2 parents c52021b + ae2fd24 commit d16fbd5

File tree

8 files changed

+40
-35
lines changed

8 files changed

+40
-35
lines changed

ROADMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ ObjectQL is the **Standard Protocol for AI Software Generation** — a universal
8888
- ✅ 67 documentation files (.mdx) across 12 sections
8989
-`@objectql/driver-turso` — Turso/libSQL driver (Phase A: Core Driver) with 125 tests, 3 connection modes (remote, local, embedded replica)
9090
-`@objectql/driver-turso` — Phase B: Multi-Tenant Router, Schema Diff Engine, Platform API Client, Driver Plugin (52 new tests, 177 total)
91+
- ✅ Fix test quality: replaced all `expect(true).toBe(true)` placeholder assertions with meaningful state checks across `plugin-optimizations`, `protocol-odata-v4`, `protocol-json-rpc`, and `protocol-graphql` (7 files, 10 assertions fixed)
9192

9293
---
9394

packages/foundation/plugin-optimizations/test/optimizations.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,9 @@ describe('SQLQueryOptimizer', () => {
700700
fields: { name: { type: 'text' } },
701701
indexes: [{ name: 'idx_name', fields: ['name'], unique: false }],
702702
});
703-
// No error is the assertion
704-
expect(true).toBe(true);
703+
// Verify the schema was registered by observing optimize behavior
704+
const sql = optimizer.optimize({ object: 'accounts' });
705+
expect(sql).toContain('accounts');
705706
});
706707
});
707708

packages/protocols/graphql/src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ describe('GraphQLPlugin', () => {
6565
it('should install successfully', async () => {
6666
await plugin.install?.({ engine: kernel });
6767

68-
// Plugin should be installed without errors
69-
expect(true).toBe(true);
68+
// Verify the engine reference was stored after installation
69+
expect((plugin as any).engine).toBeDefined();
7070
});
7171
});
7272

packages/protocols/graphql/src/integration.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,11 @@ describe('GraphQL Protocol Integration Tests', () => {
298298
describe('Error Handling', () => {
299299
it('should handle invalid object name', async () => {
300300
try {
301-
await kernel.repository.find('nonexistent', {});
302-
// If no error is thrown, the test should still pass
303-
// as some drivers may return empty results
304-
expect(true).toBe(true);
301+
const result = await kernel.repository.find('nonexistent', {});
302+
// Driver returns an empty array for unknown collections
303+
expect(Array.isArray(result)).toBe(true);
305304
} catch (error) {
306-
// Error is also acceptable
305+
// Error is also acceptable — some drivers throw for unknown objects
307306
expect(error).toBeDefined();
308307
}
309308
});

packages/protocols/json-rpc/src/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ describe('JSONRPCPlugin', () => {
6666
it('should install successfully', async () => {
6767
await plugin.install?.({ engine: kernel });
6868

69-
// Plugin should be installed without errors
70-
expect(true).toBe(true);
69+
// Verify the engine reference was stored after installation
70+
expect((plugin as any).engine).toBeDefined();
7171
});
7272

7373
it('should start and stop successfully', async () => {
7474
await plugin.install?.({ engine: kernel });
7575
await plugin.onStart?.({ engine: kernel });
7676

77-
// Plugin should start without errors
78-
expect(true).toBe(true);
77+
// Verify the HTTP server was created and is listening
78+
expect((plugin as any).server?.listening).toBe(true);
7979

8080
await plugin.onStop?.({ engine: kernel });
8181

82-
// Plugin should stop without errors
83-
expect(true).toBe(true);
82+
// Verify the HTTP server stopped accepting connections
83+
expect((plugin as any).server?.listening).toBe(false);
8484
});
8585
});
8686

packages/protocols/json-rpc/src/integration.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,9 @@ describe('JSON-RPC 2.0 Protocol Integration Tests', () => {
290290
it('should handle method not found (-32601)', async () => {
291291
try {
292292
// Simulate calling non-existent method
293-
await kernel.repository.find('nonexistent', {});
294-
expect(true).toBe(true); // Driver may return empty
293+
const result = await kernel.repository.find('nonexistent', {});
294+
// Driver returns empty array for unknown collections
295+
expect(Array.isArray(result)).toBe(true);
295296
} catch (error) {
296297
expect(error).toBeDefined();
297298
}
@@ -311,11 +312,11 @@ describe('JSON-RPC 2.0 Protocol Integration Tests', () => {
311312

312313
it('should handle application errors', async () => {
313314
try {
314-
await kernel.repository.update('tasks', 'non-existent', {
315+
const result = await kernel.repository.update('tasks', 'non-existent', {
315316
title: 'Updated'
316317
});
317-
// May return null or throw
318-
expect(true).toBe(true);
318+
// MemoryDriver returns null for non-existent records in non-strict mode
319+
expect(result).toBeNull();
319320
} catch (error) {
320321
expect(error).toBeDefined();
321322
}
@@ -559,17 +560,19 @@ describe('JSON-RPC 2.0 Protocol Integration Tests', () => {
559560
describe('Error Handling and Recovery', () => {
560561
it('should handle null parameters gracefully', async () => {
561562
try {
562-
await kernel.repository.find('tasks', null as any);
563-
expect(true).toBe(true);
563+
const result = await kernel.repository.find('tasks', null as any);
564+
// Driver handles null query gracefully — returns records or empty array
565+
expect(result).toBeDefined();
564566
} catch (error) {
565567
expect(error).toBeDefined();
566568
}
567569
});
568570

569571
it('should handle empty object name', async () => {
570572
try {
571-
await kernel.repository.find('', {});
572-
expect(true).toBe(true);
573+
const result = await kernel.repository.find('', {});
574+
// Driver returns empty array for unknown/empty collection names
575+
expect(Array.isArray(result)).toBe(true);
573576
} catch (error) {
574577
expect(error).toBeDefined();
575578
}

packages/protocols/odata-v4/src/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ describe('ODataV4Plugin', () => {
6767
it('should install successfully', async () => {
6868
await plugin.install?.({ engine: kernel });
6969

70-
// Plugin should be installed without errors
71-
expect(true).toBe(true);
70+
// Verify the engine reference was stored after installation
71+
expect((plugin as any).engine).toBeDefined();
7272
});
7373

7474
it('should start and stop successfully', async () => {
7575
await plugin.install?.({ engine: kernel });
7676
await plugin.onStart?.({ engine: kernel });
7777

78-
// Plugin should start without errors
79-
expect(true).toBe(true);
78+
// Verify the HTTP server was created and is listening
79+
expect((plugin as any).server).toBeDefined();
8080

8181
await plugin.onStop?.({ engine: kernel });
8282

83-
// Plugin should stop without errors
84-
expect(true).toBe(true);
83+
// Verify the HTTP server was torn down
84+
expect((plugin as any).server).toBeUndefined();
8585
});
8686
});
8787

packages/protocols/odata-v4/src/integration.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ describe('OData V4 Protocol Integration Tests', () => {
385385
describe('Error Response Format', () => {
386386
it('should handle invalid entity set', async () => {
387387
try {
388-
await kernel.repository.find('NonExistent', {});
389-
// If no error, that's fine - driver returns empty
390-
expect(true).toBe(true);
388+
const result = await kernel.repository.find('NonExistent', {});
389+
// Driver returns an empty array for unknown collections
390+
expect(Array.isArray(result)).toBe(true);
391391
} catch (error: any) {
392392
// Error should have proper structure
393393
expect(error).toBeDefined();
@@ -421,8 +421,9 @@ describe('OData V4 Protocol Integration Tests', () => {
421421
it('should handle malformed requests', async () => {
422422
try {
423423
// Pass invalid query format
424-
await kernel.repository.find('Products', null as any);
425-
expect(true).toBe(true);
424+
const result = await kernel.repository.find('Products', null as any);
425+
// Driver handles null query gracefully — returns records or empty array
426+
expect(result).toBeDefined();
426427
} catch (error) {
427428
expect(error).toBeDefined();
428429
}

0 commit comments

Comments
 (0)