From f8a0d13d707fd601b793ff9dea9ec532719fb5b7 Mon Sep 17 00:00:00 2001 From: Aniket Kumar <86551851+aniketkrs@users.noreply.github.com> Date: Tue, 13 Oct 2026 17:49:47 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20fix:=20show=20matching=20prompts?= =?UTF-8?q?=20when=20typing=20commands=20in=20the=20slash=20menu=20(#17046?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(prompts): include command in prompt group list projections * test(prompts): add regression tests for command in list projections * test(prompts): add required production ID to list fixture --------- Co-authored-by: Atef Bellaaj --- .../data-schemas/src/methods/prompt.spec.ts | 42 +++++++++++++++++++ packages/data-schemas/src/methods/prompt.ts | 4 +- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/packages/data-schemas/src/methods/prompt.spec.ts b/packages/data-schemas/src/methods/prompt.spec.ts index 60e7f36a26..6334e6b229 100644 --- a/packages/data-schemas/src/methods/prompt.spec.ts +++ b/packages/data-schemas/src/methods/prompt.spec.ts @@ -767,3 +767,45 @@ describe('Prompt method failure contracts', () => { expect(all.data).toHaveLength(2); }); }); + +describe('Prompt group list projections include `command`', () => { + let commandGroupId: string; + + beforeEach(async () => { + const group = ( + await PromptGroup.create({ + name: 'Command Projection Group', + command: 'mytest-cmd', + productionId: new ObjectId(), + author: testUsers.owner._id, + authorName: testUsers.owner.name, + }) + ).toObject() as unknown as LeanPromptGroup; + commandGroupId = String(group._id); + }); + + afterEach(async () => { + await PromptGroup.deleteMany({}); + }); + + it('getPromptGroups includes command in the list projection', async () => { + const result = await methods.getPromptGroups({ + pageNumber: 1, + pageSize: 10, + name: 'Command Projection', + }); + if (!('promptGroups' in result)) { + throw new Error(`Expected prompt groups, received: ${JSON.stringify(result)}`); + } + expect(result.promptGroups).toHaveLength(1); + expect(result.promptGroups[0].command).toBe('mytest-cmd'); + }); + + it('getListPromptGroupsByAccess includes command in the list projection', async () => { + const result = await methods.getListPromptGroupsByAccess({ + accessibleIds: [commandGroupId], + }); + expect(result.data).toHaveLength(1); + expect(result.data[0].command).toBe('mytest-cmd'); + }); +}); diff --git a/packages/data-schemas/src/methods/prompt.ts b/packages/data-schemas/src/methods/prompt.ts index a7aba67d98..8848f76d5c 100644 --- a/packages/data-schemas/src/methods/prompt.ts +++ b/packages/data-schemas/src/methods/prompt.ts @@ -310,7 +310,7 @@ export function createPromptMethods( .skip(skip) .limit(limit) .select( - 'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt', + 'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt command', ) .lean(), PromptGroup.countDocuments(query), @@ -450,7 +450,7 @@ export function createPromptMethods( const findQuery = PromptGroup.find(matchQuery) .sort({ numberOfGenerations: -1, updatedAt: -1, _id: 1 }) .select( - 'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt', + 'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt command', ); if (isPaginated && normalizedLimit) {