Skip to content

Commit

Permalink
Merge branch 'development' into fix/2750-simple-rag
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaBondar committed Dec 20, 2024
2 parents 0d55378 + e64a3ea commit 54e055b
Show file tree
Hide file tree
Showing 45 changed files with 887 additions and 526 deletions.
56 changes: 56 additions & 0 deletions apps/chat-e2e/src/assertions/renameConversationModalAssertion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { BaseAssertion } from '@/src/assertions/baseAssertion';
import { RenameConversationModal } from '@/src/ui/webElements/renameConversationModal';
import { expect } from '@playwright/test';

export class RenameConversationModalAssertion extends BaseAssertion {
readonly renameModal: RenameConversationModal;

constructor(renameModal: RenameConversationModal) {
super();
this.renameModal = renameModal;
}

async assertModalIsVisible() {
await this.assertElementState(
this.renameModal.getElementLocator(),
'visible',
'Rename Conversation Modal should be visible',
);
}

async assertModalTitle(expectedTitle: string) {
await expect
.soft(
this.renameModal.title.getElementLocator(),
'Rename Conversation Modal title should match',
)
.toHaveText(expectedTitle);
}

async assertInputValue(expectedValue: string) {
await expect
.soft(
this.renameModal.nameInput.getElementLocator(),
'Rename Conversation Modal input value should match',
)
.toHaveText(expectedValue);
}

async assertSaveButtonIsEnabled() {
await expect
.soft(
this.renameModal.saveButton.getElementLocator(),
'Save button should be enabled',
)
.toBeEnabled();
}

async assertSaveButtonIsDisabled() {
await expect
.soft(
this.renameModal.saveButton.getElementLocator(),
'Save button should be disabled',
)
.toBeDisabled();
}
}
16 changes: 16 additions & 0 deletions apps/chat-e2e/src/core/dialFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { AddonsDialogAssertion } from '@/src/assertions/addonsDialogAssertion';
import { ConversationToPublishAssertion } from '@/src/assertions/conversationToPublishAssertion';
import { ManageAttachmentsAssertion } from '@/src/assertions/manageAttachmentsAssertion';
import { MessageTemplateModalAssertion } from '@/src/assertions/messageTemplateModalAssertion';
import { RenameConversationModalAssertion } from '@/src/assertions/renameConversationModalAssertion';
import { SelectFolderModalAssertion } from '@/src/assertions/selectFolderModalAssertion';
import { SettingsModalAssertion } from '@/src/assertions/settingsModalAssertion';
import { SideBarEntityAssertion } from '@/src/assertions/sideBarEntityAssertion';
Expand Down Expand Up @@ -110,6 +111,7 @@ import { ModelInfoTooltip } from '@/src/ui/webElements/modelInfoTooltip';
import { PlaybackControl } from '@/src/ui/webElements/playbackControl';
import { PromptModalDialog } from '@/src/ui/webElements/promptModalDialog';
import { PublishingRequestModal } from '@/src/ui/webElements/publishingRequestModal';
import { RenameConversationModal } from '@/src/ui/webElements/renameConversationModal';
import { Search } from '@/src/ui/webElements/search';
import { SettingsModal } from '@/src/ui/webElements/settingsModal';
import { ShareModal } from '@/src/ui/webElements/shareModal';
Expand Down Expand Up @@ -179,6 +181,8 @@ const dialTest = test.extend<
promptDropdownMenu: DropdownMenu;
confirmationDialog: ConfirmationDialog;
promptModalDialog: PromptModalDialog;
renameConversationModal: RenameConversationModal;
renameConversationModalAssertion: RenameConversationModalAssertion;
variableModalDialog: VariableModalDialog;
chatHeader: ChatHeader;
modelInfoTooltip: ModelInfoTooltip;
Expand Down Expand Up @@ -504,6 +508,18 @@ const dialTest = test.extend<
const promptModalDialog = new PromptModalDialog(page);
await use(promptModalDialog);
},
renameConversationModal: async ({ page }, use) => {
const renameConversationModal = new RenameConversationModal(page);
await use(renameConversationModal);
},
renameConversationModalAssertion: async (
{ renameConversationModal },
use,
) => {
const renameConversationModalAssertion =
new RenameConversationModalAssertion(renameConversationModal);
await use(renameConversationModalAssertion);
},
variableModalDialog: async ({ page }, use) => {
const variableModalDialog = new VariableModalDialog(page);
await use(variableModalDialog);
Expand Down
1 change: 1 addition & 0 deletions apps/chat-e2e/src/testData/expectedConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const ExpectedConstants = {
`${ExpectedConstants.newFolderTitle} ${index}`,
newPromptFolderWithIndexTitle: (index: number) =>
`${ExpectedConstants.newFolderTitle} ${index}`,
renameConversationModalTitle: 'Rename conversation',
emptyString: '',
defaultTemperature: '1',
signInButtonTitle: 'Sign in with Credentials',
Expand Down
77 changes: 44 additions & 33 deletions apps/chat-e2e/src/tests/chatBarConversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '@/src/testData';
import { Colors, Overflow, Styles } from '@/src/ui/domData';
import { ChatBarSelectors } from '@/src/ui/selectors';
import { EditInput } from '@/src/ui/webElements';
import { GeneratorUtil } from '@/src/utils';
import { ModelsUtil } from '@/src/utils/modelsUtil';
import { expect } from '@playwright/test';
Expand Down Expand Up @@ -102,6 +101,8 @@ dialTest(
conversationData,
dataInjector,
setTestIds,
renameConversationModal,
renameConversationModalAssertion,
}) => {
setTestIds('EPMRTC-588', 'EPMRTC-816', 'EPMRTC-1494');
const newName = 'new name to cancel';
Expand Down Expand Up @@ -149,20 +150,25 @@ dialTest(
async () => {
await conversations.openEntityDropdownMenu(conversationName);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
const chatNameOverflow = await conversations
.getEntityName(conversationName)
.getComputedStyleProperty(Styles.text_overflow);
await renameConversationModalAssertion.assertModalIsVisible();
await renameConversationModalAssertion.assertModalTitle(
ExpectedConstants.renameConversationModalTitle,
);
const modalInputValue = await renameConversationModal.getInputValue();
expect
.soft(chatNameOverflow[0], ExpectedMessages.chatNameIsTruncated)
.toBe(undefined);
.soft(
modalInputValue,
'Modal input should contain the initial conversation name',
)
.toBe(conversationName);
},
);

await dialTest.step(
'Set new conversation name, cancel edit and verify conversation with initial name shown',
async () => {
await conversations.openEditEntityNameMode(newName);
await conversations.getEditInputActions().clickCancelButton();
await renameConversationModal.nameInput.fillInInput(newName);
await renameConversationModal.cancelButton.click();
await expect
.soft(
conversations.getEntityByName(newName),
Expand Down Expand Up @@ -199,6 +205,7 @@ dialTest(
conversationData,
dataInjector,
setTestIds,
renameConversationModal,
}) => {
setTestIds('EPMRTC-584', 'EPMRTC-819');
const conversation = conversationData.prepareDefaultConversation();
Expand All @@ -209,7 +216,7 @@ dialTest(
await dialHomePage.waitForPageLoaded();
await conversations.openEntityDropdownMenu(conversation.name);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
await conversations.editConversationNameWithTick(newName, {
await renameConversationModal.editConversationNameWithSaveButton(newName, {
isHttpMethodTriggered: false,
});
await expect
Expand Down Expand Up @@ -258,6 +265,7 @@ dialTest(
setTestIds,
errorPopup,
errorToast,
renameConversationModal,
}) => {
setTestIds(
'EPMRTC-585',
Expand All @@ -281,7 +289,7 @@ dialTest(
await conversations.selectConversation(conversation.name);
await conversations.openEntityDropdownMenu(conversation.name);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
await conversations.editConversationNameWithEnter(
await renameConversationModal.editConversationNameWithEnter(
newLongNameWithMiddleSpacesEndDot,
);

Expand Down Expand Up @@ -374,6 +382,7 @@ dialTest(
conversationData,
dataInjector,
setTestIds,
renameConversationModal,
}) => {
setTestIds(
'EPMRTC-595',
Expand All @@ -383,7 +392,6 @@ dialTest(
'EPMRTC-1574',
'EPMRTC-1276',
);
let editInputContainer: EditInput;
const newNameWithEndDot = 'updated folder name.';
let conversation: Conversation;

Expand All @@ -399,52 +407,54 @@ dialTest(
await dialHomePage.waitForPageLoaded();
await conversations.openEntityDropdownMenu(conversation.name);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
editInputContainer =
await conversations.openEditEntityNameMode(newNameWithEndDot);
await conversations.getEditInputActions().clickTickButton();
await renameConversationModal.editConversationNameWithSaveButton(
newNameWithEndDot,
{ isHttpMethodTriggered: false },
);

const errorMessage = await errorToast.getElementContent();
expect
.soft(errorMessage, ExpectedMessages.notAllowedNameErrorShown)
.toBe(ExpectedConstants.nameWithDotErrorMessage);
await errorToast.closeToast();
},
);

await dialTest.step(
'Start typing prohibited symbols and verify they are not displayed in text input',
async () => {
await editInputContainer.editInput.click();
await editInputContainer.editValue(
await renameConversationModal.editInputValue(
ExpectedConstants.restrictedNameChars,
);
const inputContent = await editInputContainer.getEditInputValue();
const inputContent = await renameConversationModal.getInputValue();
expect
.soft(inputContent, ExpectedMessages.charactersAreNotDisplayed)
.toBe('');
await renameConversationModal.cancelButton.click();
},
);

await dialTest.step(
'Set empty conversation name or spaces and verify initial name is preserved',
async () => {
const name = GeneratorUtil.randomArrayElement(['', ' ']);
editInputContainer = await conversations.openEditEntityNameMode(name);
await conversations.getEditInputActions().clickTickButton();
await expect
.soft(
conversations.getEntityByName(conversation.name),
ExpectedMessages.conversationNameNotUpdated,
)
.toBeVisible();
},
);
//TODO decide if that is a correct behavior - to delete this step since the new modal doesn't let us press the "save" button with spaces in the input
// await dialTest.step(
// 'Set empty conversation name or spaces and verify initial name is preserved',
// async () => {
// const name = GeneratorUtil.randomArrayElement(['', ' ']);
// await renameConversationModal.editConversationNameWithEnter(name);
// await expect
// .soft(
// conversations.getEntityByName(conversation.name),
// ExpectedMessages.conversationNameNotUpdated,
// )
// .toBeVisible();
// },
// );

await dialTest.step(
'Verify renaming conversation to the name with special symbols is successful',
async () => {
await conversations.openEntityDropdownMenu(conversation.name);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
await conversations.editConversationNameWithTick(
await renameConversationModal.editConversationNameWithSaveButton(
ExpectedConstants.allowedSpecialChars,
{ isHttpMethodTriggered: false },
);
Expand Down Expand Up @@ -1307,6 +1317,7 @@ dialTest(
chatMessages,
chat,
setTestIds,
renameConversationModal,
}) => {
setTestIds('EPMRTC-2849', 'EPMRTC-2959');
const updatedConversationName = `😂👍🥳 😷 🤧 🤠 🥴😇 😈 ⭐あおㅁㄹñ¿äß`;
Expand All @@ -1325,7 +1336,7 @@ dialTest(
await conversations.selectConversation(conversation.name);
await conversations.openEntityDropdownMenu(conversation.name);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
await conversations.editConversationNameWithTick(
await renameConversationModal.editConversationNameWithSaveButton(
updatedConversationName,
);
await expect
Expand Down
5 changes: 4 additions & 1 deletion apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dialTest(
shareModal,
conversationDropdownMenu,
downloadAssertion,
renameConversationModal,
}) => {
setTestIds(
'EPMRTC-934',
Expand Down Expand Up @@ -106,7 +107,9 @@ dialTest(
await dialTest.step('Click on Rename, rename and confirm', async () => {
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
firstConversation.name = 'Renamed chat';
await conversations.editConversationNameWithTick(firstConversation.name);
await renameConversationModal.editConversationNameWithSaveButton(
firstConversation.name,
);
await conversations.getEntityByName(firstConversation.name).waitFor();
await conversationAssertion.assertSelectedConversation(
secondConversation.name,
Expand Down
5 changes: 4 additions & 1 deletion apps/chat-e2e/src/tests/compareMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ dialTest(
conversationDropdownMenu,
compare,
compareConversation,
renameConversationModal,
}) => {
setTestIds(
'EPMRTC-560',
Expand Down Expand Up @@ -1613,7 +1614,9 @@ dialTest(
const newLeftChatName = GeneratorUtil.randomString(7);
await conversations.openEntityDropdownMenu(updatedRequestContent, 1);
await conversationDropdownMenu.selectMenuOption(MenuOptions.rename);
await conversations.editConversationNameWithTick(newLeftChatName);
await renameConversationModal.editConversationNameWithSaveButton(
newLeftChatName,
);

const chatTitle = await leftChatHeader.chatTitle.getElementContent();
expect
Expand Down
Loading

0 comments on commit 54e055b

Please sign in to comment.