Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/epam/ai-dial-chat in…
Browse files Browse the repository at this point in the history
…to development
  • Loading branch information
Derikyan committed Dec 20, 2024
2 parents ae2825c + 96b1bfb commit 1677ee5
Show file tree
Hide file tree
Showing 129 changed files with 4,369 additions and 1,496 deletions.
17 changes: 13 additions & 4 deletions apps/chat-e2e/src/assertions/api/apiAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,19 @@ export class ApiAssertion {
.toBe(expectedTemperature);
}

public async assertRequestPrompt(request: ChatBody, expectedPrompt: string) {
expect
.soft(request.prompt, ExpectedMessages.chatRequestPromptIsValid)
.toBe(expectedPrompt);
public async assertRequestPrompt(
request: ChatBody,
expectedPrompt: string | undefined,
) {
if (request.prompt === undefined) {
expect
.soft(request.prompt, ExpectedMessages.chatRequestPromptIsValid)
.toBeUndefined();
} else {
expect
.soft(request.prompt, ExpectedMessages.chatRequestPromptIsValid)
.toBe(expectedPrompt);
}
}

public async assertRequestAddons(
Expand Down
32 changes: 32 additions & 0 deletions apps/chat-e2e/src/assertions/baseAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,42 @@ export class BaseAssertion {
.toHaveText(expectedText);
}

public async assertElementAttribute(
element: BaseElement | Locator,
attribute: string,
expectedValue: string,
expectedMessage?: string,
) {
const elementLocator =
element instanceof BaseElement
? element.getElementLocator()
: (element as Locator);
await expect
.soft(
elementLocator,
expectedMessage ?? ExpectedMessages.elementAttributeValueIsValid,
)
.toHaveAttribute(attribute, expectedValue);
}

public async assertElementColor(element: BaseElement, expectedColor: string) {
const style = await element.getComputedStyleProperty(Styles.color);
expect
.soft(style[0], ExpectedMessages.elementColorIsValid)
.toBe(expectedColor);
}

public async assertElementsCount(
element: BaseElement | Locator,
expectedCount: number,
) {
const elementsCount =
element instanceof BaseElement
? await element.getElementsCount()
: await element.count();

expect
.soft(elementsCount, ExpectedMessages.elementsCountIsValid)
.toBe(expectedCount);
}
}
10 changes: 4 additions & 6 deletions apps/chat-e2e/src/assertions/chatMessagesAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,14 @@ export class ChatMessagesAssertion extends BaseAssertion {
message: string | number,
expectedState: ElementState,
) {
const chatMessage = this.chatMessages.getChatMessage(message);
await chatMessage.scrollIntoViewIfNeeded();
await chatMessage.hover();
const editIcon = this.chatMessages.setMessageTemplateIcon(chatMessage);
const chatMessage = await this.chatMessages.hoverOverMessage(message);
const templateIcon = this.chatMessages.setMessageTemplateIcon(chatMessage);
expectedState === 'visible'
? await expect
.soft(editIcon, ExpectedMessages.buttonIsVisible)
.soft(templateIcon, ExpectedMessages.buttonIsVisible)
.toBeVisible()
: await expect
.soft(editIcon, ExpectedMessages.buttonIsNotVisible)
.soft(templateIcon, ExpectedMessages.buttonIsNotVisible)
.toBeHidden();
}

Expand Down
28 changes: 28 additions & 0 deletions apps/chat-e2e/src/assertions/folderAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ export class FolderAssertion<T extends Folders> extends BaseAssertion {
.toBe(expectedColor);
}

public async assertFolderEntityColor(
folder: TreeEntity,
folderEntity: TreeEntity,
expectedColor: string,
) {
const folderEntityElement = this.folder.getFolderEntityNameElement(
folder.name,
folderEntity.name,
folder.index,
folderEntity.index,
);
await this.assertElementColor(folderEntityElement, expectedColor);
}

public async assertFolderEditInputState(expectedState: ElementState) {
const editInputLocator = this.folder
.getEditFolderInput()
Expand Down Expand Up @@ -352,6 +366,20 @@ export class FolderAssertion<T extends Folders> extends BaseAssertion {
await this.assertElementState(entityArrowIcon, expectedState);
}

public async assertFolderEntityIcon(
folder: TreeEntity,
folderEntity: TreeEntity,
expectedIcon: string,
) {
const folderEntityIcon = this.folder.getFolderEntityIcon(
folder.name,
folderEntity.name,
folder.index,
folderEntity.index,
);
await this.assertEntityIcon(folderEntityIcon, expectedIcon);
}

public async assertFoldersCount(expectedCount: number) {
const actualFoldersCount = await this.folder.getFoldersCount();
expect
Expand Down
1 change: 1 addition & 0 deletions apps/chat-e2e/src/assertions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export * from './addonsDialogAssertion';
export * from './marketplaceAgentsAssertion';
export * from './conversationToCompareAssertion';
export * from './conversationToPublishAssertion';
export * from './publishFolderAssertion';
13 changes: 9 additions & 4 deletions apps/chat-e2e/src/assertions/manageAttachmentsAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ export class ManageAttachmentsAssertion {
state: ElementCaretState,
) {
const sectionElement = this.attachFilesModal.getSectionElement(section);
const isExpanded =
await this.attachFilesModal.isSectionExpanded(sectionElement);
const filesSection = this.attachFilesModal.getFilesSection(sectionElement);
state === 'expanded'
? expect(isExpanded, `Section "${section}" is ${state}`).toBeTruthy()
: expect(isExpanded, `Section "${section}" is ${state}`).toBeFalsy();
? await expect(
filesSection,
`Section "${section}" is ${state}`,
).toBeVisible()
: await expect(
filesSection,
`Section "${section}" is ${state}`,
).toBeHidden();
}
}
11 changes: 11 additions & 0 deletions apps/chat-e2e/src/assertions/messageTemplateModalAssertion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BaseAssertion } from '@/src/assertions/baseAssertion';
import { MessageTemplateModal } from '@/src/ui/webElements';

export class MessageTemplateModalAssertion extends BaseAssertion {
readonly messageTemplateModal: MessageTemplateModal;

constructor(messageTemplateModal: MessageTemplateModal) {
super();
this.messageTemplateModal = messageTemplateModal;
}
}
47 changes: 47 additions & 0 deletions apps/chat-e2e/src/assertions/publishFolderAssertion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { FolderAssertion } from '@/src/assertions/folderAssertion';
import { PublishingExpectedMessages, TreeEntity } from '@/src/testData';
import { PublishFolder } from '@/src/ui/webElements/entityTree';

export class PublishFolderAssertion<
T extends PublishFolder,
> extends FolderAssertion<PublishFolder> {
readonly publishFolder: T;

constructor(publishFolder: T) {
super(publishFolder);
this.publishFolder = publishFolder;
}

public async assertFolderEntityVersion(
folder: TreeEntity,
folderEntity: TreeEntity,
expectedVersion: string,
) {
await this.assertElementText(
this.publishFolder.getFolderEntityVersion(
folder.name,
folderEntity.name,
folder.index,
folderEntity.index,
),
expectedVersion,
PublishingExpectedMessages.entityVersionIsValid,
);
}

public async assertFolderEntityVersionColor(
folder: TreeEntity,
folderEntity: TreeEntity,
expectedColor: string,
) {
await this.assertElementColor(
this.publishFolder.getFolderEntityVersionElement(
folder.name,
folderEntity.name,
folder.index,
folderEntity.index,
),
expectedColor,
);
}
}
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();
}
}
24 changes: 12 additions & 12 deletions apps/chat-e2e/src/core/dialAdminFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ChatHeaderAssertion,
ChatMessagesAssertion,
MenuAssertion,
PublishFolderAssertion,
TooltipAssertion,
} from '@/src/assertions';
import { ConversationToApproveAssertion } from '@/src/assertions/conversationToApproveAssertion';
Expand All @@ -28,11 +29,11 @@ import {
ApproveRequiredConversationsTree,
ConversationsToApproveTree,
ConversationsTree,
FolderConversationsToApprove,
FolderPrompts,
Folders,
OrganizationConversationsTree,
PromptsTree,
PublishFolder,
} from '@/src/ui/webElements/entityTree';
import { Tooltip } from '@/src/ui/webElements/tooltip';
import { Page } from '@playwright/test';
Expand All @@ -56,14 +57,14 @@ const dialAdminTest = dialTest.extend<{
adminOrganizationFolderConversationAssertions: FolderAssertion<Folders>;
adminPublishingApprovalModalAssertion: PublishingApprovalModalAssertion;
adminConversationToApproveAssertion: ConversationToApproveAssertion;
adminFolderToApproveAssertion: PublishFolderAssertion<FolderConversationsToApprove>;
adminPublicationReviewControl: PublicationReviewControl;
adminChatHeader: ChatHeader;
adminChatMessages: ChatMessages;
adminOrganizationFolderDropdownMenu: DropdownMenu;
adminApproveRequiredConversationDropdownMenu: DropdownMenu;
adminTooltip: Tooltip;
adminOrganizationConversations: OrganizationConversationsTree;
adminPublishingApprovalFolderConversationsAssertion: FolderAssertion<PublishFolder>;
adminChatHeaderAssertion: ChatHeaderAssertion<ChatHeader>;
adminChatMessagesAssertion: ChatMessagesAssertion;
adminOrganizationFolderDropdownMenuAssertion: MenuAssertion;
Expand Down Expand Up @@ -176,16 +177,6 @@ const dialAdminTest = dialTest.extend<{
adminChatBar.getOrganizationConversationsTree();
await use(adminOrganizationConversations);
},
adminPublishingApprovalFolderConversationsAssertion: async (
{ adminPublishingApprovalModal },
use,
) => {
const adminPublishingApprovalFolderConversationsAssertion =
new FolderAssertion(
adminPublishingApprovalModal.getFolderConversationsToApprove(),
);
await use(adminPublishingApprovalFolderConversationsAssertion);
},
adminChatHeaderAssertion: async ({ adminChatHeader }, use) => {
const adminChatHeaderAssertion = new ChatHeaderAssertion(adminChatHeader);
await use(adminChatHeaderAssertion);
Expand Down Expand Up @@ -231,6 +222,15 @@ const dialAdminTest = dialTest.extend<{
new ConversationToApproveAssertion(adminConversationsToApprove);
await use(adminConversationToApproveAssertion);
},
adminFolderToApproveAssertion: async (
{ adminPublishingApprovalModal },
use,
) => {
const adminFolderToApproveAssertion = new PublishFolderAssertion(
adminPublishingApprovalModal.getFolderConversationsToApprove(),
);
await use(adminFolderToApproveAssertion);
},
adminOrganizationFolderDropdownMenuAssertion: async (
{ adminOrganizationFolderDropdownMenu },
use,
Expand Down
Loading

0 comments on commit 1677ee5

Please sign in to comment.