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: fixed conversation model #201

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ConversationBuilder {
id: uuidv4(),
name: DEFAULT_CONVERSATION_NAME,
messages: [],
model: ModelsUtil.getDefaultModel()!,
model: { id: ModelsUtil.getDefaultModel()!.id },
prompt: DEFAULT_SYSTEM_PROMPT,
temperature: DEFAULT_TEMPERATURE,
replay: defaultReplay,
Expand Down
7 changes: 4 additions & 3 deletions e2e/src/testData/conversationHistory/conversationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export class ConversationData extends FolderData {
}

public prepareDefaultConversation(model?: OpenAIEntityModel, name?: string) {
const modelToUse =
model ?? this.conversationBuilder.getConversation().model;
const modelToUse = model
? { id: model.id }
: this.conversationBuilder.getConversation().model;
const userMessage: Message = {
role: 'user',
content: 'test request',
Expand Down Expand Up @@ -155,7 +156,7 @@ export class ConversationData extends FolderData {
request?: string,
) {
const conversation = this.conversationBuilder.getConversation();
conversation.model = model;
conversation.model = { id: model.id };
conversation.selectedAddons = addons;
const userMessage: Message = {
role: 'user',
Expand Down
1 change: 1 addition & 0 deletions e2e/src/testData/expectedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export enum ExpectedMessages {
chatRequestTemperatureIsValid = 'Chat API request temperature is valid',
chatRequestAddonsAreValid = 'Chat API request addons are valid',
sendMessageButtonDisabled = 'Send message button is disabled',
sendMessageButtonEnabled = 'Send message button is enabled',
tooltipContentIsValid = 'Tooltip content is valid',
headerTitleCorrespondRequest = 'Chat header title correspond sent request',
headerIconsCountIsValid = 'Chat header icons number is valid',
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/tests/chatHeader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test(
const modelInfo = await chatInfoTooltip.getModelInfo();
expect
.soft(modelInfo, ExpectedMessages.chatInfoModelIsValid)
.toBe(conversation.model.name);
.toBe(ModelsUtil.getModel(conversation.model.id)!.name);

const modelInfoIcon = await chatInfoTooltip.getModelIcon();
expect
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/tests/promptExportImport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ test('Import a prompt in nested folder', async ({
}
});

await test.step('Update id and name of exported зкщьзеы and import them again', async () => {
await test.step('Update id and name of exported prompts and import them again', async () => {
for (const exportedData of exportedPrompts) {
const exportedContent = FileUtil.readFileData(exportedData.path);
const prompt = exportedContent.prompts[0];
Expand Down
57 changes: 28 additions & 29 deletions e2e/src/tests/replay.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ChatBody, Conversation } from '@/src/types/chat';
import { FolderInterface } from '@/src/types/folder';
import { OpenAIEntityModel } from '@/src/types/openai';

import test from '@/e2e/src/core/fixtures';
import {
ExpectedConstants,
ExpectedMessages,
FolderConversation,
MenuOptions,
ModelIds,
} from '@/e2e/src/testData';
Expand Down Expand Up @@ -155,42 +155,41 @@ test('[Replay]chat is created in the same folder where its parent is located', a
conversationDropdownMenu,
}) => {
setTestIds('EPMRTC-503');
let conversationInFolder: FolderConversation;

await test.step('Prepare conversation inside folder', async () => {
conversationInFolder =
conversationData.prepareDefaultConversationInFolder();
await localStorageManager.setFolders(conversationInFolder.folders);
await localStorageManager.setConversationHistory(
conversationInFolder.conversations[0],
);
let nestedFolders: FolderInterface[];
let nestedConversations: Conversation[] = [];
const nestedLevels = 3;

await test.step('Prepare 3 levels folders hierarchy with chats inside', async () => {
nestedFolders = conversationData.prepareNestedFolder(nestedLevels);
nestedConversations =
conversationData.prepareConversationsForNestedFolders(nestedFolders);
await localStorageManager.setFolders(...nestedFolders);
await localStorageManager.setOpenedFolders(...nestedFolders);
await localStorageManager.setConversationHistory(...nestedConversations);
});

await test.step('Open Replay drop-down menu for conversation inside folder', async () => {
await test.step('Select Replay from drop-down menu for conversations inside 1st and 3rd level folders', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
await folderConversations.expandCollapseFolder(
conversationInFolder!.folders.name,
);

await folderConversations.openFolderConversationDropdownMenu(
conversationInFolder!.folders.name,
conversationInFolder!.conversations[0].name,
);
await conversationDropdownMenu.selectMenuOption(MenuOptions.replay);
for (let i = 0; i < nestedLevels; i = i + 2) {
await folderConversations.openFolderConversationDropdownMenu(
nestedFolders[i + 1].name,
nestedConversations[i + 1].name,
);
await conversationDropdownMenu.selectMenuOption(MenuOptions.replay);
}
});

await test.step('Verify new Replay conversation is created inside folder', async () => {
const isConversationVisible =
await folderConversations.isFolderConversationVisible(
conversationInFolder!.folders.name,
await test.step('Verify new Replay conversations are created inside 1st and 3rd level folders', async () => {
for (let i = 0; i < nestedLevels; i = i + 2) {
await folderConversations.getFolderConversation(
nestedFolders[i + 1].name,
`${ExpectedConstants.replayConversation}${
conversationInFolder!.conversations[0].name
nestedConversations[i + 1].name
}`,
);
expect
.soft(isConversationVisible, ExpectedMessages.conversationMovedToFolder)
.toBeTruthy();
).waitFor;
}
});
});

Expand Down Expand Up @@ -479,7 +478,7 @@ test(
const modelInfo = await chatInfoTooltip.getModelInfo();
expect
.soft(modelInfo, ExpectedMessages.chatInfoModelIsValid)
.toBe(conversation.model.name);
.toBe(ModelsUtil.getModel(conversation.model.id)!.name);

const modelInfoIcon = await chatInfoTooltip.getModelIcon();
expect
Expand Down
31 changes: 29 additions & 2 deletions e2e/src/tests/workWithModels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
ExpectedMessages,
ModelIds,
} from '@/e2e/src/testData';
import { ModelsUtil } from '@/e2e/src/utils';
import { GeneratorUtil, ModelsUtil } from '@/e2e/src/utils';
import { expect } from '@playwright/test';

const userRequests = ['first request', 'second request', 'third request'];
const requestTerm = 'qwer';
const request = 'write down 30 adjectives';
const expectedResponse = 'The sky is blue.';
const sysPrompt = `Type: "${expectedResponse}" if user types ${requestTerm}`;
let gpt35Model: OpenAIEntityModel;
Expand Down Expand Up @@ -264,7 +265,6 @@ test('Stop generating for models like GPT (1 symbol = 1 token)', async ({
chatMessages,
}) => {
setTestIds('EPMRTC-478');
const request = 'write down 30 adjectives';
await test.step('Send request and stop generation immediately', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
Expand Down Expand Up @@ -322,3 +322,30 @@ test('Stop generating for models like GPT (1 symbol = 1 token)', async ({
.toBeTruthy();
});
});

test('Send button in new message is available for Model if previous response is partly received when Stop generating was used', async ({
dialHomePage,
chat,
setTestIds,
chatMessages,
sendMessage,
}) => {
setTestIds('EPMRTC-1533');
await test.step('Send request and stop generation immediately', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
await chat.sendRequestWithButton(request, false);
await chatMessages.waitForPartialMessageReceived(2);
await chat.stopGenerating.click();
await chat.stopGenerating.waitForState({ state: 'hidden' });
});

await test.step('Type a new message and verify Send button is enabled', async () => {
await sendMessage.messageInput.fillInInput(GeneratorUtil.randomString(10));
const isSendButtonEnabled =
await sendMessage.sendMessageButton.isElementEnabled();
expect
.soft(isSendButtonEnabled, ExpectedMessages.sendMessageButtonEnabled)
.toBeTruthy();
});
});
Loading