diff --git a/CHANGELOG.md b/CHANGELOG.md index bba7637f8..de65e0e9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 remains lazy (cold-start only) via `ensureApp()` / `ensureKernel()` in `_kernel.ts`. ### Fixed +- **Service-analytics build error (TS6133)** — Removed unused `measure` variable in + `native-sql-strategy.ts` that caused the DTS build to fail with `noUnusedLocals` enabled, + blocking the entire CI build pipeline. +- **Next.js adapter test failures** — Updated 9 metadata API test assertions to match the + current `dispatch(method, path, body, queryParams, context)` call signature used by the + implementation. Tests were still expecting the old `dispatch(subPath, context, method, body)` + signature. +- **Auth plugin test failures** — Fixed 2 tests in `auth-plugin.test.ts` that referenced the + wrong `AuthManager` instance via `registerService.mock.calls`. Added `mockClear()` before + local plugin init to ensure `mock.calls[0]` points to the correct AuthManager for the test's + plugin instance. - **SvelteKit adapter test failures** — Updated test mock to include `dispatch()` method and aligned Metadata, Data, Error handling, and toResponse test assertions with the unified catch-all dispatch pattern used by the implementation and all other adapters (e.g. Hono). diff --git a/packages/adapters/nextjs/src/metadata-api.test.ts b/packages/adapters/nextjs/src/metadata-api.test.ts index c1379bfbe..2853084a3 100644 --- a/packages/adapters/nextjs/src/metadata-api.test.ts +++ b/packages/adapters/nextjs/src/metadata-api.test.ts @@ -127,10 +127,11 @@ describe('Next.js Metadata API Integration Tests', () => { expect(res.status).toBe(200); expect(res.body.data).toHaveLength(2); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'objects', - expect.objectContaining({ request: expect.anything() }), 'GET', + '/meta/objects', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); }); @@ -153,10 +154,11 @@ describe('Next.js Metadata API Integration Tests', () => { expect(res.status).toBe(200); expect(res.body.data.name).toBe('account'); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'objects/account', - expect.objectContaining({ request: expect.anything() }), 'GET', + '/meta/objects/account', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); }); @@ -178,10 +180,11 @@ describe('Next.js Metadata API Integration Tests', () => { const res = await handler(req, { params: { objectstack: ['meta', 'objects'] } }); expect(res.status).toBe(201); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'objects', - expect.objectContaining({ request: expect.anything() }), 'POST', + '/meta/objects', body, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); }); @@ -199,10 +202,11 @@ describe('Next.js Metadata API Integration Tests', () => { const res = await handler(req, { params: { objectstack: ['meta', 'objects', 'account'] } }); expect(res.status).toBe(200); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'objects/account', - expect.objectContaining({ request: expect.anything() }), 'PUT', + '/meta/objects/account', body, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); }); @@ -229,10 +233,11 @@ describe('Next.js Metadata API Integration Tests', () => { const req = makeReq('http://localhost/api/meta/views'); await handler(req, { params: { objectstack: ['meta', 'views'] } }); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'views', - expect.objectContaining({ request: expect.anything() }), 'GET', + '/meta/views', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); @@ -240,10 +245,11 @@ describe('Next.js Metadata API Integration Tests', () => { const req = makeReq('http://localhost/api/meta/flows'); await handler(req, { params: { objectstack: ['meta', 'flows'] } }); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'flows', - expect.objectContaining({ request: expect.anything() }), 'GET', + '/meta/flows', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); @@ -251,10 +257,11 @@ describe('Next.js Metadata API Integration Tests', () => { const req = makeReq('http://localhost/api/meta/agents'); await handler(req, { params: { objectstack: ['meta', 'agents'] } }); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'agents', - expect.objectContaining({ request: expect.anything() }), 'GET', + '/meta/agents', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); }); @@ -684,10 +691,11 @@ describe('Next.js Metadata API Integration Tests', () => { const req = makeReq('http://localhost/api/meta/objects/account/fields/name'); await handler(req, { params: { objectstack: ['meta', 'objects', 'account', 'fields', 'name'] } }); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - 'objects/account/fields/name', - expect.any(Object), 'GET', + '/meta/objects/account/fields/name', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); @@ -696,10 +704,11 @@ describe('Next.js Metadata API Integration Tests', () => { // With just ['meta'], subPath becomes empty after slice(1) await handler(req, { params: { objectstack: ['meta'] } }); expect(mockDispatcher.dispatch).toHaveBeenCalledWith( - '', - expect.any(Object), 'GET', + '/meta', undefined, + {}, + expect.objectContaining({ request: expect.anything() }), ); }); }); diff --git a/packages/plugins/plugin-auth/src/auth-plugin.test.ts b/packages/plugins/plugin-auth/src/auth-plugin.test.ts index 56229f6f1..bf0551368 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.test.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.test.ts @@ -299,6 +299,7 @@ describe('AuthPlugin', () => { baseUrl: 'http://localhost:3000', }); mockContext.hook = localHookCapture.hookFn; + (mockContext.registerService as any).mockClear(); await localPlugin.init(mockContext); const mockRawApp = { all: vi.fn() }; @@ -314,7 +315,7 @@ describe('AuthPlugin', () => { throw new Error(`Service not found: ${name}`); }); - const registeredAuthManager = (mockContext.registerService as any).mock.calls.at(-1)[1]; + const registeredAuthManager = (mockContext.registerService as any).mock.calls[0][1]; const setRuntimeSpy = vi.spyOn(registeredAuthManager, 'setRuntimeBaseUrl'); await localPlugin.start(mockContext); @@ -330,6 +331,7 @@ describe('AuthPlugin', () => { secret: 'test-secret-at-least-32-chars-long', }); mockContext.hook = localHookCapture.hookFn; + (mockContext.registerService as any).mockClear(); await localPlugin.init(mockContext); const mockRawApp = { all: vi.fn() }; @@ -345,7 +347,7 @@ describe('AuthPlugin', () => { throw new Error(`Service not found: ${name}`); }); - const registeredAuthManager = (mockContext.registerService as any).mock.calls.at(-1)[1]; + const registeredAuthManager = (mockContext.registerService as any).mock.calls[0][1]; const setRuntimeSpy = vi.spyOn(registeredAuthManager, 'setRuntimeBaseUrl'); await localPlugin.start(mockContext); diff --git a/packages/services/service-analytics/src/strategies/native-sql-strategy.ts b/packages/services/service-analytics/src/strategies/native-sql-strategy.ts index 9e121ced2..617e65f84 100644 --- a/packages/services/service-analytics/src/strategies/native-sql-strategy.ts +++ b/packages/services/service-analytics/src/strategies/native-sql-strategy.ts @@ -176,8 +176,6 @@ export class NativeSQLStrategy implements AnalyticsStrategy { } if (query.measures) { for (const m of query.measures) { - const fieldName = m.includes('.') ? m.split('.')[1] : m; - const measure = cube.measures[fieldName]; fields.push({ name: m, type: 'number' }); } }