Skip to content

Commit

Permalink
Merge branch 'development' into fix/2598-refactor-init-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gimir authored Nov 18, 2024
2 parents dfe173a + 4e1a6e0 commit 609ad97
Show file tree
Hide file tree
Showing 13 changed files with 666 additions and 1 deletion.
25 changes: 25 additions & 0 deletions apps/chat-e2e/config/monitoring.playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import config from './chat.playwright.config';

import { devices } from '@playwright/test';

/**
* See https://playwright.dev/docs/test-configuration.
*/
config.projects = [
{
name: 'auth',
fullyParallel: true,
testMatch: /desktopAuth\.ts/,
},
{
name: 'monitoring',
testMatch: /\/monitoring\/.*\.test\.ts/,
use: {
...devices['Desktop Chrome'],
viewport: { width: 1536, height: 864 },
},
dependencies: ['auth'],
},
];

export default config;
11 changes: 11 additions & 0 deletions apps/chat-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
}
}
},
"e2e:monitoring": {
"cache": false,
"executor": "@nx/playwright:playwright",
"outputs": ["{workspaceRoot}/dist/.playwright/monitoring-e2e"],
"defaultConfiguration": "development",
"configurations": {
"development": {
"config": "apps/chat-e2e/config/monitoring.playwright.config.ts"
}
}
},
"e2e": {
"cache": false,
"defaultConfiguration": "development",
Expand Down
4 changes: 3 additions & 1 deletion apps/chat-e2e/src/tests/desktopAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const usernames = process.env
.E2E_USERNAME!.split(',')
.slice(0, +config.workers! + 2);
//admin user to test publishing feature is required
usernames.push(process.env.E2E_ADMIN!);
if (process.env.E2E_ADMIN) {
usernames.push(process.env.E2E_ADMIN);
}

for (let i = 0; i < usernames.length; i++) {
test(`Authenticate user: ${usernames[i]}`, async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Conversation } from '@/chat/types/chat';
import dialTest from '@/src/core/dialFixtures';
import { MenuOptions } from '@/src/testData';
import { UploadDownloadData } from '@/src/ui/pages';

dialTest(
'Export and import a conversation',
async ({
dialHomePage,
conversations,
conversationData,
dataInjector,
chatBar,
conversationDropdownMenu,
confirmationDialog,
conversationAssertion,
}) => {
let exportedData: UploadDownloadData;
let conversationOutsideFolder: Conversation;

await dialTest.step('Prepare conversation', async () => {
conversationOutsideFolder = conversationData.prepareDefaultConversation();
await dataInjector.createConversations([conversationOutsideFolder]);
});

await dialTest.step(
'Export conversation using chat bar conversation menu',
async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded();
await conversations.selectConversation(conversationOutsideFolder.name);
await conversations.openEntityDropdownMenu(
conversationOutsideFolder.name,
);
await conversationDropdownMenu.selectMenuOption(MenuOptions.export);
exportedData = await dialHomePage.downloadData(() =>
conversationDropdownMenu.selectMenuOption(
MenuOptions.withoutAttachments,
),
);
},
);

await dialTest.step(
'Delete conversation, re-import it again and verify it displayed',
async () => {
await conversations.openEntityDropdownMenu(
conversationOutsideFolder.name,
);
await conversationDropdownMenu.selectMenuOption(MenuOptions.delete);
await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' });

await dialHomePage.importFile(exportedData, () =>
chatBar.importButton.click(),
);
await conversationAssertion.assertEntityState(
{ name: conversationOutsideFolder.name },
'visible',
);
},
);
},
);
124 changes: 124 additions & 0 deletions apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { DialAIEntityModel } from '@/chat/types/models';
import dialTest from '@/src/core/dialFixtures';
import {
ExpectedConstants,
ExpectedMessages,
MockedChatApiResponseBodies,
} from '@/src/testData';
import { ModelsUtil } from '@/src/utils';
import { expect } from '@playwright/test';

let defaultModel: DialAIEntityModel;
let recentModelIds: string[];
let recentAddonIds: string[];
let allEntities: DialAIEntityModel[];

dialTest.beforeAll(async () => {
defaultModel = ModelsUtil.getDefaultModel()!;
recentModelIds = ModelsUtil.getRecentModelIds();
allEntities = ModelsUtil.getOpenAIEntities();
recentAddonIds = ModelsUtil.getRecentAddonIds();
});

dialTest(
'Create new conversation and send new message',
async ({
dialHomePage,
chatBar,
conversations,
talkToEntities,
entitySettings,
temperatureSlider,
chat,
chatMessages,
addons,
}) => {
const expectedAddons = ModelsUtil.getAddons();
await dialTest.step(
'Create new conversation and verify it is moved under Today section in chat bar',
async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({
isNewConversationVisible: true,
});
await chatBar.createNewConversation();

const todayConversations = await conversations.getTodayConversations();
expect
.soft(
todayConversations.length,
ExpectedMessages.newConversationCreated,
)
.toBe(2);
for (const todayConversation of todayConversations) {
expect
.soft(todayConversation, ExpectedMessages.conversationOfToday)
.toEqual(
expect.stringContaining(ExpectedConstants.newConversationTitle),
);
}
},
);

await dialTest.step(
'Verify the list of recent entities and default settings for default model',
async () => {
const expectedDefaultRecentEntities = [];
for (const entity of recentModelIds) {
expectedDefaultRecentEntities.push(
allEntities.find((e) => e.id === entity)!.name,
);
}

const recentTalkTo = await talkToEntities.getTalkToEntityNames();
expect
.soft(recentTalkTo, ExpectedMessages.recentEntitiesVisible)
.toEqual(expectedDefaultRecentEntities);

const defaultSystemPrompt = await entitySettings.getSystemPrompt();
expect
.soft(
defaultSystemPrompt,
ExpectedMessages.defaultSystemPromptIsEmpty,
)
.toBe(ExpectedConstants.emptyString);

const defaultTemperature = await temperatureSlider.getTemperature();
expect
.soft(defaultTemperature, ExpectedMessages.defaultTemperatureIsOne)
.toBe(ExpectedConstants.defaultTemperature);

const selectedAddons = await addons.getSelectedAddons();
expect
.soft(selectedAddons, ExpectedMessages.noAddonsSelected)
.toEqual(defaultModel.selectedAddons ?? []);

const expectedDefaultRecentAddons = [];
for (const addonId of recentAddonIds) {
expectedDefaultRecentAddons.push(
expectedAddons.find((a) => a.id === addonId)?.name || addonId,
);
}
const recentAddons = await addons.getRecentAddons();
expect
.soft(recentAddons, ExpectedMessages.recentAddonsVisible)
.toEqual(expectedDefaultRecentAddons);
},
);

await dialTest.step(
'Send request to chat and verify response received',
async () => {
await dialHomePage.mockChatTextResponse(
MockedChatApiResponseBodies.simpleTextBody,
);
await chat.sendRequestWithKeyboard('test request');
const messagesCount =
await chatMessages.chatMessages.getElementsCount();
expect
.soft(messagesCount, ExpectedMessages.messageCountIsCorrect)
.toBe(2);
},
);
},
);
32 changes: 32 additions & 0 deletions apps/chat-e2e/src/tests/monitoring/createNewPrompt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import dialTest from '@/src/core/dialFixtures';

