Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: added tests for Stop button behaviour #311

Merged
merged 16 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d98575f
e2e/medium_priority_compare_tests: added tests for compare feature
irinakartun Dec 4, 2023
bfb097a
e2e/medium_priority_compare_tests: fixed like/dislike element visibil…
irinakartun Dec 4, 2023
829881e
Merge branch 'development' of github.com:epam/ai-dial-chat into e2e/m…
irinakartun Dec 4, 2023
fa6ed2d
Merge branch 'development' into e2e/medium_priority_compare_tests
IlyaBondar Dec 6, 2023
47eb699
Merge branch 'development' into e2e/medium_priority_compare_tests
irinakartun Dec 7, 2023
ffe0896
e2e/medium_priority_compare_tests: added index for chat message locator
irinakartun Dec 7, 2023
685c681
e2e/long_names_truncate_sidebar_search_tests: added tests to verify l…
irinakartun Dec 7, 2023
f5ab47c
Merge branch 'development' of github.com:epam/ai-dial-chat into e2e/l…
irinakartun Dec 11, 2023
d92bc11
e2e/errors_on_stop_button_tests: added tests for Stop button behaviour
irinakartun Dec 11, 2023
0298500
Merge branch 'development' of github.com:epam/ai-dial-chat into e2e/e…
irinakartun Dec 12, 2023
2871f1a
e2e/errors_on_stop_button_tests: updated test for collapse/expand fol…
irinakartun Dec 12, 2023
7af7df5
Merge branch 'development' of github.com:epam/ai-dial-chat into e2e/e…
irinakartun Dec 18, 2023
a49ccbb
Merge branch 'development' into e2e/errors_on_stop_button_tests
irinakartun Dec 18, 2023
11d76d8
Merge branch 'development' into e2e/errors_on_stop_button_tests
irinakartun Dec 20, 2023
5007d85
Merge branch 'development' into e2e/errors_on_stop_button_tests
irinakartun Dec 20, 2023
7c85556
Merge branch 'development' into e2e/errors_on_stop_button_tests
mikitabut Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions e2e/src/core/localStorageManager .ts

This file was deleted.

2 changes: 2 additions & 0 deletions e2e/src/testData/expectedConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const ExpectedConstants = {
'This mode replicates user requests from the original conversation including settings set in each message.',
replayOldVersionWarning:
'Please note that some of your messages were created in older DIAL version. "Replay as is" could be working not as expected.',
regenerateResponseTooltip:
'Please regenerate response to continue working with chat',
};

