From 765cd446a5b51cc029935e6b3a7c4f5aacbb3374 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Thu, 30 Jan 2025 16:11:24 +0100 Subject: [PATCH 01/28] feat(chat): move from to endpoint for conversations/prompts rename (Issue #3052) --- .../Chat/ConversationContextMenu.tsx | 6 +- .../components/Chat/EmptyChatDescription.tsx | 8 +- .../Chat/RenameConversationModal.tsx | 15 +- apps/chat/src/components/Chat/ShareModal.tsx | 1 + .../components/Chat/TalkTo/TalkToModal.tsx | 6 +- .../src/components/Chatbar/ChatFolders.tsx | 8 +- apps/chat/src/components/Chatbar/Chatbar.tsx | 6 +- .../src/components/Promptbar/Promptbar.tsx | 6 +- .../Promptbar/components/Prompt.tsx | 6 +- .../Promptbar/components/PromptFolders.tsx | 8 +- .../conversations/conversations.epics.ts | 154 +++++++++++------- .../conversations/conversations.reducers.ts | 57 ++++--- apps/chat/src/store/prompts/prompts.epics.ts | 113 +++++++------ .../src/store/prompts/prompts.reducers.ts | 40 ++++- .../utils/app/data/conversation-service.ts | 5 + .../chat/src/utils/app/data/prompt-service.ts | 5 + 16 files changed, 265 insertions(+), 179 deletions(-) diff --git a/apps/chat/src/components/Chat/ConversationContextMenu.tsx b/apps/chat/src/components/Chat/ConversationContextMenu.tsx index 218a8f2880..bab4f56c9b 100644 --- a/apps/chat/src/components/Chat/ConversationContextMenu.tsx +++ b/apps/chat/src/components/Chat/ConversationContextMenu.tsx @@ -239,9 +239,9 @@ export const ConversationContextMenu = ({ }), ); dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { + ConversationsActions.moveConversation({ + conversation, + newValues: { folderId: isNewFolder ? constructPath(getConversationRootId(), folderPath) : folderPath, diff --git a/apps/chat/src/components/Chat/EmptyChatDescription.tsx b/apps/chat/src/components/Chat/EmptyChatDescription.tsx index 68356a750d..4b6664cc2f 100644 --- a/apps/chat/src/components/Chat/EmptyChatDescription.tsx +++ b/apps/chat/src/components/Chat/EmptyChatDescription.tsx @@ -111,13 +111,13 @@ const EmptyChatDescriptionView = ({ const handleSelectVersion = useCallback( (model: DialAIEntityModel) => { dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { model: { id: model.reference } }, + ConversationsActions.moveConversation({ + conversation, + newValues: { model: { id: model.reference } }, }), ); }, - [conversation.id, dispatch], + [conversation, dispatch], ); if (models.length === 0) { diff --git a/apps/chat/src/components/Chat/RenameConversationModal.tsx b/apps/chat/src/components/Chat/RenameConversationModal.tsx index 2ddbc76fd9..55ec4c5918 100644 --- a/apps/chat/src/components/Chat/RenameConversationModal.tsx +++ b/apps/chat/src/components/Chat/RenameConversationModal.tsx @@ -42,13 +42,12 @@ export const RenameConversationModal = () => { const RenameConversationView = () => { const { t } = useTranslation(Translation.Chat); + const dispatch = useAppDispatch(); - const inputRef = useRef(null); const allConversations = useAppSelector( ConversationsSelectors.selectConversations, ); - const renamingConversation = useAppSelector( ConversationsSelectors.selectRenamingConversation, ); @@ -57,6 +56,8 @@ const RenameConversationView = () => { const [isConfirmRenaming, setIsConfirmRenaming] = useState(false); const [originConversationName, setOriginConversationName] = useState(''); + const inputRef = useRef(null); + useEffect(() => { if (renamingConversation) { setNewConversationName(renamingConversation.name || ''); @@ -82,13 +83,9 @@ const RenameConversationView = () => { if (!name.trim()) return; if (name.length > 0 && renamingConversation) { dispatch( - ConversationsActions.updateConversation({ - id: renamingConversation.id, - values: { - name, - isNameChanged: true, - isShared: false, - }, + ConversationsActions.moveConversation({ + conversation: renamingConversation, + newValues: { name }, }), ); dispatch(ConversationsActions.setRenamingConversationId(null)); diff --git a/apps/chat/src/components/Chat/ShareModal.tsx b/apps/chat/src/components/Chat/ShareModal.tsx index bd12d731a3..be9e1ca412 100644 --- a/apps/chat/src/components/Chat/ShareModal.tsx +++ b/apps/chat/src/components/Chat/ShareModal.tsx @@ -166,6 +166,7 @@ export default function ShareModalView() { }, [dispatch, entity, handleClose]); useEffect(() => () => clearTimeout(timeoutRef.current), []); + return ( { }), ); dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { folderId }, + ConversationsActions.moveConversation({ + conversation, + newValues: { folderId }, }), ); dispatch(ConversationsActions.resetSearch()); diff --git a/apps/chat/src/components/Promptbar/Promptbar.tsx b/apps/chat/src/components/Promptbar/Promptbar.tsx index 717ac85ae6..d31ddedac8 100644 --- a/apps/chat/src/components/Promptbar/Promptbar.tsx +++ b/apps/chat/src/components/Promptbar/Promptbar.tsx @@ -167,9 +167,9 @@ const Promptbar = () => { }), ); dispatch( - PromptsActions.updatePrompt({ - id: prompt.id, - values: { folderId }, + PromptsActions.movePrompt({ + prompt, + newValues: { folderId }, }), ); } diff --git a/apps/chat/src/components/Promptbar/components/Prompt.tsx b/apps/chat/src/components/Promptbar/components/Prompt.tsx index 7ad72f9b28..5f789b4875 100644 --- a/apps/chat/src/components/Promptbar/components/Prompt.tsx +++ b/apps/chat/src/components/Promptbar/components/Prompt.tsx @@ -328,9 +328,9 @@ export const PromptComponent = ({ }), ); dispatch( - PromptsActions.updatePrompt({ - id: prompt.id, - values: { + PromptsActions.movePrompt({ + prompt, + newValues: { folderId: isNewFolder ? constructPath(getPromptRootId(), folderPath) : folderPath, diff --git a/apps/chat/src/components/Promptbar/components/PromptFolders.tsx b/apps/chat/src/components/Promptbar/components/PromptFolders.tsx index 5bfc267f8d..436ddd4295 100644 --- a/apps/chat/src/components/Promptbar/components/PromptFolders.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptFolders.tsx @@ -133,11 +133,9 @@ const PromptFolderTemplate = ({ if (promptData) { const prompt: PromptInfo = JSON.parse(promptData); dispatch( - PromptsActions.updatePrompt({ - id: prompt.id, - values: { - folderId: folder.id, - }, + PromptsActions.movePrompt({ + prompt, + newValues: { folderId: folder.id }, }), ); } else if (folderData) { diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index 66a1342f84..86117c6192 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -864,9 +864,9 @@ const updateFolderEpic: AppEpic = (action$, state$) => conversations.forEach((conversation) => { actions.push( of( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { + ConversationsActions.moveConversation({ + conversation, + newValues: { folderId: updateFolderId(conversation.folderId), }, }), @@ -1278,7 +1278,7 @@ const sendMessageEpic: AppEpic = (action$, state$) => true, ); - const updatedConversation: Conversation = regenerateConversationId({ + const updatedConversation = regenerateConversationId({ ...payload.conversation, lastActivityDate: Date.now(), replay: payload.conversation.replay @@ -1308,12 +1308,24 @@ const sendMessageEpic: AppEpic = (action$, state$) => return concat( ...actions, - of( - ConversationsActions.updateConversation({ - id: payload.conversation.id, - values: updatedConversation, - }), + iif( + () => + newConversationName !== payload.conversation.name && + !isEntityIdLocal(payload.conversation), + of( + ConversationsActions.moveConversation({ + conversation: payload.conversation, + newValues: updatedConversation, + }), + ), + of( + ConversationsActions.updateConversation({ + id: payload.conversation.id, + values: updatedConversation, + }), + ), ), + of( ModelsActions.updateRecentModels({ modelId: updatedConversation.model.id, @@ -2319,39 +2331,71 @@ const saveConversationEpic: AppEpic = (action$) => }), ); -const recreateConversationEpic: AppEpic = (action$) => +const moveConversationEpic: AppEpic = (action$) => action$.pipe( - filter(ConversationsActions.recreateConversation.match), - mergeMap(({ payload }) => { - return ConversationService.createConversation(payload.new).pipe( + filter(ConversationsActions.moveConversation.match), + map(({ payload }) => + ConversationsActions.moveConversationRegenerated({ + oldConversation: payload.conversation, + newConversation: regenerateConversationId({ + ...payload.conversation, + ...payload.newValues, + }), + }), + ), + ); + +const moveConversationRegeneratedEpic: AppEpic = (action$) => + action$.pipe( + filter(ConversationsActions.moveConversationRegenerated.match), + switchMap(({ payload }) => { + if (isEntityIdLocal(payload.oldConversation)) { + return of( + ConversationsActions.updateConversation({ + id: payload.oldConversation.id, + values: payload.newConversation, + }), + ); + } + + if (payload.newConversation.id === payload.oldConversation.id) { + return EMPTY; + } + + return ConversationService.moveConversation({ + sourceUrl: payload.oldConversation.id, + destinationUrl: payload.newConversation.id, + overwrite: false, + }).pipe( switchMap(() => - ConversationService.deleteConversation( - getConversationInfoFromId(payload.old.id), + of( + ConversationsActions.updateConversation({ + id: payload.newConversation.id, + values: payload.newConversation, + }), ), ), - switchMap(() => of(ConversationsActions.saveConversationSuccess())), - catchError((err) => { - console.error(err); - return concat( - of( - ConversationsActions.recreateConversationFail({ - newId: payload.new.id, - oldConversation: payload.old, - }), - ), - of( - UIActions.showErrorToast( - translate( - 'An error occurred while saving the conversation. Please refresh the page.', - ), - ), - ), - ); + catchError(() => { + return of(ConversationsActions.moveConversationFail(payload)); }), ); }), ); +const moveConversationFailEpic: AppEpic = (action$) => + action$.pipe( + filter(ConversationsActions.moveConversationFail.match), + switchMap(() => { + return of( + UIActions.showErrorToast( + translate( + 'It looks like conversation already exist. Please reload the page', + ), + ), + ); + }), + ); + const updateConversationEpic: AppEpic = (action$, state$) => action$.pipe( filter(ConversationsActions.updateConversation.match), @@ -2369,33 +2413,23 @@ const updateConversationEpic: AppEpic = (action$, state$) => ), ); } - const newConversation: Conversation = regenerateConversationId({ - ...(conversation as Conversation), - ...values, - lastActivityDate: Date.now(), - }); return concat( iif( - () => !!conversation && conversation.id !== newConversation.id, + () => !conversation.isPlayback || values.isPlayback === false, of( - ConversationsActions.recreateConversation({ - new: newConversation, - old: conversation, + ConversationsActions.saveConversation({ + ...conversation, + ...values, }), ), - iif( - () => !newConversation.isPlayback, - of(ConversationsActions.saveConversation(newConversation)), - EMPTY, - ), + EMPTY, ), of( ConversationsActions.updateConversationSuccess({ id, conversation: { ...values, - id: newConversation.id, }, }), ), @@ -3012,17 +3046,15 @@ const applyMarketplaceModelEpic: AppEpic = (action$, state$) => iif( () => !!conversation, of( - ConversationsActions.updateConversation({ - id: conversation?.id as string, - values: { - ...(conversation - ? getConversationModelParams( - conversation as Conversation, - modelToApply?.reference, - modelsMap, - addonsMap, - ) - : {}), + ConversationsActions.moveConversation({ + conversation: conversation!, + newValues: { + ...getConversationModelParams( + conversation as Conversation, + modelToApply?.reference, + modelsMap, + addonsMap, + ), }, }), ), @@ -3172,10 +3204,12 @@ export const ConversationsEpics = combineEpics( initFoldersAndConversationsEpic, // update + moveConversationEpic, + moveConversationRegeneratedEpic, + moveConversationFailEpic, updateConversationEpic, updateLocalConversationEpic, saveConversationEpic, - recreateConversationEpic, createNewConversationsEpic, applyMarketplaceModelEpic, applyMarketplaceModelSuccessEpic, diff --git a/apps/chat/src/store/conversations/conversations.reducers.ts b/apps/chat/src/store/conversations/conversations.reducers.ts index 5b9553f171..56aa1c1af4 100644 --- a/apps/chat/src/store/conversations/conversations.reducers.ts +++ b/apps/chat/src/store/conversations/conversations.reducers.ts @@ -101,43 +101,54 @@ export const conversationsSlice = createSlice({ }); state.isNewConversationUpdating = false; }, - recreateConversation: ( + moveConversation: ( state, - action: PayloadAction<{ new: Conversation; old: Conversation }>, + _action: PayloadAction<{ + conversation: ConversationInfo; + newValues: Partial; + }>, + ) => state, + moveConversationRegenerated: ( + state, + { + payload, + }: PayloadAction<{ + oldConversation: ConversationInfo; + newConversation: ConversationInfo; + }>, ) => { - if (!action.payload.old.messages.length) { - state.isNewConversationUpdating = true; - } + state.conversations = state.conversations.map((conv) => { + if (payload.oldConversation.id === conv.id) { + return payload.newConversation; + } + + return conv; + }); + state.selectedConversationsIds = state.selectedConversationsIds.map( + (id) => + id === payload.oldConversation.id ? payload.newConversation.id : id, + ); }, - recreateConversationFail: ( + moveConversationFail: ( state, { payload, }: PayloadAction<{ - newId: string; - oldConversation: Conversation; + oldConversation: ConversationInfo; + newConversation: ConversationInfo; }>, ) => { - state.isNewConversationUpdating = false; state.conversations = state.conversations.map((conv) => { - if (conv.id === payload.newId) { - const conversation = conv as Conversation; - return { - ...conversation, - ...payload.oldConversation, - messages: conversation.messages, - isMessageStreaming: false, - }; + if (payload.newConversation.id === conv.id) { + return payload.oldConversation; } return conv; }); - - if (payload.newId !== payload.oldConversation.id) { - state.selectedConversationsIds = state.selectedConversationsIds.map( - (id) => (id === payload.newId ? payload.oldConversation.id! : id), - ); - } + state.selectedConversationsIds = state.selectedConversationsIds.map( + (id) => + id === payload.newConversation.id ? payload.oldConversation.id : id, + ); }, updateConversation: ( state, diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 53b522feab..4b8c755d49 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -31,7 +31,6 @@ import { generateNextName, getFolderFromId, getParentFolderIdsFromFolderId, - splitEntityId, updateMovedFolderId, } from '@/src/utils/app/folders'; import { getPromptRootId, isEntityIdExternal } from '@/src/utils/app/id'; @@ -219,38 +218,62 @@ const savePromptEpic: AppEpic = (action$) => ignoreElements(), ); -const recreatePromptEpic: AppEpic = (action$) => +const movePromptEpic: AppEpic = (action$) => action$.pipe( - filter(PromptsActions.recreatePrompt.match), - mergeMap(({ payload }) => { - const { parentPath } = splitEntityId(payload.old.id); - return PromptService.createPrompt(payload.new).pipe( + filter(PromptsActions.movePrompt.match), + map(({ payload }) => + PromptsActions.movePromptRegenerated({ + oldPrompt: payload.prompt, + newPrompt: { + ...payload.prompt, + ...payload.newValues, + id: constructPath( + payload.newValues.folderId ?? payload.prompt.folderId, + getPromptApiKey({ ...payload.prompt, ...payload.newValues }), + ), + }, + }), + ), + ); + +const movePromptRegeneratedEpic: AppEpic = (action$) => + action$.pipe( + filter(PromptsActions.movePromptRegenerated.match), + switchMap(({ payload }) => { + if (payload.newPrompt.id === payload.oldPrompt.id) { + return EMPTY; + } + + return PromptService.movePrompt({ + sourceUrl: payload.oldPrompt.id, + destinationUrl: payload.newPrompt.id, + overwrite: false, + }).pipe( switchMap(() => - PromptService.deletePrompt({ - id: payload.old.id, - folderId: parentPath || getPromptRootId(), - name: payload.old.name, - }), + of( + PromptsActions.updatePrompt({ + id: payload.newPrompt.id, + values: payload.newPrompt, + }), + ), ), - catchError((err) => { - console.error(err); - return concat( - of( - PromptsActions.recreatePromptFail({ - newId: payload.new.id, - oldPrompt: payload.old, - }), - ), - of( - UIActions.showErrorToast( - translate( - 'An error occurred while saving the prompt. Please refresh the page.', - ), - ), - ), - ); + catchError(() => { + return of(PromptsActions.movePromptFail(payload)); }), - ignoreElements(), + ); + }), + ); + +const movePromptFailEpic: AppEpic = (action$) => + action$.pipe( + filter(PromptsActions.movePromptFail.match), + switchMap(() => { + return of( + UIActions.showErrorToast( + translate( + 'It looks like prompt already exist. Please reload the page', + ), + ), ); }), ); @@ -275,22 +298,14 @@ const updatePromptEpic: AppEpic = (action$, state$) => ); } - const newPrompt: Prompt = { - ...prompt, - ...values, - id: constructPath( - values.folderId || prompt.folderId, - getPromptApiKey({ ...prompt, ...values }), - ), - }; - return concat( - of(PromptsActions.updatePromptSuccess({ prompt: newPrompt, id })), - iif( - () => !!prompt && prompt.id !== newPrompt.id, - of(PromptsActions.recreatePrompt({ old: prompt, new: newPrompt })), - of(PromptsActions.savePrompt(newPrompt)), + of( + PromptsActions.updatePromptSuccess({ + prompt: { ...values }, + id, + }), ), + of(PromptsActions.savePrompt({ ...prompt, ...values })), ); }), ); @@ -423,11 +438,9 @@ const updateFolderEpic: AppEpic = (action$, state$) => prompts.forEach((prompt) => { actions.push( of( - PromptsActions.updatePrompt({ - id: prompt.id, - values: { - folderId: updateFolderId(prompt.folderId), - }, + PromptsActions.movePrompt({ + prompt, + newValues: { folderId: updateFolderId(prompt.folderId) }, }), ), ); @@ -895,7 +908,9 @@ export const PromptsEpics = combineEpics( saveNewPromptEpic, deleteFolderEpic, savePromptEpic, - recreatePromptEpic, + movePromptEpic, + movePromptRegeneratedEpic, + movePromptFailEpic, updatePromptEpic, deletePromptEpic, clearPromptsEpic, diff --git a/apps/chat/src/store/prompts/prompts.reducers.ts b/apps/chat/src/store/prompts/prompts.reducers.ts index 9b466fd516..6529719615 100644 --- a/apps/chat/src/store/prompts/prompts.reducers.ts +++ b/apps/chat/src/store/prompts/prompts.reducers.ts @@ -105,20 +105,42 @@ export const promptsSlice = createSlice({ ); }, savePrompt: (state, _action: PayloadAction) => state, - recreatePrompt: ( + movePrompt: ( state, - _action: PayloadAction<{ new: Prompt; old: PromptInfo }>, + _action: PayloadAction<{ + prompt: PromptInfo; + newValues: Partial; + }>, ) => state, - recreatePromptFail: ( + movePromptRegenerated: ( state, - { payload }: PayloadAction<{ oldPrompt: Prompt; newId: string }>, + { + payload, + }: PayloadAction<{ + oldPrompt: PromptInfo; + newPrompt: PromptInfo; + }>, ) => { state.prompts = state.prompts.map((prompt) => { - if (prompt.id === payload.newId) { - return { - ...prompt, - ...payload.oldPrompt, - }; + if (payload.oldPrompt.id === prompt.id) { + return payload.newPrompt; + } + + return prompt; + }); + }, + movePromptFail: ( + state, + { + payload, + }: PayloadAction<{ + oldPrompt: PromptInfo; + newPrompt: PromptInfo; + }>, + ) => { + state.prompts = state.prompts.map((prompt) => { + if (payload.newPrompt.id === prompt.id) { + return payload.oldPrompt; } return prompt; diff --git a/apps/chat/src/utils/app/data/conversation-service.ts b/apps/chat/src/utils/app/data/conversation-service.ts index 2de8954ab3..6113015b86 100644 --- a/apps/chat/src/utils/app/data/conversation-service.ts +++ b/apps/chat/src/utils/app/data/conversation-service.ts @@ -1,6 +1,7 @@ import { Observable } from 'rxjs'; import { Conversation } from '@/src/types/chat'; +import { MoveModel } from '@/src/types/common'; import { FolderInterface, FoldersAndEntities } from '@/src/types/folder'; import { UIStorageKeys } from '@/src/types/storage'; @@ -28,6 +29,10 @@ export class ConversationService { return DataService.getDataStorage().createConversation(conversation); } + public static moveConversation(moveModel: MoveModel): Observable { + return DataService.getDataStorage().move(moveModel); + } + public static updateConversation( conversation: Conversation, ): Observable { diff --git a/apps/chat/src/utils/app/data/prompt-service.ts b/apps/chat/src/utils/app/data/prompt-service.ts index c44b1a79e8..8304e716aa 100644 --- a/apps/chat/src/utils/app/data/prompt-service.ts +++ b/apps/chat/src/utils/app/data/prompt-service.ts @@ -4,6 +4,7 @@ import { constructPath } from '@/src/utils/app/file'; import { getPromptRootId, isRootPromptId } from '@/src/utils/app/id'; import { regeneratePromptId } from '@/src/utils/app/prompts'; +import { MoveModel } from '@/src/types/common'; import { FolderInterface, FoldersAndEntities } from '@/src/types/folder'; import { Prompt, PromptInfo } from '@/src/types/prompt'; @@ -55,6 +56,10 @@ export class PromptService { return DataService.getDataStorage().createPrompt(prompt); } + public static movePrompt(moveModel: MoveModel): Observable { + return DataService.getDataStorage().move(moveModel); + } + public static updatePrompt(prompt: Prompt): Observable { return DataService.getDataStorage().updatePrompt(prompt); } From e0c1ccc2df28f07ded032d6790c7bfa17341833f Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Fri, 31 Jan 2025 13:08:42 +0100 Subject: [PATCH 02/28] feat/3052-from-edit-to-move-endpoint: fixed method to rename --- apps/chat-e2e/src/ui/webElements/renameConversationModal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts b/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts index af78f85929..327729186e 100644 --- a/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts +++ b/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts @@ -30,7 +30,7 @@ export class RenameConversationModal extends BaseElement { await this.nameInput.fillInInput(newName); if (isApiStorageType && isHttpMethodTriggered) { const respPromise = this.page.waitForResponse( - (resp) => resp.request().method() === 'DELETE', + (resp) => resp.request().method() === 'PUT', ); await confirmationAction(); await respPromise; From 48e4b49b650ca9c0630b688813bd34e7bca9b0a4 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Fri, 31 Jan 2025 14:42:02 +0100 Subject: [PATCH 03/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- apps/chat-e2e/src/tests/parametrizedReplay.test.ts | 4 +++- .../ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts index bbcd143478..1f02b2e859 100644 --- a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts +++ b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts @@ -266,7 +266,9 @@ dialTest( await dialTest.step( 'Export conversation and then delete all Dial entities', async () => { - await conversations.openEntityDropdownMenu(conversation.name, 2); + await conversations.openEntityDropdownMenu(conversation.name, { + exactMatch: true, + }); await conversationDropdownMenu.selectMenuOption(MenuOptions.export); exportedData = await dialHomePage.downloadData( () => diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts index 4db878ae26..a9027bd092 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts @@ -79,7 +79,7 @@ export class SideBarEntitiesTree extends EntitiesTree { { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, ) { return this.getDropdownMenu().selectMenuOption(name, { - triggeredHttpMethod: 'DELETE', + triggeredHttpMethod: 'PUT', isHttpMethodTriggered, }); } From be5a177522a728c234f98ae8bc490d15f4beb244 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Fri, 31 Jan 2025 16:03:22 +0100 Subject: [PATCH 04/28] fix local conversations --- apps/chat/src/store/conversations/conversations.epics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index 86117c6192..d28f9d0211 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -2352,7 +2352,7 @@ const moveConversationRegeneratedEpic: AppEpic = (action$) => if (isEntityIdLocal(payload.oldConversation)) { return of( ConversationsActions.updateConversation({ - id: payload.oldConversation.id, + id: payload.newConversation.id, values: payload.newConversation, }), ); From 1c088f4beb04acc66edaa5bba9fefaa7cdd91ab9 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Fri, 31 Jan 2025 16:21:15 +0100 Subject: [PATCH 05/28] fix prompt name saving --- apps/chat/src/components/Promptbar/Promptbar.tsx | 6 +++--- apps/chat/src/store/prompts/prompts.reducers.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/chat/src/components/Promptbar/Promptbar.tsx b/apps/chat/src/components/Promptbar/Promptbar.tsx index 526c8d7dfc..cba494d485 100644 --- a/apps/chat/src/components/Promptbar/Promptbar.tsx +++ b/apps/chat/src/components/Promptbar/Promptbar.tsx @@ -47,9 +47,9 @@ const PromptActionsBlock = () => { isNewPromptCreating ? dispatch(PromptsActions.createNewPrompt(regeneratePromptId(prompt))) : dispatch( - PromptsActions.updatePrompt({ - id: prompt.id, - values: { + PromptsActions.movePrompt({ + prompt, + newValues: { name: prompt.name, description: prompt.description, content: prompt.content, diff --git a/apps/chat/src/store/prompts/prompts.reducers.ts b/apps/chat/src/store/prompts/prompts.reducers.ts index 6529719615..283bc83b99 100644 --- a/apps/chat/src/store/prompts/prompts.reducers.ts +++ b/apps/chat/src/store/prompts/prompts.reducers.ts @@ -109,7 +109,7 @@ export const promptsSlice = createSlice({ state, _action: PayloadAction<{ prompt: PromptInfo; - newValues: Partial; + newValues: Partial; }>, ) => state, movePromptRegenerated: ( From 87bb1a8d09ffc4552166662940573be56554ea0d Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Fri, 31 Jan 2025 19:03:52 +0100 Subject: [PATCH 06/28] feat/3052-from-edit-to-move-endpoint: fixed more e2e --- apps/chat-e2e/src/tests/defaultModelSettings.test.ts | 1 - apps/chat-e2e/src/tests/sharedChatIcons.test.ts | 4 ++-- apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts | 2 +- apps/chat-e2e/src/tests/sharedPromptIcons.test.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/chat-e2e/src/tests/defaultModelSettings.test.ts b/apps/chat-e2e/src/tests/defaultModelSettings.test.ts index 63510d655c..cdb637d8ad 100644 --- a/apps/chat-e2e/src/tests/defaultModelSettings.test.ts +++ b/apps/chat-e2e/src/tests/defaultModelSettings.test.ts @@ -414,7 +414,6 @@ dialTest( }); await dialHomePage.waitForPageLoaded(); await chat.changeAgentButton.click(); - nonDefaultModel = ModelsUtil.getModel('gpt-4-turbo-2024-04-09')!; await talkToAgentDialog.selectAgent(nonDefaultModel, marketplacePage); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index 296e56f25f..9c2eaa22ae 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -417,7 +417,7 @@ dialTest( await dialTest.step( 'Confirm conversation rename and verify conversation is not shared and arrow icon disappears', async () => { - await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' }); + await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); await conversationAssertion.assertEntityArrowIconState( { name: newName }, 'hidden', @@ -443,7 +443,7 @@ dialTest( await dialTest.step( 'Confirm conversation model change and verify conversation is not shared and arrow icon disappears', async () => { - await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' }); + await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); await conversationAssertion.assertEntityArrowIconState( { name: newName }, 'hidden', diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index b28793bafe..7d3bda1c9a 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -368,7 +368,7 @@ dialSharedWithMeTest( ); await renameConversationModal.saveButton.click(); await confirmationDialog.confirm({ - triggeredHttpMethod: 'DELETE', + triggeredHttpMethod: 'PUT', }); break; case 'model change': diff --git a/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts b/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts index 01d3016b32..64d1369d91 100644 --- a/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts @@ -240,7 +240,7 @@ dialTest( async () => { await promptModalDialog.setField(promptModalDialog.name, newName); await promptModalDialog.saveButton.click(); - await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' }); + await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); await promptAssertion.assertEntityArrowIconState( { name: newName }, 'hidden', From 6e588d68a46539374014d678de41081ffcf204b4 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Mon, 3 Feb 2025 12:45:47 +0100 Subject: [PATCH 07/28] fix updates and remove unhare dialogs --- apps/chat/public/locales/en/sidebar.json | 10 +-- .../Chat/RenameConversationModal.tsx | 58 +++--------------- .../components/Chat/TalkTo/TalkToModal.tsx | 56 +++-------------- apps/chat/src/components/Folder/Folder.tsx | 29 --------- .../src/components/Promptbar/Promptbar.tsx | 2 +- .../Promptbar/components/PromptModal.tsx | 61 ++++++------------- .../conversations/conversations.reducers.ts | 2 +- apps/chat/src/store/prompts/prompts.epics.ts | 21 +++++++ .../src/store/prompts/prompts.reducers.ts | 7 +++ 9 files changed, 72 insertions(+), 174 deletions(-) diff --git a/apps/chat/public/locales/en/sidebar.json b/apps/chat/public/locales/en/sidebar.json index 609a54a8aa..9d4ab29986 100644 --- a/apps/chat/public/locales/en/sidebar.json +++ b/apps/chat/public/locales/en/sidebar.json @@ -1,8 +1,8 @@ { "share.modal.link.description": "This link is temporary and will be active for 3 days.", - "share.modal.link_conversation": "This conversation and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming or changing the model will stop sharing.", - "share.modal.link_prompt": "This prompt and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming will stop sharing.", - "share.modal.link_conversations_folder": "This conversation folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming will stop sharing.", - "share.modal.link_prompts_folder": "This prompt folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming will stop sharing.", - "share.modal.link_application": "This application and its updates will be visible to users with the link. Renaming or changing the version will stop sharing." + "share.modal.link_conversation": "This conversation and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", + "share.modal.link_prompt": "This prompt and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", + "share.modal.link_conversations_folder": "This conversation folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", + "share.modal.link_prompts_folder": "This prompt folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", + "share.modal.link_application": "This application and its updates will be visible to users with the link." } diff --git a/apps/chat/src/components/Chat/RenameConversationModal.tsx b/apps/chat/src/components/Chat/RenameConversationModal.tsx index 09fbefd9d4..a9c77ba934 100644 --- a/apps/chat/src/components/Chat/RenameConversationModal.tsx +++ b/apps/chat/src/components/Chat/RenameConversationModal.tsx @@ -28,7 +28,6 @@ import { UIActions } from '@/src/store/ui/ui.reducers'; import { DISALLOW_INTERACTIONS } from '@/src/constants/modal'; -import { ConfirmDialog } from '../Common/ConfirmDialog'; import Modal from '../Common/Modal'; export const RenameConversationModal = () => { @@ -53,7 +52,6 @@ const RenameConversationView = () => { ); const [newConversationName, setNewConversationName] = useState(''); - const [isConfirmRenaming, setIsConfirmRenaming] = useState(false); const [originConversationName, setOriginConversationName] = useState(''); const inputRef = useRef(null); @@ -69,7 +67,6 @@ const RenameConversationView = () => { } else { setNewConversationName(''); setOriginConversationName(''); - setIsConfirmRenaming(false); } }, [renamingConversation]); @@ -78,22 +75,6 @@ const RenameConversationView = () => { [newConversationName], ); - const performRename = useCallback( - (name: string) => { - if (!name.trim()) return; - if (name.length > 0 && renamingConversation) { - dispatch( - ConversationsActions.moveConversation({ - conversation: renamingConversation, - newValues: { name }, - }), - ); - dispatch(ConversationsActions.setRenamingConversationId(null)); - } - }, - [renamingConversation, dispatch], - ); - const handleRename = useCallback(() => { if (!renamingConversation) return; @@ -128,23 +109,16 @@ const RenameConversationView = () => { return; } - if ( - renamingConversation.isShared && - newName !== renamingConversation.name - ) { - setIsConfirmRenaming(true); - return; + if (newName.length > 0) { + dispatch( + ConversationsActions.moveConversation({ + conversation: renamingConversation, + newValues: { name: newName, isNameChanged: true }, + }), + ); + dispatch(ConversationsActions.setRenamingConversationId(null)); } - - performRename(newName); - }, [ - newName, - renamingConversation, - allConversations, - performRename, - dispatch, - t, - ]); + }, [newName, renamingConversation, allConversations, dispatch, t]); const handleEnterDown = useCallback( (e: KeyboardEvent) => { @@ -209,20 +183,6 @@ const RenameConversationView = () => { {t('Save')} - { - setIsConfirmRenaming(false); - if (result) performRename(newName); - handleClose(); - }} - /> ); }; diff --git a/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx b/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx index d672fae03e..48700d3bb0 100644 --- a/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx +++ b/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx @@ -80,8 +80,6 @@ const TalkToModalView = ({ const [publishModel, setPublishModel] = useState< ShareEntity & { iconUrl?: string } >(); - const [sharedConversationNewModel, setSharedConversationNewModel] = - useState(); const isPlayback = conversation.playback?.isPlayback; const isReplay = conversation.replay?.isReplay; @@ -172,7 +170,16 @@ const TalkToModalView = ({ t, ]); - const handleUpdateConversationModel = useCallback( + const handleCloseApplicationLogs = useCallback( + () => setLogModel(undefined), + [], + ); + + const handleOpenApplicationLogs = useCallback((entity: DialAIEntityModel) => { + setLogModel(entity); + }, []); + + const handleSelectModel = useCallback( (entity: DialAIEntityModel) => { const model = modelsMap[entity.reference]; @@ -201,31 +208,6 @@ const TalkToModalView = ({ [addonsMap, conversation, dispatch, modelsMap, onClose], ); - const handleCloseApplicationLogs = useCallback( - () => setLogModel(undefined), - [], - ); - - const handleOpenApplicationLogs = useCallback((entity: DialAIEntityModel) => { - setLogModel(entity); - }, []); - - const handleSelectModel = useCallback( - (entity: DialAIEntityModel) => { - if (conversation.isShared && entity.reference !== conversation.model.id) { - setSharedConversationNewModel(entity); - return; - } - - handleUpdateConversationModel(entity); - }, - [ - conversation.isShared, - conversation.model.id, - handleUpdateConversationModel, - ], - ); - const handleEditApplication = useCallback( (entity: DialAIEntityModel) => { dispatch(ApplicationActions.get({ applicationId: entity.id })); @@ -370,24 +352,6 @@ const TalkToModalView = ({ entityId={logModel.id} /> )} - {sharedConversationNewModel && ( - { - if (result && sharedConversationNewModel) { - handleUpdateConversationModel(sharedConversationNewModel); - } - - setSharedConversationNewModel(undefined); - }} - /> - )} ); }; diff --git a/apps/chat/src/components/Folder/Folder.tsx b/apps/chat/src/components/Folder/Folder.tsx index 4d7f5c5ebe..133aeddf3d 100644 --- a/apps/chat/src/components/Folder/Folder.tsx +++ b/apps/chat/src/components/Folder/Folder.tsx @@ -185,7 +185,6 @@ const Folder = ({ const [renameValue, setRenameValue] = useState(currentFolder.name); const [isDraggingOver, setIsDraggingOver] = useState(false); const [isContextMenu, setIsContextMenu] = useState(false); - const [isConfirmRenaming, setIsConfirmRenaming] = useState(false); const dragDropElement = useRef(null); const [isPublishing, setIsPublishing] = useState(false); const [isUnpublishing, setIsUnpublishing] = useState(false); @@ -460,13 +459,6 @@ const Folder = ({ } } - if (currentFolder.isShared && newName !== currentFolder.name) { - setIsConfirmRenaming(true); - setIsRenaming(false); - setIsContextMenu(false); - return; - } - if (newName && newName !== currentFolder.name) { onRenameFolder(newName, currentFolder.id); } @@ -1316,27 +1308,6 @@ const Folder = ({ }} /> )} - { - setIsConfirmRenaming(false); - if (result) { - const newName = prepareEntityName(renameValue); - - if (newName) { - onRenameFolder!(newName, currentFolder.id); - } - - setRenameValue(''); - } - }} - /> ); }; diff --git a/apps/chat/src/components/Promptbar/Promptbar.tsx b/apps/chat/src/components/Promptbar/Promptbar.tsx index cba494d485..fe48312de2 100644 --- a/apps/chat/src/components/Promptbar/Promptbar.tsx +++ b/apps/chat/src/components/Promptbar/Promptbar.tsx @@ -47,7 +47,7 @@ const PromptActionsBlock = () => { isNewPromptCreating ? dispatch(PromptsActions.createNewPrompt(regeneratePromptId(prompt))) : dispatch( - PromptsActions.movePrompt({ + PromptsActions.moveOrUpdatePrompt({ prompt, newValues: { name: prompt.name, diff --git a/apps/chat/src/components/Promptbar/components/PromptModal.tsx b/apps/chat/src/components/Promptbar/components/PromptModal.tsx index b7f6a571b2..b1f273d14b 100644 --- a/apps/chat/src/components/Promptbar/components/PromptModal.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptModal.tsx @@ -31,7 +31,6 @@ import { useAppDispatch, useAppSelector } from '@/src/store/hooks'; import { PromptsSelectors } from '@/src/store/prompts/prompts.reducers'; import { UIActions } from '@/src/store/ui/ui.reducers'; -import { ConfirmDialog } from '@/src/components/Common/ConfirmDialog'; import { NotFoundEntity } from '@/src/components/Common/NotFoundEntity'; import EmptyRequiredInputMessage from '../../Common/EmptyRequiredInputMessage'; @@ -60,7 +59,6 @@ export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { selectedPrompt?.description || '', ); const [content, setContent] = useState(selectedPrompt?.content || ''); - const [isConfirmDialog, setIsConfirmDialog] = useState(false); const [submitted, setSubmitted] = useState(false); const [isDotError, setIsDotError] = useState(false); @@ -97,20 +95,6 @@ export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { onBlur(e); }; - const updatePrompt = useCallback( - (selectedPrompt: Prompt) => { - onUpdatePrompt({ - ...selectedPrompt, - name: trimEndDots(name), - description: description?.trim(), - content: content.trim(), - }); - setSubmitted(false); - onClose(); - }, - [content, description, name, onClose, onUpdatePrompt], - ); - const handleRename = useCallback( (selectedPrompt: Prompt) => { setSubmitted(true); @@ -141,14 +125,25 @@ export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { return; } - if (selectedPrompt.isShared && selectedPrompt.name !== newName) { - setIsConfirmDialog(true); - return; - } - - updatePrompt(selectedPrompt); + onUpdatePrompt({ + ...selectedPrompt, + name: trimEndDots(name), + description: description?.trim(), + content: content.trim(), + }); + setSubmitted(false); + onClose(); }, - [allPrompts, dispatch, name, t, updatePrompt], + [ + allPrompts, + content, + description, + dispatch, + name, + onClose, + onUpdatePrompt, + t, + ], ); const handleSubmit = useCallback( @@ -313,26 +308,6 @@ export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { - { - setIsConfirmDialog(false); - if (result) { - updatePrompt({ - ...selectedPrompt, - isShared: false, - }); - setSubmitted(false); - onClose(); - } - }} - /> ) : ( diff --git a/apps/chat/src/store/conversations/conversations.reducers.ts b/apps/chat/src/store/conversations/conversations.reducers.ts index 56aa1c1af4..01afbff4bc 100644 --- a/apps/chat/src/store/conversations/conversations.reducers.ts +++ b/apps/chat/src/store/conversations/conversations.reducers.ts @@ -105,7 +105,7 @@ export const conversationsSlice = createSlice({ state, _action: PayloadAction<{ conversation: ConversationInfo; - newValues: Partial; + newValues: Partial; }>, ) => state, moveConversationRegenerated: ( diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 4b8c755d49..6c88dc3440 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -218,6 +218,26 @@ const savePromptEpic: AppEpic = (action$) => ignoreElements(), ); +const moveOrUpdatePromptEpic: AppEpic = (action$) => + action$.pipe( + filter(PromptsActions.moveOrUpdatePrompt.match), + switchMap(({ payload }) => { + if ( + typeof payload.newValues.name === 'string' && + payload.newValues.name !== payload.prompt.name + ) { + return of(PromptsActions.movePrompt(payload)); + } + + return of( + PromptsActions.updatePrompt({ + id: payload.prompt.id, + values: payload.newValues, + }), + ); + }), + ); + const movePromptEpic: AppEpic = (action$) => action$.pipe( filter(PromptsActions.movePrompt.match), @@ -908,6 +928,7 @@ export const PromptsEpics = combineEpics( saveNewPromptEpic, deleteFolderEpic, savePromptEpic, + moveOrUpdatePromptEpic, movePromptEpic, movePromptRegeneratedEpic, movePromptFailEpic, diff --git a/apps/chat/src/store/prompts/prompts.reducers.ts b/apps/chat/src/store/prompts/prompts.reducers.ts index 283bc83b99..59170d6ef9 100644 --- a/apps/chat/src/store/prompts/prompts.reducers.ts +++ b/apps/chat/src/store/prompts/prompts.reducers.ts @@ -105,6 +105,13 @@ export const promptsSlice = createSlice({ ); }, savePrompt: (state, _action: PayloadAction) => state, + moveOrUpdatePrompt: ( + state, + _action: PayloadAction<{ + prompt: PromptInfo; + newValues: Partial; + }>, + ) => state, movePrompt: ( state, _action: PayloadAction<{ From 889efd94e0a908775efa477319d8e420eedd3509 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Mon, 3 Feb 2025 13:05:47 +0100 Subject: [PATCH 08/28] fix prompt update --- .../src/components/Promptbar/Promptbar.tsx | 37 +++++++++---------- .../Promptbar/components/PromptModal.tsx | 25 +++++++++++-- apps/chat/src/store/prompts/prompts.epics.ts | 6 +++ 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/apps/chat/src/components/Promptbar/Promptbar.tsx b/apps/chat/src/components/Promptbar/Promptbar.tsx index fe48312de2..f46a4b416d 100644 --- a/apps/chat/src/components/Promptbar/Promptbar.tsx +++ b/apps/chat/src/components/Promptbar/Promptbar.tsx @@ -32,34 +32,31 @@ import Sidebar from '../Sidebar'; const PromptActionsBlock = () => { const { t } = useTranslation(Translation.PromptBar); - const dispatch = useAppDispatch(); - const isNewPromptCreating = useAppSelector( - PromptsSelectors.selectIsNewPromptCreating, - ); + const dispatch = useAppDispatch(); const { showModal, isModalPreviewMode } = useAppSelector( PromptsSelectors.selectIsEditModalOpen, ); - const handleUpdate = useCallback( + const handleCreate = useCallback( (prompt: Prompt) => { - isNewPromptCreating - ? dispatch(PromptsActions.createNewPrompt(regeneratePromptId(prompt))) - : dispatch( - PromptsActions.moveOrUpdatePrompt({ - prompt, - newValues: { - name: prompt.name, - description: prompt.description, - content: prompt.content, - isShared: prompt.isShared, - }, - }), - ); + dispatch(PromptsActions.createNewPrompt(regeneratePromptId(prompt))); + }, + [dispatch], + ); + + const handleUpdate = useCallback( + (oldPrompt: Prompt, newPrompt: Prompt) => { + dispatch( + PromptsActions.moveOrUpdatePrompt({ + prompt: oldPrompt, + newValues: newPrompt, + }), + ); dispatch(PromptsActions.resetSearch()); }, - [dispatch, isNewPromptCreating], + [dispatch], ); const handleClose = useCallback(() => { @@ -77,7 +74,6 @@ const PromptActionsBlock = () => { dispatch(PromptsActions.setIsEditModalOpen({ isOpen: true })); dispatch(PromptsActions.resetChosenPrompts()); }} - disabled={isNewPromptCreating} data-qa="new-entity" > @@ -90,6 +86,7 @@ const PromptActionsBlock = () => { isOpen onClose={handleClose} onUpdatePrompt={handleUpdate} + onCreatePrompt={handleCreate} /> )} diff --git a/apps/chat/src/components/Promptbar/components/PromptModal.tsx b/apps/chat/src/components/Promptbar/components/PromptModal.tsx index b1f273d14b..8dec249bf3 100644 --- a/apps/chat/src/components/Promptbar/components/PromptModal.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptModal.tsx @@ -40,14 +40,23 @@ import Tooltip from '../../Common/Tooltip'; interface Props { isOpen: boolean; onClose: () => void; - onUpdatePrompt: (prompt: Prompt) => void; + onUpdatePrompt: (oldPrompt: Prompt, newPrompt: Prompt) => void; + onCreatePrompt: (prompt: Prompt) => void; } -export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { +export const PromptModal: FC = ({ + isOpen, + onClose, + onUpdatePrompt, + onCreatePrompt, +}) => { const { t } = useTranslation(Translation.PromptBar); const dispatch = useAppDispatch(); + const isNewPromptCreating = useAppSelector( + PromptsSelectors.selectIsNewPromptCreating, + ); const selectedPrompt = useAppSelector( PromptsSelectors.selectSelectedOrNewPrompt, ); @@ -125,12 +134,18 @@ export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { return; } - onUpdatePrompt({ + const updatedPrompt = { ...selectedPrompt, name: trimEndDots(name), description: description?.trim(), content: content.trim(), - }); + }; + + if (isNewPromptCreating) { + onCreatePrompt(updatedPrompt); + } + + onUpdatePrompt(selectedPrompt, updatedPrompt); setSubmitted(false); onClose(); }, @@ -139,8 +154,10 @@ export const PromptModal: FC = ({ isOpen, onClose, onUpdatePrompt }) => { content, description, dispatch, + isNewPromptCreating, name, onClose, + onCreatePrompt, onUpdatePrompt, t, ], diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 6c88dc3440..41ae6753b1 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -222,6 +222,12 @@ const moveOrUpdatePromptEpic: AppEpic = (action$) => action$.pipe( filter(PromptsActions.moveOrUpdatePrompt.match), switchMap(({ payload }) => { + console.log( + typeof payload.newValues.name === 'string' && + payload.newValues.name !== payload.prompt.name, + ); + console.log(payload.prompt); + console.log(payload.newValues); if ( typeof payload.newValues.name === 'string' && payload.newValues.name !== payload.prompt.name From a2cb220385252cf91b42275509d53057e6a3e7fd Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Mon, 3 Feb 2025 13:10:01 +0100 Subject: [PATCH 09/28] remoce logs --- apps/chat/src/store/prompts/prompts.epics.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 41ae6753b1..6c88dc3440 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -222,12 +222,6 @@ const moveOrUpdatePromptEpic: AppEpic = (action$) => action$.pipe( filter(PromptsActions.moveOrUpdatePrompt.match), switchMap(({ payload }) => { - console.log( - typeof payload.newValues.name === 'string' && - payload.newValues.name !== payload.prompt.name, - ); - console.log(payload.prompt); - console.log(payload.newValues); if ( typeof payload.newValues.name === 'string' && payload.newValues.name !== payload.prompt.name From 22836a470dade46cb47313184e8a0536ed6ccedb Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Mon, 3 Feb 2025 14:34:16 +0100 Subject: [PATCH 10/28] revert rename folder confirmation for shared folders --- apps/chat/public/locales/en/sidebar.json | 4 +- apps/chat/src/components/Folder/Folder.tsx | 29 +++++++++++ .../Promptbar/components/PromptFolders.tsx | 52 +++++++++++-------- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/apps/chat/public/locales/en/sidebar.json b/apps/chat/public/locales/en/sidebar.json index 9d4ab29986..7c78520f4b 100644 --- a/apps/chat/public/locales/en/sidebar.json +++ b/apps/chat/public/locales/en/sidebar.json @@ -2,7 +2,7 @@ "share.modal.link.description": "This link is temporary and will be active for 3 days.", "share.modal.link_conversation": "This conversation and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", "share.modal.link_prompt": "This prompt and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", - "share.modal.link_conversations_folder": "This conversation folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", - "share.modal.link_prompts_folder": "This prompt folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.", + "share.modal.link_conversations_folder": "This conversation folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming will stop sharing.", + "share.modal.link_prompts_folder": "This prompt folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming will stop sharing.", "share.modal.link_application": "This application and its updates will be visible to users with the link." } diff --git a/apps/chat/src/components/Folder/Folder.tsx b/apps/chat/src/components/Folder/Folder.tsx index 133aeddf3d..4d7f5c5ebe 100644 --- a/apps/chat/src/components/Folder/Folder.tsx +++ b/apps/chat/src/components/Folder/Folder.tsx @@ -185,6 +185,7 @@ const Folder = ({ const [renameValue, setRenameValue] = useState(currentFolder.name); const [isDraggingOver, setIsDraggingOver] = useState(false); const [isContextMenu, setIsContextMenu] = useState(false); + const [isConfirmRenaming, setIsConfirmRenaming] = useState(false); const dragDropElement = useRef(null); const [isPublishing, setIsPublishing] = useState(false); const [isUnpublishing, setIsUnpublishing] = useState(false); @@ -459,6 +460,13 @@ const Folder = ({ } } + if (currentFolder.isShared && newName !== currentFolder.name) { + setIsConfirmRenaming(true); + setIsRenaming(false); + setIsContextMenu(false); + return; + } + if (newName && newName !== currentFolder.name) { onRenameFolder(newName, currentFolder.id); } @@ -1308,6 +1316,27 @@ const Folder = ({ }} /> )} + { + setIsConfirmRenaming(false); + if (result) { + const newName = prepareEntityName(renameValue); + + if (newName) { + onRenameFolder!(newName, currentFolder.id); + } + + setRenameValue(''); + } + }} + /> ); }; diff --git a/apps/chat/src/components/Promptbar/components/PromptFolders.tsx b/apps/chat/src/components/Promptbar/components/PromptFolders.tsx index 5ac220476a..e2d70784b4 100644 --- a/apps/chat/src/components/Promptbar/components/PromptFolders.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptFolders.tsx @@ -200,6 +200,35 @@ const PromptFolderTemplate = ({ [dispatch], ); + const handleFolderRename = useCallback( + (name: string, folderId: string) => { + dispatch( + PromptsActions.updateFolder({ + folderId, + values: { name, isShared: false }, + }), + ); + }, + [dispatch], + ); + + const handleFolderDelete = useCallback( + (folderId: string) => { + if (folder.sharedWithMe) { + dispatch( + ShareActions.discardSharedWithMe({ + resourceIds: [folder.id], + isFolder: true, + featureType: FeatureType.Prompt, + }), + ); + } else { + dispatch(PromptsActions.deleteFolder({ folderId })); + } + }, + [dispatch, folder.id, folder.sharedWithMe], + ); + const handleFolderSelect = useCallback( (folderId: string) => { if (isFolderEmpty) { @@ -260,27 +289,8 @@ const PromptFolderTemplate = ({ highlightedFolders={allowHighlight ? highlightedFolders : []} openedFoldersIds={openedFoldersIds} handleDrop={handleDrop} - onRenameFolder={(name, folderId) => { - dispatch( - PromptsActions.updateFolder({ - folderId, - values: { name }, - }), - ); - }} - onDeleteFolder={(folderId: string) => { - if (folder.sharedWithMe) { - dispatch( - ShareActions.discardSharedWithMe({ - resourceIds: [folder.id], - isFolder: true, - featureType: FeatureType.Prompt, - }), - ); - } else { - dispatch(PromptsActions.deleteFolder({ folderId })); - } - }} + onRenameFolder={handleFolderRename} + onDeleteFolder={handleFolderDelete} onClickFolder={handleFolderClick} featureType={FeatureType.Prompt} canSelectFolders={isSelectMode} From 606a50100dbafa307aefbaa0248e57a864d07e33 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Mon, 3 Feb 2025 15:13:52 +0100 Subject: [PATCH 11/28] do not trigger update when creating new prompt --- apps/chat/src/components/Promptbar/components/PromptModal.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/chat/src/components/Promptbar/components/PromptModal.tsx b/apps/chat/src/components/Promptbar/components/PromptModal.tsx index 8dec249bf3..c5b0ab0079 100644 --- a/apps/chat/src/components/Promptbar/components/PromptModal.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptModal.tsx @@ -143,9 +143,10 @@ export const PromptModal: FC = ({ if (isNewPromptCreating) { onCreatePrompt(updatedPrompt); + } else { + onUpdatePrompt(selectedPrompt, updatedPrompt); } - onUpdatePrompt(selectedPrompt, updatedPrompt); setSubmitted(false); onClose(); }, From a01f60db88d8a78695a83a04275e534e449b62d3 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Tue, 4 Feb 2025 10:11:47 +0100 Subject: [PATCH 12/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- .../src/testData/expectedConstants.ts | 15 ++--- .../src/tests/promptMaximumNameLength.test.ts | 8 ++- apps/chat-e2e/src/tests/promptUsage.test.ts | 19 ++---- .../src/tests/sharedChatIcons.test.ts | 66 ++++++------------- .../src/tests/sharedFilesAttachments.test.ts | 23 +------ .../src/tests/sharedPromptIcons.test.ts | 36 ++-------- .../src/ui/webElements/entityTree/folders.ts | 5 +- .../src/ui/webElements/promptModalDialog.ts | 8 +-- 8 files changed, 49 insertions(+), 131 deletions(-) diff --git a/apps/chat-e2e/src/testData/expectedConstants.ts b/apps/chat-e2e/src/testData/expectedConstants.ts index d534495691..78c0593527 100644 --- a/apps/chat-e2e/src/testData/expectedConstants.ts +++ b/apps/chat-e2e/src/testData/expectedConstants.ts @@ -57,20 +57,11 @@ export const ExpectedConstants = { 'Deleting will stop sharing and other users will no longer see this conversation.', renameSharedFolderMessage: 'Renaming will stop sharing and other users will no longer see this folder.', - renameSharedConversationMessage: - 'Renaming will stop sharing and other users will no longer see this conversation.', deleteSharedPromptMessage: 'Are you sure that you want to delete a prompt?\n' + 'Deleting will stop sharing and other users will no longer see this prompt.', - sharedConversationModelChangeDialogTitle: 'Confirm model changing', - renameSharedConversationDialogTitle: 'Confirm renaming conversation', - renameSharedPromptDialogTitle: 'Confirm renaming prompt', notAllowedToMoveParentToChild: "It's not allowed to move parent folder in child folder", - sharedConversationModelChangeMessage: - 'Model changing will stop sharing and other users will no longer see this conversation.', - renameSharedPromptMessage: - 'Renaming will stop sharing and other users will no longer see this prompt.', deletePromptConfirmationModalTitle: 'Confirm deleting prompt', deletePromptConfirmationModalMessage: 'Are you sure that you want to delete a prompt?', @@ -116,9 +107,9 @@ export const ExpectedConstants = { responseFileUrlContentPattern: (model: string) => new RegExp('/appdata/' + model + '/images/.*\\.png', 'g'), shareConversationText: - 'This link is temporary and will be active for 3 days. This conversation and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming or changing the model will stop sharing.', + 'This link is temporary and will be active for 3 days. This conversation and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.', sharePromptText: - 'This link is temporary and will be active for 3 days. This prompt and future changes to it will be visible to users who follow the link. Only owner will be able to make changes. Renaming will stop sharing.', + 'This link is temporary and will be active for 3 days. This prompt and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.', shareApplicationText: 'This application and its updates will be visible to users with the link. Renaming or changing the version will stop sharing.', shareConversationFolderText: @@ -299,6 +290,8 @@ export const API = { promptsHost: () => `${API.listingHost}/prompts`, filesListingHost: () => `${API.listingHost}/files`, fileHost: '/api/files', + conversationHost: '/api/conversations', + promptHost: '/api/prompts', importFileRootPath: (bucket: string) => `files/${bucket}`, modelFilePath: (modelId: string) => `appdata/${modelId}/images`, importFilePath: (bucket: string, modelId: string) => diff --git a/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts b/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts index 20aa0c46a8..a93ffabc1d 100644 --- a/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts +++ b/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts @@ -138,14 +138,18 @@ dialTest( ExpectedConstants.newPromptFolderWithIndexTitle(1), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(longName); + await folderPrompts.editFolderNameWithTick(longName, { + isHttpMethodTriggered: false, + }); // Rename folder_child await folderPrompts.openFolderDropdownMenu( ExpectedConstants.newPromptFolderWithIndexTitle(2), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(longName); + await folderPrompts.editFolderNameWithTick(longName, { + isHttpMethodTriggered: false, + }); }, ); diff --git a/apps/chat-e2e/src/tests/promptUsage.test.ts b/apps/chat-e2e/src/tests/promptUsage.test.ts index 1a539726a6..ce2f643e8a 100644 --- a/apps/chat-e2e/src/tests/promptUsage.test.ts +++ b/apps/chat-e2e/src/tests/promptUsage.test.ts @@ -1,4 +1,3 @@ -import { Conversation } from '@/chat/types/chat'; import { Prompt } from '@/chat/types/prompt'; import { ShareByLinkResponseModel } from '@/chat/types/share'; import dialTest from '@/src/core/dialFixtures'; @@ -510,7 +509,6 @@ dialTest( async ({ dialHomePage, promptData, - conversationData, dataInjector, agentSettings, conversationSettingsModal, @@ -533,24 +531,17 @@ dialTest( `{{${aVar}}}`, `{{${bVar}|${bVarDefaultValue}}}`, ); - let conversation: Conversation; - await dialTest.step( - 'Prepare prompt with vars and empty conversation', - async () => { - prompt = promptData.preparePrompt(promptContent); - conversation = conversationData.prepareEmptyConversation(); - await dataInjector.createPrompts([prompt]); - await dataInjector.createConversations([conversation]); - }, - ); + await dialTest.step('Prepare prompt with vars', async () => { + prompt = promptData.preparePrompt(promptContent); + await dataInjector.createPrompts([prompt]); + }); await dialTest.step( `Type / in system prompt field, select created prompt and verify variable modal with default values is displayed`, async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(conversation.name); await chat.configureSettingsButton.click(); await agentSettings.setSystemPrompt('/'); const promptsList = agentSettings.getPromptList(); @@ -574,7 +565,7 @@ dialTest( await agentSettingAssertion.assertSystemPromptValue( promptTemplate(aVarValue, bVarDefaultValue), ); - await conversationSettingsModal.cancelButton.click(); + await conversationSettingsModal.applyChangesButton.click(); }, ); diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index 9c2eaa22ae..24501bccdc 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -316,8 +316,6 @@ dialTest( marketplacePage, conversations, conversationDropdownMenu, - confirmationDialog, - confirmationDialogAssertion, conversationSettingsModal, chat, setTestIds, @@ -335,6 +333,7 @@ dialTest( let thirdConversationToShare: Conversation; let randomAddon: DialAIEntityModel; let randomModel: DialAIEntityModel; + let defaultModelId: string; let newName: string; await dialTest.step( @@ -361,10 +360,11 @@ dialTest( await mainUserShareApiHelper.shareEntityByLink([conversation]); await additionalUserShareApiHelper.acceptInvite(shareByLinkResponse); } + defaultModelId = ModelsUtil.getDefaultModel()!.id; randomAddon = GeneratorUtil.randomArrayElement(ModelsUtil.getAddons()); randomModel = GeneratorUtil.randomArrayElement( ModelsUtil.getLatestModels().filter( - (model) => model.id !== ModelsUtil.getDefaultModel()!.id, + (model) => model.id !== defaultModelId, ), ); await localStorageManager.setRecentAddonsIds(randomAddon); @@ -395,7 +395,7 @@ dialTest( ); await dialTest.step( - 'Update conversation name for the 2nd conversation and verify confirmation modal is displayed', + 'Update conversation name for the 2nd conversation and verify conversation is shared, shared icon is displayed', async () => { newName = GeneratorUtil.randomString(10); await conversations.selectConversation(secondConversationToShare.name); @@ -403,77 +403,51 @@ dialTest( secondConversationToShare.name, ); await conversationDropdownMenu.selectMenuOption(MenuOptions.rename); - await renameConversationModal.editInputValue(newName); - await renameConversationModal.saveButton.click(); - await confirmationDialogAssertion.assertConfirmationDialogTitle( - ExpectedConstants.renameSharedConversationDialogTitle, - ); - await confirmationDialogAssertion.assertConfirmationMessage( - ExpectedConstants.renameSharedConversationMessage, + await renameConversationModal.editConversationNameWithSaveButton( + newName, ); - }, - ); - - await dialTest.step( - 'Confirm conversation rename and verify conversation is not shared and arrow icon disappears', - async () => { - await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); await conversationAssertion.assertEntityArrowIconState( { name: newName }, - 'hidden', + 'visible', ); }, ); await dialTest.step( - 'Update model for the 3rd conversation and verify confirmation modal is displayed', + 'Update model for the 3rd conversation and verify conversation is shared, shared icon is displayed', async () => { await conversations.selectConversation(thirdConversationToShare.name); await chatHeader.chatAgent.click(); await talkToAgentDialog.selectAgent(randomModel, marketplacePage); - await confirmationDialogAssertion.assertConfirmationDialogTitle( - ExpectedConstants.sharedConversationModelChangeDialogTitle, - ); - await confirmationDialogAssertion.assertConfirmationMessage( - ExpectedConstants.sharedConversationModelChangeMessage, - ); - }, - ); - - await dialTest.step( - 'Confirm conversation model change and verify conversation is not shared and arrow icon disappears', - async () => { - await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); await conversationAssertion.assertEntityArrowIconState( { name: newName }, - 'hidden', + 'visible', ); }, ); await dialSharedWithMeTest.step( - 'Verify only conversation with updated settings is shared with user', + 'Verify conversations remained shared with user', async () => { - const sharedEntities = - await additionalUserShareApiHelper.listSharedWithMeConversations(); - await shareApiAssertion.assertSharedWithMeEntityState( - sharedEntities, - firstConversationToShare, - 'visible', - ); - secondConversationToShare.id = secondConversationToShare.id.replace( secondConversationToShare.name, newName, ); - for (const sharedConversation of [ + thirdConversationToShare.id = thirdConversationToShare.id.replace( + defaultModelId, + randomModel.id, + ); + const sharedEntities = + await additionalUserShareApiHelper.listSharedWithMeConversations(); + for (const conversation of [ + firstConversationToShare, secondConversationToShare, thirdConversationToShare, ]) { await shareApiAssertion.assertSharedWithMeEntityState( sharedEntities, - sharedConversation, - 'hidden', + conversation, + 'visible', ); } }, diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index 7d3bda1c9a..85aa710b54 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -52,7 +52,6 @@ dialSharedWithMeTest( additionalShareUserLocalStorageManager, additionalShareUserAttachFilesModal, additionalShareUserToastAssertion, - additionalShareUserDataInjector, conversations, attachmentDropdownMenu, attachFilesModal, @@ -85,7 +84,6 @@ dialSharedWithMeTest( let imageUrl2: string; let imageInConversationInFolderUrl: string; let specialCharsImageUrl: string; - let conversationToShare: Conversation; //TODO EPMRTC-4135 blocked by the #1076 // let imageInFolderUrl2: string; let shareByLinkResponse: ShareByLinkResponseModel; @@ -292,18 +290,6 @@ dialSharedWithMeTest( }, ); - await dialSharedWithMeTest.step( - 'Prepare conversation to share of the user 2', - async () => { - conversationData.resetData(); - conversationToShare = - conversationData.prepareEmptyConversation(defaultModelId); - await additionalShareUserDataInjector.createConversations([ - conversationToShare, - ]); - }, - ); - await dialSharedWithMeTest.step( 'By user2 create a conversation with attachments from Shared with me section in Manage attachments', async () => { @@ -313,9 +299,6 @@ dialSharedWithMeTest( const newRequest = GeneratorUtil.randomString(10); await additionalShareUserDialHomePage.openHomePage(); await additionalShareUserDialHomePage.waitForPageLoaded(); - await additionalShareUserConversations.selectConversation( - conversationToShare.name, - ); await additionalShareUserSendMessage.attachmentMenuTrigger.click(); await additionalShareUserAttachmentDropdownMenu.selectMenuOption( @@ -363,13 +346,9 @@ dialSharedWithMeTest( ); conversationWithTwoResponses.name = GeneratorUtil.randomString(10); await conversationDropdownMenu.selectMenuOption(MenuOptions.rename); - await renameConversationModal.editInputValue( + await renameConversationModal.editConversationNameWithSaveButton( conversationWithTwoResponses.name, ); - await renameConversationModal.saveButton.click(); - await confirmationDialog.confirm({ - triggeredHttpMethod: 'PUT', - }); break; case 'model change': await chatHeader.chatAgent.click(); diff --git a/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts b/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts index 64d1369d91..f11d49ff06 100644 --- a/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts @@ -170,8 +170,6 @@ dialTest( promptModalDialog, mainUserShareApiHelper, additionalUserShareApiHelper, - confirmationDialogAssertion, - confirmationDialog, shareApiAssertion, setTestIds, }) => { @@ -209,47 +207,25 @@ dialTest( ); await dialTest.step( - 'Edit prompt name and verify confirmation modal appears on prompt save', + 'Edit prompt name and verify shared icon is displayed on the prompt', async () => { await prompts.openEntityDropdownMenu(prompt.name); await promptDropdownMenu.selectMenuOption(MenuOptions.edit); await promptModalDialog.setField(promptModalDialog.name, newName); await promptModalDialog.saveButton.click(); - await confirmationDialogAssertion.assertConfirmationDialogTitle( - ExpectedConstants.renameSharedPromptDialogTitle, - ); - await confirmationDialogAssertion.assertConfirmationMessage( - ExpectedConstants.renameSharedPromptMessage, - ); - }, - ); - - await dialTest.step( - 'Cancel confirmation modal and verify shared icon is displayed on prompt', - async () => { - await confirmationDialog.cancelDialog(); - await promptAssertion.assertEntityArrowIconState( - { name: prompt.name }, + await promptAssertion.assertElementState( + prompts.getEntityByName(newName), 'visible', ); - }, - ); - - await dialTest.step( - 'Confirm prompt renaming and verify shared icon is not displayed on prompt', - async () => { - await promptModalDialog.setField(promptModalDialog.name, newName); - await promptModalDialog.saveButton.click(); - await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); await promptAssertion.assertEntityArrowIconState( { name: newName }, - 'hidden', + 'visible', ); }, ); await dialTest.step( - 'Verify prompt is not shared with another user', + 'Verify prompt remained shared with another user', async () => { const sharedEntities = await additionalUserShareApiHelper.listSharedWithMePrompts(); @@ -257,7 +233,7 @@ dialTest( await shareApiAssertion.assertSharedWithMeEntityState( sharedEntities, prompt, - 'hidden', + 'visible', ); }, ); diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts b/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts index 5cab449763..c9630f1d21 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts @@ -219,8 +219,9 @@ export class Folders extends BaseElement { if (isHttpMethodTriggered && isApiStorageType) { const respPromise = this.page.waitForResponse((resp) => { return ( - resp.url().includes(API.conversationsHost()) || - resp.url().includes(API.promptsHost()) + resp.request().method() === 'PUT' && + (resp.url().includes(API.conversationHost) || + resp.url().includes(API.promptHost)) ); }); await folderInputActions.clickTickButton(); diff --git a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts index 913c2eb618..2274ce1a6e 100644 --- a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts +++ b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts @@ -1,4 +1,5 @@ import { isApiStorageType } from '@/src/hooks/global-setup'; +import { API } from '@/src/testData'; import { Attributes } from '@/src/ui/domData'; import { keys } from '@/src/ui/keyboard'; import { ErrorLabelSelectors } from '@/src/ui/selectors'; @@ -77,10 +78,9 @@ export class PromptModalDialog extends BaseElement { ) { await this.fillPromptDetails(name, description, value); if (isApiStorageType) { - const respPromise = this.page.waitForResponse((resp) => { - const method = resp.request().method(); - return method === 'POST' || method === 'PUT'; - }); + const respPromise = this.page.waitForResponse((resp) => + resp.request().url().includes(API.promptHost), + ); await method(); const response = await respPromise; return response.request().postDataJSON(); From cb9c42a107b737898890cdffd6e0df33cd1f1cb9 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Tue, 4 Feb 2025 12:49:31 +0100 Subject: [PATCH 13/28] fix import --- apps/chat/src/components/Chat/RenameConversationModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/chat/src/components/Chat/RenameConversationModal.tsx b/apps/chat/src/components/Chat/RenameConversationModal.tsx index a9c77ba934..0e08e73817 100644 --- a/apps/chat/src/components/Chat/RenameConversationModal.tsx +++ b/apps/chat/src/components/Chat/RenameConversationModal.tsx @@ -28,7 +28,7 @@ import { UIActions } from '@/src/store/ui/ui.reducers'; import { DISALLOW_INTERACTIONS } from '@/src/constants/modal'; -import Modal from '../Common/Modal'; +import { Modal } from '../Common/Modal'; export const RenameConversationModal = () => { const renamingConversation = useAppSelector( From eee2e780b83f9a5c6d5874a7b47c549e37659f5a Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Tue, 4 Feb 2025 17:23:10 +0100 Subject: [PATCH 14/28] refactor to previous logic and replace recreate with move --- .../Chat/ConversationContextMenu.tsx | 6 +- .../components/Chat/EmptyChatDescription.tsx | 8 +- .../Chat/RenameConversationModal.tsx | 6 +- .../components/Chat/TalkTo/TalkToModal.tsx | 6 +- .../src/components/Chatbar/ChatFolders.tsx | 6 +- apps/chat/src/components/Chatbar/Chatbar.tsx | 6 +- .../src/components/Promptbar/Promptbar.tsx | 12 +- .../Promptbar/components/Prompt.tsx | 6 +- .../Promptbar/components/PromptFolders.tsx | 6 +- .../conversations/conversations.epics.ts | 123 ++++++------------ .../conversations/conversations.reducers.ts | 33 ++--- apps/chat/src/store/prompts/prompts.epics.ts | 97 ++++---------- .../src/store/prompts/prompts.reducers.ts | 25 +--- 13 files changed, 112 insertions(+), 228 deletions(-) diff --git a/apps/chat/src/components/Chat/ConversationContextMenu.tsx b/apps/chat/src/components/Chat/ConversationContextMenu.tsx index f8474becc8..64accd8369 100644 --- a/apps/chat/src/components/Chat/ConversationContextMenu.tsx +++ b/apps/chat/src/components/Chat/ConversationContextMenu.tsx @@ -238,9 +238,9 @@ export const ConversationContextMenu = ({ }), ); dispatch( - ConversationsActions.moveConversation({ - conversation, - newValues: { + ConversationsActions.updateConversation({ + id: conversation.id, + values: { folderId: isNewFolder ? constructPath(getConversationRootId(), folderPath) : folderPath, diff --git a/apps/chat/src/components/Chat/EmptyChatDescription.tsx b/apps/chat/src/components/Chat/EmptyChatDescription.tsx index 5d348938c6..ba93bbf51e 100644 --- a/apps/chat/src/components/Chat/EmptyChatDescription.tsx +++ b/apps/chat/src/components/Chat/EmptyChatDescription.tsx @@ -102,13 +102,13 @@ const EmptyChatDescriptionView = ({ const handleSelectVersion = useCallback( (model: DialAIEntityModel) => { dispatch( - ConversationsActions.moveConversation({ - conversation, - newValues: { model: { id: model.reference } }, + ConversationsActions.updateConversation({ + id: conversation.id, + values: { model: { id: model.reference } }, }), ); }, - [conversation, dispatch], + [conversation.id, dispatch], ); if (models.length === 0) { diff --git a/apps/chat/src/components/Chat/RenameConversationModal.tsx b/apps/chat/src/components/Chat/RenameConversationModal.tsx index 0e08e73817..96c3266ed9 100644 --- a/apps/chat/src/components/Chat/RenameConversationModal.tsx +++ b/apps/chat/src/components/Chat/RenameConversationModal.tsx @@ -111,9 +111,9 @@ const RenameConversationView = () => { if (newName.length > 0) { dispatch( - ConversationsActions.moveConversation({ - conversation: renamingConversation, - newValues: { name: newName, isNameChanged: true }, + ConversationsActions.updateConversation({ + id: renamingConversation.id, + values: { name: newName, isNameChanged: true }, }), ); dispatch(ConversationsActions.setRenamingConversationId(null)); diff --git a/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx b/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx index a1b2a4926e..0101c92035 100644 --- a/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx +++ b/apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx @@ -189,9 +189,9 @@ const TalkToModalView = ({ conversation.replay?.replayAsIs) ) { dispatch( - ConversationsActions.moveConversation({ - conversation, - newValues: { + ConversationsActions.updateConversation({ + id: conversation.id, + values: { ...getConversationModelParams( conversation, entity.reference, diff --git a/apps/chat/src/components/Chatbar/ChatFolders.tsx b/apps/chat/src/components/Chatbar/ChatFolders.tsx index 469a3af7ee..d54ca1a850 100644 --- a/apps/chat/src/components/Chatbar/ChatFolders.tsx +++ b/apps/chat/src/components/Chatbar/ChatFolders.tsx @@ -142,9 +142,9 @@ const ChatFolderTemplate = ({ if (conversationData) { const conversation: Conversation = JSON.parse(conversationData); dispatch( - ConversationsActions.moveConversation({ - conversation, - newValues: { folderId: folder.id }, + ConversationsActions.updateConversation({ + id: conversation.id, + values: { folderId: folder.id }, }), ); } else if (folderData) { diff --git a/apps/chat/src/components/Chatbar/Chatbar.tsx b/apps/chat/src/components/Chatbar/Chatbar.tsx index 6901658f68..c7e47206ef 100644 --- a/apps/chat/src/components/Chatbar/Chatbar.tsx +++ b/apps/chat/src/components/Chatbar/Chatbar.tsx @@ -163,9 +163,9 @@ export const Chatbar = () => { }), ); dispatch( - ConversationsActions.moveConversation({ - conversation, - newValues: { folderId }, + ConversationsActions.updateConversation({ + id: conversation.id, + values: { folderId }, }), ); dispatch(ConversationsActions.resetSearch()); diff --git a/apps/chat/src/components/Promptbar/Promptbar.tsx b/apps/chat/src/components/Promptbar/Promptbar.tsx index f46a4b416d..a7ce130bde 100644 --- a/apps/chat/src/components/Promptbar/Promptbar.tsx +++ b/apps/chat/src/components/Promptbar/Promptbar.tsx @@ -49,9 +49,9 @@ const PromptActionsBlock = () => { const handleUpdate = useCallback( (oldPrompt: Prompt, newPrompt: Prompt) => { dispatch( - PromptsActions.moveOrUpdatePrompt({ - prompt: oldPrompt, - newValues: newPrompt, + PromptsActions.updatePrompt({ + id: oldPrompt.id, + values: newPrompt, }), ); dispatch(PromptsActions.resetSearch()); @@ -164,9 +164,9 @@ const Promptbar = () => { }), ); dispatch( - PromptsActions.movePrompt({ - prompt, - newValues: { folderId }, + PromptsActions.updatePrompt({ + id: prompt.id, + values: { folderId }, }), ); } diff --git a/apps/chat/src/components/Promptbar/components/Prompt.tsx b/apps/chat/src/components/Promptbar/components/Prompt.tsx index 79f4488f31..12f9405a99 100644 --- a/apps/chat/src/components/Promptbar/components/Prompt.tsx +++ b/apps/chat/src/components/Promptbar/components/Prompt.tsx @@ -327,9 +327,9 @@ export const PromptComponent = ({ }), ); dispatch( - PromptsActions.movePrompt({ - prompt, - newValues: { + PromptsActions.updatePrompt({ + id: prompt.id, + values: { folderId: isNewFolder ? constructPath(getPromptRootId(), folderPath) : folderPath, diff --git a/apps/chat/src/components/Promptbar/components/PromptFolders.tsx b/apps/chat/src/components/Promptbar/components/PromptFolders.tsx index e2d70784b4..7a779249c3 100644 --- a/apps/chat/src/components/Promptbar/components/PromptFolders.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptFolders.tsx @@ -132,9 +132,9 @@ const PromptFolderTemplate = ({ if (promptData) { const prompt: PromptInfo = JSON.parse(promptData); dispatch( - PromptsActions.movePrompt({ - prompt, - newValues: { folderId: folder.id }, + PromptsActions.updatePrompt({ + id: prompt.id, + values: { folderId: folder.id }, }), ); } else if (folderData) { diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index d28f9d0211..9445e5967d 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -864,9 +864,9 @@ const updateFolderEpic: AppEpic = (action$, state$) => conversations.forEach((conversation) => { actions.push( of( - ConversationsActions.moveConversation({ - conversation, - newValues: { + ConversationsActions.updateConversation({ + id: conversation.id, + values: { folderId: updateFolderId(conversation.folderId), }, }), @@ -1308,24 +1308,12 @@ const sendMessageEpic: AppEpic = (action$, state$) => return concat( ...actions, - iif( - () => - newConversationName !== payload.conversation.name && - !isEntityIdLocal(payload.conversation), - of( - ConversationsActions.moveConversation({ - conversation: payload.conversation, - newValues: updatedConversation, - }), - ), - of( - ConversationsActions.updateConversation({ - id: payload.conversation.id, - values: updatedConversation, - }), - ), + of( + ConversationsActions.updateConversation({ + id: payload.conversation.id, + values: updatedConversation, + }), ), - of( ModelsActions.updateRecentModels({ modelId: updatedConversation.model.id, @@ -2331,67 +2319,33 @@ const saveConversationEpic: AppEpic = (action$) => }), ); -const moveConversationEpic: AppEpic = (action$) => +const moveConversationFailEpic: AppEpic = (action$) => action$.pipe( - filter(ConversationsActions.moveConversation.match), - map(({ payload }) => - ConversationsActions.moveConversationRegenerated({ - oldConversation: payload.conversation, - newConversation: regenerateConversationId({ - ...payload.conversation, - ...payload.newValues, - }), - }), - ), + filter(ConversationsActions.moveConversationFail.match), + switchMap(() => { + return of( + UIActions.showErrorToast( + translate( + 'It looks like conversation already exist. Please reload the page', + ), + ), + ); + }), ); -const moveConversationRegeneratedEpic: AppEpic = (action$) => +const moveConversationEpic: AppEpic = (action$) => action$.pipe( - filter(ConversationsActions.moveConversationRegenerated.match), - switchMap(({ payload }) => { - if (isEntityIdLocal(payload.oldConversation)) { - return of( - ConversationsActions.updateConversation({ - id: payload.newConversation.id, - values: payload.newConversation, - }), - ); - } - - if (payload.newConversation.id === payload.oldConversation.id) { - return EMPTY; - } - + filter(ConversationsActions.moveConversation.match), + mergeMap(({ payload }) => { return ConversationService.moveConversation({ sourceUrl: payload.oldConversation.id, destinationUrl: payload.newConversation.id, overwrite: false, }).pipe( - switchMap(() => - of( - ConversationsActions.updateConversation({ - id: payload.newConversation.id, - values: payload.newConversation, - }), - ), - ), catchError(() => { return of(ConversationsActions.moveConversationFail(payload)); }), - ); - }), - ); - -const moveConversationFailEpic: AppEpic = (action$) => - action$.pipe( - filter(ConversationsActions.moveConversationFail.match), - switchMap(() => { - return of( - UIActions.showErrorToast( - translate( - 'It looks like conversation already exist. Please reload the page', - ), - ), + ignoreElements(), ); }), ); @@ -2414,23 +2368,31 @@ const updateConversationEpic: AppEpic = (action$, state$) => ); } + const newConversation: Conversation = regenerateConversationId({ + ...(conversation as Conversation), + ...values, + lastActivityDate: Date.now(), + }); + return concat( iif( - () => !conversation.isPlayback || values.isPlayback === false, + () => !!conversation && conversation.id !== newConversation.id, of( - ConversationsActions.saveConversation({ - ...conversation, - ...values, + ConversationsActions.moveConversation({ + newConversation, + oldConversation: conversation, }), ), - EMPTY, + iif( + () => !newConversation.isPlayback, + of(ConversationsActions.saveConversation(newConversation)), + EMPTY, + ), ), of( ConversationsActions.updateConversationSuccess({ id, - conversation: { - ...values, - }, + conversation: { ...values }, }), ), ); @@ -3046,9 +3008,9 @@ const applyMarketplaceModelEpic: AppEpic = (action$, state$) => iif( () => !!conversation, of( - ConversationsActions.moveConversation({ - conversation: conversation!, - newValues: { + ConversationsActions.updateConversation({ + id: conversation?.id as string, + values: { ...getConversationModelParams( conversation as Conversation, modelToApply?.reference, @@ -3205,7 +3167,6 @@ export const ConversationsEpics = combineEpics( // update moveConversationEpic, - moveConversationRegeneratedEpic, moveConversationFailEpic, updateConversationEpic, updateLocalConversationEpic, diff --git a/apps/chat/src/store/conversations/conversations.reducers.ts b/apps/chat/src/store/conversations/conversations.reducers.ts index 01afbff4bc..51d520ad9b 100644 --- a/apps/chat/src/store/conversations/conversations.reducers.ts +++ b/apps/chat/src/store/conversations/conversations.reducers.ts @@ -103,39 +103,22 @@ export const conversationsSlice = createSlice({ }, moveConversation: ( state, - _action: PayloadAction<{ - conversation: ConversationInfo; - newValues: Partial; - }>, - ) => state, - moveConversationRegenerated: ( - state, - { - payload, - }: PayloadAction<{ - oldConversation: ConversationInfo; - newConversation: ConversationInfo; + action: PayloadAction<{ + newConversation: Conversation; + oldConversation: Conversation; }>, ) => { - state.conversations = state.conversations.map((conv) => { - if (payload.oldConversation.id === conv.id) { - return payload.newConversation; - } - - return conv; - }); - state.selectedConversationsIds = state.selectedConversationsIds.map( - (id) => - id === payload.oldConversation.id ? payload.newConversation.id : id, - ); + if (!action.payload.oldConversation.messages.length) { + state.isNewConversationUpdating = true; + } }, moveConversationFail: ( state, { payload, }: PayloadAction<{ - oldConversation: ConversationInfo; - newConversation: ConversationInfo; + oldConversation: Conversation; + newConversation: Conversation; }>, ) => { state.conversations = state.conversations.map((conv) => { diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 6c88dc3440..18659b2024 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -218,22 +218,16 @@ const savePromptEpic: AppEpic = (action$) => ignoreElements(), ); -const moveOrUpdatePromptEpic: AppEpic = (action$) => +const movePromptFailEpic: AppEpic = (action$) => action$.pipe( - filter(PromptsActions.moveOrUpdatePrompt.match), - switchMap(({ payload }) => { - if ( - typeof payload.newValues.name === 'string' && - payload.newValues.name !== payload.prompt.name - ) { - return of(PromptsActions.movePrompt(payload)); - } - + filter(PromptsActions.movePromptFail.match), + switchMap(() => { return of( - PromptsActions.updatePrompt({ - id: payload.prompt.id, - values: payload.newValues, - }), + UIActions.showErrorToast( + translate( + 'It looks like prompt already exist. Please reload the page', + ), + ), ); }), ); @@ -241,59 +235,16 @@ const moveOrUpdatePromptEpic: AppEpic = (action$) => const movePromptEpic: AppEpic = (action$) => action$.pipe( filter(PromptsActions.movePrompt.match), - map(({ payload }) => - PromptsActions.movePromptRegenerated({ - oldPrompt: payload.prompt, - newPrompt: { - ...payload.prompt, - ...payload.newValues, - id: constructPath( - payload.newValues.folderId ?? payload.prompt.folderId, - getPromptApiKey({ ...payload.prompt, ...payload.newValues }), - ), - }, - }), - ), - ); - -const movePromptRegeneratedEpic: AppEpic = (action$) => - action$.pipe( - filter(PromptsActions.movePromptRegenerated.match), - switchMap(({ payload }) => { - if (payload.newPrompt.id === payload.oldPrompt.id) { - return EMPTY; - } - + mergeMap(({ payload }) => { return PromptService.movePrompt({ sourceUrl: payload.oldPrompt.id, destinationUrl: payload.newPrompt.id, overwrite: false, }).pipe( - switchMap(() => - of( - PromptsActions.updatePrompt({ - id: payload.newPrompt.id, - values: payload.newPrompt, - }), - ), - ), catchError(() => { return of(PromptsActions.movePromptFail(payload)); }), - ); - }), - ); - -const movePromptFailEpic: AppEpic = (action$) => - action$.pipe( - filter(PromptsActions.movePromptFail.match), - switchMap(() => { - return of( - UIActions.showErrorToast( - translate( - 'It looks like prompt already exist. Please reload the page', - ), - ), + ignoreElements(), ); }), ); @@ -318,14 +269,22 @@ const updatePromptEpic: AppEpic = (action$, state$) => ); } + const newPrompt: Prompt = { + ...prompt, + ...values, + id: constructPath( + values.folderId || prompt.folderId, + getPromptApiKey({ ...prompt, ...values }), + ), + }; + return concat( - of( - PromptsActions.updatePromptSuccess({ - prompt: { ...values }, - id, - }), + of(PromptsActions.updatePromptSuccess({ prompt: newPrompt, id })), + iif( + () => !!prompt && prompt.id !== newPrompt.id, + of(PromptsActions.movePrompt({ oldPrompt: prompt, newPrompt })), + of(PromptsActions.savePrompt(newPrompt)), ), - of(PromptsActions.savePrompt({ ...prompt, ...values })), ); }), ); @@ -458,9 +417,9 @@ const updateFolderEpic: AppEpic = (action$, state$) => prompts.forEach((prompt) => { actions.push( of( - PromptsActions.movePrompt({ - prompt, - newValues: { folderId: updateFolderId(prompt.folderId) }, + PromptsActions.updatePrompt({ + id: prompt.id, + values: { folderId: updateFolderId(prompt.folderId) }, }), ), ); @@ -928,9 +887,7 @@ export const PromptsEpics = combineEpics( saveNewPromptEpic, deleteFolderEpic, savePromptEpic, - moveOrUpdatePromptEpic, movePromptEpic, - movePromptRegeneratedEpic, movePromptFailEpic, updatePromptEpic, deletePromptEpic, diff --git a/apps/chat/src/store/prompts/prompts.reducers.ts b/apps/chat/src/store/prompts/prompts.reducers.ts index 59170d6ef9..dcf3b5c3b9 100644 --- a/apps/chat/src/store/prompts/prompts.reducers.ts +++ b/apps/chat/src/store/prompts/prompts.reducers.ts @@ -115,34 +115,17 @@ export const promptsSlice = createSlice({ movePrompt: ( state, _action: PayloadAction<{ - prompt: PromptInfo; - newValues: Partial; + newPrompt: Prompt; + oldPrompt: Prompt; }>, ) => state, - movePromptRegenerated: ( - state, - { - payload, - }: PayloadAction<{ - oldPrompt: PromptInfo; - newPrompt: PromptInfo; - }>, - ) => { - state.prompts = state.prompts.map((prompt) => { - if (payload.oldPrompt.id === prompt.id) { - return payload.newPrompt; - } - - return prompt; - }); - }, movePromptFail: ( state, { payload, }: PayloadAction<{ - oldPrompt: PromptInfo; - newPrompt: PromptInfo; + newPrompt: Prompt; + oldPrompt: Prompt; }>, ) => { state.prompts = state.prompts.map((prompt) => { From 15d42546794af3d3c2684593f5850a4e984609af Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Tue, 4 Feb 2025 17:59:46 +0100 Subject: [PATCH 15/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- apps/chat-e2e/src/testData/expectedConstants.ts | 1 + apps/chat-e2e/src/tests/folderNameNumeration.test.ts | 1 + apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts | 4 +++- apps/chat-e2e/src/ui/webElements/promptModalDialog.ts | 10 +++++++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/chat-e2e/src/testData/expectedConstants.ts b/apps/chat-e2e/src/testData/expectedConstants.ts index 78c0593527..0539d0bae2 100644 --- a/apps/chat-e2e/src/testData/expectedConstants.ts +++ b/apps/chat-e2e/src/testData/expectedConstants.ts @@ -292,6 +292,7 @@ export const API = { fileHost: '/api/files', conversationHost: '/api/conversations', promptHost: '/api/prompts', + moveHost: '/api/ops/resource/move', importFileRootPath: (bucket: string) => `files/${bucket}`, modelFilePath: (modelId: string) => `appdata/${modelId}/images`, importFilePath: (bucket: string, modelId: string) => diff --git a/apps/chat-e2e/src/tests/folderNameNumeration.test.ts b/apps/chat-e2e/src/tests/folderNameNumeration.test.ts index 129d54523c..21722418e3 100644 --- a/apps/chat-e2e/src/tests/folderNameNumeration.test.ts +++ b/apps/chat-e2e/src/tests/folderNameNumeration.test.ts @@ -117,6 +117,7 @@ dialTest( await folderDropdownMenu.selectMenuOption(MenuOptions.rename); await folderConversations.editFolderNameWithTick( GeneratorUtil.randomString(5), + { isHttpMethodTriggered: false }, ); await chatBar.createNewFolder(); diff --git a/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts b/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts index 3a8a9e51fc..09fccc452c 100644 --- a/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts +++ b/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts @@ -41,7 +41,9 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(1), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(duplicatedFolderName); + await folderPrompts.editFolderNameWithTick(duplicatedFolderName, { + isHttpMethodTriggered: false, + }); }); await dialTest.step( diff --git a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts index 2274ce1a6e..9c815318ec 100644 --- a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts +++ b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts @@ -76,11 +76,15 @@ export class PromptModalDialog extends BaseElement { value: string, method: () => Promise, ) { + const isNameUpdated = (await this.getName()) !== name; await this.fillPromptDetails(name, description, value); if (isApiStorageType) { - const respPromise = this.page.waitForResponse((resp) => - resp.request().url().includes(API.promptHost), - ); + const respPromise = this.page.waitForResponse((resp) => { + const url = resp.request().url(); + return isNameUpdated + ? url.includes(API.moveHost) + : url.includes(API.promptHost); + }); await method(); const response = await respPromise; return response.request().postDataJSON(); From 73b122480e4356edfa44056aaac23b33d8a40092 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Tue, 4 Feb 2025 21:33:52 +0100 Subject: [PATCH 16/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- apps/chat-e2e/src/ui/webElements/entityTree/folders.ts | 10 +++------- .../entityTree/sidebar/sideBarEntitiesTree.ts | 2 +- .../src/ui/webElements/renameConversationModal.ts | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts b/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts index c9630f1d21..c23c58b705 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts @@ -217,13 +217,9 @@ export class Folders extends BaseElement { await this.editFolderName(newName); const folderInputActions = this.getEditFolderInputActions(); if (isHttpMethodTriggered && isApiStorageType) { - const respPromise = this.page.waitForResponse((resp) => { - return ( - resp.request().method() === 'PUT' && - (resp.url().includes(API.conversationHost) || - resp.url().includes(API.promptHost)) - ); - }); + const respPromise = this.page.waitForResponse((resp) => + resp.url().includes(API.moveHost), + ); await folderInputActions.clickTickButton(); return respPromise; } diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts index a9027bd092..bef67c582f 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree.ts @@ -79,7 +79,7 @@ export class SideBarEntitiesTree extends EntitiesTree { { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, ) { return this.getDropdownMenu().selectMenuOption(name, { - triggeredHttpMethod: 'PUT', + triggeredHttpMethod: 'POST', isHttpMethodTriggered, }); } diff --git a/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts b/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts index 327729186e..b5a477e664 100644 --- a/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts +++ b/apps/chat-e2e/src/ui/webElements/renameConversationModal.ts @@ -30,7 +30,7 @@ export class RenameConversationModal extends BaseElement { await this.nameInput.fillInInput(newName); if (isApiStorageType && isHttpMethodTriggered) { const respPromise = this.page.waitForResponse( - (resp) => resp.request().method() === 'PUT', + (resp) => resp.request().method() === 'POST', ); await confirmationAction(); await respPromise; From 2ae720651fdb52ad93a610cf3ae6b49420f0e7d7 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Wed, 5 Feb 2025 09:08:51 +0100 Subject: [PATCH 17/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts | 1 + apps/chat-e2e/src/tests/promptFolderNumeration.test.ts | 9 +++++++-- .../chat-e2e/src/tests/promptFoldersSpecialChars.test.ts | 8 ++++++-- apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts | 4 ---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts b/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts index 09fccc452c..29e50afcb5 100644 --- a/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts +++ b/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts @@ -209,6 +209,7 @@ dialTest( await folderDropdownMenu.selectMenuOption(MenuOptions.rename); await folderPrompts.editFolderNameWithTick( ExpectedConstants.newFolderWithIndexTitle(2), + { isHttpMethodTriggered: false }, ); }); diff --git a/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts b/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts index 0fa327e37e..b844dc34f1 100644 --- a/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts +++ b/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts @@ -163,7 +163,9 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(folderNumber), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick('Renamed Folder'); + await folderPrompts.editFolderNameWithTick('Renamed Folder', { + isHttpMethodTriggered: false, + }); await promptBar.createNewFolder(); await expect @@ -211,6 +213,7 @@ dialTest( await promptDropdownMenu.selectMenuOption(MenuOptions.rename); await folderPrompts.editFolderNameWithTick( ExpectedConstants.newPromptFolderWithIndexTitle(999), + { isHttpMethodTriggered: false }, ); }); @@ -285,7 +288,9 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(i), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(duplicatedFolderName); + await folderPrompts.editFolderNameWithTick(duplicatedFolderName, { + isHttpMethodTriggered: false, + }); await expect( folderPrompts.getFolderByName(duplicatedFolderName, i), ExpectedMessages.folderNameUpdated, diff --git a/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts b/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts index 42ab42c4ea..a5ed20fb55 100644 --- a/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts +++ b/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts @@ -81,7 +81,9 @@ dialTest( }); await dialTest.step('Rename it to contain special characters', async () => { - await folderPrompts.editFolderNameWithTick(newNameWithSpecialChars); + await folderPrompts.editFolderNameWithTick(newNameWithSpecialChars, { + isHttpMethodTriggered: false, + }); await promptBarFolderAssertion.assertFolderState( { name: newNameWithSpecialChars }, 'visible', @@ -174,7 +176,9 @@ dialTest( async () => { await folderPrompts.openFolderDropdownMenu(expectedName); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(newNameWithEmojis); + await folderPrompts.editFolderNameWithTick(newNameWithEmojis, { + isHttpMethodTriggered: false, + }); await promptBarFolderAssertion.assertFolderState( { name: newNameWithEmojis }, 'visible', diff --git a/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts b/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts index a93ffabc1d..c04716ce8e 100644 --- a/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts +++ b/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts @@ -75,10 +75,6 @@ dialTest( await dialTest.step('Rename the prompt to a long name', async () => { await prompts.openEntityDropdownMenu(expectedName); await promptDropdownMenu.selectMenuOption(MenuOptions.edit); - await promptModalDialog.setField( - promptModalDialog.name, - nameUnder160Symbols, - ); // Wait for the API request to update the prompt name await promptModalDialog.updatePromptDetailsWithButton( nameUnder160Symbols, From a486fa5191e36bb86f7d93e113f9d1b0ced0068a Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Wed, 5 Feb 2025 10:32:30 +0100 Subject: [PATCH 18/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- .../src/assertions/api/apiAssertion.ts | 42 +++++++++---------- .../chat-e2e/src/testData/expectedMessages.ts | 6 +-- apps/chat-e2e/src/tests/compareMode.test.ts | 2 +- .../src/tests/sharedPromptView.test.ts | 29 +++++++++---- 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/apps/chat-e2e/src/assertions/api/apiAssertion.ts b/apps/chat-e2e/src/assertions/api/apiAssertion.ts index 0b5de1a925..80e620b2a6 100644 --- a/apps/chat-e2e/src/assertions/api/apiAssertion.ts +++ b/apps/chat-e2e/src/assertions/api/apiAssertion.ts @@ -1,6 +1,6 @@ import { ChatBody } from '@/chat/types/chat'; +import { MoveModel } from '@/chat/types/common'; import { DialAIEntityModel } from '@/chat/types/models'; -import { Prompt } from '@/chat/types/prompt'; import { ExpectedConstants, ExpectedMessages } from '@/src/testData'; import { Message } from '@epam/ai-dial-shared'; import { expect } from '@playwright/test'; @@ -123,30 +123,30 @@ export class ApiAssertion { .toBe(expectedMessage); } - public async assertRequestPromptName(request: Prompt, expectedValue: string) { - expect - .soft(request.name, ExpectedMessages.promptRequestNameIsValid) - .toBe(expectedValue); - } - - public async assertRequestPromptDescription( - request: Prompt, - expectedValue: string, + public async assertMoveRequest( + request: MoveModel, + expectedDestination: string, + expectedSource: string, + isOverwritten = false, ) { expect .soft( - request.description, - ExpectedMessages.promptRequestDescriptionIsValid, + request.destinationUrl.endsWith(`/${expectedDestination}`), + ExpectedMessages.moveDestinationIsValid, ) - .toBe(expectedValue); - } - - public async assertRequestPromptContent( - request: Prompt, - expectedValue: string, - ) { + .toBeTruthy(); expect - .soft(request.content, ExpectedMessages.promptRequestContentIsValid) - .toBe(expectedValue); + .soft( + request.sourceUrl.endsWith(`/${expectedSource}`), + ExpectedMessages.moveSourceIsValid, + ) + .toBeTruthy(); + isOverwritten + ? expect + .soft(isOverwritten, ExpectedMessages.moveSourceIsValid) + .toBeTruthy() + : expect + .soft(isOverwritten, ExpectedMessages.moveOverwriteIsValid) + .toBeFalsy(); } } diff --git a/apps/chat-e2e/src/testData/expectedMessages.ts b/apps/chat-e2e/src/testData/expectedMessages.ts index 9cf5c2418b..333ce94921 100644 --- a/apps/chat-e2e/src/testData/expectedMessages.ts +++ b/apps/chat-e2e/src/testData/expectedMessages.ts @@ -91,9 +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', + moveDestinationIsValid = 'Move API request destination is valid', + moveSourceIsValid = 'Move API request source is valid', + moveOverwriteIsValid = 'Move API request overwrite 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 9e59029519..ff34a3575a 100644 --- a/apps/chat-e2e/src/tests/compareMode.test.ts +++ b/apps/chat-e2e/src/tests/compareMode.test.ts @@ -601,7 +601,7 @@ dialTest( }, ); - await dialTest.step( + await dialTest.step.skip( 'Put like/dislike for compared chat, open this chat and verify like/dislike saved', async () => { const rate = GeneratorUtil.randomArrayElement(Object.values(Rate)); diff --git a/apps/chat-e2e/src/tests/sharedPromptView.test.ts b/apps/chat-e2e/src/tests/sharedPromptView.test.ts index fe3100a8d9..93a3b22eae 100644 --- a/apps/chat-e2e/src/tests/sharedPromptView.test.ts +++ b/apps/chat-e2e/src/tests/sharedPromptView.test.ts @@ -157,6 +157,9 @@ dialSharedWithMeTest( setTestIds('EPMRTC-3185', 'EPMRTC-2032'); let prompt: Prompt; let shareByLinkResponse: ShareByLinkResponseModel; + const updatedName = GeneratorUtil.randomString(10); + const updatedDescription = GeneratorUtil.randomString(10); + const updatedContent = GeneratorUtil.randomString(10); await dialSharedWithMeTest.step('Prepare shared prompt', async () => { prompt = promptData.preparePrompt( @@ -211,9 +214,6 @@ 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, @@ -224,12 +224,27 @@ dialSharedWithMeTest( { name: updatedName }, 'visible', ); - await apiAssertion.assertRequestPromptName(request, updatedName); - await apiAssertion.assertRequestPromptDescription( - request, + await apiAssertion.assertMoveRequest(request, updatedName, prompt.name); + }, + ); + + await dialSharedWithMeTest.step( + 'Open duplicated prompt and verify params are updated', + async () => { + await additionalShareUserPrompts.openEntityDropdownMenu(updatedName); + await additionalShareUserPromptDropdownMenu.selectMenuOption( + MenuOptions.edit, + { triggeredHttpMethod: 'GET' }, + ); + await additionalShareUserPromptModalAssertion.assertPromptName( + updatedName, + ); + await additionalShareUserPromptModalAssertion.assertPromptDescription( updatedDescription, ); - await apiAssertion.assertRequestPromptContent(request, updatedContent); + await additionalShareUserPromptModalAssertion.assertPromptContent( + updatedContent, + ); }, ); }, From 9c2c70234121d211800dd67397eee74a5eea5c3e Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Wed, 5 Feb 2025 12:13:50 +0100 Subject: [PATCH 19/28] fix conversation/prompt update --- apps/chat/src/store/conversations/conversations.epics.ts | 7 ++++++- apps/chat/src/store/prompts/prompts.epics.ts | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index 9445e5967d..9afc52bc58 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -2342,6 +2342,11 @@ const moveConversationEpic: AppEpic = (action$) => destinationUrl: payload.newConversation.id, overwrite: false, }).pipe( + switchMap(() => { + return of( + ConversationsActions.saveConversation(payload.newConversation), + ); + }), catchError(() => { return of(ConversationsActions.moveConversationFail(payload)); }), @@ -2392,7 +2397,7 @@ const updateConversationEpic: AppEpic = (action$, state$) => of( ConversationsActions.updateConversationSuccess({ id, - conversation: { ...values }, + conversation: { ...newConversation }, }), ), ); diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 18659b2024..f7c58863c2 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -241,10 +241,12 @@ const movePromptEpic: AppEpic = (action$) => destinationUrl: payload.newPrompt.id, overwrite: false, }).pipe( + switchMap(() => { + return of(PromptsActions.savePrompt(payload.newPrompt)); + }), catchError(() => { return of(PromptsActions.movePromptFail(payload)); }), - ignoreElements(), ); }), ); From ae82cdcc32afd36086b40afb3d9bc63988707e58 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Wed, 5 Feb 2025 14:28:01 +0100 Subject: [PATCH 20/28] remove ignore elements --- apps/chat/src/store/conversations/conversations.epics.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index 9afc52bc58..f12f5a3ed4 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -2350,7 +2350,6 @@ const moveConversationEpic: AppEpic = (action$) => catchError(() => { return of(ConversationsActions.moveConversationFail(payload)); }), - ignoreElements(), ); }), ); From e98b9416c6bbf5f70b2fd49ece07e5df682b45b0 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Wed, 5 Feb 2025 14:44:33 +0100 Subject: [PATCH 21/28] refactor with regeneratePromptId --- apps/chat/src/store/prompts/prompts.epics.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index f7c58863c2..387665c8d2 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -271,14 +271,10 @@ const updatePromptEpic: AppEpic = (action$, state$) => ); } - const newPrompt: Prompt = { + const newPrompt: Prompt = regeneratePromptId({ ...prompt, ...values, - id: constructPath( - values.folderId || prompt.folderId, - getPromptApiKey({ ...prompt, ...values }), - ), - }; + }); return concat( of(PromptsActions.updatePromptSuccess({ prompt: newPrompt, id })), From 1adcc03b4056588e95e0bec8d250e959ceac7cc7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kezik Date: Wed, 5 Feb 2025 14:47:00 +0100 Subject: [PATCH 22/28] remove imports --- apps/chat/src/store/prompts/prompts.epics.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/chat/src/store/prompts/prompts.epics.ts b/apps/chat/src/store/prompts/prompts.epics.ts index 387665c8d2..d7bf3230e2 100644 --- a/apps/chat/src/store/prompts/prompts.epics.ts +++ b/apps/chat/src/store/prompts/prompts.epics.ts @@ -25,7 +25,6 @@ import { } from '@/src/utils/app/common'; import { PromptService } from '@/src/utils/app/data/prompt-service'; import { getOrUploadPrompt } from '@/src/utils/app/data/storages/api/prompt-api-storage'; -import { constructPath } from '@/src/utils/app/file'; import { addGeneratedFolderId, generateNextName, @@ -43,7 +42,6 @@ import { mapPublishedItems, } from '@/src/utils/app/publications'; import { translate } from '@/src/utils/app/translation'; -import { getPromptApiKey } from '@/src/utils/server/api'; import { FeatureType } from '@/src/types/common'; import { FolderType } from '@/src/types/folder'; From 786b11874345bb2396cfc2bc6b69f289ab16db70 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Wed, 5 Feb 2025 14:49:39 +0100 Subject: [PATCH 23/28] feat/3052-from-edit-to-move-endpoint: fixed e2e --- .../src/tests/sharedPromptIcons.test.ts | 3 +-- .../src/ui/webElements/promptModalDialog.ts | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts b/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts index f11d49ff06..888e580aa5 100644 --- a/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedPromptIcons.test.ts @@ -211,8 +211,7 @@ dialTest( async () => { await prompts.openEntityDropdownMenu(prompt.name); await promptDropdownMenu.selectMenuOption(MenuOptions.edit); - await promptModalDialog.setField(promptModalDialog.name, newName); - await promptModalDialog.saveButton.click(); + await promptModalDialog.updatePromptDetailsWithButton(newName); await promptAssertion.assertElementState( prompts.getEntityByName(newName), 'visible', diff --git a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts index 9c815318ec..2214e9b4e4 100644 --- a/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts +++ b/apps/chat-e2e/src/ui/webElements/promptModalDialog.ts @@ -28,7 +28,7 @@ export class PromptModalDialog extends BaseElement { public async fillPromptDetails( name: string, description: string | undefined, - value: string, + value: string | undefined, ) { await this.name.click(); await this.page.keyboard.press(keys.ctrlPlusA); @@ -38,9 +38,11 @@ export class PromptModalDialog extends BaseElement { if (description !== undefined) { await this.description.typeInInput(description); } - await this.prompt.click(); - await this.page.keyboard.press(keys.ctrlPlusA); - await this.prompt.typeInInput(value); + if (value !== undefined) { + await this.prompt.click(); + await this.page.keyboard.press(keys.ctrlPlusA); + await this.prompt.typeInInput(value); + } } public async setField(field: BaseElement, value: string) { @@ -52,8 +54,8 @@ export class PromptModalDialog extends BaseElement { public async updatePromptDetailsWithButton( name: string, - description: string | undefined, - value: string, + description?: string | undefined, + value?: string | undefined, ) { return this.updatePromptDetails(name, description, value, () => this.saveButton.click(), @@ -62,8 +64,8 @@ export class PromptModalDialog extends BaseElement { public async updatePromptDetailsWithEnter( name: string, - description: string, - value: string, + description?: string, + value?: string | undefined, ) { return this.updatePromptDetails(name, description, value, () => this.page.keyboard.press(keys.enter), @@ -73,7 +75,7 @@ export class PromptModalDialog extends BaseElement { public async updatePromptDetails( name: string, description: string | undefined, - value: string, + value: string | undefined, method: () => Promise, ) { const isNameUpdated = (await this.getName()) !== name; From 21594b1c6ecfd42b6988a686a79711b76f70507e Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Thu, 6 Feb 2025 14:16:38 +0100 Subject: [PATCH 24/28] feat/3052-from-edit-to-move-endpoint: improved e2e --- .../src/tests/chatBarConversation.test.ts | 2 +- .../tests/chatBarFolderConversation.test.ts | 6 +- .../src/tests/folderNameNumeration.test.ts | 5 +- apps/chat-e2e/src/tests/folderPrompts.test.ts | 4 +- .../src/tests/promptFolderNamesakes.test.ts | 9 +- .../src/tests/promptFolderNumeration.test.ts | 11 +-- .../tests/promptFoldersSpecialChars.test.ts | 8 +- .../src/tests/promptMaximumNameLength.test.ts | 8 +- .../publishConversationToOrganisation.test.ts | 4 +- .../publishFolderWithConversation.test.ts | 2 +- apps/chat-e2e/src/tests/publishPrompt.test.ts | 28 ++++-- .../src/tests/selectUploadFolder.test.ts | 20 ++-- .../src/tests/sharedChatIcons.test.ts | 5 +- .../src/tests/sharedFilesAttachments.test.ts | 6 ++ .../src/tests/sharedPromptFolderIcons.test.ts | 2 +- .../src/ui/webElements/chatMessages.ts | 37 ++++---- .../src/ui/webElements/entityTree/folders.ts | 94 +++++++++++++++++-- 17 files changed, 167 insertions(+), 84 deletions(-) diff --git a/apps/chat-e2e/src/tests/chatBarConversation.test.ts b/apps/chat-e2e/src/tests/chatBarConversation.test.ts index 0809f404ff..512d94bf4e 100644 --- a/apps/chat-e2e/src/tests/chatBarConversation.test.ts +++ b/apps/chat-e2e/src/tests/chatBarConversation.test.ts @@ -758,7 +758,7 @@ dialTest( 1, ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderConversations.editFolderNameWithEnter(folderName); + await folderConversations.renameEmptyFolderWithEnter(folderName); await conversations.openEntityDropdownMenu(conversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.moveTo); diff --git a/apps/chat-e2e/src/tests/chatBarFolderConversation.test.ts b/apps/chat-e2e/src/tests/chatBarFolderConversation.test.ts index c60813fe71..b95c4795c2 100644 --- a/apps/chat-e2e/src/tests/chatBarFolderConversation.test.ts +++ b/apps/chat-e2e/src/tests/chatBarFolderConversation.test.ts @@ -181,7 +181,7 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(randomFolderIndex), ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderConversations.editFolderNameWithEnter(newNameWithSpaces); + await folderConversations.renameEmptyFolderWithEnter(newNameWithSpaces); await expect .soft( folderConversations.getFolderByName(newNameWithSpaces.trim()), @@ -393,7 +393,9 @@ dialTest( await dialTest.step( 'Edit folder name using tick button and verify it is renamed', async () => { - await folderConversations.editFolderNameWithTick(newFolderNameToSet); + await folderConversations.renameFolderWithContentWithTick( + newFolderNameToSet, + ); await expect .soft(toast.getElementLocator(), ExpectedMessages.noErrorToastIsShown) .toBeHidden(); diff --git a/apps/chat-e2e/src/tests/folderNameNumeration.test.ts b/apps/chat-e2e/src/tests/folderNameNumeration.test.ts index 21722418e3..ace7c23bb1 100644 --- a/apps/chat-e2e/src/tests/folderNameNumeration.test.ts +++ b/apps/chat-e2e/src/tests/folderNameNumeration.test.ts @@ -115,9 +115,8 @@ dialTest( async () => { await folderConversations.openFolderDropdownMenu(incrementedFolderName); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderConversations.editFolderNameWithTick( + await folderConversations.renameEmptyFolderWithTick( GeneratorUtil.randomString(5), - { isHttpMethodTriggered: false }, ); await chatBar.createNewFolder(); @@ -174,7 +173,7 @@ dialTest( nestedFolders[nestedFolderLevel - 1].name, ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderConversations.editFolderNameWithTick( + await folderConversations.renameFolderWithContentWithTick( expectedDuplicatedFolderName, ); diff --git a/apps/chat-e2e/src/tests/folderPrompts.test.ts b/apps/chat-e2e/src/tests/folderPrompts.test.ts index ffa5b811d3..4df6de4a0a 100644 --- a/apps/chat-e2e/src/tests/folderPrompts.test.ts +++ b/apps/chat-e2e/src/tests/folderPrompts.test.ts @@ -124,7 +124,7 @@ dialTest( 'Select "Rename" option, set new name and verify folder is renamed', async () => { await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithEnter(newName); + await folderPrompts.renameEmptyFolderWithEnter(newName); await promptBarFolderAssertion.assertFolderState( { name: newName }, 'visible', @@ -196,7 +196,7 @@ dialTest( await dialHomePage.waitForPageLoaded(); await folderPrompts.openFolderDropdownMenu(promptInFolder.folders.name); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(newName); + await folderPrompts.renameFolderWithContentWithTick(newName); await expect .soft( folderPrompts.getFolderByName(newName), diff --git a/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts b/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts index 29e50afcb5..543af89a18 100644 --- a/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts +++ b/apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts @@ -41,9 +41,7 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(1), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(duplicatedFolderName, { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick(duplicatedFolderName); }); await dialTest.step( @@ -53,7 +51,7 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(2), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(duplicatedFolderName, { + await folderPrompts.renameEmptyFolderWithTick(duplicatedFolderName, { isHttpMethodTriggered: false, }); const errorMessage = await toast.getElementContent(); @@ -207,9 +205,8 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(3), ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick( + await folderPrompts.renameEmptyFolderWithTick( ExpectedConstants.newFolderWithIndexTitle(2), - { isHttpMethodTriggered: false }, ); }); diff --git a/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts b/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts index b844dc34f1..0e66db4df4 100644 --- a/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts +++ b/apps/chat-e2e/src/tests/promptFolderNumeration.test.ts @@ -163,9 +163,7 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(folderNumber), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick('Renamed Folder', { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick('Renamed Folder'); await promptBar.createNewFolder(); await expect @@ -211,9 +209,8 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(1), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick( + await folderPrompts.renameEmptyFolderWithTick( ExpectedConstants.newPromptFolderWithIndexTitle(999), - { isHttpMethodTriggered: false }, ); }); @@ -288,9 +285,7 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(i), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(duplicatedFolderName, { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick(duplicatedFolderName); await expect( folderPrompts.getFolderByName(duplicatedFolderName, i), ExpectedMessages.folderNameUpdated, diff --git a/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts b/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts index a5ed20fb55..2892a91805 100644 --- a/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts +++ b/apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts @@ -81,9 +81,7 @@ dialTest( }); await dialTest.step('Rename it to contain special characters', async () => { - await folderPrompts.editFolderNameWithTick(newNameWithSpecialChars, { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick(newNameWithSpecialChars); await promptBarFolderAssertion.assertFolderState( { name: newNameWithSpecialChars }, 'visible', @@ -176,9 +174,7 @@ dialTest( async () => { await folderPrompts.openFolderDropdownMenu(expectedName); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(newNameWithEmojis, { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick(newNameWithEmojis); await promptBarFolderAssertion.assertFolderState( { name: newNameWithEmojis }, 'visible', diff --git a/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts b/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts index c04716ce8e..460ffde4cf 100644 --- a/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts +++ b/apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts @@ -134,18 +134,14 @@ dialTest( ExpectedConstants.newPromptFolderWithIndexTitle(1), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(longName, { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick(longName); // Rename folder_child await folderPrompts.openFolderDropdownMenu( ExpectedConstants.newPromptFolderWithIndexTitle(2), ); await promptDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(longName, { - isHttpMethodTriggered: false, - }); + await folderPrompts.renameEmptyFolderWithTick(longName); }, ); diff --git a/apps/chat-e2e/src/tests/publishConversationToOrganisation.test.ts b/apps/chat-e2e/src/tests/publishConversationToOrganisation.test.ts index 05682f59a1..6ad69bda18 100644 --- a/apps/chat-e2e/src/tests/publishConversationToOrganisation.test.ts +++ b/apps/chat-e2e/src/tests/publishConversationToOrganisation.test.ts @@ -310,7 +310,7 @@ dialAdminTest( await dialTest.step('Verify folder renaming and max length', async () => { await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await selectFolders.editFolderNameWithTick(newFolderName, { + await selectFolders.renameEmptyFolderWithTick(newFolderName, { isHttpMethodTriggered: false, }); await selectFoldersAssertion.assertFolderState( @@ -406,7 +406,7 @@ dialAdminTest( true, ); //TODO: remove next line when fixed https://github.com/epam/ai-dial-chat/issues/2294 - await selectFolders.editFolderNameWithTick( + await selectFolders.renameEmptyFolderWithTick( GeneratorUtil.randomString(5), { isHttpMethodTriggered: false, diff --git a/apps/chat-e2e/src/tests/publishFolderWithConversation.test.ts b/apps/chat-e2e/src/tests/publishFolderWithConversation.test.ts index 7999afcaa7..cf7d924b9f 100644 --- a/apps/chat-e2e/src/tests/publishFolderWithConversation.test.ts +++ b/apps/chat-e2e/src/tests/publishFolderWithConversation.test.ts @@ -547,7 +547,7 @@ dialAdminTest( 'Create new folder, select it and verify publish path changed', async () => { await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithTick(orgFolder, { + await selectFolders.renameEmptyFolderWithTick(orgFolder, { isHttpMethodTriggered: false, }); await selectFolderModal.clickSelectFolderButton({ diff --git a/apps/chat-e2e/src/tests/publishPrompt.test.ts b/apps/chat-e2e/src/tests/publishPrompt.test.ts index 415e4e495e..d8192d36e1 100644 --- a/apps/chat-e2e/src/tests/publishPrompt.test.ts +++ b/apps/chat-e2e/src/tests/publishPrompt.test.ts @@ -87,10 +87,14 @@ dialAdminTest( .getChangePublishToPath() .changeButton.click(); await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithEnter(folderName); + await selectFolders.renameEmptyFolderWithEnter(folderName, { + isHttpMethodTriggered: false, + }); await selectFolders.openFolderDropdownMenu(folderName); await folderDropdownMenu.selectMenuOption(MenuOptions.addNewFolder); - await selectFolders.editFolderNameWithEnter(`${folderName} 2`); + await selectFolders.renameEmptyFolderWithEnter(`${folderName} 2`, { + isHttpMethodTriggered: false, + }); await selectFolders.openFolderDropdownMenu(`${folderName} 2`); await folderDropdownMenu.selectMenuOption(MenuOptions.delete); await confirmationDialog.confirm(); @@ -121,10 +125,14 @@ dialAdminTest( 'User creates folder and rename it under Organization, user renames folder', async () => { await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithEnter(`${folderName}_rename`); + await selectFolders.renameEmptyFolderWithEnter(`${folderName}_rename`, { + isHttpMethodTriggered: false, + }); await selectFolders.openFolderDropdownMenu(`${folderName}_rename`); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await selectFolders.editFolderNameWithEnter(folderName); + await selectFolders.renameEmptyFolderWithEnter(folderName, { + isHttpMethodTriggered: false, + }); }, ); @@ -143,7 +151,9 @@ dialAdminTest( .getChangePublishToPath() .changeButton.click(); await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithEnter(folderName); + await selectFolders.renameEmptyFolderWithEnter(folderName, { + isHttpMethodTriggered: false, + }); }, ); @@ -514,14 +524,18 @@ dialAdminTest( .getChangePublishToPath() .changeButton.click(); await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithEnter(`${folderNameTemplate} 1`); + await selectFolders.renameEmptyFolderWithEnter( + `${folderNameTemplate} 1`, + { isHttpMethodTriggered: false }, + ); for (let i = 1; i < 4; i++) { await selectFolders.openFolderDropdownMenu( `${folderNameTemplate} ${i}`, ); await folderDropdownMenu.selectMenuOption(MenuOptions.addNewFolder); - await selectFolders.editFolderNameWithEnter( + await selectFolders.renameEmptyFolderWithEnter( `${folderNameTemplate} ${i + 1}`, + { isHttpMethodTriggered: false }, ); } await selectFolders.openFolderDropdownMenu(`${folderNameTemplate} 4`); diff --git a/apps/chat-e2e/src/tests/selectUploadFolder.test.ts b/apps/chat-e2e/src/tests/selectUploadFolder.test.ts index 60ac7b6900..31a5679425 100644 --- a/apps/chat-e2e/src/tests/selectUploadFolder.test.ts +++ b/apps/chat-e2e/src/tests/selectUploadFolder.test.ts @@ -72,7 +72,9 @@ dialTest( await dialTest.step( 'Set new name, hit Enter and verify name is updated, edit mode is closed', async () => { - await selectFolders.editFolderNameWithEnter(updatedFolderName); + await selectFolders.renameEmptyFolderWithEnter(updatedFolderName, { + isHttpMethodTriggered: false, + }); await expect .soft( selectFolders.getEditFolderInput().getElementLocator(), @@ -255,7 +257,7 @@ dialTest( 'Click "Create new folder" icon, set long folder name and verify it is truncated with dots', async () => { await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithTick(longFolderName, { + await selectFolders.renameEmptyFolderWithTick(longFolderName, { isHttpMethodTriggered: false, }); const folderNameOverflowProp = await selectFolders @@ -296,7 +298,7 @@ dialTest( async () => { await selectFolders.openFolderDropdownMenu(longFolderName); await folderDropdownMenu.selectMenuOption(MenuOptions.addNewFolder); - await selectFolders.editFolderNameWithTick(longFolderName, { + await selectFolders.renameEmptyFolderWithTick(longFolderName, { isHttpMethodTriggered: false, }); const childFolderNameOverflowProp = await selectFolders @@ -376,7 +378,7 @@ dialTest( 'Click "Create new folder" again and edit name to "New folder 999"', async () => { await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithTick( + await selectFolders.renameEmptyFolderWithTick( ExpectedConstants.newFolderWithIndexTitle(updateFoldeNameIndex), { isHttpMethodTriggered: false }, ); @@ -521,7 +523,7 @@ dialTest( 2, ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await selectFolders.editFolderNameWithTick(newChildFolderName, { + await selectFolders.renameEmptyFolderWithTick(newChildFolderName, { isHttpMethodTriggered: false, }); await expect @@ -543,7 +545,7 @@ dialTest( ExpectedConstants.newFolderWithIndexTitle(1), ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await selectFolders.editFolderNameWithTick(newParentFolderName, { + await selectFolders.renameEmptyFolderWithTick(newParentFolderName, { isHttpMethodTriggered: false, }); //TODO: remove next line when fixed https://github.com/epam/ai-dial-chat/issues/1551 @@ -602,7 +604,7 @@ dialTest( 'Click "Create new folder" again, set new folder name with end dot, confirm and verify error toast is shown', async () => { await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithTick( + await selectFolders.renameEmptyFolderWithTick( `${GeneratorUtil.randomString(10)}.`, { isHttpMethodTriggered: false }, ); @@ -620,7 +622,7 @@ dialTest( 'Create new folder, set name to already existing one, confirm and verify error message is shown', async () => { await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithTick( + await selectFolders.renameEmptyFolderWithTick( ExpectedConstants.newFolderWithIndexTitle(1), { isHttpMethodTriggered: false }, ); @@ -673,7 +675,7 @@ dialTest( async () => { const nameWithSpaces = GeneratorUtil.randomArrayElement(['', ' ']); await selectFolderModal.newFolderButton.click(); - await selectFolders.editFolderNameWithTick(nameWithSpaces, { + await selectFolders.renameEmptyFolderWithTick(nameWithSpaces, { isHttpMethodTriggered: false, }); await expect diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index 24501bccdc..f3936ca064 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -764,7 +764,10 @@ dialTest( nestedFolders[nestedLevel - 2].name, ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderConversations.editFolderNameWithEnter(newFolderName); + await folderConversations.renameFolderWithContentWithEnter( + newFolderName, + { isHttpMethodTriggered: false }, + ); expect .soft( diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index 85aa710b54..2668a73dcc 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -666,6 +666,8 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoRequestsWithAttachments.name, + undefined, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages.expandChatMessageAttachment( @@ -695,6 +697,8 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoResponsesWithAttachments.name, + undefined, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages.expandChatMessageAttachment( @@ -734,6 +738,8 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( user1ConversationInFolder.name, + undefined, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages.expandChatMessageAttachment( diff --git a/apps/chat-e2e/src/tests/sharedPromptFolderIcons.test.ts b/apps/chat-e2e/src/tests/sharedPromptFolderIcons.test.ts index 003b4c2751..edb72bd931 100644 --- a/apps/chat-e2e/src/tests/sharedPromptFolderIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedPromptFolderIcons.test.ts @@ -137,7 +137,7 @@ dialTest( nestedFolders[sharedFolderIndex].name, ); await folderDropdownMenu.selectMenuOption(MenuOptions.rename); - await folderPrompts.editFolderNameWithTick(newFolderName, { + await folderPrompts.renameEmptyFolderWithTick(newFolderName, { isHttpMethodTriggered: false, }); await confirmationDialogAssertion.assertConfirmationMessage( diff --git a/apps/chat-e2e/src/ui/webElements/chatMessages.ts b/apps/chat-e2e/src/ui/webElements/chatMessages.ts index 175154929d..a28a0b46c2 100644 --- a/apps/chat-e2e/src/ui/webElements/chatMessages.ts +++ b/apps/chat-e2e/src/ui/webElements/chatMessages.ts @@ -189,37 +189,32 @@ export class ChatMessages extends BaseElement { attachmentTitle: string, { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, ) { - const isCollapsed = - await this.getCollapsedChatMessageAttachment(message).isVisible(); - if (isCollapsed) { - const messageAttachment = this.getChatMessageAttachment( - message, - attachmentTitle, + await this.getCollapsedChatMessageAttachment(message).waitFor(); + const messageAttachment = this.getChatMessageAttachment( + message, + attachmentTitle, + ); + if (isApiStorageType && isHttpMethodTriggered) { + const respPromise = this.page.waitForResponse( + (resp) => + resp.request().method() === 'GET' && + resp.url().includes(attachmentTitle), + { timeout: config.use!.actionTimeout! * 2 }, ); - if (isApiStorageType && isHttpMethodTriggered) { - const respPromise = this.page.waitForResponse( - (resp) => - resp.request().method() === 'GET' && - resp.url().includes(attachmentTitle), - { timeout: config.use!.actionTimeout! * 2 }, - ); - await messageAttachment.click(); - return respPromise; - } await messageAttachment.click(); + return respPromise; } + await messageAttachment.click(); } public async collapseChatMessageAttachment( message: string | number, attachmentTitle: string, ) { - const isExpanded = await this.getChatMessage(message) + await this.getChatMessage(message) .locator(ChatSelectors.attachmentExpanded) - .isVisible(); - if (isExpanded) { - await this.getChatMessageAttachment(message, attachmentTitle).click(); - } + .waitFor(); + await this.getChatMessageAttachment(message, attachmentTitle).click(); } public async getChatMessageAttachmentUrl(message: string | number) { diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts b/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts index c23c58b705..d9c83bf9a6 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts @@ -205,25 +205,103 @@ export class Folders extends BaseElement { return this.folderDotsMenu(name, index); } - public async editFolderNameWithEnter(newName: string) { - await this.editFolderName(newName); - await this.page.keyboard.press(keys.enter); + public async renameEmptyFolderWithEnter( + newName: string, + { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, + ) { + await this.renameEmptyFolder( + newName, + () => this.page.keyboard.press(keys.enter), + { isHttpMethodTriggered }, + ); } - public async editFolderNameWithTick( + public async renameFolderWithContentWithEnter( + newName: string, + { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, + ) { + await this.renameFolderWithContent( + newName, + () => this.page.keyboard.press(keys.enter), + { isHttpMethodTriggered }, + ); + } + + public async renameEmptyFolderWithTick( + newName: string, + { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, + ) { + const folderInputActions = this.getEditFolderInputActions(); + await this.renameEmptyFolder( + newName, + () => folderInputActions.clickTickButton(), + { + isHttpMethodTriggered, + }, + ); + } + + public async renameFolderWithContentWithTick( newName: string, { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, ) { - await this.editFolderName(newName); const folderInputActions = this.getEditFolderInputActions(); + await this.renameFolderWithContent( + newName, + () => folderInputActions.clickTickButton(), + { isHttpMethodTriggered }, + ); + } + + //listing API is triggered if to rename folder on side panel + //no API is triggered if to rename folder in 'Manage Attachments' or 'Change path' modals + public async renameEmptyFolder( + newName: string, + method: () => Promise, + { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, + ) { + await this.editFolderName(newName); if (isHttpMethodTriggered && isApiStorageType) { const respPromise = this.page.waitForResponse((resp) => - resp.url().includes(API.moveHost), + resp.url().includes(API.listingHost), ); - await folderInputActions.clickTickButton(); + await method(); return respPromise; } - await folderInputActions.clickTickButton(); + await method(); + } + + //3 API calls are triggered if to rename folder with content + //if shared folder is renamed, confirmation popup is prompted + public async renameFolderWithContent( + newName: string, + method: () => Promise, + { isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {}, + ) { + await this.editFolderName(newName); + if (isApiStorageType && isHttpMethodTriggered) { + const hostsMap = new Map([ + [API.listingHost, 'GET'], + [API.moveHost, 'POST'], + ['/api/', 'PUT'], + ]); + const responses = []; + for (const [host, method] of hostsMap) { + const resp = this.page.waitForResponse( + (response) => + response.url().includes(host) && + response.request().method() === method && + response.status() === 200, + ); + responses.push(resp); + } + await method(); + for (const resp of responses) { + await resp; + } + } else { + await method(); + } } public async editFolderName(newName: string) { From 3f3a7c239c71361fdf9684f390d62c1235093199 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Thu, 6 Feb 2025 17:26:59 +0100 Subject: [PATCH 25/28] feat/3052-from-edit-to-move-endpoint: added Get response waiting on conversation select --- apps/chat-e2e/src/tests/abortedReplay.test.ts | 16 ++++++--- .../chatExportImportWithAttachment.test.ts | 8 +++-- .../tests/chatSelectionFunctionality.test.ts | 4 ++- apps/chat-e2e/src/tests/compareMode.test.ts | 36 ++++++++++--------- .../duplicateSharedConversations.test.ts | 2 -- .../src/tests/messageTemplate.test.ts | 2 +- .../src/tests/parametrizedReplay.test.ts | 12 +++++-- apps/chat-e2e/src/tests/playBack.test.ts | 12 +++++-- apps/chat-e2e/src/tests/replay.test.ts | 12 +++++-- apps/chat-e2e/src/tests/scrolling.test.ts | 22 +++++------- .../shareConversationWithContent.test.ts | 7 ++-- .../src/tests/sharedChatIcons.test.ts | 12 +++++-- .../src/tests/sharedFilesAttachments.test.ts | 5 ++- .../sidebar/baseSideBarConversationTree.ts | 2 +- 14 files changed, 95 insertions(+), 57 deletions(-) diff --git a/apps/chat-e2e/src/tests/abortedReplay.test.ts b/apps/chat-e2e/src/tests/abortedReplay.test.ts index 3593b909be..9a4868f46f 100644 --- a/apps/chat-e2e/src/tests/abortedReplay.test.ts +++ b/apps/chat-e2e/src/tests/abortedReplay.test.ts @@ -116,7 +116,9 @@ dialTest( iconsToBeLoaded: [secondRandomModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.getEntityByName(replayConversation.name).waitFor(); await conversations.openEntityDropdownMenu(replayConversation.name); await conversationDropdownMenuAssertion.assertMenuExcludesOptions( @@ -406,7 +408,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await chat.startReplay(); await sendMessage.messageInput.fillInInput(message); @@ -507,7 +511,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await context.setOffline(true); await chat.startReplay(); }, @@ -580,7 +586,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); const isStartReplayEnabled = await chat.replay.isElementEnabled(); expect .soft(isStartReplayEnabled, ExpectedMessages.startReplayVisible) diff --git a/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts b/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts index 7a91aea4dc..592567519d 100644 --- a/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts +++ b/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts @@ -429,7 +429,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name); + await conversations.selectConversation(playbackConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.openEntityDropdownMenu(playbackConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.export); exportedData = await dialHomePage.downloadData( @@ -576,7 +578,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.openEntityDropdownMenu(replayConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.export); exportedData = await dialHomePage.downloadData( diff --git a/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts b/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts index f5ec812682..2c488c7728 100644 --- a/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts +++ b/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts @@ -66,7 +66,9 @@ dialTest( await dialTest.step('Open start page', async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(secondConversation.name); + await conversations.selectConversation(secondConversation.name, { + isHttpMethodTriggered: true, + }); }); await dialTest.step('Hover over chat1', async () => { diff --git a/apps/chat-e2e/src/tests/compareMode.test.ts b/apps/chat-e2e/src/tests/compareMode.test.ts index 36c0334e4e..5c9185af43 100644 --- a/apps/chat-e2e/src/tests/compareMode.test.ts +++ b/apps/chat-e2e/src/tests/compareMode.test.ts @@ -264,9 +264,13 @@ dialTest( iconsToBeLoaded: [defaultModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(modelConversation.name, { - exactMatch: true, - }); + await conversations.selectConversation( + modelConversation.name, + { isHttpMethodTriggered: false }, + { + exactMatch: true, + }, + ); await conversations.openEntityDropdownMenu(modelConversation.name, { exactMatch: true, }); @@ -288,7 +292,9 @@ dialTest( await dialTest.step( 'Open another conversation and verify compare mode is closed', async () => { - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await expect .soft(compare.getElementLocator(), ExpectedMessages.compareModeClosed) .toBeHidden(); @@ -446,7 +452,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversation.name); + await conversations.selectConversation(firstConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.compare); @@ -613,11 +621,7 @@ dialTest( .soft(isComparedMessageRated, ExpectedMessages.chatMessageIsRated) .toBeTruthy(); - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await chatMessages .getChatMessageRate(firstConversation.messages.length + 2, rate) .waitFor(); @@ -1101,7 +1105,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversation.name); + await conversations.selectConversation(firstConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.compare); await compareConversation.checkShowAllConversations(); @@ -1374,11 +1380,9 @@ dialTest( await dialTest.step( 'Switch to comparing conversation and verify Compare mode is closed', async () => { - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name, { + isHttpMethodTriggered: false, + }); await expect .soft(compare.getElementLocator(), ExpectedMessages.compareModeClosed) .toBeHidden(); diff --git a/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts b/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts index ab84a078ad..da423ffa22 100644 --- a/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts +++ b/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts @@ -162,8 +162,6 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationName, - undefined, - { isHttpMethodTriggered: false }, ); await additionalShareUserChat.duplicateConversation(); await additionalShareUserConversations diff --git a/apps/chat-e2e/src/tests/messageTemplate.test.ts b/apps/chat-e2e/src/tests/messageTemplate.test.ts index 5e4b0af789..fa66cd5226 100644 --- a/apps/chat-e2e/src/tests/messageTemplate.test.ts +++ b/apps/chat-e2e/src/tests/messageTemplate.test.ts @@ -1014,10 +1014,10 @@ dialTest( async () => { await conversations.selectConversation( replayName, + { isHttpMethodTriggered: false }, { exactMatch: true, }, - { isHttpMethodTriggered: false }, ); await chat.startReplay( simpleConversationMessage.messages[0].content, diff --git a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts index 1f02b2e859..bbce70d001 100644 --- a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts +++ b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts @@ -99,7 +99,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await chat.replay.click(); await variableModalAssertion.assertVariableModalState('visible'); }, @@ -254,7 +256,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await chat.changeAgentButton.click(); await talkToAgentDialog.selectAgent(randomModel, marketplacePage); await chat.replay.click(); @@ -365,7 +369,9 @@ dialSharedWithMeTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await chat.proceedReplaying(); await variableModalAssertion.assertVariableModalState('hidden'); }, diff --git a/apps/chat-e2e/src/tests/playBack.test.ts b/apps/chat-e2e/src/tests/playBack.test.ts index e73b74f213..573de0d093 100644 --- a/apps/chat-e2e/src/tests/playBack.test.ts +++ b/apps/chat-e2e/src/tests/playBack.test.ts @@ -438,7 +438,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name); + await conversations.selectConversation(playbackConversation.name, { + isHttpMethodTriggered: true, + }); await conversations .getEntityByName(playbackConversation.name) .waitFor(); @@ -694,7 +696,9 @@ dialTest( iconsToBeLoaded: [defaultModel!.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name); + await conversations.selectConversation(playbackConversation.name, { + isHttpMethodTriggered: true, + }); await chatHeader.leavePlaybackMode.click(); await expect .soft( @@ -765,7 +769,9 @@ dialTest( await dialTest.step('Verify playback next message has scroll', async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name); + await conversations.selectConversation(playbackConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.getEntityByName(playbackConversation.name).waitFor(); await chat.playNextChatMessage(); const isPlaybackNextMessageScrollable = await playbackControl diff --git a/apps/chat-e2e/src/tests/replay.test.ts b/apps/chat-e2e/src/tests/replay.test.ts index 209549589e..da5e8119d5 100644 --- a/apps/chat-e2e/src/tests/replay.test.ts +++ b/apps/chat-e2e/src/tests/replay.test.ts @@ -538,7 +538,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, ); @@ -632,7 +634,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await conversations.openEntityDropdownMenu(replayConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.rename); @@ -742,7 +746,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name); + await conversations.selectConversation(replayConversation.name, { + isHttpMethodTriggered: true, + }); await agentInfoAssertion.assertElementText( agentInfo.agentName, ExpectedConstants.replayAsIsLabel, diff --git a/apps/chat-e2e/src/tests/scrolling.test.ts b/apps/chat-e2e/src/tests/scrolling.test.ts index f11e5c7aa5..41a75b66ce 100644 --- a/apps/chat-e2e/src/tests/scrolling.test.ts +++ b/apps/chat-e2e/src/tests/scrolling.test.ts @@ -236,11 +236,7 @@ dialTest( await dialTest.step( 'Back to the first conversation, create new conversation and verify no "Scroll down" button is visible', async () => { - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await header.createNewConversation(); await expect .soft( @@ -254,11 +250,7 @@ dialTest( await dialTest.step( 'Create Replay conversation based on the first one and verify it is selected and highlighted', async () => { - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.replay, { triggeredHttpMethod: 'POST', @@ -360,9 +352,13 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversation.name, { - exactMatch: true, - }); + await conversations.selectConversation( + firstConversation.name, + { isHttpMethodTriggered: false }, + { + exactMatch: true, + }, + ); await chat.scrollContent(0, -100); await conversations.openEntityDropdownMenu(firstConversationName, { exactMatch: true, diff --git a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts index 68b0ee5b9c..29c92af403 100644 --- a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts +++ b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts @@ -149,6 +149,7 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( responseImageConversation.name, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages @@ -177,6 +178,7 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( requestImageConversation.name, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages .getChatMessage(chatResponseIndex) @@ -209,6 +211,7 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( stageConversation.name, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages .getChatMessage(chatResponseIndex) @@ -222,6 +225,7 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( codeConversation.name, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages .getChatMessage(chatResponseIndex) @@ -677,6 +681,7 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( imageConversation.name, + { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages.expandChatMessageAttachment( @@ -753,8 +758,6 @@ dialSharedWithMeTest( async () => { await additionalShareUserConversations.selectConversation( secondUserEmptyConversation.name, - undefined, - { isHttpMethodTriggered: false }, ); await additionalShareUserSendMessage.attachmentMenuTrigger.click(); diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index f3936ca064..6c03047f2c 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -377,7 +377,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversationToShare.name); + await conversations.selectConversation(firstConversationToShare.name, { + isHttpMethodTriggered: true, + }); await chatHeader.openConversationSettingsPopup(); await agentSettings.setSystemPrompt(GeneratorUtil.randomString(5)); await temperatureSlider.setTemperature(0); @@ -398,7 +400,9 @@ dialTest( 'Update conversation name for the 2nd conversation and verify conversation is shared, shared icon is displayed', async () => { newName = GeneratorUtil.randomString(10); - await conversations.selectConversation(secondConversationToShare.name); + await conversations.selectConversation(secondConversationToShare.name, { + isHttpMethodTriggered: true, + }); await conversations.openEntityDropdownMenu( secondConversationToShare.name, ); @@ -534,7 +538,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(conversation.name); + await conversations.selectConversation(conversation.name, { + isHttpMethodTriggered: true, + }); for (const conversation of [ replayConversation, playbackConversation, diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index 2668a73dcc..a1b5c3f06a 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -415,6 +415,7 @@ dialSharedWithMeTest( await dialHomePage.waitForPageLoaded(); await conversations.selectConversation( conversationWithSpecialChars.name, + { isHttpMethodTriggered: true }, ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( @@ -447,6 +448,7 @@ dialSharedWithMeTest( await dialHomePage.waitForPageLoaded(); await conversations.selectConversation( conversationWithSpecialChars.name, + { isHttpMethodTriggered: true }, ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( @@ -666,7 +668,6 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoRequestsWithAttachments.name, - undefined, { isHttpMethodTriggered: true }, ); @@ -697,7 +698,6 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoResponsesWithAttachments.name, - undefined, { isHttpMethodTriggered: true }, ); @@ -738,7 +738,6 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( user1ConversationInFolder.name, - undefined, { isHttpMethodTriggered: true }, ); diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts index 84c36346ca..016c118559 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts @@ -6,8 +6,8 @@ import { SideBarEntitiesTree } from '@/src/ui/webElements/entityTree/sidebar/sid export class BaseSideBarConversationTree extends SideBarEntitiesTree { public async selectConversation( name: string, - indexOrOptions?: number | { exactMatch: boolean; index?: number }, { isHttpMethodTriggered = false }: { isHttpMethodTriggered?: boolean } = {}, + indexOrOptions?: number | { exactMatch: boolean; index?: number }, ) { const conversationToSelect = this.getTreeEntity(name, indexOrOptions); if (isApiStorageType && isHttpMethodTriggered) { From 0499e28f93dfe831c3a2107a9ff6aaaf0d4c6b77 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Thu, 6 Feb 2025 18:11:58 +0100 Subject: [PATCH 26/28] Revert "feat/3052-from-edit-to-move-endpoint: added Get response waiting on conversation select" This reverts commit 3f3a7c239c71361fdf9684f390d62c1235093199. --- apps/chat-e2e/src/tests/abortedReplay.test.ts | 16 +++------ .../chatExportImportWithAttachment.test.ts | 8 ++--- .../tests/chatSelectionFunctionality.test.ts | 4 +-- apps/chat-e2e/src/tests/compareMode.test.ts | 36 +++++++++---------- .../duplicateSharedConversations.test.ts | 2 ++ .../src/tests/messageTemplate.test.ts | 2 +- .../src/tests/parametrizedReplay.test.ts | 12 ++----- apps/chat-e2e/src/tests/playBack.test.ts | 12 ++----- apps/chat-e2e/src/tests/replay.test.ts | 12 ++----- apps/chat-e2e/src/tests/scrolling.test.ts | 22 +++++++----- .../shareConversationWithContent.test.ts | 7 ++-- .../src/tests/sharedChatIcons.test.ts | 12 ++----- .../src/tests/sharedFilesAttachments.test.ts | 5 +-- .../sidebar/baseSideBarConversationTree.ts | 2 +- 14 files changed, 57 insertions(+), 95 deletions(-) diff --git a/apps/chat-e2e/src/tests/abortedReplay.test.ts b/apps/chat-e2e/src/tests/abortedReplay.test.ts index 9a4868f46f..3593b909be 100644 --- a/apps/chat-e2e/src/tests/abortedReplay.test.ts +++ b/apps/chat-e2e/src/tests/abortedReplay.test.ts @@ -116,9 +116,7 @@ dialTest( iconsToBeLoaded: [secondRandomModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await conversations.getEntityByName(replayConversation.name).waitFor(); await conversations.openEntityDropdownMenu(replayConversation.name); await conversationDropdownMenuAssertion.assertMenuExcludesOptions( @@ -408,9 +406,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await chat.startReplay(); await sendMessage.messageInput.fillInInput(message); @@ -511,9 +507,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await context.setOffline(true); await chat.startReplay(); }, @@ -586,9 +580,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); const isStartReplayEnabled = await chat.replay.isElementEnabled(); expect .soft(isStartReplayEnabled, ExpectedMessages.startReplayVisible) diff --git a/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts b/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts index 592567519d..7a91aea4dc 100644 --- a/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts +++ b/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts @@ -429,9 +429,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(playbackConversation.name); await conversations.openEntityDropdownMenu(playbackConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.export); exportedData = await dialHomePage.downloadData( @@ -578,9 +576,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await conversations.openEntityDropdownMenu(replayConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.export); exportedData = await dialHomePage.downloadData( diff --git a/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts b/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts index 2c488c7728..f5ec812682 100644 --- a/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts +++ b/apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts @@ -66,9 +66,7 @@ dialTest( await dialTest.step('Open start page', async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(secondConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(secondConversation.name); }); await dialTest.step('Hover over chat1', async () => { diff --git a/apps/chat-e2e/src/tests/compareMode.test.ts b/apps/chat-e2e/src/tests/compareMode.test.ts index 5c9185af43..36c0334e4e 100644 --- a/apps/chat-e2e/src/tests/compareMode.test.ts +++ b/apps/chat-e2e/src/tests/compareMode.test.ts @@ -264,13 +264,9 @@ dialTest( iconsToBeLoaded: [defaultModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation( - modelConversation.name, - { isHttpMethodTriggered: false }, - { - exactMatch: true, - }, - ); + await conversations.selectConversation(modelConversation.name, { + exactMatch: true, + }); await conversations.openEntityDropdownMenu(modelConversation.name, { exactMatch: true, }); @@ -292,9 +288,7 @@ dialTest( await dialTest.step( 'Open another conversation and verify compare mode is closed', async () => { - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await expect .soft(compare.getElementLocator(), ExpectedMessages.compareModeClosed) .toBeHidden(); @@ -452,9 +446,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(firstConversation.name); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.compare); @@ -621,7 +613,11 @@ dialTest( .soft(isComparedMessageRated, ExpectedMessages.chatMessageIsRated) .toBeTruthy(); - await conversations.selectConversation(firstConversation.name); + await conversations.selectConversation( + firstConversation.name, + undefined, + { isHttpMethodTriggered: false }, + ); await chatMessages .getChatMessageRate(firstConversation.messages.length + 2, rate) .waitFor(); @@ -1105,9 +1101,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(firstConversation.name); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.compare); await compareConversation.checkShowAllConversations(); @@ -1380,9 +1374,11 @@ dialTest( await dialTest.step( 'Switch to comparing conversation and verify Compare mode is closed', async () => { - await conversations.selectConversation(firstConversation.name, { - isHttpMethodTriggered: false, - }); + await conversations.selectConversation( + firstConversation.name, + undefined, + { isHttpMethodTriggered: false }, + ); await expect .soft(compare.getElementLocator(), ExpectedMessages.compareModeClosed) .toBeHidden(); diff --git a/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts b/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts index da423ffa22..ab84a078ad 100644 --- a/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts +++ b/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts @@ -162,6 +162,8 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationName, + undefined, + { isHttpMethodTriggered: false }, ); await additionalShareUserChat.duplicateConversation(); await additionalShareUserConversations diff --git a/apps/chat-e2e/src/tests/messageTemplate.test.ts b/apps/chat-e2e/src/tests/messageTemplate.test.ts index fa66cd5226..5e4b0af789 100644 --- a/apps/chat-e2e/src/tests/messageTemplate.test.ts +++ b/apps/chat-e2e/src/tests/messageTemplate.test.ts @@ -1014,10 +1014,10 @@ dialTest( async () => { await conversations.selectConversation( replayName, - { isHttpMethodTriggered: false }, { exactMatch: true, }, + { isHttpMethodTriggered: false }, ); await chat.startReplay( simpleConversationMessage.messages[0].content, diff --git a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts index bbce70d001..1f02b2e859 100644 --- a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts +++ b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts @@ -99,9 +99,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await chat.replay.click(); await variableModalAssertion.assertVariableModalState('visible'); }, @@ -256,9 +254,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await chat.changeAgentButton.click(); await talkToAgentDialog.selectAgent(randomModel, marketplacePage); await chat.replay.click(); @@ -369,9 +365,7 @@ dialSharedWithMeTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await chat.proceedReplaying(); await variableModalAssertion.assertVariableModalState('hidden'); }, diff --git a/apps/chat-e2e/src/tests/playBack.test.ts b/apps/chat-e2e/src/tests/playBack.test.ts index 573de0d093..e73b74f213 100644 --- a/apps/chat-e2e/src/tests/playBack.test.ts +++ b/apps/chat-e2e/src/tests/playBack.test.ts @@ -438,9 +438,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(playbackConversation.name); await conversations .getEntityByName(playbackConversation.name) .waitFor(); @@ -696,9 +694,7 @@ dialTest( iconsToBeLoaded: [defaultModel!.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(playbackConversation.name); await chatHeader.leavePlaybackMode.click(); await expect .soft( @@ -769,9 +765,7 @@ dialTest( await dialTest.step('Verify playback next message has scroll', async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(playbackConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(playbackConversation.name); await conversations.getEntityByName(playbackConversation.name).waitFor(); await chat.playNextChatMessage(); const isPlaybackNextMessageScrollable = await playbackControl diff --git a/apps/chat-e2e/src/tests/replay.test.ts b/apps/chat-e2e/src/tests/replay.test.ts index da5e8119d5..209549589e 100644 --- a/apps/chat-e2e/src/tests/replay.test.ts +++ b/apps/chat-e2e/src/tests/replay.test.ts @@ -538,9 +538,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, ); @@ -634,9 +632,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await conversations.openEntityDropdownMenu(replayConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.rename); @@ -746,9 +742,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(replayConversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(replayConversation.name); await agentInfoAssertion.assertElementText( agentInfo.agentName, ExpectedConstants.replayAsIsLabel, diff --git a/apps/chat-e2e/src/tests/scrolling.test.ts b/apps/chat-e2e/src/tests/scrolling.test.ts index 41a75b66ce..f11e5c7aa5 100644 --- a/apps/chat-e2e/src/tests/scrolling.test.ts +++ b/apps/chat-e2e/src/tests/scrolling.test.ts @@ -236,7 +236,11 @@ dialTest( await dialTest.step( 'Back to the first conversation, create new conversation and verify no "Scroll down" button is visible', async () => { - await conversations.selectConversation(firstConversation.name); + await conversations.selectConversation( + firstConversation.name, + undefined, + { isHttpMethodTriggered: false }, + ); await header.createNewConversation(); await expect .soft( @@ -250,7 +254,11 @@ dialTest( await dialTest.step( 'Create Replay conversation based on the first one and verify it is selected and highlighted', async () => { - await conversations.selectConversation(firstConversation.name); + await conversations.selectConversation( + firstConversation.name, + undefined, + { isHttpMethodTriggered: false }, + ); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.replay, { triggeredHttpMethod: 'POST', @@ -352,13 +360,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation( - firstConversation.name, - { isHttpMethodTriggered: false }, - { - exactMatch: true, - }, - ); + await conversations.selectConversation(firstConversation.name, { + exactMatch: true, + }); await chat.scrollContent(0, -100); await conversations.openEntityDropdownMenu(firstConversationName, { exactMatch: true, diff --git a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts index 29c92af403..68b0ee5b9c 100644 --- a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts +++ b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts @@ -149,7 +149,6 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( responseImageConversation.name, - { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages @@ -178,7 +177,6 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( requestImageConversation.name, - { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages .getChatMessage(chatResponseIndex) @@ -211,7 +209,6 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( stageConversation.name, - { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages .getChatMessage(chatResponseIndex) @@ -225,7 +222,6 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( codeConversation.name, - { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages .getChatMessage(chatResponseIndex) @@ -681,7 +677,6 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( imageConversation.name, - { isHttpMethodTriggered: true }, ); await additionalShareUserChatMessages.expandChatMessageAttachment( @@ -758,6 +753,8 @@ dialSharedWithMeTest( async () => { await additionalShareUserConversations.selectConversation( secondUserEmptyConversation.name, + undefined, + { isHttpMethodTriggered: false }, ); await additionalShareUserSendMessage.attachmentMenuTrigger.click(); diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index 6c03047f2c..f3936ca064 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -377,9 +377,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversationToShare.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(firstConversationToShare.name); await chatHeader.openConversationSettingsPopup(); await agentSettings.setSystemPrompt(GeneratorUtil.randomString(5)); await temperatureSlider.setTemperature(0); @@ -400,9 +398,7 @@ dialTest( 'Update conversation name for the 2nd conversation and verify conversation is shared, shared icon is displayed', async () => { newName = GeneratorUtil.randomString(10); - await conversations.selectConversation(secondConversationToShare.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(secondConversationToShare.name); await conversations.openEntityDropdownMenu( secondConversationToShare.name, ); @@ -538,9 +534,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(conversation.name, { - isHttpMethodTriggered: true, - }); + await conversations.selectConversation(conversation.name); for (const conversation of [ replayConversation, playbackConversation, diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index a1b5c3f06a..2668a73dcc 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -415,7 +415,6 @@ dialSharedWithMeTest( await dialHomePage.waitForPageLoaded(); await conversations.selectConversation( conversationWithSpecialChars.name, - { isHttpMethodTriggered: true }, ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( @@ -448,7 +447,6 @@ dialSharedWithMeTest( await dialHomePage.waitForPageLoaded(); await conversations.selectConversation( conversationWithSpecialChars.name, - { isHttpMethodTriggered: true }, ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( @@ -668,6 +666,7 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoRequestsWithAttachments.name, + undefined, { isHttpMethodTriggered: true }, ); @@ -698,6 +697,7 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoResponsesWithAttachments.name, + undefined, { isHttpMethodTriggered: true }, ); @@ -738,6 +738,7 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( user1ConversationInFolder.name, + undefined, { isHttpMethodTriggered: true }, ); diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts index 016c118559..84c36346ca 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts @@ -6,8 +6,8 @@ import { SideBarEntitiesTree } from '@/src/ui/webElements/entityTree/sidebar/sid export class BaseSideBarConversationTree extends SideBarEntitiesTree { public async selectConversation( name: string, - { isHttpMethodTriggered = false }: { isHttpMethodTriggered?: boolean } = {}, indexOrOptions?: number | { exactMatch: boolean; index?: number }, + { isHttpMethodTriggered = false }: { isHttpMethodTriggered?: boolean } = {}, ) { const conversationToSelect = this.getTreeEntity(name, indexOrOptions); if (isApiStorageType && isHttpMethodTriggered) { From c9ab9b5e793232f8f18f3b15389314b74c0b26b8 Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Thu, 6 Feb 2025 18:28:25 +0100 Subject: [PATCH 27/28] feat/3052-from-edit-to-move-endpoint: fixed tests with agent change --- apps/chat-e2e/src/tests/compareMode.test.ts | 22 ++++++++----------- .../duplicateSharedConversations.test.ts | 2 -- apps/chat-e2e/src/tests/scrolling.test.ts | 22 ++++++++----------- .../shareConversationWithContent.test.ts | 2 -- .../src/tests/sharedChatIcons.test.ts | 3 +-- .../src/tests/sharedFilesAttachments.test.ts | 3 --- .../sidebar/baseSideBarConversationTree.ts | 2 +- .../src/ui/webElements/talkToAgentDialog.ts | 9 ++++++++ 8 files changed, 29 insertions(+), 36 deletions(-) diff --git a/apps/chat-e2e/src/tests/compareMode.test.ts b/apps/chat-e2e/src/tests/compareMode.test.ts index 36c0334e4e..6996350fed 100644 --- a/apps/chat-e2e/src/tests/compareMode.test.ts +++ b/apps/chat-e2e/src/tests/compareMode.test.ts @@ -264,9 +264,13 @@ dialTest( iconsToBeLoaded: [defaultModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(modelConversation.name, { - exactMatch: true, - }); + await conversations.selectConversation( + modelConversation.name, + { isHttpMethodTriggered: false }, + { + exactMatch: true, + }, + ); await conversations.openEntityDropdownMenu(modelConversation.name, { exactMatch: true, }); @@ -613,11 +617,7 @@ dialTest( .soft(isComparedMessageRated, ExpectedMessages.chatMessageIsRated) .toBeTruthy(); - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await chatMessages .getChatMessageRate(firstConversation.messages.length + 2, rate) .waitFor(); @@ -1374,11 +1374,7 @@ dialTest( await dialTest.step( 'Switch to comparing conversation and verify Compare mode is closed', async () => { - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await expect .soft(compare.getElementLocator(), ExpectedMessages.compareModeClosed) .toBeHidden(); diff --git a/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts b/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts index ab84a078ad..da423ffa22 100644 --- a/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts +++ b/apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts @@ -162,8 +162,6 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationName, - undefined, - { isHttpMethodTriggered: false }, ); await additionalShareUserChat.duplicateConversation(); await additionalShareUserConversations diff --git a/apps/chat-e2e/src/tests/scrolling.test.ts b/apps/chat-e2e/src/tests/scrolling.test.ts index f11e5c7aa5..41a75b66ce 100644 --- a/apps/chat-e2e/src/tests/scrolling.test.ts +++ b/apps/chat-e2e/src/tests/scrolling.test.ts @@ -236,11 +236,7 @@ dialTest( await dialTest.step( 'Back to the first conversation, create new conversation and verify no "Scroll down" button is visible', async () => { - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await header.createNewConversation(); await expect .soft( @@ -254,11 +250,7 @@ dialTest( await dialTest.step( 'Create Replay conversation based on the first one and verify it is selected and highlighted', async () => { - await conversations.selectConversation( - firstConversation.name, - undefined, - { isHttpMethodTriggered: false }, - ); + await conversations.selectConversation(firstConversation.name); await conversations.openEntityDropdownMenu(firstConversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.replay, { triggeredHttpMethod: 'POST', @@ -360,9 +352,13 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversations.selectConversation(firstConversation.name, { - exactMatch: true, - }); + await conversations.selectConversation( + firstConversation.name, + { isHttpMethodTriggered: false }, + { + exactMatch: true, + }, + ); await chat.scrollContent(0, -100); await conversations.openEntityDropdownMenu(firstConversationName, { exactMatch: true, diff --git a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts index 68b0ee5b9c..9df432146e 100644 --- a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts +++ b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts @@ -753,8 +753,6 @@ dialSharedWithMeTest( async () => { await additionalShareUserConversations.selectConversation( secondUserEmptyConversation.name, - undefined, - { isHttpMethodTriggered: false }, ); await additionalShareUserSendMessage.attachmentMenuTrigger.click(); diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index f3936ca064..f90b2ae032 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -313,7 +313,6 @@ dialTest( temperatureSlider, agentSettings, addons, - marketplacePage, conversations, conversationDropdownMenu, conversationSettingsModal, @@ -418,7 +417,7 @@ dialTest( async () => { await conversations.selectConversation(thirdConversationToShare.name); await chatHeader.chatAgent.click(); - await talkToAgentDialog.selectAgent(randomModel, marketplacePage); + await talkToAgentDialog.selectRecentAgent(randomModel); await conversationAssertion.assertEntityArrowIconState( { name: newName }, 'visible', diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index 2668a73dcc..87842dbb81 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -666,7 +666,6 @@ dialSharedWithMeTest( await additionalShareUserDialHomePage.waitForPageLoaded(); await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoRequestsWithAttachments.name, - undefined, { isHttpMethodTriggered: true }, ); @@ -697,7 +696,6 @@ dialSharedWithMeTest( async () => { await additionalShareUserSharedWithMeConversations.selectConversation( conversationWithTwoResponsesWithAttachments.name, - undefined, { isHttpMethodTriggered: true }, ); @@ -738,7 +736,6 @@ dialSharedWithMeTest( await additionalShareUserSharedWithMeConversations.selectConversation( user1ConversationInFolder.name, - undefined, { isHttpMethodTriggered: true }, ); diff --git a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts index 84c36346ca..016c118559 100644 --- a/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts +++ b/apps/chat-e2e/src/ui/webElements/entityTree/sidebar/baseSideBarConversationTree.ts @@ -6,8 +6,8 @@ import { SideBarEntitiesTree } from '@/src/ui/webElements/entityTree/sidebar/sid export class BaseSideBarConversationTree extends SideBarEntitiesTree { public async selectConversation( name: string, - indexOrOptions?: number | { exactMatch: boolean; index?: number }, { isHttpMethodTriggered = false }: { isHttpMethodTriggered?: boolean } = {}, + indexOrOptions?: number | { exactMatch: boolean; index?: number }, ) { const conversationToSelect = this.getTreeEntity(name, indexOrOptions); if (isApiStorageType && isHttpMethodTriggered) { diff --git a/apps/chat-e2e/src/ui/webElements/talkToAgentDialog.ts b/apps/chat-e2e/src/ui/webElements/talkToAgentDialog.ts index 662835eb57..8c822a1146 100644 --- a/apps/chat-e2e/src/ui/webElements/talkToAgentDialog.ts +++ b/apps/chat-e2e/src/ui/webElements/talkToAgentDialog.ts @@ -135,4 +135,13 @@ export class TalkToAgentDialog extends BaseElement { public async selectReplayAsIs() { await this.getAgents().getAgent(ExpectedConstants.replayAsIsLabel).click(); } + + //select agent available on 'Talk to' modal + public async selectRecentAgent(agent: DialAIEntityModel) { + const resp = this.page.waitForResponse((r) => + r.url().includes(API.moveHost), + ); + await this.getAgents().getAgent(agent).click(); + await resp; + } } From 9d3df949911fff507b857286e4c78e151b5d95ce Mon Sep 17 00:00:00 2001 From: Irina_Kartun Date: Thu, 6 Feb 2025 21:49:13 +0100 Subject: [PATCH 28/28] feat/3052-from-edit-to-move-endpoint: fixed tests --- apps/chat-e2e/src/tests/conversationNameNumeration.test.ts | 6 +++++- apps/chat-e2e/src/tests/messageTemplate.test.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/chat-e2e/src/tests/conversationNameNumeration.test.ts b/apps/chat-e2e/src/tests/conversationNameNumeration.test.ts index 2f1169c677..32b1e6a827 100644 --- a/apps/chat-e2e/src/tests/conversationNameNumeration.test.ts +++ b/apps/chat-e2e/src/tests/conversationNameNumeration.test.ts @@ -339,7 +339,11 @@ dialTest( await dialTest.step( 'Send one more request to "test" conversation and verify name is not changed', async () => { - await conversations.selectConversation(requestBasedConversationName, 2); + await conversations.selectConversation( + requestBasedConversationName, + { isHttpMethodTriggered: false }, + 2, + ); await chat.sendRequestWithButton('1+2', false); expect .soft( diff --git a/apps/chat-e2e/src/tests/messageTemplate.test.ts b/apps/chat-e2e/src/tests/messageTemplate.test.ts index 5e4b0af789..fa66cd5226 100644 --- a/apps/chat-e2e/src/tests/messageTemplate.test.ts +++ b/apps/chat-e2e/src/tests/messageTemplate.test.ts @@ -1014,10 +1014,10 @@ dialTest( async () => { await conversations.selectConversation( replayName, + { isHttpMethodTriggered: false }, { exactMatch: true, }, - { isHttpMethodTriggered: false }, ); await chat.startReplay( simpleConversationMessage.messages[0].content,