diff --git a/apps/chat-e2e/src/assertions/api/apiAssertion.ts b/apps/chat-e2e/src/assertions/api/apiAssertion.ts index 886b89df1c..08d3a9d169 100644 --- a/apps/chat-e2e/src/assertions/api/apiAssertion.ts +++ b/apps/chat-e2e/src/assertions/api/apiAssertion.ts @@ -1,5 +1,6 @@ import { ChatBody } from '@/chat/types/chat'; import { DialAIEntityModel } from '@/chat/types/models'; +import { Prompt } from '@/chat/types/prompt'; import { ExpectedConstants, ExpectedMessages } from '@/src/testData'; import { expect } from '@playwright/test'; import { APIResponse } from 'playwright-core'; @@ -102,4 +103,31 @@ export class ApiAssertion { .toBeDefined(); } } + + public async assertRequestPromptName(request: Prompt, expectedValue: string) { + expect + .soft(request.name, ExpectedMessages.promptRequestNameIsValid) + .toBe(expectedValue); + } + + public async assertRequestPromptDescription( + request: Prompt, + expectedValue: string, + ) { + expect + .soft( + request.description, + ExpectedMessages.promptRequestDescriptionIsValid, + ) + .toBe(expectedValue); + } + + public async assertRequestPromptContent( + request: Prompt, + expectedValue: string, + ) { + expect + .soft(request.content, ExpectedMessages.promptRequestContentIsValid) + .toBe(expectedValue); + } } diff --git a/apps/chat-e2e/src/assertions/promptListAssertion.ts b/apps/chat-e2e/src/assertions/promptListAssertion.ts index e7f39d62ed..432262c7ac 100644 --- a/apps/chat-e2e/src/assertions/promptListAssertion.ts +++ b/apps/chat-e2e/src/assertions/promptListAssertion.ts @@ -10,13 +10,16 @@ export class PromptListAssertion { this.promptList = promptList; } - public async assertPromptOptionOverflow(name: string) { + public async assertPromptOptionOverflow( + name: string, + expectedOverflow: Overflow, + ) { const promptOptionOverflow = await this.promptList .getPromptOption(name) .getComputedStyleProperty(Styles.text_overflow); expect .soft(promptOptionOverflow[0], ExpectedMessages.entityNameIsTruncated) - .toBe(Overflow.ellipsis); + .toBe(expectedOverflow); } public async assertPromptListState(expectedState: ElementState) { @@ -35,12 +38,24 @@ export class PromptListAssertion { .toBeHidden(); } - public async assertPromptListOptions(expectedOptions: string[]) { - expect - .soft( - await this.promptList.getPromptOptions().getElementsInnerContent(), - ExpectedMessages.promptListValuesIsValid, - ) - .toEqual(expectedOptions); + public async assertPromptListOptions( + expectedIncludedOptions: string[], + expectedExcludedOptions?: string[], + ) { + const listOptions = await this.promptList + .getPromptOptions() + .getElementsInnerContent(); + for (const includedOption of expectedIncludedOptions) { + expect + .soft(listOptions, ExpectedMessages.promptListValuesIsValid) + .toContain(includedOption); + } + if (expectedExcludedOptions) { + for (const excludedOption of expectedExcludedOptions) { + expect + .soft(listOptions, ExpectedMessages.promptListValuesIsValid) + .not.toContain(excludedOption); + } + } } } diff --git a/apps/chat-e2e/src/assertions/sendMessageAssertion.ts b/apps/chat-e2e/src/assertions/sendMessageAssertion.ts index aa58870d43..8d4160255c 100644 --- a/apps/chat-e2e/src/assertions/sendMessageAssertion.ts +++ b/apps/chat-e2e/src/assertions/sendMessageAssertion.ts @@ -26,11 +26,11 @@ export class SendMessageAssertion { .toBe(initialWidth); } - public async assertMessageValue(expectedValue: string) { + public async assertMessageValue(expectedValue: string | undefined) { const messageValue = await this.sendMessage.getMessage(); expect .soft(messageValue, ExpectedMessages.messageContentIsValid) - .toBe(expectedValue); + .toBe(expectedValue ?? ''); } public async assertContinueReplayButtonState(expectedState: ElementState) { diff --git a/apps/chat-e2e/src/core/dialSharedWithMeFixtures.ts b/apps/chat-e2e/src/core/dialSharedWithMeFixtures.ts index 2afeb74835..e8c69eb06b 100644 --- a/apps/chat-e2e/src/core/dialSharedWithMeFixtures.ts +++ b/apps/chat-e2e/src/core/dialSharedWithMeFixtures.ts @@ -12,6 +12,7 @@ import { Conversations, DropdownMenu, EntitySelector, + EntitySettings, ErrorToast, FolderPrompts, PromptBar, @@ -26,9 +27,11 @@ import { import config from '@/config/chat.playwright.config'; import { ConfirmationDialogAssertion } from '@/src/assertions/confirmationDialogAssertion'; +import { EntitySettingAssertion } from '@/src/assertions/entitySettingAssertion'; import { FolderAssertion } from '@/src/assertions/folderAssertion'; import { MenuAssertion } from '@/src/assertions/menuAssertion'; import { PromptAssertion } from '@/src/assertions/promptAssertion'; +import { PromptListAssertion } from '@/src/assertions/promptListAssertion'; import { PromptModalAssertion } from '@/src/assertions/promptModalAssertion'; import { SendMessageAssertion } from '@/src/assertions/sendMessageAssertion'; import { SharedPromptPreviewModalAssertion } from '@/src/assertions/sharedPromptPreviewModalAssertion'; @@ -58,6 +61,7 @@ const dialSharedWithMeTest = dialTest.extend<{ additionalShareUserSharedFolderPrompts: SharedFolderPrompts; additionalShareUserChat: Chat; additionalShareUserConversationSettings: ConversationSettings; + additionalShareUserEntitySettings: EntitySettings; additionalShareUserTalkToSelector: EntitySelector; additionalShareUserRecentEntities: RecentEntities; additionalShareUserChatHeader: ChatHeader; @@ -91,6 +95,9 @@ const dialSharedWithMeTest = dialTest.extend<{ additionalShareUserConfirmationDialogAssertion: ConfirmationDialogAssertion; additionalShareUserPromptAssertion: PromptAssertion; additionalShareUserPromptModalAssertion: PromptModalAssertion; + additionalShareUserPromptBarFolderAssertion: FolderAssertion; + additionalShareUserSystemPromptListAssertion: PromptListAssertion; + additionalShareUserEntitySettingAssertion: EntitySettingAssertion; }>({ additionalShareUserPage: async ({ browser }, use) => { const context = await browser.newContext({ @@ -208,6 +215,14 @@ const dialSharedWithMeTest = dialTest.extend<{ additionalShareUserAppContainer.getConversationSettings(); await use(additionalShareUserConversationSettings); }, + additionalShareUserEntitySettings: async ( + { additionalShareUserConversationSettings }, + use, + ) => { + const additionalShareUserEntitySettings = + additionalShareUserConversationSettings.getEntitySettings(); + await use(additionalShareUserEntitySettings); + }, additionalShareUserTalkToSelector: async ( { additionalShareUserConversationSettings }, use, @@ -441,6 +456,33 @@ const dialSharedWithMeTest = dialTest.extend<{ ); await use(additionalShareUserPromptModalAssertion); }, + additionalShareUserPromptBarFolderAssertion: async ( + { additionalShareUserFolderPrompts }, + use, + ) => { + const additionalShareUserPromptBarFolderAssertion = new FolderAssertion( + additionalShareUserFolderPrompts, + ); + await use(additionalShareUserPromptBarFolderAssertion); + }, + additionalShareUserSystemPromptListAssertion: async ( + { additionalShareUserEntitySettings }, + use, + ) => { + const additionalShareUserSystemPromptListAssertion = + new PromptListAssertion( + additionalShareUserEntitySettings.getPromptList(), + ); + await use(additionalShareUserSystemPromptListAssertion); + }, + additionalShareUserEntitySettingAssertion: async ( + { additionalShareUserEntitySettings }, + use, + ) => { + const additionalShareUserEntitySettingAssertion = + new EntitySettingAssertion(additionalShareUserEntitySettings); + await use(additionalShareUserEntitySettingAssertion); + }, }); export let shareUserBucket: string; diff --git a/apps/chat-e2e/src/testData/expectedMessages.ts b/apps/chat-e2e/src/testData/expectedMessages.ts index c8a2b17ea0..a00db4abee 100644 --- a/apps/chat-e2e/src/testData/expectedMessages.ts +++ b/apps/chat-e2e/src/testData/expectedMessages.ts @@ -91,6 +91,9 @@ export enum ExpectedMessages { chatRequestAddonsAreValid = 'Chat API request addons are valid', chatRequestMessageIsValid = 'Chat API request message is valid', chatRequestAttachmentIsValid = 'Chat API request attachment is valid', + promptRequestNameIsValid = 'Prompt API request name is valid', + promptRequestDescriptionIsValid = 'Prompt API request description is valid', + promptRequestContentIsValid = 'Prompt API request content is valid', sendMessageButtonDisabled = 'Send message button is disabled', sendMessageButtonEnabled = 'Send message button is enabled', tooltipContentIsValid = 'Tooltip content is valid', diff --git a/apps/chat-e2e/src/tests/compareMode.test.ts b/apps/chat-e2e/src/tests/compareMode.test.ts index b5b51fa2bc..68f291b4c7 100644 --- a/apps/chat-e2e/src/tests/compareMode.test.ts +++ b/apps/chat-e2e/src/tests/compareMode.test.ts @@ -722,7 +722,7 @@ dialTest( .selectModel(firstUpdatedRandomModel); const leftEntitySettings = leftConversationSettings.getEntitySettings(); if (firstUpdatedRandomModel.features?.systemPrompt) { - await leftEntitySettings.setSystemPrompt(firstUpdatedPrompt); + await leftEntitySettings.clearAndSetSystemPrompt(firstUpdatedPrompt); } await leftEntitySettings .getTemperatureSlider() @@ -734,7 +734,9 @@ dialTest( const rightEntitySettings = rightConversationSettings.getEntitySettings(); if (secondUpdatedRandomModel.features?.systemPrompt) { - await rightEntitySettings.setSystemPrompt(secondUpdatedPrompt); + await rightEntitySettings.clearAndSetSystemPrompt( + secondUpdatedPrompt, + ); } await rightEntitySettings .getTemperatureSlider() diff --git a/apps/chat-e2e/src/tests/duplicateSharedPrompts.test.ts b/apps/chat-e2e/src/tests/duplicateSharedPrompts.test.ts new file mode 100644 index 0000000000..2452ac381c --- /dev/null +++ b/apps/chat-e2e/src/tests/duplicateSharedPrompts.test.ts @@ -0,0 +1,118 @@ +import { ShareByLinkResponseModel } from '@/chat/types/share'; +import dialSharedWithMeTest from '@/src/core/dialSharedWithMeFixtures'; +import { ExpectedConstants, FolderPrompt, MenuOptions } from '@/src/testData'; + +dialSharedWithMeTest( + 'Shared with me. Duplicate prompt.\n' + + 'Shared with me. Move duplicated prompt to New folder', + async ({ + additionalShareUserDialHomePage, + promptData, + dataInjector, + mainUserShareApiHelper, + additionalUserShareApiHelper, + additionalShareUserSharedFolderPrompts, + additionalShareUserSharedWithMePromptDropdownMenu, + additionalShareUserPrompts, + additionalShareUserPromptBarFolderAssertion, + additionalShareUserPromptDropdownMenu, + additionalShareUserFolderPrompts, + additionalShareUserPromptAssertion, + setTestIds, + }) => { + setTestIds('EPMRTC-1872', 'EPMRTC-2037'); + let folderPrompt: FolderPrompt; + let promptName: string; + let shareFolderByLinkResponse: ShareByLinkResponseModel; + + await dialSharedWithMeTest.step( + 'Prepare folder with prompt and share it', + async () => { + folderPrompt = promptData.prepareDefaultPromptInFolder(); + promptName = folderPrompt.prompts[0].name; + await dataInjector.createPrompts( + folderPrompt.prompts, + folderPrompt.folders, + ); + shareFolderByLinkResponse = + await mainUserShareApiHelper.shareEntityByLink( + folderPrompt.prompts, + true, + ); + await additionalUserShareApiHelper.acceptInvite( + shareFolderByLinkResponse, + ); + }, + ); + + await dialSharedWithMeTest.step( + 'Select "Duplicate" option in dropdown menu for shared folder prompt and verify prompt is duplicated in Recent section', + async () => { + await additionalShareUserDialHomePage.openHomePage(); + await additionalShareUserDialHomePage.waitForPageLoaded({ + isNewConversationVisible: true, + }); + await additionalShareUserSharedFolderPrompts.expandFolder( + folderPrompt.folders.name, + { isHttpMethodTriggered: true }, + ); + await additionalShareUserSharedFolderPrompts.openFolderEntityDropdownMenu( + folderPrompt.folders.name, + promptName, + ); + await additionalShareUserSharedWithMePromptDropdownMenu.selectMenuOption( + MenuOptions.duplicate, + { triggeredHttpMethod: 'POST' }, + ); + await additionalShareUserPromptAssertion.assertEntityState( + { name: promptName }, + 'visible', + ); + }, + ); + + await dialSharedWithMeTest.step( + 'Verify prompts with incremented names are created on duplication', + async () => { + for (let i = 1; i <= 2; i++) { + await additionalShareUserSharedFolderPrompts.openFolderEntityDropdownMenu( + folderPrompt.folders.name, + promptName, + ); + await additionalShareUserSharedWithMePromptDropdownMenu.selectMenuOption( + MenuOptions.duplicate, + { triggeredHttpMethod: 'POST' }, + ); + await additionalShareUserPromptAssertion.assertEntityState( + { name: `${promptName} ${i}` }, + 'visible', + ); + } + }, + ); + + await dialSharedWithMeTest.step( + 'Select "Move To -> New folder" option in dropdown menu for duplicated prompt and verify prompt is successfully moved', + async () => { + await additionalShareUserPrompts.openEntityDropdownMenu( + `${promptName} 2`, + ); + await additionalShareUserPromptDropdownMenu.selectMenuOption( + MenuOptions.moveTo, + ); + await additionalShareUserPromptDropdownMenu.selectMenuOption( + MenuOptions.newFolder, + { triggeredHttpMethod: 'POST' }, + ); + await additionalShareUserFolderPrompts.expandFolder( + ExpectedConstants.newFolderWithIndexTitle(1), + ); + await additionalShareUserPromptBarFolderAssertion.assertFolderEntityState( + { name: ExpectedConstants.newFolderWithIndexTitle(1) }, + { name: `${promptName} 2` }, + 'visible', + ); + }, + ); + }, +); diff --git a/apps/chat-e2e/src/tests/promptUsage.test.ts b/apps/chat-e2e/src/tests/promptUsage.test.ts index 47f8e68a37..e182a7c661 100644 --- a/apps/chat-e2e/src/tests/promptUsage.test.ts +++ b/apps/chat-e2e/src/tests/promptUsage.test.ts @@ -1,12 +1,15 @@ import { Conversation } from '@/chat/types/chat'; import { Prompt } from '@/chat/types/prompt'; +import { ShareByLinkResponseModel } from '@/chat/types/share'; import dialTest from '@/src/core/dialFixtures'; +import dialSharedWithMeTest from '@/src/core/dialSharedWithMeFixtures'; import { ExpectedConstants, + FolderPrompt, MenuOptions, MockedChatApiResponseBodies, } from '@/src/testData'; -import { Colors, Styles } from '@/src/ui/domData'; +import { Colors, Overflow, Styles } from '@/src/ui/domData'; import { keys } from '@/src/ui/keyboard'; import { GeneratorUtil } from '@/src/utils'; @@ -70,6 +73,7 @@ dialTest( ); await sendMessagePromptListAssertion.assertPromptOptionOverflow( promptToSelect.name, + Overflow.ellipsis, ); }, ); @@ -83,10 +87,15 @@ dialTest( `Type "/the" in send message input and verify one prompt is shown`, async () => { await sendMessage.messageInput.fillInInput(searchTerm); + const includedOptions = promptNames.filter((p) => + p.toLowerCase().includes(searchTerm.substring(1)), + ); + const excludedOptions = promptNames.filter( + (p) => !p.toLowerCase().includes(searchTerm.substring(1)), + ); await sendMessagePromptListAssertion.assertPromptListOptions( - promptNames.filter((p) => - p.toLowerCase().includes(searchTerm.substring(1)), - ), + includedOptions, + excludedOptions, ); }, ); @@ -579,3 +588,125 @@ dialTest( ); }, ); + +dialSharedWithMeTest( + 'Shared with me. Use shared with me prompt in system prompt', + async ({ + additionalShareUserDialHomePage, + promptData, + dataInjector, + mainUserShareApiHelper, + additionalUserShareApiHelper, + additionalShareUserEntitySettings, + additionalShareUserVariableModalDialog, + additionalShareUserChat, + additionalShareUserSystemPromptListAssertion, + additionalShareUserVariableModalAssertion, + additionalShareUserEntitySettingAssertion, + apiAssertion, + setTestIds, + setIssueIds, + }) => { + setTestIds('EPMRTC-3502'); + setIssueIds('1562'); + let folderPrompt: FolderPrompt; + let promptWithParams: Prompt; + let promptInFolder: Prompt; + let sharePromptByLinkResponse: ShareByLinkResponseModel; + let shareFolderByLinkResponse: ShareByLinkResponseModel; + const promptTemplate = (param: string) => `Hi ${param}`; + const promptParam = 'where'; + const promptParamValue = 'there'; + const promptContent = promptTemplate(`{{${promptParam}}}`); + + await dialSharedWithMeTest.step( + 'Prepare folder with prompt, prompt with parameters and share them', + async () => { + folderPrompt = promptData.prepareDefaultPromptInFolder(); + promptInFolder = folderPrompt.prompts[0]; + promptData.resetData(); + promptWithParams = promptData.preparePrompt(promptContent); + await dataInjector.createPrompts( + [promptWithParams, ...folderPrompt.prompts], + folderPrompt.folders, + ); + sharePromptByLinkResponse = + await mainUserShareApiHelper.shareEntityByLink([promptWithParams]); + shareFolderByLinkResponse = + await mainUserShareApiHelper.shareEntityByLink( + folderPrompt.prompts, + true, + ); + await additionalUserShareApiHelper.acceptInvite( + sharePromptByLinkResponse, + ); + await additionalUserShareApiHelper.acceptInvite( + shareFolderByLinkResponse, + ); + }, + ); + + await dialTest.step( + `Type / in system prompt field, select shared prompt with parameters and verify variable modal with default values is displayed`, + async () => { + await additionalShareUserDialHomePage.openHomePage(); + await additionalShareUserDialHomePage.waitForPageLoaded({ + isNewConversationVisible: true, + }); + await additionalShareUserEntitySettings.setSystemPrompt('/'); + await additionalShareUserSystemPromptListAssertion.assertPromptListOptions( + [promptWithParams.name, promptInFolder.name], + ); + await additionalShareUserEntitySettings + .getPromptList() + .selectPromptWithKeyboard(promptWithParams.name, { + triggeredHttpMethod: 'PUT', + }); + await additionalShareUserVariableModalAssertion.assertVariableModalState( + 'visible', + ); + await additionalShareUserVariableModalAssertion.assertPromptVariableValue( + promptParam, + '', + ); + await additionalShareUserVariableModalDialog.setVariableValue( + promptParam, + promptParamValue, + ); + await additionalShareUserVariableModalDialog.submitButton.click(); + await additionalShareUserEntitySettingAssertion.assertSystemPromptValue( + promptTemplate(promptParamValue), + ); + }, + ); + + await dialTest.step( + `Type / in system prompt field, select shared folder prompt and verify it is applied after the first prompt`, + async () => { + await additionalShareUserEntitySettings.setSystemPrompt('/'); + await additionalShareUserEntitySettings + .getPromptList() + .selectPromptWithKeyboard(promptInFolder.name, { + triggeredHttpMethod: 'PUT', + }); + await additionalShareUserEntitySettingAssertion.assertSystemPromptValue( + promptTemplate(promptParamValue) + promptInFolder.content, + ); + }, + ); + + await dialTest.step( + `Send request and verify system prompt is applied`, + async () => { + const request = await additionalShareUserChat.sendRequestWithKeyboard( + 'test', + false, + ); + await apiAssertion.assertRequestPrompt( + request, + promptTemplate(promptParamValue) + promptInFolder.content, + ); + }, + ); + }, +); diff --git a/apps/chat-e2e/src/tests/sharedPromptView.test.ts b/apps/chat-e2e/src/tests/sharedPromptView.test.ts index 1ce99456c3..b9bbf4f22a 100644 --- a/apps/chat-e2e/src/tests/sharedPromptView.test.ts +++ b/apps/chat-e2e/src/tests/sharedPromptView.test.ts @@ -140,7 +140,8 @@ dialSharedWithMeTest( ); dialSharedWithMeTest( - 'Prompt View form: Duplicate shared prompt', + 'Prompt View form: Duplicate shared prompt.\n' + + 'Shared with me. Edit duplicated prompt', async ({ additionalShareUserDialHomePage, promptData, @@ -151,9 +152,11 @@ dialSharedWithMeTest( additionalShareUserPromptPreviewModal, additionalShareUserPromptAssertion, additionalShareUserPromptModalAssertion, + additionalShareUserPromptModalDialog, + apiAssertion, setTestIds, }) => { - setTestIds('EPMRTC-3185'); + setTestIds('EPMRTC-3185', 'EPMRTC-2032'); let prompt: Prompt; let shareByLinkResponse: ShareByLinkResponseModel; @@ -176,9 +179,7 @@ dialSharedWithMeTest( shareByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserPromptPreviewModal.duplicatePrompt(); await additionalShareUserPromptAssertion.assertEntityState( { name: prompt.name }, @@ -206,5 +207,30 @@ dialSharedWithMeTest( ); }, ); + + await dialSharedWithMeTest.step( + 'Verify prompt params can be updated', + async () => { + const updatedName = GeneratorUtil.randomString(10); + const updatedDescription = GeneratorUtil.randomString(10); + const updatedContent = GeneratorUtil.randomString(10); + const request = + await additionalShareUserPromptModalDialog.updatePromptDetailsWithButton( + updatedName, + updatedDescription, + updatedContent, + ); + await additionalShareUserPromptAssertion.assertEntityState( + { name: updatedName }, + 'visible', + ); + await apiAssertion.assertRequestPromptName(request, updatedName); + await apiAssertion.assertRequestPromptDescription( + request, + updatedDescription, + ); + await apiAssertion.assertRequestPromptContent(request, updatedContent); + }, + ); }, ); diff --git a/apps/chat-e2e/src/tests/sharedWithMePromptFolders.test.ts b/apps/chat-e2e/src/tests/sharedWithMePromptFolders.test.ts index 3b028f5228..7b0bd73be6 100644 --- a/apps/chat-e2e/src/tests/sharedWithMePromptFolders.test.ts +++ b/apps/chat-e2e/src/tests/sharedWithMePromptFolders.test.ts @@ -65,9 +65,7 @@ dialSharedWithMeTest( shareFolderByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedPromptPreviewModalAssertion.assertSharedPromptPreviewModalState( 'visible', ); @@ -88,9 +86,7 @@ dialSharedWithMeTest( sharePromptByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedPromptPreviewModalAssertion.assertSharedPromptPreviewModalState( 'visible', ); @@ -156,9 +152,7 @@ dialSharedWithMeTest( shareFolderByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedPromptPreviewModalAssertion.assertSharedPromptPreviewModalState( 'visible', ); @@ -226,9 +220,7 @@ dialSharedWithMeTest( shareFolderByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedPromptPreviewModalAssertion.assertSharedPromptPreviewModalState( 'visible', ); @@ -300,9 +292,7 @@ dialSharedWithMeTest( shareFolderByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedPromptPreviewModalAssertion.assertSharedPromptPreviewModalState( 'visible', ); @@ -376,6 +366,7 @@ dialSharedWithMeTest( dialSharedWithMeTest( 'Shared with me. The folder structure is visible if share folder structure with prompt inside.\n' + 'Shared with me. Prompt structure appears only once if to open the same link several times.\n' + + 'Shared with me. Use shared with me prompt in input box' + 'Shared prompt folder structure is updated if to remove prompt from original folder', async ({ additionalShareUserDialHomePage, @@ -386,10 +377,12 @@ dialSharedWithMeTest( additionalUserShareApiHelper, additionalShareUserSharedFolderPromptsAssertions, additionalShareUserSharedFolderPrompts, + additionalShareUserSendMessage, + additionalShareUserSendMessageAssertion, shareApiAssertion, setTestIds, }) => { - setTestIds('EPMRTC-2033', 'EPMRTC-1862', 'EPMRTC-1864'); + setTestIds('EPMRTC-2033', 'EPMRTC-1862', 'EPMRTC-3500', 'EPMRTC-1864'); let folderPrompt: FolderPrompt; let folder: FolderInterface; let prompt: Prompt; @@ -448,6 +441,21 @@ dialSharedWithMeTest( }, ); + await dialSharedWithMeTest.step( + 'Create new conversation, type "/" in the request field, select shared prompt and verify it is applied', + async () => { + await additionalShareUserSendMessage.messageInput.fillInInput('/'); + await additionalShareUserSendMessage + .getPromptList() + .selectPromptWithKeyboard(prompt.name, { + triggeredHttpMethod: 'GET', + }); + await additionalShareUserSendMessageAssertion.assertMessageValue( + prompt.content, + ); + }, + ); + await dialSharedWithMeTest.step( 'Move prompt out of shared folder by main user', async () => { diff --git a/apps/chat-e2e/src/tests/sharedWithMePrompts.test.ts b/apps/chat-e2e/src/tests/sharedWithMePrompts.test.ts index 14ed3c3827..cca45db7db 100644 --- a/apps/chat-e2e/src/tests/sharedWithMePrompts.test.ts +++ b/apps/chat-e2e/src/tests/sharedWithMePrompts.test.ts @@ -53,9 +53,7 @@ dialSharedWithMeTest( shareByLinkResponse.invitationLink, ), ); - await additionalShareUserDialHomePage.waitForPageLoaded({ - isNewConversationVisible: true, - }); + await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMePromptAssertion.assertEntityState( { name: prompt.name }, 'visible', diff --git a/apps/chat-e2e/src/tests/workWithModels.test.ts b/apps/chat-e2e/src/tests/workWithModels.test.ts index 748d77813e..e1ed3ab7c7 100644 --- a/apps/chat-e2e/src/tests/workWithModels.test.ts +++ b/apps/chat-e2e/src/tests/workWithModels.test.ts @@ -11,7 +11,7 @@ import { ModelIds, Theme, } from '@/src/testData'; -import { Cursors, Styles } from '@/src/ui/domData'; +import { Cursors, Overflow, Styles } from '@/src/ui/domData'; import { keys } from '@/src/ui/keyboard'; import { GeneratorUtil, ModelsUtil } from '@/src/utils'; import { expect } from '@playwright/test'; @@ -610,7 +610,10 @@ dialTest( }); await entitySettings.setSystemPrompt('/'); const promptsList = entitySettings.getPromptList(); - await systemPromptListAssertion.assertPromptOptionOverflow(prompt.name); + await systemPromptListAssertion.assertPromptOptionOverflow( + prompt.name, + Overflow.ellipsis, + ); await promptsList.selectPromptWithKeyboard(prompt.name, { triggeredHttpMethod: 'PUT', diff --git a/apps/chat-e2e/src/ui/webElements/entitySettings.ts b/apps/chat-e2e/src/ui/webElements/entitySettings.ts index cba86ebcd1..598657c360 100644 --- a/apps/chat-e2e/src/ui/webElements/entitySettings.ts +++ b/apps/chat-e2e/src/ui/webElements/entitySettings.ts @@ -62,11 +62,16 @@ export class EntitySettings extends BaseElement { } public async setSystemPrompt(prompt: string) { - await this.systemPrompt.fillInInput(prompt); + await this.systemPrompt.typeInInput(prompt); // eslint-disable-next-line playwright/no-wait-for-timeout await this.page.waitForTimeout(PROMPT_APPLY_DELAY); } + public async clearAndSetSystemPrompt(prompt: string) { + await this.clearSystemPrompt(); + await this.setSystemPrompt(prompt); + } + public async getSystemPrompt() { return this.systemPrompt.getElementContent(); } diff --git a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts index 39feaca726..913c2eb618 100644 --- a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts +++ b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts @@ -54,7 +54,7 @@ export class PromptModalDialog extends BaseElement { description: string | undefined, value: string, ) { - await this.updatePromptDetails(name, description, value, () => + return this.updatePromptDetails(name, description, value, () => this.saveButton.click(), ); } @@ -64,7 +64,7 @@ export class PromptModalDialog extends BaseElement { description: string, value: string, ) { - await this.updatePromptDetails(name, description, value, () => + return this.updatePromptDetails(name, description, value, () => this.page.keyboard.press(keys.enter), ); } @@ -82,7 +82,8 @@ export class PromptModalDialog extends BaseElement { return method === 'POST' || method === 'PUT'; }); await method(); - return respPromise; + const response = await respPromise; + return response.request().postDataJSON(); } await method(); }