export enum Groups {
Expand Down
3 changes: 3 additions & 0 deletions e2e/src/testData/expectedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export enum ExpectedMessages {
newFolderCreated = 'New folder is created',
folderCollapsed = 'Folder is collapsed',
folderExpanded = 'Folder is expanded',
folderCaretIsVisible = 'Folder caret is visible',
folderCaretIsNotVisible = 'Folder caret is not visible',
folderNameUpdated = 'Folder name is updated',
folderNameNotUpdated = 'Folder name is not updated',
folderDeleted = 'Folder is deleted',
Expand Down Expand Up @@ -174,4 +176,5 @@ export enum ExpectedMessages {
entityNameIsTruncated = 'Entity name is truncated',
folderNameIsTruncated = 'Folder name is truncated in side panel',
chatNameIsTruncated = 'Chat name is truncated in side panel',
sendButtonCursorIsNotAllowed = 'Send button cursor is not allowed',
}
130 changes: 94 additions & 36 deletions e2e/src/tests/chatBarFolderConversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import test from '@/e2e/src/core/fixtures';
import {
ExpectedConstants,
ExpectedMessages,
FolderConversation,
MenuOptions,
} from '@/e2e/src/testData';
import { Overflow, Styles } from '@/e2e/src/ui/domData';
import { Attributes, Overflow, Styles } from '@/e2e/src/ui/domData';
import { GeneratorUtil } from '@/e2e/src/utils';
import { expect } from '@playwright/test';

Expand Down Expand Up @@ -185,43 +186,100 @@ test(
},
);

test('Folders can expand and collapse', async ({
dialHomePage,
conversationData,
folderConversations,
localStorageManager,
setTestIds,
}) => {
setTestIds('EPMRTC-579');
const conversationInFolder =
conversationData.prepareDefaultConversationInFolder();
await localStorageManager.setFolders(conversationInFolder.folders);
await localStorageManager.setConversationHistory(
conversationInFolder.conversations[0],
);
const folderName = conversationInFolder.folders.name;
test(
'Folders can expand and collapse.\n' +
'Expanded and collapsed chat folders are stored locally.\n' +
'[UI] Expand/collapse icon near chat folder appears if there is any chat inside',
async ({
dialHomePage,
conversationData,
folderConversations,
localStorageManager,
setTestIds,
}) => {
setTestIds('EPMRTC-579', 'EPMRTC-1315', 'EPMRTC-1365');
let firstConversationInFolder: FolderConversation;
let secondConversationInFolder: FolderConversation;
let emptyFolder: FolderInterface;

await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded();
await folderConversations.expandCollapseFolder(folderName);
let isConversationVisible =
await folderConversations.isFolderConversationVisible(
folderName,
conversationInFolder.conversations[0].name,
);
expect
.soft(isConversationVisible, ExpectedMessages.folderExpanded)
.toBeTruthy();
await test.step('Prepare 2 conversations inside folders and one empty folder', async () => {
firstConversationInFolder =
conversationData.prepareFolderWithConversations(1);
conversationData.resetData();
secondConversationInFolder =
conversationData.prepareFolderWithConversations(1);
conversationData.resetData();
emptyFolder = conversationData.prepareFolder();
await localStorageManager.setFolders(
firstConversationInFolder.folders,
secondConversationInFolder.folders,
emptyFolder,
);
await localStorageManager.setConversationHistory(
firstConversationInFolder.conversations[0],
secondConversationInFolder.conversations[0],
);
});
await test.step('Hover over folder with conversation and verify it has blue arrow', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded();
await folderConversations
.getFolderByName(firstConversationInFolder.folders.name)
.hover();
const firstFolderCaret = await folderConversations.getFolderCaret(
firstConversationInFolder.folders.name,
);
expect
.soft(firstFolderCaret, ExpectedMessages.folderCaretIsVisible)
.toBe(Attributes.visible);

await folderConversations.expandCollapseFolder(folderName);
isConversationVisible = await folderConversations.isFolderConversationVisible(
folderName,
conversationInFolder.conversations[0].name,
);
expect
.soft(isConversationVisible, ExpectedMessages.folderCollapsed)
.toBeFalsy();
});
await folderConversations.getFolderByName(emptyFolder.name).hover();
const emptyFolderCaret = await folderConversations.getFolderCaret(
emptyFolder.name,
);
expect
.soft(emptyFolderCaret, ExpectedMessages.folderCaretIsNotVisible)
.toBe(Attributes.invisible);
});

await test.step('Expand one folder, collapse another and verify state is saved after browser refresh', async () => {
await folderConversations.expandCollapseFolder(
firstConversationInFolder.folders.name,
);
for (let i = 1; i <= 2; i++) {
await folderConversations.expandCollapseFolder(
secondConversationInFolder.folders.name,
);
}

let i = 2;
while (i > 0) {
if (i === 1) {
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
}
const isFirstConversationVisible =
await folderConversations.isFolderConversationVisible(
firstConversationInFolder.folders.name,
firstConversationInFolder.conversations[0].name,
);
expect
.soft(isFirstConversationVisible, ExpectedMessages.folderExpanded)
.toBeTruthy();

const isSecondConversationVisible =
await folderConversations.isFolderConversationVisible(
secondConversationInFolder.folders.name,
secondConversationInFolder.conversations[0].name,
);
expect
.soft(isSecondConversationVisible, ExpectedMessages.folderCollapsed)
.toBeFalsy();
i--;
}
});
},
);

