-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into fix/2598-refactor-init-requests
- Loading branch information
Showing
13 changed files
with
666 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/chat-e2e/src/tests/monitoring/conversationExportImport.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
124
apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
apps/chat-e2e/src/tests/monitoring/createNewPrompt.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}, | ||
); | ||
}, | ||
); |
44 changes: 44 additions & 0 deletions
44
apps/chat-e2e/src/tests/monitoring/deleteFolderWithConversations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
apps/chat-e2e/src/tests/monitoring/deleteFolderWithPrompts.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
); | ||
}, | ||
); | ||
}, | ||
); |
Oops, something went wrong.