dialTest(
'Create new prompt',
async ({ dialHomePage, promptBar, promptModalDialog, promptAssertion }) => {
const newName = 'test prompt';
const newDescr = 'test description';
const newValue = 'what is {{}}';

await dialTest.step('Click "New prompt" button', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({
isNewConversationVisible: true,
});
await promptBar.createNewPrompt();
});

await dialTest.step(
'Fill in required fields, click Save and verify prompt is created',
async () => {
await promptModalDialog.setField(promptModalDialog.name, newName);
await promptModalDialog.setField(promptModalDialog.prompt, newValue);
await promptModalDialog.setField(
promptModalDialog.description,
newDescr,
);
await promptModalDialog.saveButton.click();
await promptAssertion.assertEntityState({ name: newName }, 'visible');
},
);
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import dialTest from '@/src/core/dialFixtures';
import { ExpectedMessages, MenuOptions } from '@/src/testData';
import { expect } from '@playwright/test';

dialTest(
'Delete folder with conversation inside',
async ({
dialHomePage,
conversationData,
folderConversations,
dataInjector,
conversationDropdownMenu,
conversations,
confirmationDialog,
chatBarFolderAssertion,
}) => {
const conversationInFolder =
conversationData.prepareDefaultConversationInFolder();
await dataInjector.createConversations(
conversationInFolder.conversations,
conversationInFolder.folders,
);

await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded({ isNewConversationVisible: true });
await folderConversations.openFolderDropdownMenu(
conversationInFolder.folders.name,
);
await conversationDropdownMenu.selectMenuOption(MenuOptions.delete);
await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' });
await chatBarFolderAssertion.assertFolderState(
{ name: conversationInFolder.folders.name },
'hidden',
);

const todayConversations = await conversations.getTodayConversations();
expect
.soft(
todayConversations.includes(conversationInFolder.conversations[0].name),
ExpectedMessages.conversationOfToday,
)
.toBeFalsy();
},
);
45 changes: 45 additions & 0 deletions apps/chat-e2e/src/tests/monitoring/deleteFolderWithPrompts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import dialTest from '@/src/core/dialFixtures';
import { FolderPrompt, MenuOptions } from '@/src/testData';

dialTest(
'Delete folder when there are some prompts inside',
async ({
dialHomePage,
promptData,
folderPrompts,
dataInjector,
promptDropdownMenu,
confirmationDialog,
promptBarFolderAssertion,
promptAssertion,
}) => {
let promptInFolder: FolderPrompt;

await dialTest.step('Prepare a folder with prompt', async () => {
promptInFolder = promptData.prepareDefaultPromptInFolder();
await dataInjector.createPrompts(
promptInFolder.prompts,
promptInFolder.folders,
);
});

await dialTest.step(
'Select "Delete" for folder dropdown menu, confirm and verify folder with prompt are not displayed',
async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded();
await folderPrompts.openFolderDropdownMenu(promptInFolder.folders.name);
await promptDropdownMenu.selectMenuOption(MenuOptions.delete);
await confirmationDialog.confirm();
await promptBarFolderAssertion.assertFolderState(
{ name: promptInFolder.folders.name },
'hidden',
);
await promptAssertion.assertEntityState(
{ name: promptInFolder.prompts[0].name },
'hidden',
);
},
);
},
);
Loading

0 comments on commit 609ad97

Please sign in to comment.