test(
'Delete folder. Cancel.\n' + 'Delete root folder with nested folders',
Expand Down
122 changes: 88 additions & 34 deletions e2e/src/tests/defaultModelSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { OpenAIEntityModel } from '@/src/types/openai';

import test from '../core/fixtures';
import { ExpectedConstants, ExpectedMessages, ModelIds } from '../testData';
import { Colors } from '../ui/domData';
import { Colors, Cursors, Styles } from '../ui/domData';

import { keys } from '@/e2e/src/ui/keyboard';
import { GeneratorUtil, ModelsUtil } from '@/e2e/src/utils';
import { expect } from '@playwright/test';

Expand Down Expand Up @@ -174,7 +175,8 @@ test(
test(
'Default model in new chat is set as in previous chat.\n' +
'Send button is disabled if the message box is empty.\n' +
'Chat name is shown in chat header',
'Chat name is shown in chat header.\n' +
`It's impossible to send a message with spaces only`,
async ({
dialHomePage,
chatBar,
Expand All @@ -184,48 +186,100 @@ test(
sendMessage,
chatHeader,
tooltip,
chatMessages,
page,
setTestIds,
}) => {
setTestIds('EPMRTC-400', 'EPMRTC-474', 'EPMRTC-817');
setTestIds('EPMRTC-400', 'EPMRTC-474', 'EPMRTC-817', 'EPMRTC-1568');
const request = 'test';
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
await talkToSelector.selectModel(bison.name);
await test.step('Verify Send button is disabled if no request message set and tooltip is shown on button hover', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
await talkToSelector.selectModel(bison.name);

const isSendMessageBtnEnabled =
await sendMessage.sendMessageButton.isElementEnabled();
expect
.soft(isSendMessageBtnEnabled, ExpectedMessages.sendMessageButtonDisabled)
.toBeFalsy();
const isSendMessageBtnEnabled =
await sendMessage.sendMessageButton.isElementEnabled();
expect
.soft(
isSendMessageBtnEnabled,
ExpectedMessages.sendMessageButtonDisabled,
)
.toBeFalsy();

await sendMessage.sendMessageButton.hoverOver();
const tooltipContent = await tooltip.getContent();
expect
.soft(tooltipContent, ExpectedMessages.tooltipContentIsValid)
.toBe(ExpectedConstants.sendMessageTooltip);
await sendMessage.sendMessageButton.hoverOver();
const tooltipContent = await tooltip.getContent();
expect
.soft(tooltipContent, ExpectedMessages.tooltipContentIsValid)
.toBe(ExpectedConstants.sendMessageTooltip);
});

await chat.sendRequestWithButton(request);
const chatTitle = await chatHeader.chatTitle.getElementInnerContent();
expect
.soft(chatTitle, ExpectedMessages.headerTitleCorrespondRequest)
.toBe(request);
await test.step('Set spaces in the message input and Send button is disabled, tooltip is shown on hover, no message send on hit Enter', async () => {
for (let i = 1; i <= 2; i++) {
if (i === 2) {
const messagesCountBefore =
await chatMessages.chatMessages.getElementsCount();
await sendMessage.messageInput.fillInInput(' ');
await page.keyboard.press(keys.enter);
const messagesCountAfter =
await chatMessages.chatMessages.getElementsCount();
expect
.soft(
messagesCountBefore === messagesCountAfter,
ExpectedMessages.messageCountIsCorrect,
)
.toBeTruthy();
}
const isSendMessageBtnEnabled =
await sendMessage.sendMessageButton.isElementEnabled();
expect
.soft(
isSendMessageBtnEnabled,
ExpectedMessages.sendMessageButtonDisabled,
)
.toBeFalsy();

await chatBar.createNewConversation();
const modelBorderColors = await recentEntities
.getRecentEntity(bison.name)
.getAllBorderColors();
Object.values(modelBorderColors).forEach((borders) => {
borders.forEach((borderColor) => {
await sendMessage.sendMessageButton.hoverOver();
const sendBtnCursor =
await sendMessage.sendMessageButton.getComputedStyleProperty(
Styles.cursor,
);
expect
.soft(borderColor, ExpectedMessages.talkToEntityIsSelected)
.toBe(Colors.highlightedEntity);
});
.soft(sendBtnCursor[0], ExpectedMessages.sendButtonCursorIsNotAllowed)
.toBe(Cursors.notAllowed);

const tooltipContent = await tooltip.getContent();
expect
.soft(tooltipContent, ExpectedMessages.tooltipContentIsValid)
.toBe(ExpectedConstants.sendMessageTooltip);
}
});

const recentTalkTo = await recentEntities.getRecentEntityNames();
expect
.soft(recentTalkTo[0], ExpectedMessages.recentEntitiesIsOnTop)
.toBe(bison.name);
await test.step('Send new request and verify it is reflected in chat header', async () => {
await chat.sendRequestWithButton(request);
const chatTitle = await chatHeader.chatTitle.getElementInnerContent();
expect
.soft(chatTitle, ExpectedMessages.headerTitleCorrespondRequest)
.toBe(request);
});

await test.step('Create new conversation and verify previous model is preselected and highlighted', async () => {
await chatBar.createNewConversation();
const modelBorderColors = await recentEntities
.getRecentEntity(bison.name)
.getAllBorderColors();
Object.values(modelBorderColors).forEach((borders) => {
borders.forEach((borderColor) => {
expect
.soft(borderColor, ExpectedMessages.talkToEntityIsSelected)
.toBe(Colors.highlightedEntity);
});
});

const recentTalkTo = await recentEntities.getRecentEntityNames();
expect
.soft(recentTalkTo[0], ExpectedMessages.recentEntitiesIsOnTop)
.toBe(bison.name);
});
},
);

Expand Down
Loading
Loading