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 25, 2024
2 parents 1677ee5 + dae64f8 commit 71cd3fa
Show file tree
Hide file tree
Showing 51 changed files with 2,344 additions and 842 deletions.
45 changes: 44 additions & 1 deletion apps/chat-e2e/src/assertions/baseAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,50 @@ export class BaseAssertion {
.toBe(expectedColor);
}

public async assertStringTruncatedTo160(
originalString: string | null | undefined,
truncatedString: string | null | undefined,
) {
const maxLength = 160;

// Handle null or undefined input
if (originalString == null || truncatedString == null) {
expect
.soft(originalString, 'Original string should not be null or undefined')
.not.toBeNull();
expect
.soft(
truncatedString,
'Truncated string should not be null or undefined',
)
.not.toBeNull();
return;
}

// Handle strings shorter than the maximum length
if (originalString.length <= maxLength) {
expect
.soft(truncatedString, 'String should not be truncated')
.toBe(originalString);
return;
}

// Assert that the truncated string has the correct length
expect
.soft(
truncatedString.length,
'Truncated string should have a length of 160',
)
.toBe(maxLength);
// Assert that the truncated string is a substring of the original
expect
.soft(
truncatedString,
'Truncated string should be a substring of the original',
)
.toBe(originalString.substring(0, maxLength));
}

public async assertElementsCount(
element: BaseElement | Locator,
expectedCount: number,
Expand All @@ -172,7 +216,6 @@ export class BaseAssertion {
element instanceof BaseElement
? await element.getElementsCount()
: await element.count();

expect
.soft(elementsCount, ExpectedMessages.elementsCountIsValid)
.toBe(expectedCount);
Expand Down
56 changes: 56 additions & 0 deletions apps/chat-e2e/src/assertions/promptPreviewModalAssertion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { BaseAssertion } from '@/src/assertions/baseAssertion';
import { ElementState, ExpectedMessages } from '@/src/testData';
import { PromptPreviewModalWindow } from '@/src/ui/webElements/promptPreviewModalWindow';

export class PromptPreviewModalAssertion extends BaseAssertion {
readonly promptPreviewModal: PromptPreviewModalWindow;

constructor(promptPreviewModal: PromptPreviewModalWindow) {
super();
this.promptPreviewModal = promptPreviewModal;
}

public async assertPromptPreviewModalState(expectedState: ElementState) {
await super.assertElementState(this.promptPreviewModal, expectedState); // Use base class method
}

public async assertPromptPreviewModalTitle(expectedValue: string) {
await super.assertElementText(
this.promptPreviewModal.modalTitle,
expectedValue,
ExpectedMessages.modalDialogTitleIsValid,
); // Use base class method
}

public async assertPromptName(expectedValue: string) {
await super.assertElementText(
this.promptPreviewModal.promptName,
expectedValue,
ExpectedMessages.promptNameValid,
); // Use base class method
}

public async assertPromptDescription(expectedValue: string | undefined) {
if (expectedValue === '' || expectedValue === undefined) {
await super.assertElementState(
this.promptPreviewModal.promptDescription,
'hidden',
ExpectedMessages.promptDescriptionValid,
);
} else {
await super.assertElementText(
this.promptPreviewModal.promptDescription,
expectedValue,
ExpectedMessages.promptDescriptionValid,
);
}
}

public async assertPromptContent(expectedValue: string) {
await super.assertElementText(
this.promptPreviewModal.promptContent,
expectedValue,
ExpectedMessages.promptContentValid,
);
}
}
4 changes: 4 additions & 0 deletions apps/chat-e2e/src/assertions/promptToApproveAssertion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PublishEntityAssertion } from '@/src/assertions/publishEntityAssertion';
import { PromptsToApproveTree } from '@/src/ui/webElements/entityTree';

export class PromptToApproveAssertion extends PublishEntityAssertion<PromptsToApproveTree> {}
4 changes: 4 additions & 0 deletions apps/chat-e2e/src/assertions/promptToPublishAssertion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PublishEntityAssertion } from '@/src/assertions/publishEntityAssertion';
import { PromptsToPublishTree } from '@/src/ui/webElements/entityTree';

export class PromptToPublishAssertion extends PublishEntityAssertion<PromptsToPublishTree> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PromptPreviewModalAssertion } from '@/src/assertions/promptPreviewModalAssertion';
import { PublishedPromptPreviewModal } from '@/src/ui/webElements/publishedPromptPreviewModal';

export class PublishedPromptPreviewModalAssertion extends PromptPreviewModalAssertion {
readonly publishedPromptPreviewModal: PublishedPromptPreviewModal;

constructor(publishedPromptPreviewModal: PublishedPromptPreviewModal) {
super(publishedPromptPreviewModal);
this.publishedPromptPreviewModal = publishedPromptPreviewModal;
}

// Add assertions specific to PublishedPromptPreviewModal here
}
67 changes: 6 additions & 61 deletions apps/chat-e2e/src/assertions/sharedPromptPreviewModalAssertion.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,25 @@
import { ElementState, ExpectedMessages } from '@/src/testData';
import { PromptPreviewModalAssertion } from '@/src/assertions/promptPreviewModalAssertion';
import { ExpectedMessages } from '@/src/testData';
import { Styles } from '@/src/ui/domData';
import { SharedPromptPreviewModal } from '@/src/ui/webElements';
import { expect } from '@playwright/test';

