Skip to content

Commit

Permalink
feat(chat): move from edit to move endpoint for conversations/pro…
Browse files Browse the repository at this point in the history
…mpts rename (Issue #3052) (#3062)
  • Loading branch information
Alexander-Kezik authored Feb 7, 2025
1 parent e0c0591 commit d0e0390
Show file tree
Hide file tree
Showing 49 changed files with 534 additions and 580 deletions.
42 changes: 21 additions & 21 deletions apps/chat-e2e/src/assertions/api/apiAssertion.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
}
}
16 changes: 5 additions & 11 deletions apps/chat-e2e/src/testData/expectedConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -300,6 +291,9 @@ export const API = {
promptsHost: () => `${API.listingHost}/prompts`,
filesListingHost: () => `${API.listingHost}/files`,
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) =>
Expand Down
6 changes: 3 additions & 3 deletions apps/chat-e2e/src/testData/expectedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/tests/chatBarConversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions apps/chat-e2e/src/tests/chatBarFolderConversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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();
Expand Down
22 changes: 9 additions & 13 deletions apps/chat-e2e/src/tests/compareMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion apps/chat-e2e/src/tests/conversationNameNumeration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions apps/chat-e2e/src/tests/duplicateSharedConversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ dialSharedWithMeTest(
async () => {
await additionalShareUserSharedWithMeConversations.selectConversation(
conversationName,
undefined,
{ isHttpMethodTriggered: false },
);
await additionalShareUserChat.duplicateConversation();
await additionalShareUserConversations
Expand Down
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/tests/folderNameNumeration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ dialTest(
async () => {
await folderConversations.openFolderDropdownMenu(incrementedFolderName);
await folderDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderConversations.editFolderNameWithTick(
await folderConversations.renameEmptyFolderWithTick(
GeneratorUtil.randomString(5),
);

Expand Down Expand Up @@ -173,7 +173,7 @@ dialTest(
nestedFolders[nestedFolderLevel - 1].name,
);
await folderDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderConversations.editFolderNameWithTick(
await folderConversations.renameFolderWithContentWithTick(
expectedDuplicatedFolderName,
);

Expand Down
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/tests/folderPrompts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/tests/messageTemplate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,10 +1014,10 @@ dialTest(
async () => {
await conversations.selectConversation(
replayName,
{ isHttpMethodTriggered: false },
{
exactMatch: true,
},
{ isHttpMethodTriggered: false },
);
await chat.startReplay(
simpleConversationMessage.messages[0].content,
Expand Down
4 changes: 3 additions & 1 deletion apps/chat-e2e/src/tests/parametrizedReplay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
() =>
Expand Down
6 changes: 3 additions & 3 deletions apps/chat-e2e/src/tests/promptFolderNamesakes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dialTest(
ExpectedConstants.newFolderWithIndexTitle(1),
);
await promptDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(duplicatedFolderName);
await folderPrompts.renameEmptyFolderWithTick(duplicatedFolderName);
});

await dialTest.step(
Expand All @@ -51,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();
Expand Down Expand Up @@ -205,7 +205,7 @@ dialTest(
ExpectedConstants.newFolderWithIndexTitle(3),
);
await folderDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(
await folderPrompts.renameEmptyFolderWithTick(
ExpectedConstants.newFolderWithIndexTitle(2),
);
});
Expand Down
6 changes: 3 additions & 3 deletions apps/chat-e2e/src/tests/promptFolderNumeration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ dialTest(
ExpectedConstants.newFolderWithIndexTitle(folderNumber),
);
await promptDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick('Renamed Folder');
await folderPrompts.renameEmptyFolderWithTick('Renamed Folder');

await promptBar.createNewFolder();
await expect
Expand Down Expand Up @@ -209,7 +209,7 @@ dialTest(
ExpectedConstants.newFolderWithIndexTitle(1),
);
await promptDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(
await folderPrompts.renameEmptyFolderWithTick(
ExpectedConstants.newPromptFolderWithIndexTitle(999),
);
});
Expand Down Expand Up @@ -285,7 +285,7 @@ dialTest(
ExpectedConstants.newFolderWithIndexTitle(i),
);
await promptDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(duplicatedFolderName);
await folderPrompts.renameEmptyFolderWithTick(duplicatedFolderName);
await expect(
folderPrompts.getFolderByName(duplicatedFolderName, i),
ExpectedMessages.folderNameUpdated,
Expand Down
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/tests/promptFoldersSpecialChars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dialTest(
});

await dialTest.step('Rename it to contain special characters', async () => {
await folderPrompts.editFolderNameWithTick(newNameWithSpecialChars);
await folderPrompts.renameEmptyFolderWithTick(newNameWithSpecialChars);
await promptBarFolderAssertion.assertFolderState(
{ name: newNameWithSpecialChars },
'visible',
Expand Down Expand Up @@ -174,7 +174,7 @@ dialTest(
async () => {
await folderPrompts.openFolderDropdownMenu(expectedName);
await folderDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(newNameWithEmojis);
await folderPrompts.renameEmptyFolderWithTick(newNameWithEmojis);
await promptBarFolderAssertion.assertFolderState(
{ name: newNameWithEmojis },
'visible',
Expand Down
8 changes: 2 additions & 6 deletions apps/chat-e2e/src/tests/promptMaximumNameLength.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -138,14 +134,14 @@ dialTest(
ExpectedConstants.newPromptFolderWithIndexTitle(1),
);
await promptDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(longName);
await folderPrompts.renameEmptyFolderWithTick(longName);

// Rename folder_child
await folderPrompts.openFolderDropdownMenu(
ExpectedConstants.newPromptFolderWithIndexTitle(2),
);
await promptDropdownMenu.selectMenuOption(MenuOptions.rename);
await folderPrompts.editFolderNameWithTick(longName);
await folderPrompts.renameEmptyFolderWithTick(longName);
},
);

Expand Down
Loading

0 comments on commit d0e0390

Please sign in to comment.