import { readFileSync } from 'node:fs'; import { join, resolve } from 'node:path'; describe('checked-in OpenAPI frontend types', () => { const rootDir = resolve(process.cwd(), '../..'); const frontendTypes = readFileSync(join(rootDir, 'apps/frontend/src/api/types.ts'), 'utf8'); const requiredPaths = [ '/api/v1/auth/register', '/api/v1/auth/login', '/api/v1/auth/refresh', '/api/v1/auth/logout', '/api/v1/auth/me', '/api/v1/securities/screener', '/api/v1/portfolios', '/api/v1/portfolios/{id}', '/api/v1/portfolios/{id}/positions', '/api/v1/portfolios/{id}/positions/{positionId}', '/api/v1/portfolios/{id}/analytics', ]; it('frontend generated types include current protected domains', () => { for (const path of requiredPaths) { expect(frontendTypes).toContain(`'${path}'`); } }); it('frontend generated types do not leak the local alternate codegen port', () => { expect(frontendTypes).not.toContain('localhost:3001'); expect(frontendTypes).not.toContain('3001'); }); it('frontend generated types include typed operations for current protected domains', () => { const requiredOperations = [ 'AuthController_register', 'AuthController_login', 'AuthController_refresh', 'AuthController_logout', 'AuthController_getProfile', 'AuthController_updateProfile', 'SecuritiesController_screener', 'PortfolioController_findAll', 'PortfolioController_create', 'PortfolioController_findOne', 'PortfolioController_update', 'PortfolioController_remove', 'PortfolioController_addPosition', 'PortfolioController_updatePosition', 'PortfolioController_removePosition', 'PortfolioController_getAnalytics', ]; for (const operation of requiredOperations) { expect(frontendTypes).toContain(`operations['${operation}']`); } }); });