export class SharedPromptPreviewModalAssertion {
export class SharedPromptPreviewModalAssertion extends PromptPreviewModalAssertion {
readonly sharedPromptPreviewModal: SharedPromptPreviewModal;

constructor(sharedPromptPreviewModal: SharedPromptPreviewModal) {
super(sharedPromptPreviewModal);
this.sharedPromptPreviewModal = sharedPromptPreviewModal;
}

public async assertSharedPromptPreviewModalState(
expectedState: ElementState,
) {
const sharedPromptPreviewModal =
this.sharedPromptPreviewModal.getElementLocator();
expectedState === 'visible'
? await expect
.soft(sharedPromptPreviewModal, ExpectedMessages.modalWindowIsOpened)
.toBeVisible()
: await expect
.soft(sharedPromptPreviewModal, ExpectedMessages.modalWindowIsClosed)
.toBeHidden();
}

public async assertSharedPromptPreviewModalTitle(expectedValue: string) {
expect
.soft(
await this.sharedPromptPreviewModal.modalTitle.getElementInnerContent(),
ExpectedMessages.modalDialogTitleIsValid,
)
.toBe(expectedValue);
}

public async assertSharedPromptName(expectedValue: string) {
expect
.soft(
await this.sharedPromptPreviewModal.promptName.getElementInnerContent(),
ExpectedMessages.promptNameValid,
)
.toBe(expectedValue);
}

public async assertSharedPromptDescription(
expectedValue: string | undefined,
) {
expectedValue === '' || expectedValue === undefined
? await expect
.soft(
this.sharedPromptPreviewModal.promptDescription.getElementLocator(),
ExpectedMessages.promptDescriptionValid,
)
.toBeHidden()
: expect
.soft(
await this.sharedPromptPreviewModal.promptDescription.getElementInnerContent(),
ExpectedMessages.promptDescriptionValid,
)
.toBe(expectedValue);
}

public async assertSharedPromptContent(expectedValue: string) {
expect
.soft(
await this.sharedPromptPreviewModal.promptContent.getElementInnerContent(),
ExpectedMessages.promptContentValid,
)
.toBe(expectedValue);
}

public async assertExportButtonColors(expectedColor: string) {
const buttonColor =
await this.sharedPromptPreviewModal.promptExportButton.getComputedStyleProperty(
Styles.color,
);
const buttonBordersColor =
await this.sharedPromptPreviewModal.promptExportButton.getAllBorderColors();

expect
.soft(buttonColor[0], ExpectedMessages.elementColorIsValid)
.toBe(expectedColor);
Expand All @@ -95,6 +39,7 @@ export class SharedPromptPreviewModalAssertion {
);
const buttonBordersColor =
await this.sharedPromptPreviewModal.promptDeleteButton.getAllBorderColors();

expect
.soft(buttonColor[0], ExpectedMessages.elementColorIsValid)
.toBe(expectedColor);
Expand Down
54 changes: 53 additions & 1 deletion apps/chat-e2e/src/core/dialAdminFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@ import {
} from '@/src/assertions';
import { ConversationToApproveAssertion } from '@/src/assertions/conversationToApproveAssertion';
import { FolderAssertion } from '@/src/assertions/folderAssertion';
import { PromptToApproveAssertion } from '@/src/assertions/promptToApproveAssertion';
import { PublishedPromptPreviewModalAssertion } from '@/src/assertions/publishedPromptPreviewModalAssertion';
import { PublishingApprovalModalAssertion } from '@/src/assertions/publishingApprovalModalAssertion';
import { SideBarEntityAssertion } from '@/src/assertions/sideBarEntityAssertion';
import dialTest, { stateFilePath } from '@/src/core/dialFixtures';
import { LocalStorageManager } from '@/src/core/localStorageManager';
import { AppContainer } from '@/src/ui/webElements/appContainer';
import {
ApproveRequiredConversationsTree,
ApproveRequiredPrompts,
ConversationsToApproveTree,
ConversationsTree,
FolderConversationsToApprove,
FolderPrompts,
Folders,
OrganizationConversationsTree,
PromptsToApproveTree,
PromptsTree,
} from '@/src/ui/webElements/entityTree';
import { PublishedPromptPreviewModal } from '@/src/ui/webElements/publishedPromptPreviewModal';
import { Tooltip } from '@/src/ui/webElements/tooltip';
import { Page } from '@playwright/test';

Expand All @@ -50,13 +55,18 @@ const dialAdminTest = dialTest.extend<{
adminConversations: ConversationsTree;
adminPrompts: PromptsTree;
adminApproveRequiredConversations: ApproveRequiredConversationsTree;
adminApproveRequiredPrompts: ApproveRequiredPrompts;
adminOrganizationFolderConversations: Folders;
adminConversationsToApprove: ConversationsToApproveTree;
adminPromptsToApprove: PromptsToApproveTree;
adminPublishingApprovalModal: PublishingApprovalModal;
adminPublishedPromptPreviewModal: PublishedPromptPreviewModal;
adminApproveRequiredConversationsAssertion: FolderAssertion<ApproveRequiredConversationsTree>;
adminApproveRequiredPromptsAssertion: FolderAssertion<ApproveRequiredPrompts>;
adminOrganizationFolderConversationAssertions: FolderAssertion<Folders>;
adminPublishingApprovalModalAssertion: PublishingApprovalModalAssertion;
adminConversationToApproveAssertion: ConversationToApproveAssertion;
adminPromptToApproveAssertion: PromptToApproveAssertion;
adminFolderToApproveAssertion: PublishFolderAssertion<FolderConversationsToApprove>;
adminPublicationReviewControl: PublicationReviewControl;
adminChatHeader: ChatHeader;
Expand All @@ -71,7 +81,24 @@ const dialAdminTest = dialTest.extend<{
adminApproveRequiredConversationDropdownMenuAssertion: MenuAssertion;
adminTooltipAssertion: TooltipAssertion;
adminOrganizationConversationAssertion: SideBarEntityAssertion<OrganizationConversationsTree>;
adminPublishedPromptPreviewModalAssertion: PublishedPromptPreviewModalAssertion;
}>({
adminPublishedPromptPreviewModalAssertion: async (
{ adminPublishedPromptPreviewModal },
use,
) => {
const adminPublishedPromptPreviewModalAssertion =
new PublishedPromptPreviewModalAssertion(
adminPublishedPromptPreviewModal,
);
await use(adminPublishedPromptPreviewModalAssertion);
},
adminPublishedPromptPreviewModal: async ({ adminPage }, use) => {
const publishedPromptPreviewModal = new PublishedPromptPreviewModal(
adminPage,
);
await use(publishedPromptPreviewModal);
},
adminPage: async ({ browser }, use) => {
const context = await browser.newContext({
storageState: stateFilePath(+config.workers! * 3),
Expand Down Expand Up @@ -114,14 +141,20 @@ const dialAdminTest = dialTest.extend<{
await use(additionalShareUserPrompts);
},
adminFolderPrompts: async ({ adminPromptBar }, use) => {
const additionalShareUserFolderPrompts = adminPromptBar.getFolderPrompts();
const additionalShareUserFolderPrompts =
adminPromptBar.getPinnedFolderPrompts();
await use(additionalShareUserFolderPrompts);
},
adminApproveRequiredConversations: async ({ adminChatBar }, use) => {
const adminApproveRequiredConversations =
adminChatBar.getApproveRequiredConversationsTree();
await use(adminApproveRequiredConversations);
},
adminApproveRequiredPrompts: async ({ adminPromptBar }, use) => {
const adminApproveRequiredPrompts =
adminPromptBar.getApproveRequiredPrompts();
await use(adminApproveRequiredPrompts);
},
adminOrganizationFolderConversations: async ({ adminChatBar }, use) => {
const adminOrganizationFolderConversations =
adminChatBar.getOrganizationFolderConversations();
Expand All @@ -135,6 +168,11 @@ const dialAdminTest = dialTest.extend<{
adminPublishingApprovalModal.getConversationsToApproveTree();
await use(adminConversationsToApprove);
},
adminPromptsToApprove: async ({ adminPublishingApprovalModal }, use) => {
const adminPromptsToApprove =
adminPublishingApprovalModal.getPromptsToApproveTree();
await use(adminPromptsToApprove);
},
adminPublishingApprovalModal: async ({ adminPage }, use) => {
const adminPublishingApprovalModal = new PublishingApprovalModal(adminPage);
await use(adminPublishingApprovalModal);
Expand Down Expand Up @@ -197,6 +235,14 @@ const dialAdminTest = dialTest.extend<{
);
await use(adminApproveRequiredConversationsAssertion);
},
adminApproveRequiredPromptsAssertion: async (
{ adminApproveRequiredPrompts },
use,
) => {
const adminApproveRequiredPromptsAssertion =
new FolderAssertion<ApproveRequiredPrompts>(adminApproveRequiredPrompts);
await use(adminApproveRequiredPromptsAssertion);
},
adminOrganizationFolderConversationAssertions: async (
{ adminOrganizationFolderConversations },
use,
Expand All @@ -222,6 +268,12 @@ const dialAdminTest = dialTest.extend<{
new ConversationToApproveAssertion(adminConversationsToApprove);
await use(adminConversationToApproveAssertion);
},
adminPromptToApproveAssertion: async ({ adminPromptsToApprove }, use) => {
const adminPromptToApproveAssertion = new PromptToApproveAssertion(
adminPromptsToApprove,
);
await use(adminPromptToApproveAssertion);
},
adminFolderToApproveAssertion: async (
{ adminPublishingApprovalModal },
use,
Expand Down
Loading

0 comments on commit 71cd3fa

Please sign in to comment.