Skip to content

Commit 42e3146

Browse files
authored
Merge pull request #943 from objectstack-ai/copilot/fix-all-ci-errors-another-one
2 parents 72e9ad2 + e57dd7e commit 42e3146

10 files changed

Lines changed: 183 additions & 158 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
remains lazy (cold-start only) via `ensureApp()` / `ensureKernel()` in `_kernel.ts`.
1616

1717
### Fixed
18+
- **SvelteKit adapter test failures** — Updated test mock to include `dispatch()` method and
19+
aligned Metadata, Data, Error handling, and toResponse test assertions with the unified
20+
catch-all dispatch pattern used by the implementation and all other adapters (e.g. Hono).
21+
Removed obsolete `handleMetadata`/`handleData` references from the mock.
1822
- **Vercel serverless 404 fix** — The previous `api/[...path].ts` path-normalisation fix is now
1923
superseded by the Hono adapter migration above. The new `api/index.ts` entrypoint combined with
2024
Vercel rewrites (`/api/*``/api`) eliminates the routing ambiguity that caused 404s.

packages/adapters/express/src/express.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ const mockDispatcher = {
77
getDiscoveryInfo: vi.fn().mockReturnValue({ version: '1.0', endpoints: [] }),
88
handleAuth: vi.fn().mockResolvedValue({ handled: true, response: { body: { ok: true }, status: 200 } }),
99
handleGraphQL: vi.fn().mockResolvedValue({ data: {} }),
10-
handleMetadata: vi.fn().mockResolvedValue({ handled: true, response: { body: { objects: [] }, status: 200 } }),
11-
handleData: vi.fn().mockResolvedValue({ handled: true, response: { body: { records: [] }, status: 200 } }),
1210
handleStorage: vi.fn().mockResolvedValue({ handled: true, response: { body: {}, status: 200 } }),
11+
dispatch: vi.fn().mockResolvedValue({ handled: true, response: { body: { success: true }, status: 200 } }),
1312
};
1413

1514
vi.mock('@objectstack/runtime', () => {

packages/adapters/fastify/src/fastify.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ const mockDispatcher = {
77
getDiscoveryInfo: vi.fn().mockReturnValue({ version: '1.0', endpoints: [] }),
88
handleAuth: vi.fn().mockResolvedValue({ handled: true, response: { body: { ok: true }, status: 200 } }),
99
handleGraphQL: vi.fn().mockResolvedValue({ data: {} }),
10-
handleMetadata: vi.fn().mockResolvedValue({ handled: true, response: { body: { objects: [] }, status: 200 } }),
11-
handleData: vi.fn().mockResolvedValue({ handled: true, response: { body: { records: [] }, status: 200 } }),
1210
handleStorage: vi.fn().mockResolvedValue({ handled: true, response: { body: {}, status: 200 } }),
11+
dispatch: vi.fn().mockResolvedValue({ handled: true, response: { body: { success: true }, status: 200 } }),
1312
};
1413

1514
vi.mock('@objectstack/runtime', () => {
@@ -91,13 +90,12 @@ describe('objectStackPlugin', () => {
9190

9291
const res = await app.inject({ method: 'GET', url: '/api/meta/objects' });
9392
expect(res.statusCode).toBe(200);
94-
const json = JSON.parse(res.payload);
95-
expect(json.objects).toBeDefined();
96-
expect(mockDispatcher.handleMetadata).toHaveBeenCalledWith(
97-
'/objects',
98-
expect.objectContaining({ request: expect.anything() }),
93+
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
9994
'GET',
95+
'/meta/objects',
10096
undefined,
97+
expect.any(Object),
98+
expect.objectContaining({ request: expect.anything() }),
10199
);
102100
});
103101

@@ -108,12 +106,10 @@ describe('objectStackPlugin', () => {
108106

109107
const res = await app.inject({ method: 'GET', url: '/api/data/account' });
110108
expect(res.statusCode).toBe(200);
111-
const json = JSON.parse(res.payload);
112-
expect(json.records).toBeDefined();
113-
expect(mockDispatcher.handleData).toHaveBeenCalledWith(
114-
'/account',
109+
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
115110
'GET',
116-
{},
111+
'/data/account',
112+
undefined,
117113
expect.any(Object),
118114
expect.objectContaining({ request: expect.anything() }),
119115
);
@@ -148,7 +144,7 @@ describe('objectStackPlugin', () => {
148144
});
149145

150146
it('returns error on exception', async () => {
151-
mockDispatcher.handleData.mockRejectedValueOnce(
147+
mockDispatcher.dispatch.mockRejectedValueOnce(
152148
Object.assign(new Error('Forbidden'), { statusCode: 403 }),
153149
);
154150
const app = Fastify();

packages/adapters/nestjs/src/__mocks__/runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class HttpDispatcher {
88
handleMetadata = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: [] } });
99
handleData = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: [] } });
1010
handleStorage = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: {} } });
11+
dispatch = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: { success: true } } });
1112

1213
constructor(_kernel: any) {}
1314
}

0 commit comments

Comments
 (0)