From 669b4ec13d451239bce47403ed1be6ec93a34ba4 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 2 Oct 2026 10:04:19 +0200 Subject: [PATCH] Improve comment validation --- .../src/app/endpoints/mcp/mcp.schemas.spec.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts b/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts index 2039e7cd91..693e5d6a7e 100644 --- a/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts +++ b/apps/api/src/app/endpoints/mcp/mcp.schemas.spec.ts @@ -1,4 +1,5 @@ import { + COMMENT_MAXIMUM_LENGTH, DEFAULT_DATE_RANGE, MCP_MAX_ACTIVITIES, SEARCH_QUERY_MAXIMUM_LENGTH, @@ -91,6 +92,30 @@ describe('IMPORT_ACTIVITIES_PARAMETERS', () => { return IMPORT_ACTIVITIES_PARAMETERS.safeParse({ activities }).success; } + it(`Accepts a comment of ${COMMENT_MAXIMUM_LENGTH} characters with spaces at the start and the end`, () => { + expect( + parse([ + createActivity({ comment: ` ${'A'.repeat(COMMENT_MAXIMUM_LENGTH)} ` }) + ]) + ).toBe(true); + }); + + it(`Refuses a comment longer than ${COMMENT_MAXIMUM_LENGTH} characters`, () => { + expect( + parse([ + createActivity({ comment: 'A'.repeat(COMMENT_MAXIMUM_LENGTH + 1) }) + ]) + ).toBe(false); + }); + + it('Removes spaces at the start and the end of a comment', () => { + expect( + IMPORT_ACTIVITIES_PARAMETERS.parse({ + activities: [createActivity({ comment: ' note ' })] + }).activities[0].comment + ).toBe('note'); + }); + it('Refuses a currency in lower case', () => { expect(parse([createActivity({ currency: 'usd' })])).toBe(false); });