feat: Implement Prompt Builder functionality in Popup and Options
Some checks failed
CI — Test & Build / Test & Build (push) Failing after 39s
Some checks failed
CI — Test & Build / Test & Build (push) Failing after 39s
- Added a new "Prompt Builder" tab in the Popup for generating AI prompts with customizable parameters. - Introduced new state variables for managing prompt styles, personas, formats, and models. - Enhanced the Options page to fetch and display models based on the provided API key. - Updated the actions and types to include the new 'prompt' action and its associated parameters. - Implemented migration logic for legacy plaintext API keys to encrypted storage. - Updated the getSystemPrompt function to incorporate prompt parameters for better instruction generation. - Added tests for the new functionality, including context menu entries and prompt generation logic.
This commit is contained in:
@@ -9,9 +9,12 @@ import {
|
||||
} from '@lib/actions';
|
||||
|
||||
describe('context-menu registry', () => {
|
||||
it('contains 5 parents + 5x5 style children = 30 entries (parity with old loops)', () => {
|
||||
expect(CONTEXT_MENU_ENTRIES).toHaveLength(30);
|
||||
it('contains one parent per action + style children for all actions except prompt', () => {
|
||||
const styledActions = ACTIONS.filter((a) => a !== 'prompt');
|
||||
expect(CONTEXT_MENU_ENTRIES).toHaveLength(ACTIONS.length + styledActions.length * CONTEXT_MENU_STYLES.length);
|
||||
expect(CONTEXT_MENU_ENTRIES.filter((e) => !e.parentId)).toHaveLength(ACTIONS.length);
|
||||
// prompt is a single item — its parameters live in the Prompt Builder dialog
|
||||
expect(CONTEXT_MENU_ENTRIES.filter((e) => e.parentId === 'lexai-prompt')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('every parent precedes its children (contextMenus.create ordering)', () => {
|
||||
@@ -31,6 +34,7 @@ describe('context-menu registry', () => {
|
||||
expect(parent).toMatchObject({ action, style: 'Default' });
|
||||
expect(parent!.title).toBe(`⚡ LexAI: ${ACTION_LABELS[action]}`);
|
||||
|
||||
if (action === 'prompt') continue; // no style children — see registry comment
|
||||
for (const style of CONTEXT_MENU_STYLES) {
|
||||
const child = findContextMenuEntry(`lexai-${action}-${style.toLowerCase()}`);
|
||||
expect(child).toMatchObject({ action, style, parentId: `lexai-${action}`, title: style });
|
||||
|
||||
Reference in New Issue
Block a user