Skip to content

Commit

Permalink
Merge branch 'fix/2297-overlay-setting-model-id' of https://github.co…
Browse files Browse the repository at this point in the history
…m/epam/ai-dial-chat into fix/2297-overlay-setting-model-id
  • Loading branch information
denys-kolomiitsev committed Nov 14, 2024
2 parents f15c054 + 6258f96 commit 6827da1
Show file tree
Hide file tree
Showing 40 changed files with 1,036 additions and 490 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/cleanup-untagged-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Cleanup untagged images

on:
schedule:
- cron: "0 0 * * *"

jobs:
clean:
name: Delete untagged images
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: snok/container-retention-policy@4f22ef80902ad409ed55a99dc5133cc1250a0d03 # v3.0.0
with:
account: ${{ github.repository_owner }}
token: ${{ secrets.GITHUB_TOKEN }}
image-names: ${{ github.event.repository.name }}
tag-selection: "untagged"
cut-off: "1d"
7 changes: 4 additions & 3 deletions apps/chat-e2e/src/assertions/api/shareApiAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ export class ShareApiAssertion {
sharedEntities: {
resources: BackendChatEntity[];
},
entity: ShareEntity,
entity: ShareEntity | string,
expectedState: ElementState,
) {
entity = typeof entity === 'string' ? entity : entity.id;
expectedState === 'visible'
? expect
.soft(
sharedEntities.resources.find((e) => e.url === entity.id),
sharedEntities.resources.find((e) => e.url === entity),
ExpectedMessages.entityIsShared,
)
.toBeDefined()
: expect
.soft(
sharedEntities.resources.find((e) => e.url === entity.id),
sharedEntities.resources.find((e) => e.url === entity),
ExpectedMessages.entityIsNotShared,
)
.toBeUndefined();
Expand Down
10 changes: 6 additions & 4 deletions apps/chat-e2e/src/assertions/baseAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ export class BaseAssertion {

public async assertEntityIcon(
iconLocator: Locator,
expectedIconSource: string,
expectedIconSource?: string,
) {
const actualIconSource = await iconLocator
.getAttribute(Attributes.src)
.then((s) => IconApiHelper.getNonCachedIconSource(s));
//assert icon source is valid
expect
.soft(actualIconSource, ExpectedMessages.entityIconIsValid)
.toBe(expectedIconSource);
if (expectedIconSource) {
expect
.soft(actualIconSource, ExpectedMessages.entityIconIsValid)
.toBe(expectedIconSource);
}
//assert icon is loaded and displayed
await expect(iconLocator).toHaveJSProperty('complete', true);
await expect(iconLocator).not.toHaveJSProperty('naturalWidth', 0);
Expand Down
11 changes: 11 additions & 0 deletions apps/chat-e2e/src/assertions/chatAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ export class ChatAssertion {
)
.toBe(ExpectedConstants.notAllowedModelError);
}

public async assertDuplicateButtonState(expectedState: ElementState) {
const duplicateButton = this.chat.duplicate.getElementLocator();
expectedState === 'visible'
? await expect
.soft(duplicateButton, ExpectedMessages.buttonIsVisible)
.toBeVisible()
: await expect
.soft(duplicateButton, ExpectedMessages.buttonIsNotVisible)
.toBeHidden();
}
}
17 changes: 17 additions & 0 deletions apps/chat-e2e/src/assertions/chatMessagesAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ export class ChatMessagesAssertion extends BaseAssertion {
.toBeHidden();
}

public async assertSetMessageTemplateIconState(
message: string | number,
expectedState: ElementState,
) {
const chatMessage = this.chatMessages.getChatMessage(message);
await chatMessage.scrollIntoViewIfNeeded();
await chatMessage.hover();
const editIcon = this.chatMessages.setMessageTemplateIcon(chatMessage);
expectedState === 'visible'
? await expect
.soft(editIcon, ExpectedMessages.buttonIsVisible)
.toBeVisible()
: await expect
.soft(editIcon, ExpectedMessages.buttonIsNotVisible)
.toBeHidden();
}

public async assertMessageDeleteIconState(
message: string | number,
expectedState: ElementState,
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/assertions/entityTreeAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class EntityTreeAssertion<T extends EntitiesTree> extends BaseAssertion {
entity: TreeEntity,
expectedState: ElementState,
) {
const entityLocator = this.treeEntities.getEntityByName(
const entityLocator = this.treeEntities.getEntityByExactName(
entity.name,
entity.index,
);
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/assertions/recentEntitiesAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class RecentEntitiesAssertion extends BaseAssertion {
.toBeVisible()
: await expect
.soft(playbackButton, ExpectedMessages.playbackIconIsHidden)
.toBeVisible();
.toBeHidden();
}

public async assertReplayAsIsBordersColor(expectedColor: string) {
Expand Down
12 changes: 12 additions & 0 deletions apps/chat-e2e/src/assertions/sendMessageAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,16 @@ export class SendMessageAssertion {
.soft(continueReplayButton, ExpectedMessages.buttonIsNotVisible)
.toBeHidden();
}

public async assertScrollDownButtonState(expectedState: ElementState) {
const scrollDownButton =
this.sendMessage.scrollDownButton.getElementLocator();
expectedState === 'visible'
? await expect
.soft(scrollDownButton, ExpectedMessages.scrollDownButtonIsVisible)
.toBeVisible()
: await expect
.soft(scrollDownButton, ExpectedMessages.scrollDownButtonIsNotVisible)
.toBeHidden();
}
}
26 changes: 25 additions & 1 deletion apps/chat-e2e/src/core/dialSharedWithMeFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import {
} from '../ui/webElements';

import config from '@/config/chat.playwright.config';
import { ErrorToastAssertion } from '@/src/assertions';
import {
ChatAssertion,
ConversationAssertion,
ErrorToastAssertion,
} from '@/src/assertions';
import { ConfirmationDialogAssertion } from '@/src/assertions/confirmationDialogAssertion';
import { EntitySettingAssertion } from '@/src/assertions/entitySettingAssertion';
import { FolderAssertion } from '@/src/assertions/folderAssertion';
Expand Down Expand Up @@ -116,6 +120,8 @@ const dialSharedWithMeTest = dialTest.extend<{
additionalShareUserEntitySettingAssertion: EntitySettingAssertion;
additionalShareUserAttachFilesModal: AttachFilesModal;
additionalShareUserErrorToastAssertion: ErrorToastAssertion;
additionalShareUserChatAssertion: ChatAssertion;
additionalShareUserConversationAssertion: ConversationAssertion;
}>({
additionalShareUserErrorToastAssertion: async (
{ additionalShareUserErrorToast },
Expand Down Expand Up @@ -585,6 +591,24 @@ const dialSharedWithMeTest = dialTest.extend<{
new EntitySettingAssertion(additionalShareUserEntitySettings);
await use(additionalShareUserEntitySettingAssertion);
},
additionalShareUserChatAssertion: async (
{ additionalShareUserChat },
use,
) => {
const additionalShareUserChatAssertion = new ChatAssertion(
additionalShareUserChat,
);
await use(additionalShareUserChatAssertion);
},
additionalShareUserConversationAssertion: async (
{ additionalShareUserConversations },
use,
) => {
const additionalShareUserConversationAssertion = new ConversationAssertion(
additionalShareUserConversations,
);
await use(additionalShareUserConversationAssertion);
},
});

export let shareUserBucket: string;
Expand Down
1 change: 1 addition & 0 deletions apps/chat-e2e/src/testData/expectedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export enum ExpectedMessages {
folderIsShared = 'Folder is shared',
promptIsNotShared = 'Prompt is not shared',
fileIsNotShared = 'File is not shared',
fileIsShared = 'File is shared',
modalWindowIsClosed = 'Modal window is closed',
modalWindowIsOpened = 'Modal window is opened',
entityNameIsFullyVisible = 'Entity name is fully visible on tooltip',
Expand Down
12 changes: 10 additions & 2 deletions apps/chat-e2e/src/tests/abortedReplay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ dialTest(
);

await dialTest.step(
'Verify no "Edit", "Delete" icons are available for partial request, no "Clear" button displayed in the header, "Continue replay" button is available',
'Verify no "Edit", "Delete", "Set message template" icons are available for partial request, no "Clear" button displayed in the header, "Continue replay" button is available',
async () => {
await chatMessagesAssertion.assertMessageEditIconState(3, 'hidden');
await chatMessagesAssertion.assertMessageDeleteIconState(3, 'hidden');
await chatMessagesAssertion.assertSetMessageTemplateIconState(
3,
'hidden',
);
await chatHeaderAssertion.assertClearButtonState('hidden');
await sendMessageAssertion.assertContinueReplayButtonState('visible');
},
Expand Down Expand Up @@ -228,7 +232,7 @@ dialTest(
);

await dialTest.step(
'Verify "Edit", "Delete" icons are available for all request, "Clear" button displayed in the header, "Continue replay" button is not available',
'Verify "Edit", "Delete", "Set message template" icons are available for all the requests, "Clear" button displayed in the header, "Continue replay" button is not available',
async () => {
for (const request of historyConversation.messages.filter(
(m) => m.role === 'user',
Expand All @@ -237,6 +241,10 @@ dialTest(
request.content,
'visible',
);
await chatMessagesAssertion.assertSetMessageTemplateIconState(
request.content,
'visible',
);
await chatMessagesAssertion.assertMessageDeleteIconState(
request.content,
'visible',
Expand Down
29 changes: 14 additions & 15 deletions apps/chat-e2e/src/tests/chatBarFolderConversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,33 @@ import { expect } from '@playwright/test';

dialTest(
'Create new chat folder.\n' +
'Share option is unavailable in chat folder if there is no any chat inside',
'Share option is unavailable in chat folder if there is no any chat inside.\n' +
'Publish folder: folder should not be empty',
async ({
dialHomePage,
chatBar,
folderConversations,
folderDropdownMenu,
chatBarFolderAssertion,
folderDropdownMenuAssertion,
setTestIds,
}) => {
setTestIds('EPMRTC-569', 'EPMRTC-2005');
setTestIds('EPMRTC-569', 'EPMRTC-2005', 'EPMRTC-4157');
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
await chatBar.createNewFolder();
await expect
.soft(
folderConversations.getFolderByName(
ExpectedConstants.newFolderWithIndexTitle(1),
),
ExpectedMessages.newFolderCreated,
)
.toBeVisible();
await chatBarFolderAssertion.assertFolderState(
{ name: ExpectedConstants.newFolderWithIndexTitle(1) },
'visible',
);

await folderConversations.openFolderDropdownMenu(
ExpectedConstants.newFolderWithIndexTitle(1),
);
const actualMenuOptions = await folderDropdownMenu.getAllMenuOptions();
expect
.soft(actualMenuOptions, ExpectedMessages.contextMenuOptionsValid)
.toEqual([MenuOptions.select, MenuOptions.rename, MenuOptions.delete]);
await folderDropdownMenuAssertion.assertMenuOptions([
MenuOptions.select,
MenuOptions.rename,
MenuOptions.delete,
]);
},
);

Expand Down
39 changes: 30 additions & 9 deletions apps/chat-e2e/src/tests/compareMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,19 @@ dialTest.beforeAll(async () => {

dialTest(
'Compare mode button creates two new chats and opens them in compare mode',
async ({ dialHomePage, setTestIds, chatBar, conversations, compare }) => {
async ({
dialHomePage,
setTestIds,
chatBar,
compare,
chat,
conversationAssertion,
}) => {
setTestIds('EPMRTC-537');
await dialTest.step(
'Click on compare button on bottom of chat bar and verify compare mode is opened for new two chats',
async () => {
const request = 'test';
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({
isNewConversationVisible: true,
Expand All @@ -48,15 +56,18 @@ dialTest(
const chatsCount = await compare.getConversationsCount();
expect.soft(chatsCount, ExpectedMessages.compareModeOpened).toBe(2);

const todayConversations = await conversations.getTodayConversations();
expect
.soft(todayConversations.length, ExpectedMessages.conversationOfToday)
.toBe(3);
await dialHomePage.mockChatTextResponse(
MockedChatApiResponseBodies.simpleTextBody,
);
await chat.sendRequestWithButton(request);

todayConversations.forEach((value) =>
expect
.soft(value, ExpectedMessages.conversationOfToday)
.toContain(ExpectedConstants.newConversationTitle),
await conversationAssertion.assertEntityState(
{ name: request },
'visible',
);
await conversationAssertion.assertEntityState(
{ name: `${request} 1` },
'visible',
);
},
);
Expand Down Expand Up @@ -478,6 +489,7 @@ dialTest(
conversations,
conversationDropdownMenu,
compareConversation,
conversationAssertion,
}) => {
setTestIds('EPMRTC-552', 'EPMRTC-558');

Expand Down Expand Up @@ -585,6 +597,15 @@ dialTest(
ExpectedMessages.requestTempIsValid,
)
.toBe(secondTemp);

await conversationAssertion.assertEntityState(
{ name: firstConversation.name },
'visible',
);
await conversationAssertion.assertEntityState(
{ name: secondConversation.name },
'visible',
);
},
);

Expand Down
Loading

0 comments on commit 6827da1

Please sign in to comment.